Skip to content

Commit 51a00be

Browse files
author
Paolo Abeni
committed
udp: fix l4 hash after reconnect
After the blamed commit below, udp_rehash() is supposed to be called with both local and remote addresses set. Currently that is already the case for IPv6 sockets, but for IPv4 the destination address is updated after rehashing. Address the issue moving the destination address and port initialization before rehashing. Fixes: 1b29a73 ("ipv6/udp: Add 4-tuple hash for connected socket") Reviewed-by: Eric Dumazet <[email protected]> Link: https://patch.msgid.link/4761e466ab9f7542c68cdc95f248987d127044d2.1733499715.git.pabeni@redhat.com Signed-off-by: Paolo Abeni <[email protected]>
1 parent 00301ef commit 51a00be

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

net/ipv4/datagram.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,17 @@ int __ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len
6161
err = -EACCES;
6262
goto out;
6363
}
64+
65+
/* Update addresses before rehashing */
66+
inet->inet_daddr = fl4->daddr;
67+
inet->inet_dport = usin->sin_port;
6468
if (!inet->inet_saddr)
65-
inet->inet_saddr = fl4->saddr; /* Update source address */
69+
inet->inet_saddr = fl4->saddr;
6670
if (!inet->inet_rcv_saddr) {
6771
inet->inet_rcv_saddr = fl4->saddr;
6872
if (sk->sk_prot->rehash)
6973
sk->sk_prot->rehash(sk);
7074
}
71-
inet->inet_daddr = fl4->daddr;
72-
inet->inet_dport = usin->sin_port;
7375
reuseport_has_conns_set(sk);
7476
sk->sk_state = TCP_ESTABLISHED;
7577
sk_set_txhash(sk);

0 commit comments

Comments
 (0)