Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 914fc9c6 authored by Maciej Żenczykowski's avatar Maciej Żenczykowski
Browse files

OffloadUtils - tcFilterAddDevBpf() - add NLA_F_NESTED to TCA_OPTIONS



The lack of this on a clearly nested attribute appears to be
a result of us reverse engineering (via strace) what the
(apparently buggy) iproute2 'ip' cli command does.

The fact things work even without it appears to be an oversight in the kernel.

They're not meant to, see kernel source in include/net/netlink.h:

static inline struct nlattr *nla_nest_start(struct sk_buff *skb, int attrtype)
{
    return nla_nest_start_noflag(skb, attrtype | NLA_F_NESTED);
}

static inline int nla_parse_nested(struct nlattr *tb[], int maxtype,
		   const struct nlattr *nla,
		   const struct nla_policy *policy,
		   struct netlink_ext_ack *extack)
{
    if (!(nla->nla_type & NLA_F_NESTED)) {
	NL_SET_ERR_MSG_ATTR(extack, nla, "NLA_F_NESTED is missing");
	return -EINVAL;
    }

    return __nla_parse(tb, maxtype, nla_data(nla), nla_len(nla), policy,
	       NL_VALIDATE_STRICT, extack);
}

and lib/nlattr.c:

if (validate & NL_VALIDATE_NESTED) {
	if ((pt->type == NLA_NESTED || pt->type == NLA_NESTED_ARRAY) &&
	    !(nla->nla_type & NLA_F_NESTED)) {
	    NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt,
			"NLA_F_NESTED is missing");
	    return -EINVAL;
	}
	if (pt->type != NLA_NESTED && pt->type != NLA_NESTED_ARRAY &&
	    pt->type != NLA_UNSPEC && (nla->nla_type & NLA_F_NESTED)) {
	    NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt,
			"NLA_F_NESTED not expected");
	    return -EINVAL;
	}
    }

Tested: atest + TreeHugger
Signed-off-by: default avatarMaciej Żenczykowski <maze@google.com>
Change-Id: I645c36810b6b30025fa21e2093ef9dee303f3b86
parent 91e8ab64
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment