]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
net/rds: Encode cp_index in TCP source port
authorGerd Rausch <gerd.rausch@oracle.com>
Tue, 3 Feb 2026 05:57:17 +0000 (22:57 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 5 Feb 2026 04:46:38 +0000 (20:46 -0800)
commita20a6992558fa7c19a03c76bea4a793ccaef8505
tree47dbe19a4966ddd150f03f607ef6bd027523756a
parent46f257ee6904125e6336d63f0694ff4c491cfbf7
net/rds: Encode cp_index in TCP source port

Upon "sendmsg", RDS/TCP selects a backend connection based
on a hash calculated from the source-port ("RDS_MPATH_HASH").

However, "rds_tcp_accept_one" accepts connections
in the order they arrive, which is non-deterministic.

Therefore the mapping of the sender's "cp->cp_index"
to that of the receiver changes if the backend
connections are dropped and reconnected.

However, connection state that's preserved across reconnects
(e.g. "cp_next_rx_seq") relies on that sender<->receiver
mapping to never change.

So we make sure that client and server of the TCP connection
have the exact same "cp->cp_index" across reconnects by
encoding "cp->cp_index" in the lower three bits of the
client's TCP source port.

A new extension "RDS_EXTHDR_SPORT_IDX" is introduced,
that allows the server to tell the difference between
clients that do the "cp->cp_index" encoding, and
legacy clients that pick source ports randomly.

Signed-off-by: Gerd Rausch <gerd.rausch@oracle.com>
Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
Link: https://patch.msgid.link/20260203055723.1085751-3-achender@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/rds/message.c
net/rds/rds.h
net/rds/recv.c
net/rds/send.c
net/rds/tcp.h
net/rds/tcp_connect.c
net/rds/tcp_listen.c