netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Maks Mishin <maks.mishinfz@gmail.com>,
	Guillaume Nault <gnault@redhat.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] f_flower: Remove always zero checks
Date: Wed, 10 Jul 2024 16:11:39 -0700	[thread overview]
Message-ID: <20240710161139.578d20dc@hermes.local> (raw)
In-Reply-To: <20240707172741.30618-1-maks.mishinFZ@gmail.com>

On Sun,  7 Jul 2024 20:27:41 +0300
Maks Mishin <maks.mishinfz@gmail.com> wrote:

> Expression 'ttl & ~(255 >> 0)' is always zero, because right operand
> has 8 trailing zero bits, which is greater or equal than the size
> of the left operand == 8 bits.
> 
> Found by RASU JSC.
> 
> Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
> ---
>  tc/f_flower.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tc/f_flower.c b/tc/f_flower.c
> index 08c1001a..244f0f7e 100644
> --- a/tc/f_flower.c
> +++ b/tc/f_flower.c
> @@ -1523,7 +1523,7 @@ static int flower_parse_mpls_lse(int *argc_p, char ***argv_p,
>  
>  			NEXT_ARG();
>  			ret = get_u8(&ttl, *argv, 10);
> -			if (ret < 0 || ttl & ~(MPLS_LS_TTL_MASK >> MPLS_LS_TTL_SHIFT)) {
> +			if (ret < 0) {
>  				fprintf(stderr, "Illegal \"ttl\"\n");
>  				return -1;
>  			}
> @@ -1936,7 +1936,7 @@ static int flower_parse_opt(const struct filter_util *qu, char *handle,
>  			}
>  			mpls_format_old = true;
>  			ret = get_u8(&ttl, *argv, 10);
> -			if (ret < 0 || ttl & ~(MPLS_LS_TTL_MASK >> MPLS_LS_TTL_SHIFT)) {
> +			if (ret < 0) {
>  				fprintf(stderr, "Illegal \"mpls_ttl\"\n");
>  				return -1;
>  			}

That is correct mathematically, but perhaps the original author had different idea.
Could we have review from someone familiar with MPLS support please.

  reply	other threads:[~2024-07-10 23:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-07 17:27 [PATCH] f_flower: Remove always zero checks Maks Mishin
2024-07-10 23:11 ` Stephen Hemminger [this message]
2024-07-17 17:21   ` Guillaume Nault
2024-07-17 18:27     ` Simon Horman
2024-07-18  0:00 ` 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=20240710161139.578d20dc@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=gnault@redhat.com \
    --cc=maks.mishinfz@gmail.com \
    --cc=netdev@vger.kernel.org \
    /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).