mirror of
https://github.com/edk2-porting/linux-next.git
synced 2025-01-26 23:55:40 +08:00
net: ipv4: Allow changing IPv4 address protocol
When IP address protocol field was added in commit 47f0bd5032
("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>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
90bf6610a1
commit
5c4a9aa856
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user