]> www.infradead.org Git - users/hch/misc.git/commit
udp: Make rehash4 independent in udp_lib_rehash()
authorPhilo Lu <lulie@linux.alibaba.com>
Fri, 10 Jan 2025 01:08:10 +0000 (09:08 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 14 Jan 2025 09:44:10 +0000 (10:44 +0100)
commit644f9108f3a505022ef43510e5143cb985e0cf8b
treedc707f812dbb35d9593feb68771b30c20efbde85
parent1f691a1fc4bef1c5cf5f503e14e1a22fc37c97e3
udp: Make rehash4 independent in udp_lib_rehash()

As discussed in [0], rehash4 could be missed in udp_lib_rehash() when
udp hash4 changes while hash2 doesn't change. This patch fixes this by
moving rehash4 codes out of rehash2 checking, and then rehash2 and
rehash4 are done separately.

By doing this, we no longer need to call rehash4 explicitly in
udp_lib_hash4(), as the rehash callback in __ip4_datagram_connect takes
it. Thus, now udp_lib_hash4() returns directly if the sk is already
hashed.

Note that uhash4 may fail to work under consecutive connect(<dst
address>) calls because rehash() is not called with every connect(). To
overcome this, connect(<AF_UNSPEC>) needs to be called after the next
connect to a new destination.

[0]
https://lore.kernel.org/all/4761e466ab9f7542c68cdc95f248987d127044d2.1733499715.git.pabeni@redhat.com/

Fixes: 78c91ae2c6de ("ipv4/udp: Add 4-tuple hash for connected socket")
Suggested-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Philo Lu <lulie@linux.alibaba.com>
Link: https://patch.msgid.link/20250110010810.107145-1-lulie@linux.alibaba.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/ipv4/udp.c