Skip to content

Commit 5c4a9aa

Browse files
pmachatadavem330
authored andcommitted
net: ipv4: Allow changing IPv4 address protocol
When IP address protocol field was added in commit 47f0bd5 ("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 <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Reviewed-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 90bf661 commit 5c4a9aa

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

net/ipv4/devinet.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,7 @@ static int inet_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh,
962962
extack);
963963
} else {
964964
u32 new_metric = ifa->ifa_rt_priority;
965+
u8 new_proto = ifa->ifa_proto;
965966

966967
inet_free_ifa(ifa);
967968

@@ -975,6 +976,8 @@ static int inet_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh,
975976
ifa->ifa_rt_priority = new_metric;
976977
}
977978

979+
ifa->ifa_proto = new_proto;
980+
978981
set_ifa_lifetime(ifa, valid_lft, prefered_lft);
979982
cancel_delayed_work(&check_lifetime_work);
980983
queue_delayed_work(system_power_efficient_wq,

0 commit comments

Comments
 (0)