On 10/5/18 11:59 AM, Christian Brauner wrote: >> + err = nlmsg_parse(nlh, hdrlen, tb, IFLA_MAX, ifla_policy, extack); >> + if (err < 0) { >> + if (cb->strict_check) >> + return -EINVAL; >> + goto walk_entries; >> + } >> >> - if (master_idx || kind_ops) >> - flags |= NLM_F_DUMP_FILTERED; >> + for (i = 0; i <= IFLA_MAX; ++i) { >> + if (!tb[i]) >> + continue; >> + switch (i) { >> + case IFLA_TARGET_NETNSID: >> + netnsid = nla_get_s32(tb[i]); >> + tgt_net = rtnl_get_net_ns_capable(skb->sk, netnsid); >> + if (IS_ERR(tgt_net)) { >> + NL_SET_ERR_MSG(extack, "Invalid target >> namespace id"); >> + return PTR_ERR(tgt_net); >> + } >> + break; >> + case IFLA_EXT_MASK: >> + ext_filter_mask = nla_get_u32(tb[i]); >> + break; >> + case IFLA_MASTER: >> + master_idx = nla_get_u32(tb[i]); >> + break; >> + case IFLA_LINKINFO: >> + kind_ops = linkinfo_to_kind_ops(tb[i]); >> + break; >> + default: >> + if (cb->strict_check) { >> + NL_SET_ERR_MSG(extack, "Unsupported attribute >> in dump request"); >> + return -EINVAL; >> + } >> + } > > This might make sense to be split into two helpers for parsing: > <blablabla>_strict() and <blablabla>_lenient(). :)
I thought about that, but there is so much overlap - they are mostly common. Besides, ifinfomsg is the header for link dumps, and ifinfomsg is the one that has been (ab)used for other message types, so strict versus lenient does not really have a differentiator for this message type - other than checking the elements of the struct.