[PATCH] [PATCH v13-pre1] add 802.1Qbh and 802.1Qbg handling

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

 



From: Scott Feldman <scofeldm@xxxxxxxxx>

Stefan, I was doing more testing and have some fixes for the bh paths. This
patch is on top of your V12 patch...

- some minor cleanups
- if association fails due to timeout, disassociate the port profile,
  otherwise association state-machine will be "in-progress" potentially
  forever.
- don't pass mac/vlan/uuids/profile when disassociating.  ifindex and vf
  are enough

Signed-off-by: Scott Feldman <scofeldm@xxxxxxxxx>
---
 src/util/macvtap.c |   75 ++++++++++++++++++++++++++++++----------------------
 1 files changed, 43 insertions(+), 32 deletions(-)


diff --git a/src/util/macvtap.c b/src/util/macvtap.c
index 71c6169..9ca6203 100644
--- a/src/util/macvtap.c
+++ b/src/util/macvtap.c
@@ -963,11 +963,11 @@ getPortProfileStatus(struct nlattr **tb, int32_t vf,
         if (tb[IFLA_PORT_SELF]) {
             if (nla_parse_nested(tb_port, IFLA_PORT_MAX, tb[IFLA_PORT_SELF],
                                  ifla_port_policy)) {
-                msg = _("error parsing IFLA_VF_SELF part");
+                msg = _("error parsing IFLA_PORT_SELF part");
                 goto err_exit;
             }
         } else {
-            msg = _("IFLA_VF_SELF is missing");
+            msg = _("IFLA_PORT_SELF is missing");
             goto err_exit;
         }
     } else {
@@ -1266,7 +1266,7 @@ doPortProfileOpCommon(bool nltarget_kernel,
                                 vf,
                                 op);
 
-    if (rc != 0) {
+    if (rc) {
         macvtapError(VIR_ERR_INTERNAL_ERROR, "%s",
                      _("sending of PortProfileRequest failed."));
         return rc;
@@ -1278,7 +1278,7 @@ doPortProfileOpCommon(bool nltarget_kernel,
             goto err_exit;
         rc = getPortProfileStatus(tb, vf, instanceId, nltarget_kernel,
                                   is8021Qbg, &status);
-        if (rc != 0)
+        if (rc)
             goto err_exit;
         if (status == PORT_PROFILE_RESPONSE_SUCCESS ||
             status == PORT_VDP_RESPONSE_SUCCESS) {
@@ -1478,16 +1478,11 @@ doPortProfileOp8021Qbh(const char *ifname,
     char *physfndev;
     unsigned char hostuuid[VIR_UUID_BUFLEN];
     int32_t vf;
-    int op = PORT_REQUEST_ASSOCIATE;
     bool nltarget_kernel = true;
     int ifindex;
     int vlanid = -1;
     const unsigned char *macaddr = NULL;
 
-    rc = virGetHostUUID(hostuuid);
-    if (rc)
-        goto err_exit;
-
     rc = getPhysfn(ifname, &vf, &physfndev);
     if (rc)
         goto err_exit;
@@ -1499,35 +1494,51 @@ doPortProfileOp8021Qbh(const char *ifname,
 
     switch (virtPortOp) {
     case ASSOCIATE:
-        op = PORT_REQUEST_ASSOCIATE;
+        rc = virGetHostUUID(hostuuid);
+        if (rc)
+            goto err_exit;
+
+        rc = doPortProfileOpCommon(nltarget_kernel, NULL, ifindex,
+                                   macaddr,
+                                   vlanid,
+                                   virtPort->u.virtPort8021Qbh.profileID,
+                                   NULL,
+                                   vm_uuid,
+                                   hostuuid,
+                                   vf,
+                                   PORT_REQUEST_ASSOCIATE);
+        if (rc == -ETIMEDOUT)
+            /* Association timed out, disassociate */
+            doPortProfileOpCommon(nltarget_kernel, NULL, ifindex,
+                                  NULL,
+                                  0,
+                                  NULL,
+                                  NULL,
+                                  NULL,
+                                  NULL,
+                                  vf,
+                                  PORT_REQUEST_DISASSOCIATE);
+        if (!rc)
+            ifaceUp(ifname);
         break;
+
     case DISASSOCIATE:
-        op = PORT_REQUEST_DISASSOCIATE;
+        rc = doPortProfileOpCommon(nltarget_kernel, NULL, ifindex,
+                                   NULL,
+                                   0,
+                                   NULL,
+                                   NULL,
+                                   NULL,
+                                   NULL,
+                                   vf,
+                                   PORT_REQUEST_DISASSOCIATE);
+        ifaceDown(ifname);
         break;
+
     default:
         macvtapError(VIR_ERR_INTERNAL_ERROR,
-                     _("operation type %d not supported"), op);
+                     _("operation type %d not supported"), virtPortOp);
         rc = 1;
-        goto err_exit;
-    }
-
-    rc = doPortProfileOpCommon(nltarget_kernel, NULL, ifindex,
-                               macaddr,
-                               vlanid,
-                               virtPort->u.virtPort8021Qbh.profileID,
-                               NULL,
-                               vm_uuid,
-                               hostuuid,
-                               vf,
-                               op);
-
-    switch (virtPortOp) {
-    case ASSOCIATE:
-        ifaceUp(ifname);
-        break;
-    case DISASSOCIATE:
-        ifaceDown(ifname);
-        break;
     }
 
 err_exit:

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]