PERFORCE change 35304 for review
Robert Watson
rwatson at FreeBSD.org
Fri Aug 1 01:47:03 GMT 2003
http://perforce.freebsd.org/chv.cgi?CH=35304
Change 35304 by rwatson at rwatson_tislabs on 2003/07/31 18:47:02
Replace a lot of:
#ifdef MAC_DEBUG
atomic_xxx_int(..., 1);
#endif
with:
MAC_DEBUG_COUNTER_xxx(...);
This shortens the label init/destroy functions some, and
centralizes the difference between the MAC_DEBUG and non-debug
cases in one place.
Affected files ...
.. //depot/projects/trustedbsd/mac/sys/kern/kern_mac.c#395 edit
Differences ...
==== //depot/projects/trustedbsd/mac/sys/kern/kern_mac.c#395 (text+ko) ====
@@ -203,6 +203,9 @@
nmacsockets, nmacmounts, nmactemp, nmacvnodes, nmacdevfsdirents,
nmacipqs, nmacpipes, nmacprocs;
+#define MAC_DEBUG_COUNTER_INC(x) atomic_add_int(x, 1);
+#define MAC_DEBUG_COUNTER_DEC(x) atomic_subtract_int(x, 1);
+
SYSCTL_UINT(_security_mac_debug_counters, OID_AUTO, mbufs, CTLFLAG_RD,
&nmacmbufs, 0, "number of mbufs in use");
SYSCTL_UINT(_security_mac_debug_counters, OID_AUTO, creds, CTLFLAG_RD,
@@ -227,6 +230,9 @@
&nmacvnodes, 0, "number of vnodes in use");
SYSCTL_UINT(_security_mac_debug_counters, OID_AUTO, devfsdirents, CTLFLAG_RD,
&nmacdevfsdirents, 0, "number of devfs dirents inuse");
+#else
+#define MAC_DEBUG_COUNTER_INC(x)
+#define MAC_DEBUG_COUNTER_INC(x)
#endif
static int error_select(int error1, int error2);
@@ -781,9 +787,7 @@
mac_init_label(&bpf_d->bd_label);
MAC_PERFORM(init_bpfdesc_label, &bpf_d->bd_label);
-#ifdef MAC_DEBUG
- atomic_add_int(&nmacbpfdescs, 1);
-#endif
+ MAC_DEBUG_COUNTER_INC(&nmacbpfdescs);
}
static void
@@ -792,9 +796,7 @@
mac_init_label(label);
MAC_PERFORM(init_cred_label, label);
-#ifdef MAC_DEBUG
- atomic_add_int(&nmaccreds, 1);
-#endif
+ MAC_DEBUG_COUNTER_INC(&nmaccreds);
}
void
@@ -810,9 +812,7 @@
mac_init_label(&de->de_label);
MAC_PERFORM(init_devfsdirent_label, &de->de_label);
-#ifdef MAC_DEBUG
- atomic_add_int(&nmacdevfsdirents, 1);
-#endif
+ MAC_DEBUG_COUNTER_INC(&nmacdevfsdirents);
}
static void
@@ -821,9 +821,7 @@
mac_init_label(label);
MAC_PERFORM(init_ifnet_label, label);
-#ifdef MAC_DEBUG
- atomic_add_int(&nmacifnets, 1);
-#endif
+ MAC_DEBUG_COUNTER_INC(&nmacifnets);
}
void
@@ -844,11 +842,9 @@
if (error) {
MAC_PERFORM(destroy_ipq_label, &ipq->ipq_label);
mac_destroy_label(&ipq->ipq_label);
+ } else {
+ MAC_DEBUG_COUNTER_INC(&nmacipqs);
}
-#ifdef MAC_DEBUG
- if (error == 0)
- atomic_add_int(&nmacipqs, 1);
-#endif
return (error);
}
@@ -865,11 +861,9 @@
if (error) {
MAC_PERFORM(destroy_mbuf_label, label);
mac_destroy_label(label);
+ } else {
+ MAC_DEBUG_COUNTER_INC(&nmacmbufs);
}
-#ifdef MAC_DEBUG
- if (error == 0)
- atomic_add_int(&nmacmbufs, 1);
-#endif
return (error);
}
@@ -912,9 +906,7 @@
mac_init_label(&mp->mnt_fslabel);
MAC_PERFORM(init_mount_label, &mp->mnt_mntlabel);
MAC_PERFORM(init_mount_fs_label, &mp->mnt_fslabel);
-#ifdef MAC_DEBUG
- atomic_add_int(&nmacmounts, 1);
-#endif
+ MAC_DEBUG_COUNTER_INC(&nmacmounts);
}
static void
@@ -923,9 +915,7 @@
mac_init_label(label);
MAC_PERFORM(init_pipe_label, label);
-#ifdef MAC_DEBUG
- atomic_add_int(&nmacpipes, 1);
-#endif
+ MAC_DEBUG_COUNTER_INC(&nmacpipes);
}
void
@@ -945,9 +935,7 @@
mac_init_label(&p->p_label);
MAC_PERFORM(init_proc_label, &p->p_label);
-#ifdef MAC_DEBUG
- atomic_add_int(&nmacprocs, 1);
-#endif
+ MAC_DEBUG_COUNTER_INC(&nmacprocs);
}
static int
@@ -961,13 +949,10 @@
if (error) {
MAC_PERFORM(destroy_socket_label, label);
mac_destroy_label(label);
+ } else {
+ MAC_DEBUG_COUNTER_INC(&nmacsockets);
}
-#ifdef MAC_DEBUG
- if (error == 0)
- atomic_add_int(&nmacsockets, 1);
-#endif
-
return (error);
}
@@ -1009,9 +994,7 @@
mac_init_label(label);
MAC_PERFORM(init_vnode_label, label);
-#ifdef MAC_DEBUG
- atomic_add_int(&nmacvnodes, 1);
-#endif
+ MAC_DEBUG_COUNTER_INC(&nmacvnodes);
}
void
@@ -1027,9 +1010,7 @@
MAC_PERFORM(destroy_bpfdesc_label, &bpf_d->bd_label);
mac_destroy_label(&bpf_d->bd_label);
-#ifdef MAC_DEBUG
- atomic_subtract_int(&nmacbpfdescs, 1);
-#endif
+ MAC_DEBUG_COUNTER_DEC(&nmacbpfdescs);
}
static void
@@ -1038,9 +1019,7 @@
MAC_PERFORM(destroy_cred_label, label);
mac_destroy_label(label);
-#ifdef MAC_DEBUG
- atomic_subtract_int(&nmaccreds, 1);
-#endif
+ MAC_DEBUG_COUNTER_DEC(&nmaccreds);
}
void
@@ -1056,9 +1035,7 @@
MAC_PERFORM(destroy_devfsdirent_label, &de->de_label);
mac_destroy_label(&de->de_label);
-#ifdef MAC_DEBUG
- atomic_subtract_int(&nmacdevfsdirents, 1);
-#endif
+ MAC_DEBUG_COUNTER_DEC(&nmacdevfsdirents);
}
static void
@@ -1067,9 +1044,7 @@
MAC_PERFORM(destroy_ifnet_label, label);
mac_destroy_label(label);
-#ifdef MAC_DEBUG
- atomic_subtract_int(&nmacifnets, 1);
-#endif
+ MAC_DEBUG_COUNTER_DEC(&nmacifnets);
}
void
@@ -1085,9 +1060,7 @@
MAC_PERFORM(destroy_ipq_label, &ipq->ipq_label);
mac_destroy_label(&ipq->ipq_label);
-#ifdef MAC_DEBUG
- atomic_subtract_int(&nmacipqs, 1);
-#endif
+ MAC_DEBUG_COUNTER_DEC(&nmacipqs);
}
void
@@ -1099,9 +1072,7 @@
MAC_PERFORM(destroy_mbuf_label, label);
mac_destroy_label(label);
-#ifdef MAC_DEBUG
- atomic_subtract_int(&nmacmbufs, 1);
-#endif
+ MAC_DEBUG_COUNTER_DEC(&nmacmbufs);
}
void
@@ -1112,9 +1083,7 @@
MAC_PERFORM(destroy_mount_fs_label, &mp->mnt_fslabel);
mac_destroy_label(&mp->mnt_fslabel);
mac_destroy_label(&mp->mnt_mntlabel);
-#ifdef MAC_DEBUG
- atomic_subtract_int(&nmacmounts, 1);
-#endif
+ MAC_DEBUG_COUNTER_DEC(&nmacmounts);
}
static void
@@ -1123,9 +1092,7 @@
MAC_PERFORM(destroy_pipe_label, label);
mac_destroy_label(label);
-#ifdef MAC_DEBUG
- atomic_subtract_int(&nmacpipes, 1);
-#endif
+ MAC_DEBUG_COUNTER_DEC(&nmacpipes);
}
void
@@ -1142,9 +1109,7 @@
MAC_PERFORM(destroy_proc_label, &p->p_label);
mac_destroy_label(&p->p_label);
-#ifdef MAC_DEBUG
- atomic_subtract_int(&nmacprocs, 1);
-#endif
+ MAC_DEBUG_COUNTER_DEC(&nmacprocs);
}
static void
@@ -1153,9 +1118,7 @@
MAC_PERFORM(destroy_socket_label, label);
mac_destroy_label(label);
-#ifdef MAC_DEBUG
- atomic_subtract_int(&nmacsockets, 1);
-#endif
+ MAC_DEBUG_COUNTER_DEC(&nmacsockets);
}
static void
@@ -1180,9 +1143,7 @@
MAC_PERFORM(destroy_vnode_label, label);
mac_destroy_label(label);
-#ifdef MAC_DEBUG
- atomic_subtract_int(&nmacvnodes, 1);
-#endif
+ MAC_DEBUG_COUNTER_DEC(&nmacvnodes);
}
void
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message
More information about the trustedbsd-cvs
mailing list