Commit 2b5d709c authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

net: hoist flag setting code to its own function

We'll use this in the next patch to set some macvlan flags.

travis-ci: success for series starting with [v10,01/11] net: pass the struct nlattrs to dump() functions
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 53241e2b
...@@ -990,6 +990,21 @@ static int bridge_link_info(NetDeviceEntry *nde, struct newlink_req *req) ...@@ -990,6 +990,21 @@ static int bridge_link_info(NetDeviceEntry *nde, struct newlink_req *req)
return 0; 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) static int restore_link(NetDeviceEntry *nde, int nlsk)
{ {
pr_info("Restoring link %s type %d\n", nde->name, nde->type); pr_info("Restoring link %s type %d\n", nde->name, nde->type);
...@@ -1800,13 +1815,8 @@ static int move_to_bridge(struct external *ext, void *arg) ...@@ -1800,13 +1815,8 @@ static int move_to_bridge(struct external *ext, void *arg)
goto out; goto out;
ifr.ifr_flags |= IFF_UP; ifr.ifr_flags |= IFF_UP;
ret = ioctl(s, SIOCSIFFLAGS, &ifr); if (changeflags(s, out, ifr.ifr_flags) < 0)
if (ret < 0) {
pr_perror("Can't set flags of interface %s to 0x%x",
out, ifr.ifr_flags);
goto out; goto out;
}
ret = 0; ret = 0;
} }
out: out:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment