xfrm: Move device notifications to a sepatate file
authorSteffen Klassert <steffen.klassert@secunet.com>
Fri, 14 Apr 2017 08:05:53 +0000 (10:05 +0200)
committerSteffen Klassert <steffen.klassert@secunet.com>
Fri, 14 Apr 2017 08:05:53 +0000 (10:05 +0200)
This is needed for the upcomming IPsec device offloading.

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
include/net/xfrm.h
net/xfrm/Makefile
net/xfrm/xfrm_device.c [new file with mode: 0644]
net/xfrm/xfrm_policy.c

index 159342f3e72b2bafd1d812716c67a63d247e7bd2..ac984da27879bd0d8f4ef51ac81e3812ac20e6ab 100644 (file)
@@ -1443,6 +1443,7 @@ struct xfrm6_tunnel {
 void xfrm_init(void);
 void xfrm4_init(void);
 int xfrm_state_init(struct net *net);
+void xfrm_dev_init(void);
 void xfrm_state_fini(struct net *net);
 void xfrm4_state_init(void);
 void xfrm4_protocol_init(void);
index c0e961983f17a077bde9bab18d946ecef0cba0ae..55b2ac3009955aacd09db22c7fc4d082807c3ed9 100644 (file)
@@ -4,7 +4,7 @@
 
 obj-$(CONFIG_XFRM) := xfrm_policy.o xfrm_state.o xfrm_hash.o \
                      xfrm_input.o xfrm_output.o \
-                     xfrm_sysctl.o xfrm_replay.o
+                     xfrm_sysctl.o xfrm_replay.o xfrm_device.o
 obj-$(CONFIG_XFRM_STATISTICS) += xfrm_proc.o
 obj-$(CONFIG_XFRM_ALGO) += xfrm_algo.o
 obj-$(CONFIG_XFRM_USER) += xfrm_user.o
diff --git a/net/xfrm/xfrm_device.c b/net/xfrm/xfrm_device.c
new file mode 100644 (file)
index 0000000..34a260a
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * xfrm_device.c - IPsec device offloading code.
+ *
+ * Copyright (c) 2015 secunet Security Networks AG
+ *
+ * Author:
+ * Steffen Klassert <steffen.klassert@secunet.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include <linux/errno.h>
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include <linux/skbuff.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <net/dst.h>
+#include <net/xfrm.h>
+#include <linux/notifier.h>
+
+static int xfrm_dev_event(struct notifier_block *this, unsigned long event, void *ptr)
+{
+       struct net_device *dev = netdev_notifier_info_to_dev(ptr);
+
+       switch (event) {
+       case NETDEV_DOWN:
+               xfrm_garbage_collect(dev_net(dev));
+       }
+       return NOTIFY_DONE;
+}
+
+static struct notifier_block xfrm_dev_notifier = {
+       .notifier_call  = xfrm_dev_event,
+};
+
+void __net_init xfrm_dev_init(void)
+{
+       register_netdevice_notifier(&xfrm_dev_notifier);
+}
index 236cbbc0ab9cfff05cd027ffb0dc56aa15e61033..7befca2a0773608f86cb5306f172f46a746bf570 100644 (file)
@@ -2929,21 +2929,6 @@ void xfrm_policy_unregister_afinfo(const struct xfrm_policy_afinfo *afinfo)
 }
 EXPORT_SYMBOL(xfrm_policy_unregister_afinfo);
 
-static int xfrm_dev_event(struct notifier_block *this, unsigned long event, void *ptr)
-{
-       struct net_device *dev = netdev_notifier_info_to_dev(ptr);
-
-       switch (event) {
-       case NETDEV_DOWN:
-               xfrm_garbage_collect(dev_net(dev));
-       }
-       return NOTIFY_DONE;
-}
-
-static struct notifier_block xfrm_dev_notifier = {
-       .notifier_call  = xfrm_dev_event,
-};
-
 #ifdef CONFIG_XFRM_STATISTICS
 static int __net_init xfrm_statistics_init(struct net *net)
 {
@@ -3020,7 +3005,7 @@ static int __net_init xfrm_policy_init(struct net *net)
        INIT_WORK(&net->xfrm.policy_hash_work, xfrm_hash_resize);
        INIT_WORK(&net->xfrm.policy_hthresh.work, xfrm_hash_rebuild);
        if (net_eq(net, &init_net))
-               register_netdevice_notifier(&xfrm_dev_notifier);
+               xfrm_dev_init();
        return 0;
 
 out_bydst: