tipc: notify pending connects of peer node loss
Subsystems (4)
cover tipc: notify pending connects of peer node loss
From: liushike <[email protected]>
This series notifies pending active opens when contact with the peer node is lost, and adds selftests for both connection-oriented socket types.
A client can send SYN and wait in connect() while the listening server has not called accept(). If the last usable link then disappears, the unmodified kernel leaves that connect waiting instead of reporting node loss. Registering pending connects lets node_lost_contact() notify them; the client receives EHOSTUNREACH. A surviving link preserves the attempt.
Patch 1 changes connection registration and error notification. Patch 2 adds selftests and their build/maintainer integration.
I am proposing net-next for this long-standing behavior change, but would appreciate guidance on whether net is the preferred target. This is an RFC for review, including the target tree and historical attribution.
I have not reliably identified the original introducing commit for a Fixes tag. Commit dadebc00299a ("tipc: eliminate port_connect()/port_disconnect() functions") moved existing registration logic in 2014; its parent already registered at connection completion, so that refactoring alone is not evidence of introduction. No Fixes tag is guessed here.
Testing used the base-commit below for the before kernel and that base plus this series for the after kernel. Both ran the identical final selftest in x86_64 QEMU/KVM guests (2 vCPUs, 1536 MiB), with GCC 9.4.0 and binutils 2.34. Two network namespaces communicate over veth pairs; fault injection disables TIPC Ethernet bearers, not physical cables.
Results (SOCK_STREAM and SOCK_SEQPACKET, nine cases each):
Before: 8 passed, 10 failed, 0 skipped; exit status 1.
After: 18 passed, 0 failed, 0 skipped; exit status 0.
On the before kernel, last-link loss, both-links loss and named node loss left connect pending beyond the two-second assertion window. Nonblocking connect and connection-wait timeout followed by node loss had no hangup event and SO_ERROR remained zero. Normal accept, surviving-link failover, rejection and named accept passed. These failures occurred after SYN reached the listener, not during topology preparation.
On the after kernel all cases passed, including EHOSTUNREACH and POLLHUP checks for asynchronous failure. The two-second bound is a test deadline, not a measurement of millisecond-level latency.
The kernel configurations differ only in CONFIG_LOCALVERSION. The build records include the base commit, patch and image hashes, configurations, compiler output, launch script and both guest TAP logs.
liushike (2):
tipc: abort pending connects when the peer node is lost
selftests: net: cover pending TIPC connects on peer node loss
MAINTAINERS | 1 + net/tipc/node.c | 37 ++- net/tipc/node.h | 1 + net/tipc/socket.c | 38 ++- tools/testing/selftests/net/Makefile | 1 + tools/testing/selftests/net/config | 1 + tools/testing/selftests/net/tipc_connect.py | 278 ++++++++++++++++++++ 7 files changed, 353 insertions(+), 4 deletions(-) create mode 100755 tools/testing/selftests/net/tipc_connect.py
base-commit: 8830e65ed46de41f849eefb8ba227d4852c460f6
Signature · 1 line
2.34.1
RFC 1/2 tipc: abort pending connects when the peer node is lost
From: liushike <[email protected]>
A client can send a SYN and block in connect() while the listening server has not yet called accept(). If the last usable link to that server is lost, the client may remain asleep until its connection timeout expires. Only established connections are in the peer node's conn_sks list, so node_lost_contact() cannot notify the pending connection.
Register an active open before sending SYN and check node availability under the node write lock. Let the existing node-loss notification abort the pending handshake with EHOSTUNREACH and wake the connect waiter. Losing one link does not abort the connect while another link survives.
Update the listening port to the accepted port in place on receipt of ACK, preserving the node-loss registration. Reject a late ACK if node loss already removed the registration, even if the node has recovered. Transfer the registration when a named SYN is rerouted to another node. Avoid registering active opens twice; remove registrations on transmit failure and terminal rejection, but retain them across overload retries and connection-wait timeouts, which do not cancel the handshake.
--- net/tipc/node.c | 37 ++++++++++++++++++++++++++++++++++++- net/tipc/node.h | 1 + net/tipc/socket.c | 38 +++++++++++++++++++++++++++++++++++--- 3 files changed, 72 insertions(+), 4 deletions(-)
net/tipc/node.c +36 -1
@@ -713,13 +713,48 @@ int tipc_node_add_conn(struct net *net, u32 dnode, u32 port, u32 peer_port) conn->peer_port = peer_port;tipc_node_write_lock (node); -list_add_tail (&conn->list, &node->conn_sks); +if (node_is_up (node)) { +list_add_tail (&conn->list, &node->conn_sks); + }else { + err = -EHOSTUNREACH ; +kfree (conn); + }tipc_node_write_unlock (node); exit:tipc_node_put (node);return err; } +/* Replace the listening port with the accepted port without losing the +* node loss subscription. A missing entry means node_lost_contact() has +* already aborted this connection attempt, even if the node is up again. +*/ +int tipc_node_update_conn (struct net *net,u32 dnode,u32 port,u32 peer_port) +{ +struct tipc_sock_conn *conn; +struct tipc_node *node; +int err = -EHOSTUNREACH ; + +if (in_own_node (net, dnode)) +return 0 ; + + node =tipc_node_find (net, dnode); +if (!node) +return err; + +tipc_node_write_lock (node); +list_for_each_entry (conn, &node->conn_sks, list) { +if (conn->port != port) +continue ; + conn->peer_port = peer_port; + err =0 ; +break ; + } +tipc_node_write_unlock (node); +tipc_node_put (node); +return err; +} +void tipc_node_remove_conn (struct net *net,u32 dnode,u32 port) {struct tipc_node *node;
net/tipc/node.h +1 -0
@@ -107,6 +107,7 @@ void tipc_node_subscribe(struct net *net, struct list_head *subscr, u32 addr);void tipc_node_unsubscribe (struct net *net,struct list_head *subscr,u32 addr);void tipc_node_broadcast (struct net *net,struct sk_buff *skb,int rc_dests);int tipc_node_add_conn (struct net *net,u32 dnode,u32 port,u32 peer_port); +int tipc_node_update_conn (struct net *net,u32 dnode,u32 port,u32 peer_port);void tipc_node_remove_conn (struct net *net,u32 dnode,u32 port);int tipc_node_get_mtu (struct net *net,u32 addr,u32 sel,bool connected);bool tipc_node_is_up (struct net *net,u32 addr);
net/tipc/socket.c +35 -3
@@ -1511,6 +1511,16 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen)return -ENOMEM ; } +/* Subscribe before sending SYN so node loss also aborts pending connects. */ +if (syn) { + rc =tipc_node_add_conn (net, skaddr.node, tsk->portid, skaddr.ref); +if (rc) { +__skb_queue_purge (&pkts); +__skb_queue_purge (&sk->sk_write_queue); +return rc; + } + } +/* Send message */ trace_tipc_sk_sendmsg (sk,skb_peek (&pkts),TIPC_DUMP_SK_SNDQ ," " ); rc =tipc_node_xmit (net, &pkts, skaddr.node, tsk->portid);
@@ -1520,6 +1530,11 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen) rc =0 ; } +if (unlikely (syn && rc)) { +tipc_node_remove_conn (net, skaddr.node, tsk->portid); +__skb_queue_purge (&sk->sk_write_queue); + } +if (unlikely (syn && !rc)) {tipc_set_sk_state (sk,TIPC_CONNECTING );if (dlen && timeout) {
@@ -1674,8 +1689,10 @@ static void tipc_sk_finish_conn(struct tipc_sock *tsk, u32 peer_port,msg_set_hdr_sz (msg,SHORT_H_SIZE );sk_reset_timer (sk, &sk->sk_timer, jiffies +CONN_PROBING_INTV ); +/* Active opens already subscribed before sending SYN. */ +if (sk->sk_state !=TIPC_CONNECTING ) +tipc_node_add_conn (net, peer_node, tsk->portid, peer_port);tipc_set_sk_state (sk,TIPC_ESTABLISHED ); -tipc_node_add_conn (net, peer_node, tsk->portid, peer_port); tsk->max_pkt =tipc_node_get_mtu (net, peer_node, tsk->portid, true); tsk->peer_caps =tipc_node_get_capabilities (net, peer_node);tsk_set_nagle (tsk);
@@ -2199,12 +2216,14 @@ static bool tipc_sk_filter_connect(struct tipc_sock *tsk, struct sk_buff *skb,struct net *net =sock_net (sk);struct tipc_msg *hdr =buf_msg (skb);bool con_msg =msg_connected (hdr); +bool reject_ack = false;u32 pport =tsk_peer_port (tsk);u32 pnode =tsk_peer_node (tsk);u32 oport =msg_origport (hdr);u32 onode =msg_orignode (hdr);int err =msg_errcode (hdr);unsigned long delay; +int rc;if (unlikely (msg_mcast (hdr)))return false;
@@ -2216,6 +2235,18 @@ static bool tipc_sk_filter_connect(struct tipc_sock *tsk, struct sk_buff *skb,if (likely (con_msg)) {if (err)break ; + rc =tipc_node_update_conn (net, pnode, tsk->portid, oport); +/* A named SYN may have been rerouted to another node. */ +if (!rc && onode != pnode) { +tipc_node_remove_conn (net, pnode, tsk->portid); + rc =tipc_node_add_conn (net, onode, tsk->portid, oport); + } +if (rc) { + err =TIPC_ERR_NO_NODE ; +/* Return a late ACK to its sender, including any data. */ + reject_ack = true; +break ; + }tipc_sk_finish_conn (tsk, oport, onode);msg_set_importance (&tsk->phdr,msg_importance (hdr));/* ACK+ message with data is added to receive queue */
@@ -2285,9 +2316,10 @@ static bool tipc_sk_filter_connect(struct tipc_sock *tsk, struct sk_buff *skb, }/* Abort connection setup attempt */ tipc_set_sk_state (sk,TIPC_DISCONNECTING ); - sk->sk_err =ECONNREFUSED ; +tipc_node_remove_conn (net, pnode, tsk->portid); + sk->sk_err = err ==TIPC_ERR_NO_NODE ?EHOSTUNREACH :ECONNREFUSED ; sk->sk_state_change (sk); -return true; +return !reject_ack; }/**
Signature · 1 line
2.34.1
Tung Quang Nguyen
maintainerRE: [RFC net-next 1/2] tipc: abort pending connects when the peer node is lost
Quoted 10 lines
Subject: [RFC net-next 1/2] tipc: abort pending connects when the peer node is lost
From: liushike <[email protected]>
A client can send a SYN and block in
connect()while the listening server has not yet calledaccept(). If the last usable link to that server is lost, the client may remain asleep until its connection timeout expires.
Only established connections are in the peer node'sconn_skslist, sonode_lost_contact()cannot notify the pending connection.
Do retrying calling connect() and setting connection timeout to link tolerance (default: 1500 ms) help your use case ?
Quoted 53 lines
Register an active open before sending SYN and check node availability under the node write lock. Let the existing node-loss notification abort the pending handshake with EHOSTUNREACH and wake the connect waiter.
Losing one link does not abort the connect while another link survives.Update the listening port to the accepted port in place on receipt of ACK, preserving the node-loss registration. Reject a late ACK if node loss already removed the registration, even if the node has recovered. Transfer the registration when a named SYN is rerouted to another node. Avoid registering active opens twice; remove registrations on transmit failure and terminal rejection, but retain them across overload retries and connection-wait timeouts, which do not cancel the handshake.
Signed-off-by liushike <[email protected]>---
net/tipc/node.c | 37 ++++++++++++++++++++++++++++++++++++- net/tipc/node.h | 1 + net/tipc/socket.c | 38 +++++++++++++++++++++++++++++++++++--- 3 files changed, 72 insertions(+), 4 deletions(-)net/tipc/node.c index renamed from net/tipc/node.c +0
-0
bd91378b7540..31f2ef44ad37100644net/tipc/node.c +6
-1@@ -713,13 +713,48 @@ int tipc_node_add_conn(struct net *net, u32 dnode, u32 port, u32 peer_port) conn->peer_port = peer_port;tipc_node_write_lock (node); -list_add_tail (&conn->list, &node->conn_sks); +if (node_is_up (node)) { +list_add_tail (&conn->list, &node->conn_sks); + }else { + err = -EHOSTUNREACH ; +kfree (conn); + }tipc_node_write_unlock (node);exit:
tipc_node_put(node); return err; }net/tipc/node.c +10
-0+/* Replace the listening port with the accepted port without losing the +* node loss subscription. A missing entry means node_lost_contact() +has +* already aborted this connection attempt, even if the node is up again. +*/ +int tipc_node_update_conn (struct net *net,u32 dnode,u32 port,u32 +peer_port) { +struct tipc_sock_conn *conn; +struct tipc_node *node; +int err = -EHOSTUNREACH ;
net/tipc/node.c int tipc_node_add_conn(struct net *net, u32 dnode, u32 port, u32 peer_port) · line 746
Quoted 10 lines
net/tipc/node.c +10
-0+ +if (in_own_node (net, dnode)) +return 0 ; + + node =tipc_node_find (net, dnode); +if (!node) +return err; + +tipc_node_write_lock (node); +list_for_each_entry (conn, &node->conn_sks, list) {
Traversing the list of thousands of connections look bad.
Have you tried to measure performance regression when one socket of this node is sending/receiving messages and 4000 thousand other connections are initiated simultaneously ?
Quoted 136 lines
net/tipc/node.c +11
-0+if (conn->port != port) +continue ; + conn->peer_port = peer_port; + err =0 ; +break ; + } +tipc_node_write_unlock (node); +tipc_node_put (node); +return err; +} +void tipc_node_remove_conn(struct net *net, u32 dnode, u32 port) { struct tipc_node *node;net/tipc/node.h index renamed from net/tipc/node.h +0
-0
154a5bbb0d29..48693a050aa8100644net/tipc/node.h +0
-0@@ -107,6 +107,7 @@ void tipc_node_subscribe(struct net *net, struct list_head *subscr, u32 addr); void tipc_node_unsubscribe(struct net *net, struct list_head *subscr, u32 addr); void tipc_node_broadcast(struct net *net,struct
sk_buff*skb, intrc_dests); inttipc_node_add_conn(struct net *net, u32 dnode, u32 port, u32 peer_port);net/tipc/node.h +2
-0+int tipc_node_update_conn (struct net *net,u32 dnode,u32 port,u32 +peer_port);void
tipc_node_remove_conn(struct net *net, u32 dnode, u32 port); inttipc_node_get_mtu(struct net *net, u32 addr, u32 sel, bool connected); booltipc_node_is_up(struct net *net, u32 addr); diff --gita/net/tipc/socket.cb/net/tipc/socket.cindex d5d70eb230b5..191579636351 100644net/tipc/socket.c +1
-0@@ -1511,6 +1511,16 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen) return -ENOMEM; } +/* Subscribe before sending SYN so node loss also aborts pending connects. */
net/tipc/socket.c +2
-0+if (syn) { + rc = tipc_node_add_conn(net, skaddr.node, tsk->portid,skaddr.ref);
net/tipc/socket.c +7
-0+if (rc) { +__skb_queue_purge (&pkts); +__skb_queue_purge (&sk->sk_write_queue); +return rc; + } + } +/* Send message */ trace_tipc_sk_sendmsg(sk, skb_peek(&pkts), TIPC_DUMP_SK_SNDQ, " "); rc = tipc_node_xmit(net, &pkts, skaddr.node, tsk->portid); @@ -1520,6 +1530,11 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen) rc = 0; }net/tipc/socket.c +5
-0+if (unlikely (syn && rc)) { +tipc_node_remove_conn (net, skaddr.node, tsk->portid); +__skb_queue_purge (&sk->sk_write_queue); + } +if (unlikely(syn && !rc)) { tipc_set_sk_state(sk, TIPC_CONNECTING); if (dlen && timeout) {net/tipc/socket.c +3
-1@@ -1674,8 +1689,10 @@ static void tipc_sk_finish_conn(struct tipc_sock *tsk, u32 peer_port,msg_set_hdr_sz (msg,SHORT_H_SIZE );sk_reset_timer (sk, &sk->sk_timer, jiffies +CONN_PROBING_INTV ); +/* Active opens already subscribed before sending SYN. */ +if (sk->sk_state !=TIPC_CONNECTING ) +tipc_node_add_conn (net, peer_node, tsk->portid, peer_port);tipc_set_sk_state (sk,TIPC_ESTABLISHED ); -tipc_node_add_conn (net, peer_node, tsk->portid, peer_port); tsk->max_pkt =tipc_node_get_mtu (net, peer_node, tsk->portid, true); tsk->peer_caps =tipc_node_get_capabilities (net, peer_node);tsk_set_nagle(tsk);net/tipc/socket.c +2
-0@@ -2199,12 +2216,14 @@ static bool tipc_sk_filter_connect(struct tipc_sock *tsk, struct sk_buff *skb, struct net *net = sock_net(sk);struct tipc_msg *hdr =buf_msg (skb);bool con_msg =msg_connected (hdr); +bool reject_ack = false;u32 pport =tsk_peer_port (tsk);u32 pnode =tsk_peer_node (tsk);u32 oport =msg_origport (hdr);u32 onode =msg_orignode (hdr);int err =msg_errcode (hdr);unsigned long delay; +int rc;if (unlikely (msg_mcast (hdr)))return false;net/tipc/socket.c +2
-0@@ -2216,6 +2235,18 @@ static bool tipc_sk_filter_connect(struct tipc_sock *tsk, struct sk_buff *skb, if (likely(con_msg)) {if (err)break ; + rc =tipc_node_update_conn (net, pnode, tsk->portid, oport); +/* A named SYN may have been rerouted to another node. */
net/tipc/socket.c +2
-0+if (!rc && onode != pnode) { + tipc_node_remove_conn(net, pnode, tsk-Quoted 1 line
portid);
net/tipc/socket.c +1
-0+ rc = tipc_node_add_conn(net, onode, tsk-Quoted 1 line
portid, oport);
net/tipc/socket.c +4
-0+ } +if (rc) { + err =TIPC_ERR_NO_NODE ; +/* Return a late ACK to its sender, including any data. */
net/tipc/socket.c +3
-0+ reject_ack = true; +break ; + }tipc_sk_finish_conn(tsk, oport, onode); msg_set_importance(&tsk->phdr, msg_importance(hdr)); /* ACK+ message with data is added to receive queue */ @@ -2285,9 +2316,10 @@ static bool tipc_sk_filter_connect(struct tipc_sock *tsk, struct sk_buff *skb, } /* Abort connection setup attempt */ tipc_set_sk_state(sk, TIPC_DISCONNECTING);net/tipc/socket.c +2
-1- sk->sk_err =ECONNREFUSED ; +tipc_node_remove_conn (net, pnode, tsk->portid); + sk->sk_err = err == TIPC_ERR_NO_NODE ? EHOSTUNREACH :ECONNREFUSED; sk->sk_state_change(sk);net/tipc/socket.c +1
-1-return true; +return !reject_ack;}
/**
--
2.34.1
Re: [RFC net-next 1/2] tipc: abort pending connects when the peer node is lost
Hi Tung,
Quoted 2 lines
Do retrying calling
connect()and setting connection timeout to link tolerance (default: 1500 ms) help your use case ?
A shorter connection timeout could mitigate the blocking time. I have not yet tested the specific 1500 ms timeout-and-retry approach on the affected application, so I cannot rule it out as a workaround.
The distinction I intended to address is between a connection setup timeout and a confirmed loss of contact with the peer. A short timeout also expires when the peer is reachable but acceptance is delayed, whereas this change reports EHOSTUNREACH once the node-loss path has determined that no usable link remains.
Also, from the current code, a connection-wait timeout leaves the socket in TIPC_CONNECTING. Calling blocking connect() again on that socket continues waiting for the pending handshake rather than starting a fresh attempt. I will evaluate the timeout-and-retry approach and clarify the application requirements before arguing that a kernel change is necessary.
Quoted 4 lines
Traversing the list of thousands of connections look bad. Have you tried to measure performance regression when one socket of this node is sending/receiving messages and 4000 thousand other connections are initiated simultaneously ?
I have not measured that workload. The results reported in the cover letter are functional tests, not scalability or performance tests.
The new lookup scans conn_sks under the node write lock. Its cost grows with the number of connections, and contention on that lock could affect traffic on an established connection. The functional results do not establish that this overhead is acceptable.
I will compare the unmodified and patched kernels with an established connection carrying traffic while other connections to the same peer are initiated concurrently. I will measure data-path throughput and latency as well as connection setup latency, and investigate avoiding the new linear scan.
To confirm the test scale, did you mean 4,000 concurrent connection attempts?
I will follow up with the measurements and the application-level comparison before posting a revised series.
Regards,
liushike
Quoted 218 lines · Tung Quang Nguyen <[email protected]> 于2026年10月8日周四 14:46写道:
Quoted 11 lines
Subject: [RFC net-next 1/2] tipc: abort pending connects when the peer node is lost
From: liushike <[email protected]>
A client can send a SYN and block in
connect()while the listening server has not yet calledaccept(). If the last usable link to that server is lost, the client may remain asleep until its connection timeout expires.
Only established connections are in the peer node'sconn_skslist, sonode_lost_contact()cannot notify the pending connection.Do retrying calling
connect()and setting connection timeout to link tolerance (default: 1500 ms) help your use case ?Quoted 53 lines
Register an active open before sending SYN and check node availability under the node write lock. Let the existing node-loss notification abort the pending handshake with EHOSTUNREACH and wake the connect waiter.
Losing one link does not abort the connect while another link survives.Update the listening port to the accepted port in place on receipt of ACK, preserving the node-loss registration. Reject a late ACK if node loss already removed the registration, even if the node has recovered. Transfer the registration when a named SYN is rerouted to another node. Avoid registering active opens twice; remove registrations on transmit failure and terminal rejection, but retain them across overload retries and connection-wait timeouts, which do not cancel the handshake.
Signed-off-by liushike <[email protected]>---
net/tipc/node.c | 37 ++++++++++++++++++++++++++++++++++++- net/tipc/node.h | 1 + net/tipc/socket.c | 38 +++++++++++++++++++++++++++++++++++--- 3 files changed, 72 insertions(+), 4 deletions(-)net/tipc/node.c index renamed from net/tipc/node.c +0
-0
bd91378b7540..31f2ef44ad37100644net/tipc/node.c +6
-1@@ -713,13 +713,48 @@ int tipc_node_add_conn(struct net *net, u32 dnode, u32 port, u32 peer_port) conn->peer_port = peer_port;tipc_node_write_lock (node); -list_add_tail (&conn->list, &node->conn_sks); +if (node_is_up (node)) { +list_add_tail (&conn->list, &node->conn_sks); + }else { + err = -EHOSTUNREACH ; +kfree (conn); + }tipc_node_write_unlock (node);exit:
tipc_node_put(node); return err; }net/tipc/node.c +10
-0+/* Replace the listening port with the accepted port without losing the +* node loss subscription. A missing entry means node_lost_contact() +has +* already aborted this connection attempt, even if the node is up again. +*/ +int tipc_node_update_conn (struct net *net,u32 dnode,u32 port,u32 +peer_port) { +struct tipc_sock_conn *conn; +struct tipc_node *node; +int err = -EHOSTUNREACH ;net/tipc/node.c int tipc_node_add_conn(struct net *net, u32 dnode, u32 port, u32 peer_port) · line 746
Quoted 10 lines
net/tipc/node.c +10
-0+ +if (in_own_node (net, dnode)) +return 0 ; + + node =tipc_node_find (net, dnode); +if (!node) +return err; + +tipc_node_write_lock (node); +list_for_each_entry (conn, &node->conn_sks, list) {Traversing the list of thousands of connections look bad.
Have you tried to measure performance regression when one socket of this node is sending/receiving messages and 4000 thousand other connections are initiated simultaneously ?Quoted 136 lines
net/tipc/node.c +11
-0+if (conn->port != port) +continue ; + conn->peer_port = peer_port; + err =0 ; +break ; + } +tipc_node_write_unlock (node); +tipc_node_put (node); +return err; +} +void tipc_node_remove_conn(struct net *net, u32 dnode, u32 port) { struct tipc_node *node;net/tipc/node.h index renamed from net/tipc/node.h +0
-0
154a5bbb0d29..48693a050aa8100644net/tipc/node.h +0
-0@@ -107,6 +107,7 @@ void tipc_node_subscribe(struct net *net, struct list_head *subscr, u32 addr); void tipc_node_unsubscribe(struct net *net, struct list_head *subscr, u32 addr); void tipc_node_broadcast(struct net *net,struct
sk_buff*skb, intrc_dests); inttipc_node_add_conn(struct net *net, u32 dnode, u32 port, u32 peer_port);net/tipc/node.h +2
-0+int tipc_node_update_conn (struct net *net,u32 dnode,u32 port,u32 +peer_port);void
tipc_node_remove_conn(struct net *net, u32 dnode, u32 port); inttipc_node_get_mtu(struct net *net, u32 addr, u32 sel, bool connected); booltipc_node_is_up(struct net *net, u32 addr); diff --gita/net/tipc/socket.cb/net/tipc/socket.cindex d5d70eb230b5..191579636351 100644net/tipc/socket.c +1
-0@@ -1511,6 +1511,16 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen) return -ENOMEM; } +/* Subscribe before sending SYN so node loss also aborts pending connects. */
net/tipc/socket.c +2
-0+if (syn) { + rc = tipc_node_add_conn(net, skaddr.node, tsk->portid,skaddr.ref);
net/tipc/socket.c +7
-0+if (rc) { +__skb_queue_purge (&pkts); +__skb_queue_purge (&sk->sk_write_queue); +return rc; + } + } +/* Send message */ trace_tipc_sk_sendmsg(sk, skb_peek(&pkts), TIPC_DUMP_SK_SNDQ, ""); rc = tipc_node_xmit(net, &pkts, skaddr.node, tsk->portid); @@ -1520,6 +1530,11 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen) rc = 0; }net/tipc/socket.c +8
-1+if (unlikely (syn && rc)) { +tipc_node_remove_conn (net, skaddr.node, tsk->portid); +__skb_queue_purge (&sk->sk_write_queue); + } +if (unlikely (syn && !rc)) {tipc_set_sk_state (sk,TIPC_CONNECTING );if (dlen && timeout) {@@ -1674,8 +1689,10 @@ static void tipc_sk_finish_conn(struct tipc_sock *tsk, u32 peer_port,msg_set_hdr_sz (msg,SHORT_H_SIZE );sk_reset_timer (sk, &sk->sk_timer, jiffies +CONN_PROBING_INTV ); +/* Active opens already subscribed before sending SYN. */ +if (sk->sk_state !=TIPC_CONNECTING ) +tipc_node_add_conn (net, peer_node, tsk->portid, peer_port);tipc_set_sk_state (sk,TIPC_ESTABLISHED ); -tipc_node_add_conn (net, peer_node, tsk->portid, peer_port); tsk->max_pkt =tipc_node_get_mtu (net, peer_node, tsk->portid, true); tsk->peer_caps =tipc_node_get_capabilities (net, peer_node);tsk_set_nagle(tsk);net/tipc/socket.c +2
-0@@ -2199,12 +2216,14 @@ static bool tipc_sk_filter_connect(struct tipc_sock *tsk, struct sk_buff *skb, struct net *net = sock_net(sk);struct tipc_msg *hdr =buf_msg (skb);bool con_msg =msg_connected (hdr); +bool reject_ack = false;u32 pport =tsk_peer_port (tsk);u32 pnode =tsk_peer_node (tsk);u32 oport =msg_origport (hdr);u32 onode =msg_orignode (hdr);int err =msg_errcode (hdr);unsigned long delay; +int rc;if (unlikely (msg_mcast (hdr)))return false;net/tipc/socket.c +2
-0@@ -2216,6 +2235,18 @@ static bool tipc_sk_filter_connect(struct tipc_sock *tsk, struct sk_buff *skb, if (likely(con_msg)) {if (err)break ; + rc =tipc_node_update_conn (net, pnode, tsk->portid, oport); +/* A named SYN may have been rerouted to another node. */
net/tipc/socket.c +2
-0+if (!rc && onode != pnode) { + tipc_node_remove_conn(net, pnode, tsk-Quoted 1 line
portid);
+ rc = tipc_node_add_conn(net, onode, tsk-
Quoted 1 line
portid, oport);
net/tipc/socket.c +4
-0+ } +if (rc) { + err =TIPC_ERR_NO_NODE ; +/* Return a late ACK to its sender, including any data. */
net/tipc/socket.c +3
-0+ reject_ack = true; +break ; + }tipc_sk_finish_conn (tsk, oport, onode); msg_set_importance(&tsk->phdr,msg_importance(hdr)); /* ACK+ message with data is added to receive queue */ @@ -2285,9 +2316,10 @@ static bool tipc_sk_filter_connect(struct tipc_sock *tsk, struct sk_buff *skb, } /* Abort connection setup attempt */ tipc_set_sk_state(sk, TIPC_DISCONNECTING);net/tipc/socket.c +2
-1- sk->sk_err =ECONNREFUSED ; +tipc_node_remove_conn (net, pnode, tsk->portid); + sk->sk_err = err == TIPC_ERR_NO_NODE ? EHOSTUNREACH :ECONNREFUSED; sk->sk_state_change(sk);net/tipc/socket.c +1
-1-return true; +return !reject_ack;}
/**
--
2.34.1
Tung Quang Nguyen
maintainerRE: [RFC net-next 1/2] tipc: abort pending connects when the peer node is lost
Quoted 3 lines
The distinction I intended to address is between a connection setup timeout and a confirmed loss of contact with the peer. A short timeout also expires when the peer is reachable but acceptance is delayed,
That can be addressed by "retry" as I suggested.
Quoted 3 lines
whereas this change
reports EHOSTUNREACH once the node-loss path has determined that no usable link remains.
I do not think it is needed.
User applications can subscribe for node-loss event. When no link is up, subscribed process will receive the loss event. This process can close the waiting/blocking socket.
Quoted 4 lines
Also, from the current code, a connection-wait timeout leaves the socket in
TIPC_CONNECTING. Calling blockingconnect()again on that socket continues waiting for the pending handshake rather than starting a fresh attempt
This behavior is expected and we will not allow a fresh connection from a waiting/blocking socket to avoid buffer-overload at listening socket/server.
Quoted 1 line
To confirm the test scale, did you mean 4,000 concurrent connection attempts?
Yes.
RFC 2/2 selftests: net: cover pending TIPC connects on peer node loss
In reply to liushikeFrom: liushike <[email protected]>
Exercise a client waiting for a listening server to accept a connection using two network namespaces and one or two Ethernet veth bearers.
Cover normal acceptance, last-link loss, survival with one remaining link, loss of both links, rejection, connection-wait timeout followed by node loss, nonblocking connects, and service-name addressing. Run each case with SOCK_STREAM and SOCK_SEQPACKET.
Wait for actual unicast links at both peers; the always-UP broadcast link does not establish peer reachability. Require node-loss completion within two seconds and check EHOSTUNREACH. For asynchronous failure, check POLLHUP with poll(), matching TIPC_DISCONNECTING semantics rather than assuming the socket becomes writable. Save topology diagnostics when a test raises an exception.
--- MAINTAINERS | 1 + tools/testing/selftests/net/Makefile | 1 + tools/testing/selftests/net/config | 1 + tools/testing/selftests/net/tipc_connect.py | 278 ++++++++++++++++++++ 4 files changed, 281 insertions(+) create mode 100755 tools/testing/selftests/net/tipc_connect.py
MAINTAINERS +1 -0
@@ -27561,6 +27561,7 @@ S: Maintained W: http://tipc.sourceforge.net/ F: include/uapi/linux/tipc*.h F: net/tipc/ +F: tools/testing/selftests/net/tipc_connect.py TLAN NETWORK DRIVER M: Samuel Chessman <[email protected]>
tools/testing/selftests/net/Makefile +1 -0
@@ -118,6 +118,7 @@ TEST_PROGS := \ test_vxlan_vnifilter_notify.sh \ test_vxlan_vnifiltering.sh \ tfo_passive.sh \ + tipc_connect.py \ traceroute.sh \ txtimestamp.sh \ udpgro.sh \
tools/testing/selftests/net/config +1 -0
@@ -128,6 +128,7 @@ CONFIG_TCP_CONG_DCTCP=y CONFIG_TCP_MD5SIG=y CONFIG_TEST_BLACKHOLE_DEV=m CONFIG_TEST_BPF=m +CONFIG_TIPC=m CONFIG_TLS=m CONFIG_TRACEPOINTS=y CONFIG_TUN=y
tools/testing/selftests/net/tipc_connect.py new file +278 -0
278 lines not on this page · raw message
Signature · 1 line
2.34.1
[email protected]
AI reviewThis is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then.
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
A message that is not in the archive (sent off-list or not yet received): CAL9mPHsf_10zX4Z_2WFHNJob7Tkfnaw6sp03q2+ujnTygn1Ucg@mail.gmail.com
The issue was first observed on actual network devices operating in a
cluster. The client was waiting in connect() for the server to accept the connection. When contact with the peer node was lost, the pending connect did not return promptly and instead continued waiting for its connection timeout.
I subsequently investigated the TIPC connection setup and node-loss paths with LLM assistance. The analysis showed that pending connects were not registered in the peer node's conn_sks list, so node_lost_contact() did not notify them. The initial report came from the observed device failure, rather than an LLM or static-analysis scan.
I then reproduced the behavior using the same final selftest on the unmodified base kernel and on that base with this series applied, in x86_64 QEMU/KVM guests. The tests use two network namespaces connected by veth pairs and disable TIPC Ethernet bearers to simulate loss of connectivity.
On the unmodified kernel, 8 tests passed and 10 failed. With the series applied, all 18 tests passed, covering SOCK_STREAM and SOCK_SEQPACKET. The node-loss cases check completion within two seconds and the expected EHOSTUNREACH error.
I will include this discovery background in the commit message if a revised series is needed. I am not reposting the series solely for this clarification.
Regards,
liushike
Quoted 56 lines · shike liu <[email protected]> 于2026年9月30日周三 10:01写道:
Hi,
Quoted 3 lines
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
The issue was first observed on actual network devices operating in a cluster. The client was waiting in
connect()for the server to accept the connection. When contact with the peer node was lost, the pending connect did not return promptly and instead continued waiting for its connection timeout.I subsequently investigated the TIPC connection setup and node-loss paths with LLM assistance. The analysis showed that pending connects were not registered in the peer node's
conn_skslist, sonode_lost_contact()did not notify them. The initial report came from the observed device failure, rather than an LLM or static-analysis scan.I then reproduced the behavior using the same final selftest on the unmodified base kernel and on that base with this series applied, in
x86_64QEMU/KVM guests. The tests use two network namespaces connected by veth pairs and disable TIPC Ethernet bearers to simulate loss of connectivity.On the unmodified kernel, 8 tests passed and 10 failed. With the series applied, all 18 tests passed, covering
SOCK_STREAMandSOCK_SEQPACKET. The node-loss cases check completion within two seconds and the expected EHOSTUNREACH error.I will include this discovery background in the commit message if a revised series is needed. I am not reposting the series solely for this clarification.
Regards,
liushikeQuoted 18 lines · <[email protected]> 于2026年9月29日周二 14:54写道:
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then.
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
Hi,
I would like to clarify the next step for this RFC series.
The issue was observed on actual network devices operating in a cluster. I have provided the discovery background in this thread. The same selftest produced 8 passes and 10 failures on the unmodified base, and all 18 tests passed with the series applied.
I have not received technical feedback on the approach yet. Since this fixes an observed connection setup failure, would net be the preferred target rather than net-next?
I have not yet reliably identified the original introducing commit for a Fixes tag. I would appreciate guidance on that point and on whether to proceed with a non-RFC submission.
Regards,
liushike
Quoted 88 lines · shike liu <[email protected]> 于2026年9月30日周三 10:08写道:
The issue was first observed on actual network devices operating in a
cluster. The client was waiting inconnect()for the server to accept the connection. When contact with the peer node was lost, the pending connect did not return promptly and instead continued waiting for its connection timeout.I subsequently investigated the TIPC connection setup and node-loss paths with LLM assistance. The analysis showed that pending connects were not registered in the peer node's
conn_skslist, sonode_lost_contact()did not notify them. The initial report came from the observed device failure, rather than an LLM or static-analysis scan.I then reproduced the behavior using the same final selftest on the unmodified base kernel and on that base with this series applied, in
x86_64QEMU/KVM guests. The tests use two network namespaces connected by veth pairs and disable TIPC Ethernet bearers to simulate loss of connectivity.On the unmodified kernel, 8 tests passed and 10 failed. With the series applied, all 18 tests passed, covering
SOCK_STREAMandSOCK_SEQPACKET. The node-loss cases check completion within two seconds and the expected EHOSTUNREACH error.I will include this discovery background in the commit message if a revised series is needed. I am not reposting the series solely for this clarification.
Regards,
liushikeQuoted 56 lines · shike liu <[email protected]> 于2026年9月30日周三 10:01写道:
Hi,
Quoted 3 lines
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
The issue was first observed on actual network devices operating in a cluster. The client was waiting in
connect()for the server to accept the connection. When contact with the peer node was lost, the pending connect did not return promptly and instead continued waiting for its connection timeout.I subsequently investigated the TIPC connection setup and node-loss paths with LLM assistance. The analysis showed that pending connects were not registered in the peer node's
conn_skslist, sonode_lost_contact()did not notify them. The initial report came from the observed device failure, rather than an LLM or static-analysis scan.I then reproduced the behavior using the same final selftest on the unmodified base kernel and on that base with this series applied, in
x86_64QEMU/KVM guests. The tests use two network namespaces connected by veth pairs and disable TIPC Ethernet bearers to simulate loss of connectivity.On the unmodified kernel, 8 tests passed and 10 failed. With the series applied, all 18 tests passed, covering
SOCK_STREAMandSOCK_SEQPACKET. The node-loss cases check completion within two seconds and the expected EHOSTUNREACH error.I will include this discovery background in the commit message if a revised series is needed. I am not reposting the series solely for this clarification.
Regards,
liushikeQuoted 18 lines · <[email protected]> 于2026年9月29日周二 14:54写道:
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then.
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.