summaryrefslogtreecommitdiffstats
path: root/sys/security/mac_ifoff
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2002-10-30 18:48:51 +0000
committerrwatson <rwatson@FreeBSD.org>2002-10-30 18:48:51 +0000
commit122a6b9ad2a52d909b8df15d6f593b8aaf8dcf55 (patch)
tree7fd5345746ac073cf8b544fe6fd189e7cef54647 /sys/security/mac_ifoff
parent50b4c8318b1a99c59fad165b4a97fd68de465f73 (diff)
downloadFreeBSD-src-122a6b9ad2a52d909b8df15d6f593b8aaf8dcf55.zip
FreeBSD-src-122a6b9ad2a52d909b8df15d6f593b8aaf8dcf55.tar.gz
Move to C99 sparse structure initialization for the mac_policy_ops
structure definition, rather than using an operation vector we translate into the structure. Originally, we used a vector for two reasons: (1) We wanted to define the structure sparsely, which wasn't supported by the C compiler for structures. For a policy with five entry points, you don't want to have to stick in a few hundred NULL function pointers. (2) We thought it would improve ABI compatibility allowing modules to work with kernels that had a superset of the entry points defined in the module, even if the kernel had changed its entry point set. Both of these no longer apply: (1) C99 gives us a way to sparsely define a static structure. (2) The ABI problems existed anyway, due to enumeration numbers, argument changes, and semantic mismatches. Since the going rule for FreeBSD is that you really need your modules to pretty closely match your kernel, it's not worth the complexity. This submit eliminates the operation vector, dynamic allocation of the operation structure, copying of the vector to the structure, and redoes the vectors in each policy to direct structure definitions. One enourmous benefit of this change is that we now get decent type checking on policy entry point implementation arguments. Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
Diffstat (limited to 'sys/security/mac_ifoff')
-rw-r--r--sys/security/mac_ifoff/mac_ifoff.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/sys/security/mac_ifoff/mac_ifoff.c b/sys/security/mac_ifoff/mac_ifoff.c
index 8aea44a..fb7e966 100644
--- a/sys/security/mac_ifoff/mac_ifoff.c
+++ b/sys/security/mac_ifoff/mac_ifoff.c
@@ -158,16 +158,12 @@ mac_ifoff_check_socket_deliver(struct socket *so, struct label *socketlabel,
return (0);
}
-static struct mac_policy_op_entry mac_ifoff_ops[] =
+static struct mac_policy_ops mac_ifoff_ops =
{
- { MAC_CHECK_BPFDESC_RECEIVE,
- (macop_t)mac_ifoff_check_bpfdesc_receive },
- { MAC_CHECK_IFNET_TRANSMIT,
- (macop_t)mac_ifoff_check_ifnet_transmit },
- { MAC_CHECK_SOCKET_DELIVER,
- (macop_t)mac_ifoff_check_socket_deliver },
- { MAC_OP_LAST, NULL }
+ .mpo_check_bpfdesc_receive = mac_ifoff_check_bpfdesc_receive,
+ .mpo_check_ifnet_transmit = mac_ifoff_check_ifnet_transmit,
+ .mpo_check_socket_deliver = mac_ifoff_check_socket_deliver,
};
-MAC_POLICY_SET(mac_ifoff_ops, trustedbsd_mac_ifoff, "TrustedBSD MAC/ifoff",
+MAC_POLICY_SET(&mac_ifoff_ops, trustedbsd_mac_ifoff, "TrustedBSD MAC/ifoff",
MPC_LOADTIME_FLAG_UNLOADOK, NULL);
OpenPOWER on IntegriCloud