[ovs-dev] [PATCH v3 1/4] tc: Add VLAN tpid for push action

Jianbo Liu jianbol at mellanox.com
Tue Jul 17 02:01:54 UTC 2018


Currently we only support 802.1q, so we can offload push action without
specifying any vlan type. Kernel will push 802.1q ethertype by default.

But to support QinQ, we need to tell what ethertype is in push action as
it could be 802.1ad.

Signed-off-by: Jianbo Liu <jianbol at mellanox.com>
Reviewed-by: Roi Dayan <roid at mellanox.com>
---
 lib/netdev-tc-offloads.c | 1 +
 lib/tc.c                 | 7 ++++++-
 lib/tc.h                 | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c
index bdf288c..93a762d 100644
--- a/lib/netdev-tc-offloads.c
+++ b/lib/netdev-tc-offloads.c
@@ -1077,6 +1077,7 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match,
         } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_PUSH_VLAN) {
             const struct ovs_action_push_vlan *vlan_push = nl_attr_get(nla);
 
+            action->vlan.vlan_push_tpid = vlan_push->vlan_tpid;
             action->vlan.vlan_push_id = vlan_tci_to_vid(vlan_push->vlan_tci);
             action->vlan.vlan_push_prio = vlan_tci_to_pcp(vlan_push->vlan_tci);
             action->type = TC_ACT_VLAN_PUSH;
diff --git a/lib/tc.c b/lib/tc.c
index 7a71036..66234ce 100644
--- a/lib/tc.c
+++ b/lib/tc.c
@@ -784,9 +784,11 @@ nl_parse_act_vlan(struct nlattr *options, struct tc_flower *flower)
     vlan_parms = vlan_attrs[TCA_VLAN_PARMS];
     v = nl_attr_get_unspec(vlan_parms, sizeof *v);
     if (v->v_action == TCA_VLAN_ACT_PUSH) {
+        struct nlattr *vlan_tpid = vlan_attrs[TCA_VLAN_PUSH_VLAN_PROTOCOL];
         struct nlattr *vlan_id = vlan_attrs[TCA_VLAN_PUSH_VLAN_ID];
         struct nlattr *vlan_prio = vlan_attrs[TCA_VLAN_PUSH_VLAN_PRIORITY];
 
+        action->vlan.vlan_push_tpid = nl_attr_get_u16(vlan_tpid);
         action->vlan.vlan_push_id = nl_attr_get_u16(vlan_id);
         action->vlan.vlan_push_prio = vlan_prio ? nl_attr_get_u8(vlan_prio) : 0;
         action->type = TC_ACT_VLAN_PUSH;
@@ -1158,7 +1160,8 @@ nl_msg_put_act_pedit(struct ofpbuf *request, struct tc_pedit *parm,
 }
 
 static void
-nl_msg_put_act_push_vlan(struct ofpbuf *request, uint16_t vid, uint8_t prio)
+nl_msg_put_act_push_vlan(struct ofpbuf *request, uint16_t tpid,
+                         uint16_t vid, uint8_t prio)
 {
     size_t offset;
 
@@ -1169,6 +1172,7 @@ nl_msg_put_act_push_vlan(struct ofpbuf *request, uint16_t vid, uint8_t prio)
                                 .v_action = TCA_VLAN_ACT_PUSH };
 
         nl_msg_put_unspec(request, TCA_VLAN_PARMS, &parm, sizeof parm);
+        nl_msg_put_u16(request, TCA_VLAN_PUSH_VLAN_PROTOCOL, tpid);
         nl_msg_put_u16(request, TCA_VLAN_PUSH_VLAN_ID, vid);
         nl_msg_put_u8(request, TCA_VLAN_PUSH_VLAN_PRIORITY, prio);
     }
@@ -1489,6 +1493,7 @@ nl_msg_put_flower_acts(struct ofpbuf *request, struct tc_flower *flower)
             case TC_ACT_VLAN_PUSH: {
                 act_offset = nl_msg_start_nested(request, act_index++);
                 nl_msg_put_act_push_vlan(request,
+                                         action->vlan.vlan_push_tpid,
                                          action->vlan.vlan_push_id,
                                          action->vlan.vlan_push_prio);
                 nl_msg_end_nested(request, act_offset);
diff --git a/lib/tc.h b/lib/tc.h
index 80505f0..d954819 100644
--- a/lib/tc.h
+++ b/lib/tc.h
@@ -119,6 +119,7 @@ struct tc_action {
         int ifindex_out;
 
         struct {
+            ovs_be16 vlan_push_tpid;
             uint16_t vlan_push_id;
             uint8_t vlan_push_prio;
         } vlan;
-- 
2.9.5



More information about the dev mailing list