netfilter: nf_flow_table_ip: Introduce nf_flow_vlan_push()
Subsystems (3)
PATCH v2 1/1 netfilter: nf_flow_table_ip: Introduce nf_flow_vlan_push()
Calling skb_reset_mac_header() before calling skb_vlan_push() does remove the error:
"skb_vlan_push got skb with skb->data not at mac header (offset 18)"
But the inner vlan tag is still not inserted correctly.
skb_vlan_push() uses __vlan_insert_inner_tag() to insert the tag at offset ETH_HLEN. But the inner tag should only be pushed, without offset, similar to nf_flow_pppoe_push().
---
net/netfilter/nf_flow_table_ip.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)
net/netfilter/nf_flow_table_ip.c +22 -3
@@ -544,6 +544,26 @@ static int nf_flow_offload_forward(struct nf_flowtable_ctx *ctx,return 1 ; } +static int nf_flow_vlan_push (struct sk_buff *skb,__be16 proto,u16 id) +{ +if (skb_vlan_tag_present (skb)) { +struct vlan_hdr *vhdr; + +if (skb_cow_head (skb,VLAN_HLEN )) +return -1 ; + +__skb_push (skb,VLAN_HLEN ); +skb_reset_network_header (skb); + vhdr = (struct vlan_hdr *)(skb->data); + vhdr->h_vlan_TCI =htons (id); + vhdr->h_vlan_encapsulated_proto = skb->protocol; + skb->protocol = proto; + }else { +__vlan_hwaccel_put_tag (skb, proto, id); + } +return 0 ; +} +static int nf_flow_pppoe_push (struct sk_buff *skb,u16 id) {int data_len = skb->len +sizeof (__be16);
@@ -738,9 +758,8 @@ static int nf_flow_encap_push(struct sk_buff *skb,switch (tuple->encap[i].proto) {case htons (ETH_P_8021Q ):case htons (ETH_P_8021AD ): -skb_reset_mac_header (skb); -if (skb_vlan_push (skb, tuple->encap[i].proto, - tuple->encap[i].id) <0 ) +if (nf_flow_vlan_push (skb, tuple->encap[i].proto, + tuple->encap[i].id) <0 )return -1 ;break ;case htons (ETH_P_PPP_SES ):
Signature · 1 line
2.53.0
Pablo Neira Ayuso
maintainerQuoted 10 lines · Eric Woudstra
Calling
skb_reset_mac_header()before callingskb_vlan_push()does remove the error:"
skb_vlan_pushgot skb withskb->datanot at mac header (offset 18)"But the inner vlan tag is still not inserted correctly.
skb_vlan_push()uses__vlan_insert_inner_tag()to insert the tag at offsetETH_HLEN. But the inner tag should only be pushed, without offset, similar tonf_flow_pppoe_push().
It is doubled-tagged-vlan that is broken, right? I observed this once but I have been burdened into a few things.
Quoted 55 lines
Fixes c653d5a78f34 ("netfilter: flowtable: inline vlan encapsulation in xmit path")Fixes a3aca98aec9a ("netfilter: nf_flow_table_ip: reset mac header before vlan push")Signed-off-by Eric Woudstra <[email protected]>---
net/netfilter/nf_flow_table_ip.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)net/netfilter/nf_flow_table_ip.c +22
-3@@ -544,6 +544,26 @@ static int nf_flow_offload_forward(struct nf_flowtable_ctx *ctx,return 1 ; } +static int nf_flow_vlan_push (struct sk_buff *skb,__be16 proto,u16 id) +{ +if (skb_vlan_tag_present (skb)) { +struct vlan_hdr *vhdr; + +if (skb_cow_head (skb,VLAN_HLEN )) +return -1 ; + +__skb_push (skb,VLAN_HLEN ); +skb_reset_network_header (skb); + vhdr = (struct vlan_hdr *)(skb->data); + vhdr->h_vlan_TCI =htons (id); + vhdr->h_vlan_encapsulated_proto = skb->protocol; + skb->protocol = proto; + }else { +__vlan_hwaccel_put_tag (skb, proto, id); + } +return 0 ; +} +static int nf_flow_pppoe_push (struct sk_buff *skb,u16 id) {int data_len = skb->len +sizeof (__be16);@@ -738,9 +758,8 @@ static int nf_flow_encap_push(struct sk_buff *skb,switch (tuple->encap[i].proto) {case htons (ETH_P_8021Q ):case htons (ETH_P_8021AD ): -skb_reset_mac_header (skb); -if (skb_vlan_push (skb, tuple->encap[i].proto, - tuple->encap[i].id) <0 ) +if (nf_flow_vlan_push (skb, tuple->encap[i].proto, + tuple->encap[i].id) <0 )return -1 ;break ;case htons (ETH_P_PPP_SES ):Signature · 1 line
2.53.0
Quoted 6 lines · Pablo Neira Ayuso
Quoted 5 lines · Eric Woudstra
Calling
skb_reset_mac_header()before callingskb_vlan_push()does remove the error:"
skb_vlan_pushgot skb withskb->datanot at mac header (offset 18)"
Quoted 8 lines
Quoted 5 lines
But the inner vlan tag is still not inserted correctly.
skb_vlan_push()uses__vlan_insert_inner_tag()to insert the tag at offsetETH_HLEN. But the inner tag should only be pushed, without offset, similar tonf_flow_pppoe_push().It is doubled-tagged-vlan that is broken, right? I observed this once but I have been burdened into a few things.
That is correct, both q-in-q and q-in-ad (that may not be the correct terms, but I think it is clear).
Quoted 55 lines
Quoted 55 lines
Fixes c653d5a78f34 ("netfilter: flowtable: inline vlan encapsulation in xmit path")Fixes a3aca98aec9a ("netfilter: nf_flow_table_ip: reset mac header before vlan push")Signed-off-by Eric Woudstra <[email protected]>---
net/netfilter/nf_flow_table_ip.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)net/netfilter/nf_flow_table_ip.c +22
-3@@ -544,6 +544,26 @@ static int nf_flow_offload_forward(struct nf_flowtable_ctx *ctx,return 1 ; } +static int nf_flow_vlan_push (struct sk_buff *skb,__be16 proto,u16 id) +{ +if (skb_vlan_tag_present (skb)) { +struct vlan_hdr *vhdr; + +if (skb_cow_head (skb,VLAN_HLEN )) +return -1 ; + +__skb_push (skb,VLAN_HLEN ); +skb_reset_network_header (skb); + vhdr = (struct vlan_hdr *)(skb->data); + vhdr->h_vlan_TCI =htons (id); + vhdr->h_vlan_encapsulated_proto = skb->protocol; + skb->protocol = proto; + }else { +__vlan_hwaccel_put_tag (skb, proto, id); + } +return 0 ; +} +static int nf_flow_pppoe_push (struct sk_buff *skb,u16 id) {int data_len = skb->len +sizeof (__be16);@@ -738,9 +758,8 @@ static int nf_flow_encap_push(struct sk_buff *skb,switch (tuple->encap[i].proto) {case htons (ETH_P_8021Q ):case htons (ETH_P_8021AD ): -skb_reset_mac_header (skb); -if (skb_vlan_push (skb, tuple->encap[i].proto, - tuple->encap[i].id) <0 ) +if (nf_flow_vlan_push (skb, tuple->encap[i].proto, + tuple->encap[i].id) <0 )return -1 ;break ;case htons (ETH_P_PPP_SES ):Signature · 1 line
2.53.0