Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org, davem@davemloft.net,
	netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com,
	edumazet@kernel.org, horms@kernel.org, fw@strlen.de, ja@ssi.bg
Subject: Re: [PATCH net 10/15] ipvs: honor the overload state and do not enter it forever
Date: Sat, 14 Nov 2026 02:15:45 +0000	[thread overview]
Message-ID: <179462254584.2199510.7662022580962263385@kernel.org> (raw)
In-Reply-To: <20261113011447.2357709-11-pablo@netfilter.org>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The commit message's reason for moving ip_vs_dest_set_min() after
  the set_max/erase cleanup in ip_vs_lblcr_schedule()…

--

ipvs: honor the overload state and do not enter it forever

This commit adds an smp_mb() and a re-read of totalconns in
__ip_vs_dest_update_overload(), so a dest cannot stay in the overload
state forever when it races with ip_vs_unbind_dest(). It also drops the
overload parameter from ip_vs_dest_update_overload() and makes LBLC and
LBLCR honor the overload state for cached dests. In LBLCR it moves the
ip_vs_dest_set_min() call to after the set_max/erase cleanup.

Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261019150249.1879516-2-pablo%40netfilter.org

> diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
> index dfb5bf83750db..4046608922e7c 100644
> --- a/net/netfilter/ipvs/ip_vs_lblcr.c
> +++ b/net/netfilter/ipvs/ip_vs_lblcr.c

[ ... ]

> @@ -658,9 +659,6 @@ ip_vs_lblcr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb,
>  	if (en) {
>  		en->lastuse = jiffies;
>  
> -		/* Get the least loaded destination */
> -		dest = ip_vs_dest_set_min(&en->set);
> -
>  		/* More than one destination + enough time passed by, cleanup */
>  		if (atomic_read(&en->set.size) > 1 &&
>  		    time_after(jiffies, en->set.lastmod +
> @@ -676,6 +674,9 @@ ip_vs_lblcr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb,
>  			spin_unlock_bh(&svc->sched_lock);
>  		}
>  
> +		/* Get the least loaded destination */
> +		dest = ip_vs_dest_set_min(&en->set);
> +
>  		/* If the destination is not overloaded, use it */
>  		if (dest && !is_overloaded(dest, svc))
>  			goto out;

[Severity: Low]
This isn't a bug, and the code change looks right. The commit message
explains the move this way:

  "Also, move the ip_vs_dest_set_min() call in LBLCR after the
  ip_vs_dest_set_erase() call that removes the most-loaded
  server because due to races we may work with dest that is
  in process of removing, i.e. ip_vs_dest_set_min() and
  ip_vs_dest_set_max() may return same dest."

Can the two helpers also return the same dest without any race?

ip_vs_dest_set_min() only replaces its candidate when another member is
strictly less loaded:

    if (((__s64)loh * atomic_read(&dest->weight) >
         (__s64)doh * atomic_read(&least->weight)) &&
        (dest->cflags & IP_VS_DEST_CF_AVAILABLE)) {

ip_vs_dest_set_max() only replaces its candidate when another member is
strictly more loaded:

    if (((__s64)moh * atomic_read(&dest->weight) <
         (__s64)doh * atomic_read(&most->weight))
        && (atomic_read(&dest->weight) > 0)) {

Take two weight-1 members with the same ip_vs_dest_conn_overhead(), for
example both idle. Both helpers then return the first list element.

Before this patch, once the set had more than one member and was older
than sysctl_lblcr_expiration, the sequence was:

ip_vs_lblcr_schedule()
    ip_vs_dest_set_min()     -> first member (tie)
    ip_vs_dest_set_max()     -> same first member (tie)
    ip_vs_dest_set_erase()   -> removes it from en->set
    goto out                 -> returns the erased dest

So on load ties the old code returned the dest it had just removed from
the cache set, with no race involved.

Could the commit message say that this also happens on ties, not only
because of races?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113011447.2357709-2-pablo%40netfilter.org

  reply	other threads:[~2026-11-14  2:15 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13  1:14 [PATCH net 00/15] IPVS fixes for net Pablo Neira Ayuso
2026-11-13  1:14 ` [PATCH net 01/15] ipvs: avoid out-of-bounds write in ip_vs_nat_icmp_v6 Pablo Neira Ayuso
2026-11-13  1:16   ` netdev-bot+sinfo
2026-11-13  3:17     ` Pablo Neira Ayuso
2026-11-14  2:15   ` netdev-bot+sashiko
2026-11-13  1:14 ` [PATCH net 02/15] ipv6: update *offset for non-first fragments in ipv6_find_hdr() Pablo Neira Ayuso
2026-11-14  2:15   ` netdev-bot+sashiko
2026-11-13  1:14 ` [PATCH net 03/15] ipvs: fix problems during connection deletion Pablo Neira Ayuso
2026-11-13  1:14 ` [PATCH net 04/15] ipvs: avoid stack overflow from recursive connection expiration Pablo Neira Ayuso
2026-11-14  2:15   ` netdev-bot+sashiko
2026-11-13  1:14 ` [PATCH net 05/15] ipvs: reject FTP control ports as data ports Pablo Neira Ayuso
2026-11-14  2:15   ` netdev-bot+sashiko
2026-11-13  1:14 ` [PATCH net 06/15] ipvs: ftp: skip conntrack templates in ip_vs_ftp_out Pablo Neira Ayuso
2026-11-13  1:14 ` [PATCH net 07/15] ipvs: ftp: add seqadj extension before linking the expectation Pablo Neira Ayuso
2026-11-14  2:15   ` netdev-bot+sashiko
2026-11-13  1:14 ` [PATCH net 08/15] ipvs: update flags and seqs in backup server under lock Pablo Neira Ayuso
2026-11-14  2:15   ` netdev-bot+sashiko
2026-11-13  1:14 ` [PATCH net 09/15] ipvs: read flags and seqs in master atomically Pablo Neira Ayuso
2026-11-13  1:14 ` [PATCH net 10/15] ipvs: honor the overload state and do not enter it forever Pablo Neira Ayuso
2026-11-14  2:15   ` netdev-bot+sashiko [this message]
2026-11-13  1:14 ` [PATCH net 11/15] ipvs: validate cport in received sync records Pablo Neira Ayuso
2026-11-14  2:15   ` netdev-bot+sashiko
2026-11-13  1:14 ` [PATCH net 12/15] ipvs: skip cport 0 connections in ip_vs_conn_out_get() Pablo Neira Ayuso
2026-11-14  2:15   ` netdev-bot+sashiko
2026-11-13  1:14 ` [PATCH net 13/15] ipvs: do not create conns from packets with port 0 Pablo Neira Ayuso
2026-11-13  1:14 ` [PATCH net 14/15] ipvs: wait grace period before reusing destinations Pablo Neira Ayuso
2026-11-14  2:15   ` netdev-bot+sashiko
2026-11-13  1:14 ` [PATCH net 15/15] ipvs: pass correct sk to update_pmtu and on tunneling Pablo Neira Ayuso
2026-11-14  2:15   ` netdev-bot+sashiko
2026-11-13 22:34 ` [PATCH net 00/15] IPVS fixes for net Pablo Neira Ayuso

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=179462254584.2199510.7662022580962263385@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=fw@strlen.de \
    --cc=horms@kernel.org \
    --cc=ja@ssi.bg \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.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