[CRIU] [PATCH v10 04/11] net: hoist flag setting code to its own function
Tycho Andersen
tycho.andersen at canonical.com
Thu Oct 20 09:25:24 PDT 2016
We'll use this in the next patch to set some macvlan flags.
Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
criu/net.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/criu/net.c b/criu/net.c
index a6c73e5..4c502cd 100644
--- a/criu/net.c
+++ b/criu/net.c
@@ -989,6 +989,21 @@ static int bridge_link_info(NetDeviceEntry *nde, struct newlink_req *req)
return 0;
}
+static int changeflags(int s, char *name, short flags)
+{
+ struct ifreq ifr;
+
+ strlcpy(ifr.ifr_name, name, IFNAMSIZ);
+ ifr.ifr_flags = flags;
+
+ if (ioctl(s, SIOCSIFFLAGS, &ifr) < 0) {
+ pr_perror("couldn't set flags on %s", name);
+ return -1;
+ }
+
+ return 0;
+}
+
static int restore_link(NetDeviceEntry *nde, int nlsk)
{
pr_info("Restoring link %s type %d\n", nde->name, nde->type);
@@ -1799,13 +1814,8 @@ static int move_to_bridge(struct external *ext, void *arg)
goto out;
ifr.ifr_flags |= IFF_UP;
- ret = ioctl(s, SIOCSIFFLAGS, &ifr);
- if (ret < 0) {
- pr_perror("Can't set flags of interface %s to 0x%x",
- out, ifr.ifr_flags);
+ if (changeflags(s, out, ifr.ifr_flags) < 0)
goto out;
- }
-
ret = 0;
}
out:
--
2.7.4
More information about the CRIU
mailing list