Skip to content

Commit 160ca01

Browse files
Theuns Verwoerddavem330
authored andcommitted
rtnetlink: Handle IFLA_MASTER parameter when processing rtnl_newlink
Allow a master interface to be specified as one of the parameters when creating a new interface via rtnl_newlink. Previously this would require invoking interface creation, waiting for it to complete, and then separately binding that new interface to a master. In particular, this is used when creating a macvlan child interface for VRRP in a VRF configuration, allowing the interface creator to specify directly what master interface should be inherited by the child, without having to deal with asynchronous complications and potential race conditions. Signed-off-by: Theuns Verwoerd <[email protected]> Acked-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 04cdf13 commit 160ca01

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

net/core/rtnetlink.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2570,7 +2570,7 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh)
25702570
return -ENODEV;
25712571
}
25722572

2573-
if (tb[IFLA_MAP] || tb[IFLA_MASTER] || tb[IFLA_PROTINFO])
2573+
if (tb[IFLA_MAP] || tb[IFLA_PROTINFO])
25742574
return -EOPNOTSUPP;
25752575

25762576
if (!ops) {
@@ -2652,6 +2652,11 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh)
26522652
if (err < 0)
26532653
goto out_unregister;
26542654
}
2655+
if (tb[IFLA_MASTER]) {
2656+
err = do_set_master(dev, nla_get_u32(tb[IFLA_MASTER]));
2657+
if (err)
2658+
goto out_unregister;
2659+
}
26552660
out:
26562661
if (link_net)
26572662
put_net(link_net);

0 commit comments

Comments
 (0)