[ovs-dev] [PATCH v4 1/4] Add support for 802.1ad (QinQ tunneling)

Ben Pfaff blp at ovn.org
Mon Jul 25 16:52:22 UTC 2016


On Tue, Jul 12, 2016 at 11:38:54PM +0800, Xiao Liang wrote:
> Flow key handleing changes:
> - Add VLAN header array in struct flow, to record multiple 802.1q VLAN
>   headers.
> - Add dpif multi-VLAN capability probing. If datapath supports multi-VLAN,
>   increase the maximum depth of nested OVS_KEY_ATTR_ENCAP.
> 
> Refacter VLAN handling in dpif-xlate:
> - Introduce 'xvlan' to track VLAN stack during flow processing.
> - Input and output VLAN translation according to the xbundle type.
> 
> Push VLAN action support:
> - Allow ethertype 0x88a8 in VLAN headers and push_vlan action.
> - Support push_vlan on dot1q packets.
> 
> Add new port VLAN mode "dot1q-tunnel":
> - Example:
>     ovs-vsctl set Port p1 vlan_mode=dot1q-tunnel tag=100
>   Pushes another VLAN 100 header on packets (tagged and untagged) on ingress,
>   and pops it on egress.
> - Customer VLAN check:
>     ovs-vsctl set Port p1 vlan_mode=dot1q-tunnel tag=100 cvlans=10,20
>   Only customer VLAN of 10 and 20 are allowed.
> 
> Signed-off-by: Xiao Liang <shaw.leon at gmail.com>

The following incremental fixes some warnings from "sparse".  The one
from odp-util.c seems petty, but the others correct real conceptual
errors even if they would not be bugs in practice.

diff --git a/lib/odp-util.c b/lib/odp-util.c
index 46ff6de..56a6145 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -5047,7 +5047,7 @@ parse_8021q_onward(const struct nlattr *attrs[OVS_KEY_ATTR_MAX + 1],
 
     while (encaps < FLOW_MAX_VLAN_HEADERS &&
            (is_mask?
-            (src_flow->vlan[encaps].tci & htons(VLAN_CFI)) :
+            (src_flow->vlan[encaps].tci & htons(VLAN_CFI)) != 0 :
             eth_type_vlan(flow->dl_type))) {
         /* Calculate fitness of outer attributes. */
         encap  = (present_attrs & (UINT64_C(1) << OVS_KEY_ATTR_ENCAP)
diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c
index c4b656e..7184184 100644
--- a/lib/ofp-actions.c
+++ b/lib/ofp-actions.c
@@ -1666,7 +1666,7 @@ static void
 format_PUSH_VLAN(const struct ofpact_push_vlan *push_vlan, struct ds *s)
 {
     ds_put_format(s, "%spush_vlan:%s%#"PRIx16,
-                  colors.param, colors.end, htons(push_vlan->ethertype));
+                  colors.param, colors.end, ntohs(push_vlan->ethertype));
 }
 
 /* Action structure for OFPAT10_SET_DL_SRC/DST and OFPAT11_SET_DL_SRC/DST. */
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index fd41ac8..90cf74a 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -1920,7 +1920,7 @@ xvlan_extract(const struct flow *flow, struct xvlan *xvlan)
                 !(flow->vlan[i].tci & htons(VLAN_CFI))) {
             break;
         }
-        xvlan[i].tpid = htons(flow->vlan[i].tpid);
+        xvlan[i].tpid = ntohs(flow->vlan[i].tpid);
         xvlan[i].vid = vlan_tci_to_vid(flow->vlan[i].tci);
         xvlan[i].pcp = flow->vlan[i].tci & htons(VLAN_PCP_MASK);
     }



More information about the dev mailing list