netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Daniel Borkmann <daniel@iogearbox.net>,
	davem@davemloft.net, kuba@kernel.org
Cc: roopa@nvidia.com, dsahern@kernel.org, m@lambda.lt,
	john.fastabend@gmail.com, netdev@vger.kernel.org,
	bpf@vger.kernel.org
Subject: Re: [PATCH net-next 2/3] net, neigh: Use NLA_POLICY_MASK helper for NDA_FLAGS_EXT attribute
Date: Wed, 13 Oct 2021 21:13:40 -0600	[thread overview]
Message-ID: <8be43259-1fc1-2c62-3cd1-100bde6ff702@gmail.com> (raw)
In-Reply-To: <20211013132140.11143-3-daniel@iogearbox.net>

On 10/13/21 7:21 AM, Daniel Borkmann wrote:
> Instead of open-coding a check for invalid bits in NTF_EXT_MASK, we can just
> use the NLA_POLICY_MASK() helper instead, and simplify NDA_FLAGS_EXT sanity
> check this way.
> 
> Suggested-by: Jakub Kicinski <kuba@kernel.org>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> ---
>  net/core/neighbour.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/net/core/neighbour.c b/net/core/neighbour.c
> index 4fc601f9cd06..922b9ed0fe76 100644
> --- a/net/core/neighbour.c
> +++ b/net/core/neighbour.c
> @@ -1834,7 +1834,7 @@ const struct nla_policy nda_policy[NDA_MAX+1] = {
>  	[NDA_MASTER]		= { .type = NLA_U32 },
>  	[NDA_PROTOCOL]		= { .type = NLA_U8 },
>  	[NDA_NH_ID]		= { .type = NLA_U32 },
> -	[NDA_FLAGS_EXT]		= { .type = NLA_U32 },
> +	[NDA_FLAGS_EXT]		= NLA_POLICY_MASK(NLA_U32, NTF_EXT_MASK),
>  	[NDA_FDB_EXT_ATTRS]	= { .type = NLA_NESTED },
>  };
>  
> @@ -1936,10 +1936,6 @@ static int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh,
>  	if (tb[NDA_FLAGS_EXT]) {
>  		u32 ext = nla_get_u32(tb[NDA_FLAGS_EXT]);
>  
> -		if (ext & ~NTF_EXT_MASK) {
> -			NL_SET_ERR_MSG(extack, "Invalid extended flags");
> -			goto out;
> -		}
>  		BUILD_BUG_ON(sizeof(neigh->flags) * BITS_PER_BYTE <
>  			     (sizeof(ndm->ndm_flags) * BITS_PER_BYTE +
>  			      hweight32(NTF_EXT_MASK)));
> 

I get that NLA_POLICY_MASK wants to standardize the logic, but the
generic extack message "reserved bit set" is less useful than the one here.

  reply	other threads:[~2021-10-14  3:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-13 13:21 [PATCH net-next 0/3] Minor managed neighbor follow-ups Daniel Borkmann
2021-10-13 13:21 ` [PATCH net-next 1/3] net, neigh: Add build-time assertion to avoid neigh->flags overflow Daniel Borkmann
2021-10-14  3:10   ` David Ahern
2021-10-13 13:21 ` [PATCH net-next 2/3] net, neigh: Use NLA_POLICY_MASK helper for NDA_FLAGS_EXT attribute Daniel Borkmann
2021-10-14  3:13   ` David Ahern [this message]
2021-10-14  8:10     ` Daniel Borkmann
2021-10-14 14:02       ` Jakub Kicinski
2021-10-13 13:21 ` [PATCH net-next 3/3] net, neigh: Reject creating NUD_PERMANENT with NTF_MANAGED entries Daniel Borkmann
2021-10-14  3:11   ` David Ahern
2021-10-15  2:30 ` [PATCH net-next 0/3] Minor managed neighbor follow-ups patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8be43259-1fc1-2c62-3cd1-100bde6ff702@gmail.com \
    --to=dsahern@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=m@lambda.lt \
    --cc=netdev@vger.kernel.org \
    --cc=roopa@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).