netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Peter Kosyh <p.kosyh@gmail.com>
Cc: Network Development <netdev@vger.kernel.org>,
	Mikhail Smirnov <smirnov@factor-ts.ru>,
	"David S. Miller" <davem@davemloft.net>,
	mmanning@vyatta.att-mail.com
Subject: Re: [PATCH] udp: compute_score and sk_bound_dev_if regression
Date: Wed, 9 Jun 2021 15:44:45 -0400	[thread overview]
Message-ID: <CA+FuTSf7WbEN_yhf_LR9RxZzgxHUcdb-OeMEA2--rci+HN2dqw@mail.gmail.com> (raw)
In-Reply-To: <87a6nzrqe0.fsf@factor-ts.ru>

On Wed, Jun 9, 2021 at 11:50 AM Peter Kosyh <p.kosyh@gmail.com> wrote:
>
>
> udp: commit 6da5b0f027a825df2aebc1927a27bda185dc03d4

For completeness, this is commit 6da5b0f027a8 ("net: ensure unbound
datagram socket to be chosen when not in a VRF"). Adding the author.

> introduced regression in compute_score() Previously for addr_any sockets an
> interface bound socket had a higher priority than an unbound socket that
> seems right. For example, this feature is used in dhcprelay daemon and now it
> is broken.
> So, this patch returns the old behavior and gives higher score for sk_bound_dev_if sockets.
>
> Signed-off-by: Peter Kosyh <p.kosyh@gmail.com>
> ---
>  net/ipv4/udp.c | 3 ++-
>  net/ipv6/udp.c | 3 ++-
>  2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
> index 15f5504adf5b..4239ffa93c6f 100644
> --- a/net/ipv4/udp.c
> +++ b/net/ipv4/udp.c
> @@ -390,7 +390,8 @@ static int compute_score(struct sock *sk, struct net *net,
>                                         dif, sdif);
>         if (!dev_match)
>                 return -1;
> -       score += 4;
> +       if (sk->sk_bound_dev_if)
> +               score += 4;
>
>         if (READ_ONCE(sk->sk_incoming_cpu) == raw_smp_processor_id())
>                 score++;
> diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
> index 199b080d418a..c2f88b5def25 100644
> --- a/net/ipv6/udp.c
> +++ b/net/ipv6/udp.c
> @@ -133,7 +133,8 @@ static int compute_score(struct sock *sk, struct net *net,
>         dev_match = udp_sk_bound_dev_eq(net, sk->sk_bound_dev_if, dif, sdif);
>         if (!dev_match)
>                 return -1;
> -       score++;
> +       if (sk->sk_bound_dev_if)
> +               score++;
>
>         if (READ_ONCE(sk->sk_incoming_cpu) == raw_smp_processor_id())
>                 score++;
> --
> 2.31.1

      reply	other threads:[~2021-06-09 19:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-09 15:47 [PATCH] udp: compute_score and sk_bound_dev_if regression Peter Kosyh
2021-06-09 19:44 ` Willem de Bruijn [this message]

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=CA+FuTSf7WbEN_yhf_LR9RxZzgxHUcdb-OeMEA2--rci+HN2dqw@mail.gmail.com \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=davem@davemloft.net \
    --cc=mmanning@vyatta.att-mail.com \
    --cc=netdev@vger.kernel.org \
    --cc=p.kosyh@gmail.com \
    --cc=smirnov@factor-ts.ru \
    /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).