From: Fernando Fernandez Mancera <fmancera@suse.de>
To: David Ahern <dsahern@kernel.org>, netdev@vger.kernel.org
Cc: tgraf@infradead.org, horms@kernel.org, pabeni@redhat.com,
kuba@kernel.org, edumazet@google.com, davem@davemloft.net
Subject: Re: [PATCH net v4] ipv4: bump rt_genid when a relevant devconf value changes through netlink
Date: Fri, 13 Mar 2026 16:13:20 +0100 [thread overview]
Message-ID: <633f5de1-daeb-48ac-aba1-92b3c3ccf5c8@suse.de> (raw)
In-Reply-To: <1644761b-4960-431f-bf3d-5593007212fc@kernel.org>
On 3/13/26 3:56 PM, David Ahern wrote:
> On 3/13/26 8:45 AM, Fernando Fernandez Mancera wrote:
>> diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
>> index 537bb6c315d2..6dd8fd0a1323 100644
>> --- a/net/ipv4/devinet.c
>> +++ b/net/ipv4/devinet.c
>> @@ -2107,8 +2109,33 @@ static int inet_set_link_af(struct net_device *dev, const struct nlattr *nla,
>> return -EINVAL;
>>
>> if (tb[IFLA_INET_CONF]) {
>> - nla_for_each_nested(a, tb[IFLA_INET_CONF], rem)
>> - ipv4_devconf_set(in_dev, nla_type(a), nla_get_u32(a));
>> + nla_for_each_nested(a, tb[IFLA_INET_CONF], rem) {
>> + int new_value = (int)nla_get_u32(a);
>> +
>> + if (ipv4_devconf_get(in_dev, nla_type(a)) == new_value)
>> + continue;
>> +
>> + ipv4_devconf_set(in_dev, nla_type(a), new_value);
>> + switch (nla_type(a)) {
>> + case IPV4_DEVCONF_FORWARDING:
>> + if (new_value)
>> + netif_disable_lro(dev);
>> + fallthrough;
>> + case IPV4_DEVCONF_NOXFRM:
>> + case IPV4_DEVCONF_NOPOLICY:
>> + case IPV4_DEVCONF_PROMOTE_SECONDARIES:
>> + case IPV4_DEVCONF_ROUTE_LOCALNET:
>> + case IPV4_DEVCONF_DROP_UNICAST_IN_L2_MULTICAST:
>> + case IPV4_DEVCONF_BC_FORWARDING:
>> + case IPV4_DEVCONF_ACCEPT_LOCAL:
>> + flush_cache = true;
>> + break;
>> + default:
>> + break;
>> + }
>> + }
>> + if (flush_cache)
>> + rt_cache_flush(net);
>> }
>>
>> return 0;
>
Hi David,
> This replicates logic in devinet_conf_proc for example. Why not refactor
> devinet.c to handle changes to values in 1 place only.
I have been looking into it but seems like too much to do it on the net
tree. I am preparing a patch for IPv4 unifying the logic as much as
possible so we can get rid of this mess.
> Also, you are flushing the cache for more values than sysfs does.
I don't think so. The problem is that the handling of sysctl is
scattered in several places.
IPV4_DEVCONF_FORWARDING is flushed at devinet_sysctl_forward().
IPV4_DEVCONF_NOXFRM, IPV4_DEVCONF_NOPOLICY,
IPV4_DEVCONF_PROMOTE_SECONDARIES, IPV4_DEVCONF_ROUTE_LOCALNET, and
IPV4_DEVCONF_DROP_UNICAST_IN_L2_MULTICAST are flushed at
ipv4_doint_and_flush() used by macro DEVINET_SYSCTL_FLUSHING_ENTRY.
Finally, IPV4_DEVCONF_BC_FORWARDING and IPV4_DEVCONF_ACCEPT_LOCAL are
flushed at devinet_conf_proc().
Yes, I know, the fact that they are scattered around is quite confusing.
This could be all unified in a single place but that would be too much
for net tree IMHO.
Please let me know if I am missing something.
Thanks,
Fernando.
next prev parent reply other threads:[~2026-03-13 15:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-13 14:45 [PATCH net v4] ipv4: bump rt_genid when a relevant devconf value changes through netlink Fernando Fernandez Mancera
2026-03-13 14:56 ` David Ahern
2026-03-13 15:13 ` Fernando Fernandez Mancera [this message]
2026-03-14 16:06 ` Jakub Kicinski
2026-03-14 16:16 ` David Ahern
2026-03-14 17:52 ` 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=633f5de1-daeb-48ac-aba1-92b3c3ccf5c8@suse.de \
--to=fmancera@suse.de \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tgraf@infradead.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