Netdev List
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@nvidia.com>
To: Fernando Fernandez Mancera <fmancera@suse.de>
Cc: netdev@vger.kernel.org, nicolas.dichtel@6wind.com,
	stephen@networkplumber.org, brian.haley@hp.com, horms@kernel.org,
	pabeni@redhat.com, kuba@kernel.org, edumazet@google.com,
	davem@davemloft.net, dsahern@kernel.org
Subject: Re: [PATCH net v2 7/7] ipv6: reset position for force_forwarding sysctl restart
Date: Mon, 22 Jun 2026 14:42:23 +0300	[thread overview]
Message-ID: <20260622114223.GA233619@shredder> (raw)
In-Reply-To: <20260620161850.7114-8-fmancera@suse.de>

On Sat, Jun 20, 2026 at 06:18:50PM +0200, Fernando Fernandez Mancera wrote:
> When handling proxy_ndp, if rtnl_net_trylock() fails, the operation is

s/proxy_ndp/force_forwarding/

> retried but the position pointer was already advanced meaning that the
> restarted sysctl will read from an incorrect offset.
> 
> Fix this by restoring the original position pointer before restarting
> the syscall.
> 
> In addition, remove the redundant position pointer restoration at the
> end of the function.
> 
> Fixes: f24987ef6959 ("ipv6: add `force_forwarding` sysctl to enable per-interface forwarding")
> Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
> ---
>  net/ipv6/addrconf.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index cbe681de3818..8c0741e9dfcc 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -6825,8 +6825,10 @@ static int addrconf_sysctl_force_forwarding(const struct ctl_table *ctl, int wri
>  	ret = proc_douintvec_minmax(&tmp_ctl, write, buffer, lenp, ppos);
>  
>  	if (write && old_val != new_val) {
> -		if (!rtnl_net_trylock(net))
> +		if (!rtnl_net_trylock(net)) {
> +			*ppos = pos;
>  			return restart_syscall();
> +		}

Are you sure that this is needed?

AFAICT, the position pointer is only advanced if the return value is
positive. From new_sync_write():

kiocb.ki_pos = (ppos ? *ppos : 0);
[...]
ret = filp->f_op->write_iter(&kiocb, &iter);
[...]
if (ret > 0 && ppos)
        *ppos = kiocb.ki_pos;

And restart_syscall() returns '-ERESTARTNOINTR'.

>  
>  		WRITE_ONCE(*valp, new_val);
>  
> @@ -6851,8 +6853,6 @@ static int addrconf_sysctl_force_forwarding(const struct ctl_table *ctl, int wri
>  		rtnl_net_unlock(net);
>  	}
>  
> -	if (ret)
> -		*ppos = pos;
>  	return ret;
>  }
>  
> -- 
> 2.54.0
> 

  reply	other threads:[~2026-06-22 11:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-20 16:18 [PATCH net v2 0/7] ipv6: fix sysctl error handling and missing notifications Fernando Fernandez Mancera
2026-06-20 16:18 ` [PATCH net v2 1/7] ipv6: fix error handling in disable_ipv6 sysctl Fernando Fernandez Mancera
2026-06-20 16:18 ` [PATCH net v2 2/7] ipv6: fix error handling in ignore_routes_with_linkdown sysctl Fernando Fernandez Mancera
2026-06-20 16:18 ` [PATCH net v2 3/7] ipv6: fix error handling in forwarding sysctl Fernando Fernandez Mancera
2026-06-20 16:18 ` [PATCH net v2 4/7] ipv6: fix error handling in disable_policy sysctl Fernando Fernandez Mancera
2026-06-20 16:18 ` [PATCH net v2 5/7] ipv6: reset value and position for proxy_ndp sysctl restart Fernando Fernandez Mancera
2026-06-22 11:48   ` Nicolas Dichtel
2026-06-20 16:18 ` [PATCH net v2 6/7] ipv6: fix missing notification for ignore_routes_with_linkdown Fernando Fernandez Mancera
2026-06-20 16:18 ` [PATCH net v2 7/7] ipv6: reset position for force_forwarding sysctl restart Fernando Fernandez Mancera
2026-06-22 11:42   ` Ido Schimmel [this message]
2026-06-22 12:19     ` Fernando Fernandez Mancera

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=20260622114223.GA233619@shredder \
    --to=idosch@nvidia.com \
    --cc=brian.haley@hp.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=fmancera@suse.de \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.dichtel@6wind.com \
    --cc=pabeni@redhat.com \
    --cc=stephen@networkplumber.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