It is possible to create a VLAN-aware bridge via IFLA_BR_VLAN_FILTERING netlink attribute while keeping the global bridge-nf-filter-vlan-tagged sysctl off. When combining this constellation with conntrack, incoming traffic is defragmented but due to the failing is_vlan_* macros, packet refragmentation does not happen. In detail, br_nf_forward hook has to set nf_bridge->physoutdev so br_nf_post_routing hook does not return early and ip_do_fragment gets called (via br_nf_dev_queue_xmit and br_nf_ip_fragment). Extending the is_vlan_* macros to also take into account the bridge's BROPT_VLAN_ENABLED flag fixes for all this. Signed-off-by: Phil Sutter --- net/bridge/br_netfilter_hooks.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/net/bridge/br_netfilter_hooks.c b/net/bridge/br_netfilter_hooks.c index 3b28f81a461a..ae7cae0a82c7 100644 --- a/net/bridge/br_netfilter_hooks.c +++ b/net/bridge/br_netfilter_hooks.c @@ -90,27 +90,38 @@ static inline __be16 vlan_proto(const struct sk_buff *skb) return 0; } -static inline bool is_vlan_ip(const struct sk_buff *skb, const struct net *net) +static inline bool is_vlan_enabled(const struct sk_buff *skb, + const struct net *net) { struct brnf_net *brnet = net_generic(net, brnf_net_id); + struct net_bridge_port *port = NULL; + + if (brnet->filter_vlan_tagged) + return true; + + if (skb->dev) + port = br_port_get_rcu(skb->dev); + + if (port && port->br) + return br_opt_get(port->br, BROPT_VLAN_ENABLED); + + return false; +} - return vlan_proto(skb) == htons(ETH_P_IP) && brnet->filter_vlan_tagged; +static inline bool is_vlan_ip(const struct sk_buff *skb, const struct net *net) +{ + return vlan_proto(skb) == htons(ETH_P_IP) && is_vlan_enabled(skb, net); } static inline bool is_vlan_ipv6(const struct sk_buff *skb, const struct net *net) { - struct brnf_net *brnet = net_generic(net, brnf_net_id); - - return vlan_proto(skb) == htons(ETH_P_IPV6) && - brnet->filter_vlan_tagged; + return vlan_proto(skb) == htons(ETH_P_IPV6) && is_vlan_enabled(skb, net); } static inline bool is_vlan_arp(const struct sk_buff *skb, const struct net *net) { - struct brnf_net *brnet = net_generic(net, brnf_net_id); - - return vlan_proto(skb) == htons(ETH_P_ARP) && brnet->filter_vlan_tagged; + return vlan_proto(skb) == htons(ETH_P_ARP) && is_vlan_enabled(skb, net); } static inline __be16 pppoe_proto(const struct sk_buff *skb) -- 2.54.0