diff options
author | David S. Miller <davem@davemloft.net> | 2018-10-06 14:43:42 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-10-06 14:43:42 -0700 |
commit | 72438f8cef4e75a22140853baa4c68392c721b22 (patch) | |
tree | 78b7b6dafd827e0d55150a227db3978d91c0b6dd /net/core | |
parent | fb4ee67529ff3e4c5874768477887c2df5714c96 (diff) | |
parent | c1d84a1b42ef70d8ae601df9cadedc7ed4f1beb1 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/rtnetlink.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 57bf96d73e3b..5564eee1e980 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -3763,16 +3763,27 @@ static int rtnl_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb) int err = 0; int fidx = 0; - err = nlmsg_parse(cb->nlh, sizeof(struct ifinfomsg), tb, - IFLA_MAX, ifla_policy, NULL); - if (err < 0) { - return -EINVAL; - } else if (err == 0) { - if (tb[IFLA_MASTER]) - br_idx = nla_get_u32(tb[IFLA_MASTER]); - } + /* A hack to preserve kernel<->userspace interface. + * Before Linux v4.12 this code accepted ndmsg since iproute2 v3.3.0. + * However, ndmsg is shorter than ifinfomsg thus nlmsg_parse() bails. + * So, check for ndmsg with an optional u32 attribute (not used here). + * Fortunately these sizes don't conflict with the size of ifinfomsg + * with an optional attribute. + */ + if (nlmsg_len(cb->nlh) != sizeof(struct ndmsg) && + (nlmsg_len(cb->nlh) != sizeof(struct ndmsg) + + nla_attr_size(sizeof(u32)))) { + err = nlmsg_parse(cb->nlh, sizeof(struct ifinfomsg), tb, + IFLA_MAX, ifla_policy, NULL); + if (err < 0) { + return -EINVAL; + } else if (err == 0) { + if (tb[IFLA_MASTER]) + br_idx = nla_get_u32(tb[IFLA_MASTER]); + } - brport_idx = ifm->ifi_index; + brport_idx = ifm->ifi_index; + } if (br_idx) { br_dev = __dev_get_by_index(net, br_idx); |