|
|
edecca |
From 665a535028d1512e2afabf3c2c1cc100debfa7d7 Mon Sep 17 00:00:00 2001
|
|
|
edecca |
Message-Id: <665a535028d1512e2afabf3c2c1cc100debfa7d7@dist-git>
|
|
|
edecca |
From: Laine Stump <laine@laine.org>
|
|
|
edecca |
Date: Mon, 14 Jan 2019 11:35:03 -0500
|
|
|
edecca |
Subject: [PATCH] util: add a function to insert new interfaces to
|
|
|
edecca |
IPv6CheckForwarding list
|
|
|
edecca |
|
|
|
edecca |
This same operation needs to be done in multiple places, so move the
|
|
|
edecca |
inline code into a separate function.
|
|
|
edecca |
|
|
|
edecca |
Signed-off-by: Laine Stump <laine@laine.org>
|
|
|
edecca |
Reviewed-by: Erik Skultety <eskultet@redhat.com>
|
|
|
edecca |
(cherry picked from commit 37bb6facfc467179d6cfe6186ad6d5a55285c2c7)
|
|
|
edecca |
|
|
|
edecca |
https://bugzilla.redhat.com/1583131
|
|
|
edecca |
|
|
|
edecca |
Conflicts: src/util/virnetdevip.c - introduction of VIR_AUTOPTR upstream led to
|
|
|
edecca |
conflicts in surrounding context, and elimination of cleanup and
|
|
|
edecca |
error labels.
|
|
|
edecca |
Signed-off-by: Laine Stump <laine@laine.org>
|
|
|
edecca |
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
edecca |
---
|
|
|
edecca |
src/util/virnetdevip.c | 29 ++++++++++++++++++++---------
|
|
|
edecca |
1 file changed, 20 insertions(+), 9 deletions(-)
|
|
|
edecca |
|
|
|
edecca |
diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c
|
|
|
edecca |
index 1bfbd20034..937ebcdbdb 100644
|
|
|
edecca |
--- a/src/util/virnetdevip.c
|
|
|
edecca |
+++ b/src/util/virnetdevip.c
|
|
|
edecca |
@@ -539,6 +539,25 @@ struct virNetDevIPCheckIPv6ForwardingData {
|
|
|
edecca |
size_t ndevices;
|
|
|
edecca |
};
|
|
|
edecca |
|
|
|
edecca |
+
|
|
|
edecca |
+static int
|
|
|
edecca |
+virNetDevIPCheckIPv6ForwardingAddIF(struct virNetDevIPCheckIPv6ForwardingData *data,
|
|
|
edecca |
+ char **ifname)
|
|
|
edecca |
+{
|
|
|
edecca |
+ size_t i;
|
|
|
edecca |
+
|
|
|
edecca |
+ /* add ifname to the array if it's not already there
|
|
|
edecca |
+ * (ifname is char** so VIR_APPEND_ELEMENT() will move the
|
|
|
edecca |
+ * original pointer out of the way and avoid having it freed)
|
|
|
edecca |
+ */
|
|
|
edecca |
+ for (i = 0; i < data->ndevices; i++) {
|
|
|
edecca |
+ if (STREQ(data->devices[i], *ifname))
|
|
|
edecca |
+ return 0;
|
|
|
edecca |
+ }
|
|
|
edecca |
+ return VIR_APPEND_ELEMENT(data->devices, data->ndevices, *ifname);
|
|
|
edecca |
+}
|
|
|
edecca |
+
|
|
|
edecca |
+
|
|
|
edecca |
static int
|
|
|
edecca |
virNetDevIPCheckIPv6ForwardingCallback(struct nlmsghdr *resp,
|
|
|
edecca |
void *opaque)
|
|
|
edecca |
@@ -551,8 +570,6 @@ virNetDevIPCheckIPv6ForwardingCallback(struct nlmsghdr *resp,
|
|
|
edecca |
int ret = 0;
|
|
|
edecca |
int len = RTM_PAYLOAD(resp);
|
|
|
edecca |
int oif = -1;
|
|
|
edecca |
- size_t i;
|
|
|
edecca |
- bool hasDevice;
|
|
|
edecca |
|
|
|
edecca |
/* Ignore messages other than route ones */
|
|
|
edecca |
if (resp->nlmsg_type != RTM_NEWROUTE)
|
|
|
edecca |
@@ -589,13 +606,7 @@ virNetDevIPCheckIPv6ForwardingCallback(struct nlmsghdr *resp,
|
|
|
edecca |
accept_ra = virNetDevIPGetAcceptRA(ifname);
|
|
|
edecca |
VIR_DEBUG("Checking route for device %s, accept_ra: %d", ifname, accept_ra);
|
|
|
edecca |
|
|
|
edecca |
- hasDevice = false;
|
|
|
edecca |
- for (i = 0; i < data->ndevices && !hasDevice; i++) {
|
|
|
edecca |
- if (STREQ(data->devices[i], ifname))
|
|
|
edecca |
- hasDevice = true;
|
|
|
edecca |
- }
|
|
|
edecca |
- if (accept_ra != 2 && !hasDevice &&
|
|
|
edecca |
- VIR_APPEND_ELEMENT(data->devices, data->ndevices, ifname) < 0)
|
|
|
edecca |
+ if (accept_ra != 2 && virNetDevIPCheckIPv6ForwardingAddIF(data, &ifname) < 0)
|
|
|
edecca |
goto error;
|
|
|
edecca |
|
|
|
edecca |
cleanup:
|
|
|
edecca |
--
|
|
|
edecca |
2.20.1
|
|
|
edecca |
|