mirror of
https://github.com/torvalds/linux.git
synced 2026-05-24 15:12:13 +02:00
rtnetlink: Call validate_linkmsg() in do_setlink().
There are 3 paths that finally call do_setlink(), and validate_linkmsg()
is called in each path.
1. RTM_NEWLINK
1-1. dev is found in __rtnl_newlink()
1-2. dev isn't found, but IFLA_GROUP is specified in
rtnl_group_changelink()
2. RTM_SETLINK
The next patch factorises 1-1 to a separate function.
As a preparation, let's move validate_linkmsg() calls to do_setlink().
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
fa8ef258da
commit
a5838cf9b2
|
|
@ -2855,6 +2855,10 @@ static int do_setlink(const struct sk_buff *skb,
|
|||
char ifname[IFNAMSIZ];
|
||||
int err;
|
||||
|
||||
err = validate_linkmsg(dev, tb, extack);
|
||||
if (err < 0)
|
||||
goto errout;
|
||||
|
||||
if (tb[IFLA_IFNAME])
|
||||
nla_strscpy(ifname, tb[IFLA_IFNAME], IFNAMSIZ);
|
||||
else
|
||||
|
|
@ -3269,10 +3273,6 @@ static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh,
|
|||
goto errout;
|
||||
}
|
||||
|
||||
err = validate_linkmsg(dev, tb, extack);
|
||||
if (err < 0)
|
||||
goto errout;
|
||||
|
||||
err = do_setlink(skb, dev, ifm, extack, tb, 0);
|
||||
errout:
|
||||
return err;
|
||||
|
|
@ -3516,9 +3516,6 @@ static int rtnl_group_changelink(const struct sk_buff *skb,
|
|||
|
||||
for_each_netdev_safe(net, dev, aux) {
|
||||
if (dev->group == group) {
|
||||
err = validate_linkmsg(dev, tb, extack);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = do_setlink(skb, dev, ifm, extack, tb, 0);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
|
@ -3744,10 +3741,6 @@ static int __rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
|
|||
if (nlh->nlmsg_flags & NLM_F_REPLACE)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
err = validate_linkmsg(dev, tb, extack);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
if (linkinfo[IFLA_INFO_DATA]) {
|
||||
if (!ops || ops != dev->rtnl_link_ops ||
|
||||
!ops->changelink)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user