[PATCH] rtnetlink: Handle IFLA_MASTER parameter when processing rtnl_newlink

Subsystems: networking [general], the rest

STALE3508d

2 messages, 2 authors, 2017-01-30 · open the first message on its own page

[PATCH] rtnetlink: Handle IFLA_MASTER parameter when processing rtnl_newlink

From: Theuns Verwoerd <hidden>
Date: 2017-01-30 22:39:19

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 <redacted>
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 75e3ea7bda08..a24719c98238 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2571,7 +2571,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) {
@@ -2653,6 +2653,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);

Re: [PATCH] rtnetlink: Handle IFLA_MASTER parameter when processing rtnl_newlink

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2017-01-30 22:52:19

On Mon, 30 Jan 2017 22:28:05 +0000
Theuns Verwoerd [off-list ref] wrote:
quoted hunk
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 <redacted>
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 75e3ea7bda08..a24719c98238 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2571,7 +2571,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) {
@@ -2653,6 +2653,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);
Your mailer is reformatting text which corrupts patches.
Please adjust your client settings, or use a different mail system.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help