Align interface name handling regarding alias interfaces in rtnl_getlink() with dev_ioctl() treating SIOCGIFINDEX ioctl calls. The latter function strips any colon suffix before doing the interface lookup, do the same for RTM_GETLINK requests.
Signed-off-by: Phil Sutter <p...@nwl.cc> --- net/core/rtnetlink.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index a51cab95ba64c..aaee4df0ff00c 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -3312,8 +3312,10 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr *nlh, return PTR_ERR(tgt_net); } - if (tb[IFLA_IFNAME]) + if (tb[IFLA_IFNAME]) { nla_strlcpy(ifname, tb[IFLA_IFNAME], IFNAMSIZ); + *strchrnul(ifname, ':') = '\0'; + } if (tb[IFLA_EXT_MASK]) ext_filter_mask = nla_get_u32(tb[IFLA_EXT_MASK]); -- 2.20.1