Skip to content

Commit

Permalink
rtnetlink: Handle IFLA_MASTER parameter when processing rtnl_newlink
Browse files Browse the repository at this point in the history
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 <theuns.verwoerd@alliedtelesis.co.nz>
Acked-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Theuns Verwoerd authored and davem330 committed Feb 1, 2017
1 parent 04cdf13 commit 160ca01
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion net/core/rtnetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -2570,7 +2570,7 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh)
return -ENODEV;
}

if (tb[IFLA_MAP] || tb[IFLA_MASTER] || tb[IFLA_PROTINFO])
if (tb[IFLA_MAP] || tb[IFLA_PROTINFO])
return -EOPNOTSUPP;

if (!ops) {
Expand Down Expand Up @@ -2652,6 +2652,11 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh)
if (err < 0)
goto out_unregister;
}
if (tb[IFLA_MASTER]) {
err = do_set_master(dev, nla_get_u32(tb[IFLA_MASTER]));
if (err)
goto out_unregister;
}
out:
if (link_net)
put_net(link_net);
Expand Down

0 comments on commit 160ca01

Please sign in to comment.