1 From: Pablo Neira Ayuso <pablo@netfilter.org>
2 Date: Thu, 25 Jan 2018 12:58:55 +0100
3 Subject: [PATCH] netfilter: nft_flow_offload: handle netdevice events from
6 Move the code that deals with device events to the core.
8 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 --- a/net/netfilter/nf_flow_table_core.c
12 +++ b/net/netfilter/nf_flow_table_core.c
13 @@ -608,28 +608,52 @@ void nf_flow_table_free(struct nf_flowta
14 .exit_batch = nf_flow_table_pernet_exit,
17 +static int nf_flow_table_netdev_event(struct notifier_block *this,
18 + unsigned long event, void *ptr)
20 + struct net_device *dev = netdev_notifier_info_to_dev(ptr);
22 + if (event != NETDEV_DOWN)
25 + nf_flow_table_cleanup(dev);
30 +static struct notifier_block flow_offload_netdev_notifier = {
31 + .notifier_call = nf_flow_table_netdev_event,
34 static int __init nf_flow_table_module_init(void)
38 ret = register_pernet_subsys(&nf_flow_table_net_ops);
42 ret = nf_flow_table_offload_init();
46 + ret = register_netdevice_notifier(&flow_offload_netdev_notifier);
48 + goto out_offload_init;
53 + nf_flow_table_offload_exit();
55 unregister_pernet_subsys(&nf_flow_table_net_ops);
59 static void __exit nf_flow_table_module_exit(void)
61 + unregister_netdevice_notifier(&flow_offload_netdev_notifier);
62 nf_flow_table_offload_exit();
63 unregister_pernet_subsys(&nf_flow_table_net_ops);
66 --- a/net/netfilter/nft_flow_offload.c
67 +++ b/net/netfilter/nft_flow_offload.c
68 @@ -444,47 +444,14 @@ static struct nft_expr_type nft_flow_off
72 -static int flow_offload_netdev_event(struct notifier_block *this,
73 - unsigned long event, void *ptr)
75 - struct net_device *dev = netdev_notifier_info_to_dev(ptr);
77 - if (event != NETDEV_DOWN)
80 - nf_flow_table_cleanup(dev);
85 -static struct notifier_block flow_offload_netdev_notifier = {
86 - .notifier_call = flow_offload_netdev_event,
89 static int __init nft_flow_offload_module_init(void)
93 - err = register_netdevice_notifier(&flow_offload_netdev_notifier);
97 - err = nft_register_expr(&nft_flow_offload_type);
104 - unregister_netdevice_notifier(&flow_offload_netdev_notifier);
107 + return nft_register_expr(&nft_flow_offload_type);
110 static void __exit nft_flow_offload_module_exit(void)
112 nft_unregister_expr(&nft_flow_offload_type);
113 - unregister_netdevice_notifier(&flow_offload_netdev_notifier);
116 module_init(nft_flow_offload_module_init);