Skip to content

Commit d7b5974

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: bridge: restore vlan tag when refragmenting
If bridge netfilter is used with both bridge-nf-call-iptables and bridge-nf-filter-vlan-tagged enabled then ip fragments in VLAN frames are sent without the vlan header. This has never worked reliably. Turns out this relied on pre-3.5 behaviour where skb frag_list was used to store ip fragments; ip_fragment() then re-used these skbs. But since commit 3cc4949 ("ipv4: use skb coalescing in defragmentation") this is no longer the case. ip_do_fragment now needs to allocate new skbs, but these don't contain the vlan tag information anymore. Fix it by storing vlan information of the ressembled skb in the br netfilter percpu frag area, and restore them for each of the fragments. Fixes: 3cc4949 ("ipv4: use skb coalescing in defragmentation") Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 33b1f31 commit d7b5974

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

net/bridge/br_netfilter.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ struct brnf_frag_data {
116116
char mac[NF_BRIDGE_MAX_MAC_HEADER_LENGTH];
117117
u8 encap_size;
118118
u8 size;
119+
u16 vlan_tci;
120+
__be16 vlan_proto;
119121
};
120122

121123
static DEFINE_PER_CPU(struct brnf_frag_data, brnf_frag_data_storage);
@@ -909,6 +911,11 @@ static int br_nf_push_frag_xmit(struct sock *sk, struct sk_buff *skb)
909911
return 0;
910912
}
911913

914+
if (data->vlan_tci) {
915+
skb->vlan_tci = data->vlan_tci;
916+
skb->vlan_proto = data->vlan_proto;
917+
}
918+
912919
skb_copy_to_linear_data_offset(skb, -data->size, data->mac, data->size);
913920
__skb_push(skb, data->encap_size);
914921

@@ -972,6 +979,9 @@ static int br_nf_dev_queue_xmit(struct sock *sk, struct sk_buff *skb)
972979
nf_bridge_update_protocol(skb);
973980

974981
data = this_cpu_ptr(&brnf_frag_data_storage);
982+
983+
data->vlan_tci = skb->vlan_tci;
984+
data->vlan_proto = skb->vlan_proto;
975985
data->encap_size = nf_bridge_encap_header_len(skb);
976986
data->size = ETH_HLEN + data->encap_size;
977987

0 commit comments

Comments
 (0)