summaryrefslogtreecommitdiff
path: root/security/smack
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2017-04-21 11:49:08 +0200
committerCasey Schaufler <casey@schaufler-ca.com>2017-06-01 09:26:43 -0700
commite661a58279132da0127c67705e59d12f6027858d (patch)
tree5b4c04dcebbbf0c271d32eedbb7f662bd9797a97 /security/smack
parentd68c51e0b377838dd31b37707813bb62089f399c (diff)
smack: use pernet operations for hook registration
It will allow us to remove the old netfilter hook api in the near future. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Diffstat (limited to 'security/smack')
-rw-r--r--security/smack/smack_netfilter.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/security/smack/smack_netfilter.c b/security/smack/smack_netfilter.c
index 205b785fb400..cdeb0f3243dd 100644
--- a/security/smack/smack_netfilter.c
+++ b/security/smack/smack_netfilter.c
@@ -18,6 +18,7 @@
#include <linux/netfilter_ipv6.h>
#include <linux/netdevice.h>
#include <net/inet_sock.h>
+#include <net/net_namespace.h>
#include "smack.h"
#if IS_ENABLED(CONFIG_IPV6)
@@ -74,20 +75,29 @@ static struct nf_hook_ops smack_nf_ops[] = {
#endif /* IPV6 */
};
-static int __init smack_nf_ip_init(void)
+static int __net_init smack_nf_register(struct net *net)
+{
+ return nf_register_net_hooks(net, smack_nf_ops,
+ ARRAY_SIZE(smack_nf_ops));
+}
+
+static void __net_exit smack_nf_unregister(struct net *net)
{
- int err;
+ nf_unregister_net_hooks(net, smack_nf_ops, ARRAY_SIZE(smack_nf_ops));
+}
+static struct pernet_operations smack_net_ops = {
+ .init = smack_nf_register,
+ .exit = smack_nf_unregister,
+};
+
+static int __init smack_nf_ip_init(void)
+{
if (smack_enabled == 0)
return 0;
printk(KERN_DEBUG "Smack: Registering netfilter hooks\n");
-
- err = nf_register_hooks(smack_nf_ops, ARRAY_SIZE(smack_nf_ops));
- if (err)
- pr_info("Smack: nf_register_hooks: error %d\n", err);
-
- return 0;
+ return register_pernet_subsys(&smack_net_ops);
}
__initcall(smack_nf_ip_init);