Skip to content

Commit

Permalink
rtnetlink: do not use RTM_GETLINK directly
Browse files Browse the repository at this point in the history
Userspace sends RTM_GETLINK type, but the kernel substracts
RTM_BASE from this, i.e. 'type' doesn't contain RTM_GETLINK
anymore but instead RTM_GETLINK - RTM_BASE.

This caused the calcit callback to not be invoked when it
should have been (and vice versa).

While at it, also fix a off-by one when checking family index. vs
handler array size.

Fixes: e1fa6d2 ("rtnetlink: call rtnl_calcit directly")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Florian Westphal authored and David S. Miller committed Aug 10, 2017
1 parent 377cb24 commit 5c2bb9b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/core/rtnetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -4167,7 +4167,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
if (kind != 2 && !netlink_net_capable(skb, CAP_NET_ADMIN))
return -EPERM;

if (family > ARRAY_SIZE(rtnl_msg_handlers))
if (family >= ARRAY_SIZE(rtnl_msg_handlers))
family = PF_UNSPEC;

rcu_read_lock();
Expand Down Expand Up @@ -4196,7 +4196,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,

refcount_inc(&rtnl_msg_handlers_ref[family]);

if (type == RTM_GETLINK)
if (type == RTM_GETLINK - RTM_BASE)
min_dump_alloc = rtnl_calcit(skb, nlh);

rcu_read_unlock();
Expand Down

0 comments on commit 5c2bb9b

Please sign in to comment.