[libvirt] [PATCH] openvswitch: Add new port VLAN mode "dot1q-tunnel"

luzhipeng at uniudc.com luzhipeng at uniudc.com
Fri Nov 23 15:00:33 UTC 2018


From: ZhiPeng Lu <luzhipeng at uniudc.com>

Signed-off-by: ZhiPeng Lu <luzhipeng at uniudc.com>
---
 docs/formatnetwork.html.in      | 13 +++++++------
 docs/schemas/networkcommon.rng  |  1 +
 src/conf/netdev_vlan_conf.c     |  2 +-
 src/util/virnetdevopenvswitch.c |  5 +++++
 src/util/virnetdevvlan.h        |  1 +
 5 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/docs/formatnetwork.html.in b/docs/formatnetwork.html.in
index 363a72b..de223e6 100644
--- a/docs/formatnetwork.html.in
+++ b/docs/formatnetwork.html.in
@@ -688,16 +688,17 @@
     </p>
     <p>
       For network connections using Open vSwitch it is also possible
-      to configure 'native-tagged' and 'native-untagged' VLAN modes
+      to configure 'native-tagged' and 'native-untagged' and 
+      'dot1q-tunnel' VLAN modes
       <span class="since">Since 1.1.0.</span> This is done with the
       optional <code>nativeMode</code> attribute on
       the <code><tag></code> subelement: <code>nativeMode</code>
-      may be set to 'tagged' or 'untagged'. The <code>id</code>
-      attribute of the <code><tag></code> subelement
-      containing <code>nativeMode</code> sets which VLAN is considered
-      to be the "native" VLAN for this interface, and
+      may be set to 'tagged' or 'untagged' or 'dot1q-tunnel'. 
+      The <code>id</code> attribute of the <code><tag></code> 
+      subelement containing <code>nativeMode</code> sets which VLAN is 
+      considered to be the "native" VLAN for this interface, and
       the <code>nativeMode</code> attribute determines whether or not
-      traffic for that VLAN will be tagged.
+      traffic for that VLAN will be tagged or QinQ.
     </p>
     <p>
       <code><vlan></code> elements can also be specified in
diff --git a/docs/schemas/networkcommon.rng b/docs/schemas/networkcommon.rng
index 2699555..11c48ff 100644
--- a/docs/schemas/networkcommon.rng
+++ b/docs/schemas/networkcommon.rng
@@ -223,6 +223,7 @@
               <choice>
                 <value>tagged</value>
                 <value>untagged</value>
+                <value>dot1q-tunnel</value>
               </choice>
             </attribute>
           </optional>
diff --git a/src/conf/netdev_vlan_conf.c b/src/conf/netdev_vlan_conf.c
index dff49c6..79710d9 100644
--- a/src/conf/netdev_vlan_conf.c
+++ b/src/conf/netdev_vlan_conf.c
@@ -29,7 +29,7 @@
 #define VIR_FROM_THIS VIR_FROM_NONE
 
 VIR_ENUM_IMPL(virNativeVlanMode, VIR_NATIVE_VLAN_MODE_LAST,
-              "default", "tagged", "untagged")
+              "default", "tagged", "untagged", "dot1q-tunnel")
 
 int
 virNetDevVlanParse(xmlNodePtr node, xmlXPathContextPtr ctxt, virNetDevVlanPtr def)
diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index 8fe06fd..ba5e333 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -91,6 +91,11 @@ virNetDevOpenvswitchConstructVlans(virCommandPtr cmd, virNetDevVlanPtr virtVlan)
         virCommandAddArg(cmd, "vlan_mode=native-untagged");
         virCommandAddArgFormat(cmd, "tag=%d", virtVlan->nativeTag);
         break;
+    case VIR_NATIVE_VLAN_MODE_DOT1Q_TUNNEL:
+        virCommandAddArg(cmd, "vlan_mode=dot1q-tunnel");
+        virCommandAddArg(cmd, "other_config:qinq-ethtype=802.1q");
+        virCommandAddArgFormat(cmd, "tag=%d", virtVlan->nativeTag);
+        break;
     case VIR_NATIVE_VLAN_MODE_DEFAULT:
     default:
         break;
diff --git a/src/util/virnetdevvlan.h b/src/util/virnetdevvlan.h
index be85f59..0667f9d 100644
--- a/src/util/virnetdevvlan.h
+++ b/src/util/virnetdevvlan.h
@@ -29,6 +29,7 @@ typedef enum {
     VIR_NATIVE_VLAN_MODE_DEFAULT = 0,
     VIR_NATIVE_VLAN_MODE_TAGGED,
     VIR_NATIVE_VLAN_MODE_UNTAGGED,
+    VIR_NATIVE_VLAN_MODE_DOT1Q_TUNNEL,
 
     VIR_NATIVE_VLAN_MODE_LAST
 } virNativeVlanMode;
-- 
1.8.3.1




More information about the libvir-list mailing list