netfilter: merge ipv4+ipv6 confirm functions
Subsystems (3)
Florian Westphal
maintainerPATCH 1/1 netfilter: merge ipv4+ipv6 confirm functions
No need to have distinct functions. After merge, ipv6 can avoid protooff computation if the connection neither needs sequence adjustment nor helper invocation -- this is the normal case.
Signed-off-by Florian Westphal <[email protected]>
--- include/net/netfilter/nf_conntrack_core.h | 3 +- net/bridge/netfilter/nf_conntrack_bridge.c | 32 +----- net/netfilter/nf_conntrack_proto.c | 124 +++++++++------------ 3 files changed, 57 insertions(+), 102 deletions(-)
include/net/netfilter/nf_conntrack_core.h +1 -2
@@ -71,8 +71,7 @@ static inline int nf_conntrack_confirm(struct sk_buff *skb)return ret; } -unsigned int nf_confirm (struct sk_buff *skb,unsigned int protoff, -struct nf_conn *ct,enum ip_conntrack_info ctinfo); +unsigned int nf_confirm (void *priv,struct sk_buff *skb,const struct nf_hook_state *state);void print_tuple (struct seq_file *s,const struct nf_conntrack_tuple *tuple,const struct nf_conntrack_l4proto *proto);
net/bridge/netfilter/nf_conntrack_bridge.c +1 -31
@@ -366,42 +366,12 @@ static int nf_ct_bridge_refrag_post(struct net *net, struct sock *sk,return br_dev_queue_push_xmit (net, sk, skb); } -static unsigned int nf_ct_bridge_confirm (struct sk_buff *skb) -{ -enum ip_conntrack_info ctinfo; -struct nf_conn *ct; -int protoff; - - ct =nf_ct_get (skb, &ctinfo); -if (!ct || ctinfo ==IP_CT_RELATED_REPLY ) -return nf_conntrack_confirm (skb); - -switch (skb->protocol) { -case htons (ETH_P_IP ): - protoff =skb_network_offset (skb) +ip_hdrlen (skb); -break ; -case htons (ETH_P_IPV6 ): { -unsigned char pnum =ipv6_hdr (skb)->nexthdr; -__be16 frag_off; - - protoff =ipv6_skip_exthdr (skb,sizeof (struct ipv6hdr ), &pnum, - &frag_off); -if (protoff <0 || (frag_off &htons (~0x7 )) !=0 ) -return nf_conntrack_confirm (skb); - } -break ; -default : -return NF_ACCEPT ; - } -return nf_confirm (skb, protoff, ct, ctinfo); -} -static unsigned int nf_ct_bridge_post (void *priv,struct sk_buff *skb,const struct nf_hook_state *state) {int ret; - ret =nf_ct_bridge_confirm (skb); + ret =nf_confirm (priv, skb, state);if (ret !=NF_ACCEPT )return ret;
net/netfilter/nf_conntrack_proto.c +55 -69
178 lines not on this page · raw message
Signature · 1 line
2.37.4
Quoted 3 lines · Florian Westphal
No need to have distinct functions. After merge, ipv6 can avoid protooff computation if the connection neither needs sequence adjustment nor helper invocation -- this is the normal case.
Applied, thanks