File tree 4 files changed +43
-1
lines changed 4 files changed +43
-1
lines changed Original file line number Diff line number Diff line change 11
11
#include <linux/wait.h>
12
12
#include <linux/list.h>
13
13
#include <linux/static_key.h>
14
+ #include <linux/module.h>
14
15
#include <linux/netfilter_defs.h>
15
16
#include <linux/netdevice.h>
16
17
#include <linux/sockptr.h>
@@ -481,6 +482,15 @@ struct nfnl_ct_hook {
481
482
};
482
483
extern const struct nfnl_ct_hook __rcu * nfnl_ct_hook ;
483
484
485
+ struct nf_defrag_hook {
486
+ struct module * owner ;
487
+ int (* enable )(struct net * net );
488
+ void (* disable )(struct net * net );
489
+ };
490
+
491
+ extern const struct nf_defrag_hook __rcu * nf_defrag_v4_hook ;
492
+ extern const struct nf_defrag_hook __rcu * nf_defrag_v6_hook ;
493
+
484
494
/*
485
495
* nf_skb_duplicated - TEE target has sent a packet
486
496
*
Original file line number Diff line number Diff line change 7
7
#include <linux/ip.h>
8
8
#include <linux/netfilter.h>
9
9
#include <linux/module.h>
10
+ #include <linux/rcupdate.h>
10
11
#include <linux/skbuff.h>
11
12
#include <net/netns/generic.h>
12
13
#include <net/route.h>
@@ -113,17 +114,31 @@ static void __net_exit defrag4_net_exit(struct net *net)
113
114
}
114
115
}
115
116
117
+ static const struct nf_defrag_hook defrag_hook = {
118
+ .owner = THIS_MODULE ,
119
+ .enable = nf_defrag_ipv4_enable ,
120
+ .disable = nf_defrag_ipv4_disable ,
121
+ };
122
+
116
123
static struct pernet_operations defrag4_net_ops = {
117
124
.exit = defrag4_net_exit ,
118
125
};
119
126
120
127
static int __init nf_defrag_init (void )
121
128
{
122
- return register_pernet_subsys (& defrag4_net_ops );
129
+ int err ;
130
+
131
+ err = register_pernet_subsys (& defrag4_net_ops );
132
+ if (err )
133
+ return err ;
134
+
135
+ rcu_assign_pointer (nf_defrag_v4_hook , & defrag_hook );
136
+ return err ;
123
137
}
124
138
125
139
static void __exit nf_defrag_fini (void )
126
140
{
141
+ rcu_assign_pointer (nf_defrag_v4_hook , NULL );
127
142
unregister_pernet_subsys (& defrag4_net_ops );
128
143
}
129
144
Original file line number Diff line number Diff line change 10
10
#include <linux/module.h>
11
11
#include <linux/skbuff.h>
12
12
#include <linux/icmp.h>
13
+ #include <linux/rcupdate.h>
13
14
#include <linux/sysctl.h>
14
15
#include <net/ipv6_frag.h>
15
16
@@ -96,6 +97,12 @@ static void __net_exit defrag6_net_exit(struct net *net)
96
97
}
97
98
}
98
99
100
+ static const struct nf_defrag_hook defrag_hook = {
101
+ .owner = THIS_MODULE ,
102
+ .enable = nf_defrag_ipv6_enable ,
103
+ .disable = nf_defrag_ipv6_disable ,
104
+ };
105
+
99
106
static struct pernet_operations defrag6_net_ops = {
100
107
.exit = defrag6_net_exit ,
101
108
};
@@ -114,6 +121,9 @@ static int __init nf_defrag_init(void)
114
121
pr_err ("nf_defrag_ipv6: can't register pernet ops\n" );
115
122
goto cleanup_frag6 ;
116
123
}
124
+
125
+ rcu_assign_pointer (nf_defrag_v6_hook , & defrag_hook );
126
+
117
127
return ret ;
118
128
119
129
cleanup_frag6 :
@@ -124,6 +134,7 @@ static int __init nf_defrag_init(void)
124
134
125
135
static void __exit nf_defrag_fini (void )
126
136
{
137
+ rcu_assign_pointer (nf_defrag_v6_hook , NULL );
127
138
unregister_pernet_subsys (& defrag6_net_ops );
128
139
nf_ct_frag6_cleanup ();
129
140
}
Original file line number Diff line number Diff line change @@ -680,6 +680,12 @@ EXPORT_SYMBOL_GPL(nfnl_ct_hook);
680
680
const struct nf_ct_hook __rcu * nf_ct_hook __read_mostly ;
681
681
EXPORT_SYMBOL_GPL (nf_ct_hook );
682
682
683
+ const struct nf_defrag_hook __rcu * nf_defrag_v4_hook __read_mostly ;
684
+ EXPORT_SYMBOL_GPL (nf_defrag_v4_hook );
685
+
686
+ const struct nf_defrag_hook __rcu * nf_defrag_v6_hook __read_mostly ;
687
+ EXPORT_SYMBOL_GPL (nf_defrag_v6_hook );
688
+
683
689
#if IS_ENABLED (CONFIG_NF_CONNTRACK )
684
690
u8 nf_ctnetlink_has_listener ;
685
691
EXPORT_SYMBOL_GPL (nf_ctnetlink_has_listener );
You can’t perform that action at this time.
0 commit comments