[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH v4 RESEND] openvswitch: Add new port VLAN mode "dot1q-tunnel"(802.1ad double-tagged)



From: ZhiPeng Lu <luzhipeng uniudc com>

This patch adds functionality to allow libvirt to configure the 'dot1q-tunnel'
modes(802.1ad double-tagged) on openvswitch networks.
For example:
    <interface type='bridge'>
      <mac address='2c:da:41:1d:05:42'/>
      <source bridge='ovs0'/>
      <vlan>
        <tag id='41' nativeMode='dot1q-tunnel'/>
      </vlan>
      <virtualport type='openvswitch'>
        <parameters interfaceid='6401a152-0b99-40b5-92be-858810aa6d37'/>
      </virtualport>
      <model type='virtio'/>
      <driver name='vhost'/>
      <alias name='net0'/>
    </interface>

Signed-off-by: ZhiPeng Lu <luzhipeng uniudc com>
---
 v1->v2:
   1. Fix "make syntax-check" failure
 v2->v3:
   1. remove other_config when updating vlan
 v3->v4:
   1. add commit message that has a brief description of the new
feature
   2. add tests for 'dot1q-tunnel' vlan mode

 docs/formatdomain.html.in                            | 20 ++++++++++++++------
 docs/formatnetwork.html.in                           | 20 +++++++++++---------
 docs/schemas/networkcommon.rng                       |  1 +
 src/conf/netdev_vlan_conf.c                          |  2 +-
 src/util/virnetdevopenvswitch.c                      |  7 +++++++
 src/util/virnetdevvlan.h                             |  1 +
 tests/networkxml2xmlin/openvswitch-net.xml           |  9 +++++++++
 tests/networkxml2xmlout/openvswitch-net.xml          |  9 +++++++++
 .../openvswitch-net-modified.xml                     |  9 +++++++++
 .../openvswitch-net-more-portgroups.xml              |  9 +++++++++
 .../openvswitch-net-without-alice.xml                |  9 +++++++++
 11 files changed, 80 insertions(+), 16 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 84259c4..ced21c0 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -6085,8 +6085,14 @@ qemu-kvm -net nic,model=? /dev/null
       <b>&lt;tag id='42'/&gt;</b>
       <b>&lt;tag id='123' nativeMode='untagged'/&gt;</b>
     <b>&lt;/vlan&gt;</b>
-    ...
   &lt;/interface&gt;
+  &lt;interface type='bridge'&gt;
+    <b>&lt;vlan trunk='yes'&gt;</b>
+      <b>&lt;tag id='42'/&gt;</b>
+      <b>&lt;tag id='123' nativeMode='dot1q-tunnel'/&gt;</b>
+    <b>&lt;/vlan&gt;</b>
+  &lt;/interface&gt;
+...
 &lt;/devices&gt;
 ...</pre>
 
@@ -6122,11 +6128,13 @@ qemu-kvm -net nic,model=? /dev/null
     </p>
     <p>
       For network connections using Open vSwitch it is also possible
-      to configure 'native-tagged' and 'native-untagged' VLAN modes
-      <span class="since">Since 1.1.0.</span> This is done with the
-      optional <code>nativeMode</code> attribute on
-      the <code>&lt;tag&gt;</code> subelement: <code>nativeMode</code>
-      may be set to 'tagged' or 'untagged'. The <code>id</code>
+      to configure 'native-tagged' and 'native-untagged'
+      <span class="since">Since 1.1.0.</span> and 'dot1q-tunnel'
+      (802.1ad double-tagged) <span class="since">Since 5.0.0.</span>
+      VLAN modes This is done with the optional <code>nativeMode</code>
+      attribute on the <code>&lt;tag&gt;</code> subelement:
+      <code>nativeMode</code> may be set to 'tagged' or 'untagged' or
+      'dot1q-tunnel'. The <code>id</code>
       attribute of the <code>&lt;tag&gt;</code> subelement
       containing <code>nativeMode</code> sets which VLAN is considered
       to be the "native" VLAN for this interface, and
diff --git a/docs/formatnetwork.html.in b/docs/formatnetwork.html.in
index 363a72b..d9ac9f7 100644
--- a/docs/formatnetwork.html.in
+++ b/docs/formatnetwork.html.in
@@ -688,16 +688,18 @@
     </p>
     <p>
       For network connections using Open vSwitch it is also possible
-      to configure 'native-tagged' and 'native-untagged' VLAN modes
-      <span class="since">Since 1.1.0.</span> This is done with the
-      optional <code>nativeMode</code> attribute on
-      the <code>&lt;tag&gt;</code> subelement: <code>nativeMode</code>
-      may be set to 'tagged' or 'untagged'. The <code>id</code>
-      attribute of the <code>&lt;tag&gt;</code> subelement
-      containing <code>nativeMode</code> sets which VLAN is considered
-      to be the "native" VLAN for this interface, and
+      to configure 'native-tagged' and 'native-untagged'
+      <span class="since">Since 1.1.0.</span>
+      and 'dot1q-tunnel'(802.1ad double-tagged) VLAN modes.
+      <span class="since">Since 5.0.0.</span> This is done with the
+      optional <code>nativeMode</code> attribute on the
+      <code>&lt;tag&gt;</code> subelement: <code>nativeMode</code>
+      may be set to 'tagged' or 'untagged' or 'dot1q-tunnel'.
+      The <code>id</code> attribute of the <code>&lt;tag&gt;</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>&lt;vlan&gt;</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..2cc576f 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;
@@ -504,6 +509,8 @@ int virNetDevOpenvswitchUpdateVlan(const char *ifname,
                          "--", "--if-exists", "clear", "Port", ifname, "tag",
                          "--", "--if-exists", "clear", "Port", ifname, "trunk",
                          "--", "--if-exists", "clear", "Port", ifname, "vlan_mode",
+                         "--", "--if-exists", "remove", "Port", ifname, "other_config",
+                         "qinq-ethtype",
                          "--", "--if-exists", "set", "Port", ifname, NULL);
 
     if (virNetDevOpenvswitchConstructVlans(cmd, virtVlan) < 0)
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;
diff --git a/tests/networkxml2xmlin/openvswitch-net.xml b/tests/networkxml2xmlin/openvswitch-net.xml
index 2f6084d..0952859 100644
--- a/tests/networkxml2xmlin/openvswitch-net.xml
+++ b/tests/networkxml2xmlin/openvswitch-net.xml
@@ -30,4 +30,13 @@
       <parameters profileid='native-profile'/>
     </virtualport>
   </portgroup>
+  <portgroup name='8021ad'>
+    <vlan trunk='yes'>
+      <tag id='555' nativeMode='dot1q-tunnel'/>
+      <tag id='666'/>
+    </vlan>
+    <virtualport>
+      <parameters profileid='8021ad-profile'/>
+    </virtualport>
+  </portgroup>
 </network>
diff --git a/tests/networkxml2xmlout/openvswitch-net.xml b/tests/networkxml2xmlout/openvswitch-net.xml
index 2f6084d..0952859 100644
--- a/tests/networkxml2xmlout/openvswitch-net.xml
+++ b/tests/networkxml2xmlout/openvswitch-net.xml
@@ -30,4 +30,13 @@
       <parameters profileid='native-profile'/>
     </virtualport>
   </portgroup>
+  <portgroup name='8021ad'>
+    <vlan trunk='yes'>
+      <tag id='555' nativeMode='dot1q-tunnel'/>
+      <tag id='666'/>
+    </vlan>
+    <virtualport>
+      <parameters profileid='8021ad-profile'/>
+    </virtualport>
+  </portgroup>
 </network>
diff --git a/tests/networkxml2xmlupdateout/openvswitch-net-modified.xml b/tests/networkxml2xmlupdateout/openvswitch-net-modified.xml
index cc0c344..e5794fc 100644
--- a/tests/networkxml2xmlupdateout/openvswitch-net-modified.xml
+++ b/tests/networkxml2xmlupdateout/openvswitch-net-modified.xml
@@ -30,4 +30,13 @@
       <parameters profileid='native-profile'/>
     </virtualport>
   </portgroup>
+  <portgroup name='8021ad'>
+    <vlan trunk='yes'>
+      <tag id='555' nativeMode='dot1q-tunnel'/>
+      <tag id='666'/>
+    </vlan>
+    <virtualport>
+      <parameters profileid='8021ad-profile'/>
+    </virtualport>
+  </portgroup>
 </network>
diff --git a/tests/networkxml2xmlupdateout/openvswitch-net-more-portgroups.xml b/tests/networkxml2xmlupdateout/openvswitch-net-more-portgroups.xml
index 7c19ad9..3df0b96 100644
--- a/tests/networkxml2xmlupdateout/openvswitch-net-more-portgroups.xml
+++ b/tests/networkxml2xmlupdateout/openvswitch-net-more-portgroups.xml
@@ -41,4 +41,13 @@
       <parameters profileid='native-profile'/>
     </virtualport>
   </portgroup>
+  <portgroup name='8021ad'>
+    <vlan trunk='yes'>
+      <tag id='555' nativeMode='dot1q-tunnel'/>
+      <tag id='666'/>
+    </vlan>
+    <virtualport>
+      <parameters profileid='8021ad-profile'/>
+    </virtualport>
+  </portgroup>
 </network>
diff --git a/tests/networkxml2xmlupdateout/openvswitch-net-without-alice.xml b/tests/networkxml2xmlupdateout/openvswitch-net-without-alice.xml
index 4104424..38846aa 100644
--- a/tests/networkxml2xmlupdateout/openvswitch-net-without-alice.xml
+++ b/tests/networkxml2xmlupdateout/openvswitch-net-without-alice.xml
@@ -20,4 +20,13 @@
       <parameters profileid='native-profile'/>
     </virtualport>
   </portgroup>
+  <portgroup name='8021ad'>
+    <vlan trunk='yes'>
+      <tag id='555' nativeMode='dot1q-tunnel'/>
+      <tag id='666'/>
+    </vlan>
+    <virtualport>
+      <parameters profileid='8021ad-profile'/>
+    </virtualport>
+  </portgroup>
 </network>
-- 
1.8.3.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]