kernel: bump 4.19 to 4.19.16
[openwrt/openwrt.git] / target / linux / generic / backport-4.19 / 343-netfilter-nft_flow_offload-handle-netdevice-events-f.patch
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
4 nf_flow_table
5
6 Move the code that deals with device events to the core.
7
8 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 ---
10
11 --- a/net/netfilter/nf_flow_table_core.c
12 +++ b/net/netfilter/nf_flow_table_core.c
13 @@ -519,5 +519,35 @@ void nf_flow_table_free(struct nf_flowta
14 }
15 EXPORT_SYMBOL_GPL(nf_flow_table_free);
16
17 +static int nf_flow_table_netdev_event(struct notifier_block *this,
18 + unsigned long event, void *ptr)
19 +{
20 + struct net_device *dev = netdev_notifier_info_to_dev(ptr);
21 +
22 + if (event != NETDEV_DOWN)
23 + return NOTIFY_DONE;
24 +
25 + nf_flow_table_cleanup(dev_net(dev), dev);
26 +
27 + return NOTIFY_DONE;
28 +}
29 +
30 +static struct notifier_block flow_offload_netdev_notifier = {
31 + .notifier_call = nf_flow_table_netdev_event,
32 +};
33 +
34 +static int __init nf_flow_table_module_init(void)
35 +{
36 + return register_netdevice_notifier(&flow_offload_netdev_notifier);
37 +}
38 +
39 +static void __exit nf_flow_table_module_exit(void)
40 +{
41 + unregister_netdevice_notifier(&flow_offload_netdev_notifier);
42 +}
43 +
44 +module_init(nf_flow_table_module_init);
45 +module_exit(nf_flow_table_module_exit);
46 +
47 MODULE_LICENSE("GPL");
48 MODULE_AUTHOR("Pablo Neira Ayuso <pablo@netfilter.org>");
49 --- a/net/netfilter/nft_flow_offload.c
50 +++ b/net/netfilter/nft_flow_offload.c
51 @@ -193,47 +193,14 @@ static struct nft_expr_type nft_flow_off
52 .owner = THIS_MODULE,
53 };
54
55 -static int flow_offload_netdev_event(struct notifier_block *this,
56 - unsigned long event, void *ptr)
57 -{
58 - struct net_device *dev = netdev_notifier_info_to_dev(ptr);
59 -
60 - if (event != NETDEV_DOWN)
61 - return NOTIFY_DONE;
62 -
63 - nf_flow_table_cleanup(dev_net(dev), dev);
64 -
65 - return NOTIFY_DONE;
66 -}
67 -
68 -static struct notifier_block flow_offload_netdev_notifier = {
69 - .notifier_call = flow_offload_netdev_event,
70 -};
71 -
72 static int __init nft_flow_offload_module_init(void)
73 {
74 - int err;
75 -
76 - err = register_netdevice_notifier(&flow_offload_netdev_notifier);
77 - if (err)
78 - goto err;
79 -
80 - err = nft_register_expr(&nft_flow_offload_type);
81 - if (err < 0)
82 - goto register_expr;
83 -
84 - return 0;
85 -
86 -register_expr:
87 - unregister_netdevice_notifier(&flow_offload_netdev_notifier);
88 -err:
89 - return err;
90 + return nft_register_expr(&nft_flow_offload_type);
91 }
92
93 static void __exit nft_flow_offload_module_exit(void)
94 {
95 nft_unregister_expr(&nft_flow_offload_type);
96 - unregister_netdevice_notifier(&flow_offload_netdev_notifier);
97 }
98
99 module_init(nft_flow_offload_module_init);