@@ -887,6 +887,7 @@ struct net_device_path {
DEV_PATH_BR_VLAN_TAG,
DEV_PATH_BR_VLAN_UNTAG,
DEV_PATH_BR_VLAN_UNTAG_HW,
+ DEV_PATH_BR_VLAN_KEEP_HW,
} vlan_mode;
u16 vlan_id;
__be16 vlan_proto;
@@ -423,6 +423,7 @@ static int br_fill_forward_path(struct net_device_path_ctx *ctx,
case DEV_PATH_BR_VLAN_UNTAG:
ctx->num_vlans--;
break;
+ case DEV_PATH_BR_VLAN_KEEP_HW:
case DEV_PATH_BR_VLAN_KEEP:
break;
}
@@ -1490,13 +1490,17 @@ int br_vlan_fill_forward_path_mode(struct net_bridge *br,
if (!(v->flags & BRIDGE_VLAN_INFO_UNTAGGED))
return 0;
- if (path->bridge.vlan_mode == DEV_PATH_BR_VLAN_TAG)
- path->bridge.vlan_mode = DEV_PATH_BR_VLAN_KEEP;
- else if (v->priv_flags & BR_VLFLAG_TAGGING_BY_SWITCHDEV)
- path->bridge.vlan_mode = DEV_PATH_BR_VLAN_UNTAG_HW;
- else
- path->bridge.vlan_mode = DEV_PATH_BR_VLAN_UNTAG;
-
+ if (path->bridge.vlan_mode == DEV_PATH_BR_VLAN_TAG) {
+ if (v->priv_flags & BR_VLFLAG_TAGGING_BY_SWITCHDEV)
+ path->bridge.vlan_mode = DEV_PATH_BR_VLAN_KEEP_HW;
+ else
+ path->bridge.vlan_mode = DEV_PATH_BR_VLAN_KEEP;
+ } else {
+ if (v->priv_flags & BR_VLFLAG_TAGGING_BY_SWITCHDEV)
+ path->bridge.vlan_mode = DEV_PATH_BR_VLAN_UNTAG_HW;
+ else
+ path->bridge.vlan_mode = DEV_PATH_BR_VLAN_UNTAG;
+ }
return 0;
}
@@ -145,6 +145,9 @@ static void nft_dev_path_info(const struct net_device_path_stack *stack,
case DEV_PATH_BR_VLAN_UNTAG_HW:
info->ingress_vlans |= BIT(info->num_encaps - 1);
break;
+ case DEV_PATH_BR_VLAN_KEEP_HW:
+ info->ingress_vlans |= BIT(info->num_encaps);
+ fallthrough;
case DEV_PATH_BR_VLAN_TAG:
info->encap[info->num_encaps].id = path->bridge.vlan_id;
info->encap[info->num_encaps].proto = path->bridge.vlan_proto;
Following the path through a bridge, there are 2 situations where the action is to keep: 1. Packets have the encap, and keep the tag at ingress and keep it at egress. It is typical in the forward path, when a vlan-device and bridge are combined. 2. Packets do not have the encap, are tagged at ingress and untagged at egress. Can be found when only a bridge is in the forward path. It is also possible in the bridged path. For switchdev userports that support SWITCHDEV_OBJ_ID_PORT_VLAN in sitaution 2, it is necessary to introduce DEV_PATH_BR_VLAN_KEEP_HW. The typical situation 1 is unchanged: DEV_PATH_BR_VLAN_KEEP. DEV_PATH_BR_VLAN_KEEP_HW is similar to DEV_PATH_BR_VLAN_TAG, with the correcponding bit in ingress_vlans set. Signed-off-by: Eric Woudstra <ericwouds@gmail.com> --- include/linux/netdevice.h | 1 + net/bridge/br_device.c | 1 + net/bridge/br_vlan.c | 18 +++++++++++------- net/netfilter/nft_flow_offload.c | 3 +++ 4 files changed, 16 insertions(+), 7 deletions(-)