Blame SOURCES/libvirt-util-check-accept_ra-for-all-nexthop-interfaces-of-multipath-routes.patch

edecca
From 1e443270387834e84a335ec500cf069172ab261c Mon Sep 17 00:00:00 2001
edecca
Message-Id: <1e443270387834e84a335ec500cf069172ab261c@dist-git>
edecca
From: Laine Stump <laine@laine.org>
edecca
Date: Mon, 14 Jan 2019 11:35:05 -0500
edecca
Subject: [PATCH] util: check accept_ra for all nexthop interfaces of multipath
edecca
 routes
edecca
edecca
When checking the setting of accept_ra, we have assumed that all
edecca
routes have a single nexthop, so the interface of the route would be
edecca
in the RTA_OIF attribute of the netlink RTM_NEWROUTE message. But
edecca
multipath routes don't have an RTA_OIF; instead, they have an
edecca
RTA_MULTIPATH attribute, which is an array of rtnexthop, with each
edecca
rtnexthop having an interface. This patch adds a loop to look at the
edecca
setting of accept_ra of the interface for every rtnexthop in the
edecca
array.
edecca
edecca
Signed-off-by: Laine Stump <laine@laine.org>
edecca
Reviewed-by: Erik Skultety <eskultet@redhat.com>
edecca
(cherry picked from commit d40b820c5d3b0c9d5222844110881af66cdbb746)
edecca
edecca
https://bugzilla.redhat.com/1583131
edecca
edecca
Conflicts: src/util/virnetdevip.c - more context conflicts due to addition of
edecca
        VIR_AUTOPTR and resulting removal of cleanup/error labels upstream.
edecca
Signed-off-by: Laine Stump <laine@laine.org>
edecca
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
edecca
---
edecca
 src/util/virnetdevip.c | 37 +++++++++++++++++++++++++++++++++++++
edecca
 1 file changed, 37 insertions(+)
edecca
edecca
diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c
edecca
index d56f4f05f3..fff41ec498 100644
edecca
--- a/src/util/virnetdevip.c
edecca
+++ b/src/util/virnetdevip.c
edecca
@@ -601,6 +601,43 @@ virNetDevIPCheckIPv6ForwardingCallback(struct nlmsghdr *resp,
edecca
         goto cleanup;
edecca
     }
edecca
 
edecca
+    /* if no RTA_OIF was found, see if this is a multipath route (one
edecca
+     * which has an array of nexthops, each with its own interface)
edecca
+     */
edecca
+
edecca
+    rta_attr = (struct rtattr *)nlmsg_find_attr(resp, sizeof(struct rtmsg), RTA_MULTIPATH);
edecca
+    if (rta_attr) {
edecca
+        /* The data of the attribute is an array of rtnexthop */
edecca
+        struct rtnexthop *nh = RTA_DATA(rta_attr);
edecca
+        size_t len = RTA_PAYLOAD(rta_attr);
edecca
+
edecca
+        /* validate the attribute array length */
edecca
+        len = MIN(len, ((char *)resp + NLMSG_PAYLOAD(resp, 0) - (char *)rta_attr));
edecca
+
edecca
+        while (len >= sizeof(*nh) && len >= nh->rtnh_len) {
edecca
+            /* check accept_ra for the interface of each nexthop */
edecca
+
edecca
+            ifname = virNetDevGetName(nh->rtnh_ifindex);
edecca
+
edecca
+            if (ifname)
edecca
+                accept_ra = virNetDevIPGetAcceptRA(ifname);
edecca
+
edecca
+            VIR_DEBUG("Checking multipath route nexthop device %s (%d), accept_ra: %d",
edecca
+                      ifname, nh->rtnh_ifindex, accept_ra);
edecca
+
edecca
+            if (!ifname ||
edecca
+                (accept_ra != 2 && virNetDevIPCheckIPv6ForwardingAddIF(data, &ifname) < 0)) {
edecca
+                goto error;
edecca
+            }
edecca
+
edecca
+            VIR_FREE(ifname); /* in case it wasn't added to the array */
edecca
+            data->hasRARoutes = true;
edecca
+
edecca
+            len -= NLMSG_ALIGN(nh->rtnh_len);
edecca
+            nh = RTNH_NEXT(nh);
edecca
+        }
edecca
+    }
edecca
+
edecca
  cleanup:
edecca
     VIR_FREE(ifname);
edecca
     return ret;
edecca
-- 
edecca
2.20.1
edecca