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 @@ -659,6 +659,23 @@ static struct pernet_operations nf_flow_
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)
37 @@ -671,8 +688,14 @@ static int __init nf_flow_table_module_i
41 + ret = register_netdevice_notifier(&flow_offload_netdev_notifier);
43 + goto out_offload_init;
48 + nf_flow_table_offload_exit();
50 unregister_pernet_subsys(&nf_flow_table_net_ops);
52 @@ -680,6 +703,7 @@ out_offload:
54 static void __exit nf_flow_table_module_exit(void)
56 + unregister_netdevice_notifier(&flow_offload_netdev_notifier);
57 nf_flow_table_offload_exit();
58 unregister_pernet_subsys(&nf_flow_table_net_ops);
60 --- a/net/netfilter/nft_flow_offload.c
61 +++ b/net/netfilter/nft_flow_offload.c
62 @@ -470,47 +470,14 @@ static struct nft_expr_type nft_flow_off
66 -static int flow_offload_netdev_event(struct notifier_block *this,
67 - unsigned long event, void *ptr)
69 - struct net_device *dev = netdev_notifier_info_to_dev(ptr);
71 - if (event != NETDEV_DOWN)
74 - nf_flow_table_cleanup(dev);
79 -static struct notifier_block flow_offload_netdev_notifier = {
80 - .notifier_call = flow_offload_netdev_event,
83 static int __init nft_flow_offload_module_init(void)
87 - err = register_netdevice_notifier(&flow_offload_netdev_notifier);
91 - err = nft_register_expr(&nft_flow_offload_type);
98 - unregister_netdevice_notifier(&flow_offload_netdev_notifier);
101 + return nft_register_expr(&nft_flow_offload_type);
104 static void __exit nft_flow_offload_module_exit(void)
106 nft_unregister_expr(&nft_flow_offload_type);
107 - unregister_netdevice_notifier(&flow_offload_netdev_notifier);
110 module_init(nft_flow_offload_module_init);