netfilter: conntrack: pptp: use single option structure
Subsystems (2)
Florian Westphal
maintainerPATCH 1/1 netfilter: conntrack: pptp: use single option structure
Instead of exposing the four hooks individually use a sinle hook ops structure.
Signed-off-by Florian Westphal <[email protected]>
--- include/linux/netfilter/nf_conntrack_pptp.h | 38 ++++++------- net/ipv4/netfilter/nf_nat_pptp.c | 24 ++++----- net/netfilter/nf_conntrack_pptp.c | 60 +++++++-------------- 3 files changed, 45 insertions(+), 77 deletions(-)
include/linux/netfilter/nf_conntrack_pptp.h +17 -21
@@ -300,26 +300,22 @@ union pptp_ctrl_union { struct PptpSetLinkInfo setlink; }; -extern int -(*nf_nat_pptp_hook_outbound)(struct sk_buff *skb, -struct nf_conn *ct,enum ip_conntrack_info ctinfo, -unsigned int protoff, -struct PptpControlHeader *ctlh, -union pptp_ctrl_union *pptpReq); - -extern int -(*nf_nat_pptp_hook_inbound)(struct sk_buff *skb, -struct nf_conn *ct,enum ip_conntrack_info ctinfo, -unsigned int protoff, -struct PptpControlHeader *ctlh, -union pptp_ctrl_union *pptpReq); - -extern void -(*nf_nat_pptp_hook_exp_gre)(struct nf_conntrack_expect *exp_orig, -struct nf_conntrack_expect *exp_reply); - -extern void -(*nf_nat_pptp_hook_expectfn)(struct nf_conn *ct, -struct nf_conntrack_expect *exp); +struct nf_nat_pptp_hook { +int (*outbound)(struct sk_buff *skb, +struct nf_conn *ct,enum ip_conntrack_info ctinfo, +unsigned int protoff, +struct PptpControlHeader *ctlh, +union pptp_ctrl_union *pptpReq); +int (*inbound)(struct sk_buff *skb, +struct nf_conn *ct,enum ip_conntrack_info ctinfo, +unsigned int protoff, +struct PptpControlHeader *ctlh, +union pptp_ctrl_union *pptpReq); +void (*exp_gre)(struct nf_conntrack_expect *exp_orig, +struct nf_conntrack_expect *exp_reply); +void (*expectfn)(struct nf_conn *ct, +struct nf_conntrack_expect *exp); +}; +extern const struct nf_nat_pptp_hook __rcu *nf_nat_pptp_hook;#endif /* _NF_CONNTRACK_PPTP_H */
net/ipv4/netfilter/nf_nat_pptp.c +10 -14
@@ -295,28 +295,24 @@ pptp_inbound_pkt(struct sk_buff *skb,return NF_ACCEPT ; } +static const struct nf_nat_pptp_hook pptp_hooks = { + .outbound = pptp_outbound_pkt, + .inbound = pptp_inbound_pkt, + .exp_gre = pptp_exp_gre, + .expectfn = pptp_nat_expected, +}; +static int __init nf_nat_helper_pptp_init (void ) { -BUG_ON (nf_nat_pptp_hook_outbound !=NULL ); -RCU_INIT_POINTER (nf_nat_pptp_hook_outbound, pptp_outbound_pkt); - -BUG_ON (nf_nat_pptp_hook_inbound !=NULL ); -RCU_INIT_POINTER (nf_nat_pptp_hook_inbound, pptp_inbound_pkt); - -BUG_ON (nf_nat_pptp_hook_exp_gre !=NULL ); -RCU_INIT_POINTER (nf_nat_pptp_hook_exp_gre, pptp_exp_gre); +WARN_ON (nf_nat_pptp_hook !=NULL ); +RCU_INIT_POINTER (nf_nat_pptp_hook, &pptp_hooks); -BUG_ON (nf_nat_pptp_hook_expectfn !=NULL ); -RCU_INIT_POINTER (nf_nat_pptp_hook_expectfn, pptp_nat_expected);return 0 ; } static void __exit nf_nat_helper_pptp_fini(void) { -RCU_INIT_POINTER (nf_nat_pptp_hook_expectfn,NULL ); -RCU_INIT_POINTER (nf_nat_pptp_hook_exp_gre,NULL ); -RCU_INIT_POINTER (nf_nat_pptp_hook_inbound,NULL ); -RCU_INIT_POINTER (nf_nat_pptp_hook_outbound,NULL ); +RCU_INIT_POINTER (nf_nat_pptp_hook,NULL );synchronize_rcu (); }
net/netfilter/nf_conntrack_pptp.c +18 -42
121 lines not on this page · raw message
Signature · 1 line
2.34.1