kernel: update U-Boot nvmem driver to v6.2 release version
[openwrt/openwrt.git] / target / linux / generic / backport-5.10 / 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 @@ -576,13 +576,41 @@ 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);
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 nf_flow_table_offload_init();
37 + int ret;
38 +
39 + ret = nf_flow_table_offload_init();
40 + if (ret)
41 + return ret;
42 +
43 + ret = register_netdevice_notifier(&flow_offload_netdev_notifier);
44 + if (ret)
45 + nf_flow_table_offload_exit();
46 +
47 + return ret;
48 }
49
50 static void __exit nf_flow_table_module_exit(void)
51 {
52 + unregister_netdevice_notifier(&flow_offload_netdev_notifier);
53 nf_flow_table_offload_exit();
54 }
55
56 --- a/net/netfilter/nft_flow_offload.c
57 +++ b/net/netfilter/nft_flow_offload.c
58 @@ -237,47 +237,14 @@ static struct nft_expr_type nft_flow_off
59 .owner = THIS_MODULE,
60 };
61
62 -static int flow_offload_netdev_event(struct notifier_block *this,
63 - unsigned long event, void *ptr)
64 -{
65 - struct net_device *dev = netdev_notifier_info_to_dev(ptr);
66 -
67 - if (event != NETDEV_DOWN)
68 - return NOTIFY_DONE;
69 -
70 - nf_flow_table_cleanup(dev);
71 -
72 - return NOTIFY_DONE;
73 -}
74 -
75 -static struct notifier_block flow_offload_netdev_notifier = {
76 - .notifier_call = flow_offload_netdev_event,
77 -};
78 -
79 static int __init nft_flow_offload_module_init(void)
80 {
81 - int err;
82 -
83 - err = register_netdevice_notifier(&flow_offload_netdev_notifier);
84 - if (err)
85 - goto err;
86 -
87 - err = nft_register_expr(&nft_flow_offload_type);
88 - if (err < 0)
89 - goto register_expr;
90 -
91 - return 0;
92 -
93 -register_expr:
94 - unregister_netdevice_notifier(&flow_offload_netdev_notifier);
95 -err:
96 - return err;
97 + return nft_register_expr(&nft_flow_offload_type);
98 }
99
100 static void __exit nft_flow_offload_module_exit(void)
101 {
102 nft_unregister_expr(&nft_flow_offload_type);
103 - unregister_netdevice_notifier(&flow_offload_netdev_notifier);
104 }
105
106 module_init(nft_flow_offload_module_init);