@@ -48,18 +48,17 @@ static const unsigned int gre_timeouts[GRE_CT_MAX] = {
4848 [GRE_CT_REPLIED ] = 180 * HZ ,
4949};
5050
51- static unsigned int proto_gre_net_id __read_mostly ;
5251/* used when expectation is added */
5352static DEFINE_SPINLOCK (keymap_lock );
5453
55- static inline struct netns_proto_gre * gre_pernet (struct net * net )
54+ static inline struct nf_gre_net * gre_pernet (struct net * net )
5655{
57- return net_generic ( net , proto_gre_net_id ) ;
56+ return & net -> ct . nf_ct_proto . gre ;
5857}
5958
60- static void nf_ct_gre_keymap_flush (struct net * net )
59+ void nf_ct_gre_keymap_flush (struct net * net )
6160{
62- struct netns_proto_gre * net_gre = gre_pernet (net );
61+ struct nf_gre_net * net_gre = gre_pernet (net );
6362 struct nf_ct_gre_keymap * km , * tmp ;
6463
6564 spin_lock_bh (& keymap_lock );
@@ -83,7 +82,7 @@ static inline int gre_key_cmpfn(const struct nf_ct_gre_keymap *km,
8382/* look up the source key for a given tuple */
8483static __be16 gre_keymap_lookup (struct net * net , struct nf_conntrack_tuple * t )
8584{
86- struct netns_proto_gre * net_gre = gre_pernet (net );
85+ struct nf_gre_net * net_gre = gre_pernet (net );
8786 struct nf_ct_gre_keymap * km ;
8887 __be16 key = 0 ;
8988
@@ -105,7 +104,7 @@ int nf_ct_gre_keymap_add(struct nf_conn *ct, enum ip_conntrack_dir dir,
105104 struct nf_conntrack_tuple * t )
106105{
107106 struct net * net = nf_ct_net (ct );
108- struct netns_proto_gre * net_gre = gre_pernet (net );
107+ struct nf_gre_net * net_gre = gre_pernet (net );
109108 struct nf_ct_pptp_master * ct_pptp_info = nfct_help_data (ct );
110109 struct nf_ct_gre_keymap * * kmp , * km ;
111110
@@ -210,7 +209,7 @@ static void gre_print_conntrack(struct seq_file *s, struct nf_conn *ct)
210209
211210static unsigned int * gre_get_timeouts (struct net * net )
212211{
213- return gre_pernet (net )-> gre_timeouts ;
212+ return gre_pernet (net )-> timeouts ;
214213}
215214
216215/* Returns verdict for packet, and may modify conntrack */
@@ -272,13 +271,13 @@ static int gre_timeout_nlattr_to_obj(struct nlattr *tb[],
272271 struct net * net , void * data )
273272{
274273 unsigned int * timeouts = data ;
275- struct netns_proto_gre * net_gre = gre_pernet (net );
274+ struct nf_gre_net * net_gre = gre_pernet (net );
276275
277276 if (!timeouts )
278277 timeouts = gre_get_timeouts (net );
279278 /* set default timeouts for GRE. */
280- timeouts [GRE_CT_UNREPLIED ] = net_gre -> gre_timeouts [GRE_CT_UNREPLIED ];
281- timeouts [GRE_CT_REPLIED ] = net_gre -> gre_timeouts [GRE_CT_REPLIED ];
279+ timeouts [GRE_CT_UNREPLIED ] = net_gre -> timeouts [GRE_CT_UNREPLIED ];
280+ timeouts [GRE_CT_REPLIED ] = net_gre -> timeouts [GRE_CT_REPLIED ];
282281
283282 if (tb [CTA_TIMEOUT_GRE_UNREPLIED ]) {
284283 timeouts [GRE_CT_UNREPLIED ] =
@@ -332,10 +331,11 @@ static struct ctl_table gre_sysctl_table[] = {
332331};
333332#endif
334333
335- static int gre_kmemdup_sysctl_table (struct net * net , struct nf_proto_net * nf ,
336- struct netns_proto_gre * net_gre )
334+ static int gre_kmemdup_sysctl_table (struct net * net )
337335{
338336#ifdef CONFIG_SYSCTL
337+ struct nf_gre_net * net_gre = gre_pernet (net );
338+ struct nf_proto_net * nf = & net_gre -> nf ;
339339 int i ;
340340
341341 if (nf -> ctl_table )
@@ -348,26 +348,25 @@ static int gre_kmemdup_sysctl_table(struct net *net, struct nf_proto_net *nf,
348348 return - ENOMEM ;
349349
350350 for (i = 0 ; i < GRE_CT_MAX ; i ++ )
351- nf -> ctl_table [i ].data = & net_gre -> gre_timeouts [i ];
351+ nf -> ctl_table [i ].data = & net_gre -> timeouts [i ];
352352#endif
353353 return 0 ;
354354}
355355
356356static int gre_init_net (struct net * net )
357357{
358- struct netns_proto_gre * net_gre = gre_pernet (net );
359- struct nf_proto_net * nf = & net_gre -> nf ;
358+ struct nf_gre_net * net_gre = gre_pernet (net );
360359 int i ;
361360
362361 INIT_LIST_HEAD (& net_gre -> keymap_list );
363362 for (i = 0 ; i < GRE_CT_MAX ; i ++ )
364- net_gre -> gre_timeouts [i ] = gre_timeouts [i ];
363+ net_gre -> timeouts [i ] = gre_timeouts [i ];
365364
366- return gre_kmemdup_sysctl_table (net , nf , net_gre );
365+ return gre_kmemdup_sysctl_table (net );
367366}
368367
369368/* protocol helper struct */
370- static const struct nf_conntrack_l4proto nf_conntrack_l4proto_gre4 = {
369+ const struct nf_conntrack_l4proto nf_conntrack_l4proto_gre = {
371370 .l4proto = IPPROTO_GRE ,
372371 .pkt_to_tuple = gre_pkt_to_tuple ,
373372#ifdef CONFIG_NF_CONNTRACK_PROCFS
@@ -391,61 +390,5 @@ static const struct nf_conntrack_l4proto nf_conntrack_l4proto_gre4 = {
391390 .nla_policy = gre_timeout_nla_policy ,
392391 },
393392#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */
394- .net_id = & proto_gre_net_id ,
395393 .init_net = gre_init_net ,
396394};
397-
398- static int proto_gre_net_init (struct net * net )
399- {
400- int ret = 0 ;
401-
402- ret = nf_ct_l4proto_pernet_register_one (net ,
403- & nf_conntrack_l4proto_gre4 );
404- if (ret < 0 )
405- pr_err ("nf_conntrack_gre4: pernet registration failed.\n" );
406- return ret ;
407- }
408-
409- static void proto_gre_net_exit (struct net * net )
410- {
411- nf_ct_l4proto_pernet_unregister_one (net , & nf_conntrack_l4proto_gre4 );
412- nf_ct_gre_keymap_flush (net );
413- }
414-
415- static struct pernet_operations proto_gre_net_ops = {
416- .init = proto_gre_net_init ,
417- .exit = proto_gre_net_exit ,
418- .id = & proto_gre_net_id ,
419- .size = sizeof (struct netns_proto_gre ),
420- };
421-
422- static int __init nf_ct_proto_gre_init (void )
423- {
424- int ret ;
425-
426- BUILD_BUG_ON (offsetof(struct netns_proto_gre , nf ) != 0 );
427-
428- ret = register_pernet_subsys (& proto_gre_net_ops );
429- if (ret < 0 )
430- goto out_pernet ;
431- ret = nf_ct_l4proto_register_one (& nf_conntrack_l4proto_gre4 );
432- if (ret < 0 )
433- goto out_gre4 ;
434-
435- return 0 ;
436- out_gre4 :
437- unregister_pernet_subsys (& proto_gre_net_ops );
438- out_pernet :
439- return ret ;
440- }
441-
442- static void __exit nf_ct_proto_gre_fini (void )
443- {
444- nf_ct_l4proto_unregister_one (& nf_conntrack_l4proto_gre4 );
445- unregister_pernet_subsys (& proto_gre_net_ops );
446- }
447-
448- module_init (nf_ct_proto_gre_init );
449- module_exit (nf_ct_proto_gre_fini );
450-
451- MODULE_LICENSE ("GPL" );
0 commit comments