Message ID | 6ffecb0f77dc6e444e3a130a09b4fd5d717e6504.1679399108.git.petrm@nvidia.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 5c4a9aa856c706def9239d1e43c4ea9fccb5c75a |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: Allow changing IPv4 address protocol | expand |
Context | Check | Description |
---|---|---|
netdev/series_format | success | Posting correctly formatted |
netdev/tree_selection | success | Clearly marked for net-next |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 20 this patch: 20 |
netdev/cc_maintainers | success | CCed 6 of 6 maintainers |
netdev/build_clang | success | Errors and warnings before: 18 this patch: 18 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/deprecated_api | success | None detected |
netdev/check_selftest | success | No net selftest shell script |
netdev/verify_fixes | success | No Fixes tag |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 20 this patch: 20 |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 15 lines checked |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
On 3/21/23 5:51 AM, Petr Machata wrote: > When IP address protocol field was added in commit 47f0bd503210 ("net: Add > new protocol attribute to IP addresses"), the semantics included the > ability to change the protocol for IPv6 addresses, but not for IPv4 > addresses. It seems this was not deliberate, but rather by accident. > > A userspace that wants to change the protocol of an address might drop and > recreate the address, but that disrupts routing and is just impractical. > > So in this patch, when an IPv4 address is replaced (through RTM_NEWADDR > request with NLM_F_REPLACE flag), update the proto at the address to the > one given in the request, or zero if none is given. This matches the > behavior of IPv6. Previously, any new value given was simply ignored. > > Signed-off-by: Petr Machata <petrm@nvidia.com> > Reviewed-by: Ido Schimmel <idosch@nvidia.com> > --- > net/ipv4/devinet.c | 3 +++ > 1 file changed, 3 insertions(+) > Reviewed-by: David Ahern <dsahern@kernel.org>
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index b0acf6e19aed..5deac0517ef7 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c @@ -962,6 +962,7 @@ static int inet_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, extack); } else { u32 new_metric = ifa->ifa_rt_priority; + u8 new_proto = ifa->ifa_proto; inet_free_ifa(ifa); @@ -975,6 +976,8 @@ static int inet_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, ifa->ifa_rt_priority = new_metric; } + ifa->ifa_proto = new_proto; + set_ifa_lifetime(ifa, valid_lft, prefered_lft); cancel_delayed_work(&check_lifetime_work); queue_delayed_work(system_power_efficient_wq,