more TIPC fixes and updates
Subsystems (3)
cover more TIPC fixes and updates
With net-next reopened, here is another batch of TIPC patches primarily from the out-of-kernel repo. There is no real binding between any of the commits aside from taking what appear to be stand-alone bits and migrating them across and fixing up minor coding style things etc. I believe there will be a chance to get a lot more of this done in this dev window, so hopefully this will be just one batch of several that I end up sending.
Basic runtime sanity test done on v2.6.36-rc1, and all patches git am cleanly on the net-next of today as well.
Thanks,
Paul.
PATCH 1/14 tipc: Fix log buffer memory leak if initialization fails
From: Anders Kaseorg <[[email protected]]>
Moves log buffer cleanup into tipc_core_stop() so that memory allocated for the log buffer is freed if tipc_core_start() is unsuccessful.
--- net/tipc/core.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
net/tipc/core.c +4 -2
@@ -169,6 +169,7 @@ void tipc_core_stop(void)tipc_nametbl_stop ();tipc_ref_table_stop ();tipc_socket_stop (); +tipc_log_resize (0 ); }/**
@@ -203,7 +204,9 @@ static int __init tipc_init(void) {int res; -tipc_log_resize (CONFIG_TIPC_LOG ); +if (tipc_log_resize (CONFIG_TIPC_LOG ) !=0 ) +warn ("Unable to create log buffer\n" ); +info ("Activated (version " TIPC_MOD_VER " compiled " __DATE__" " __TIME__")\n" );
@@ -230,7 +233,6 @@ static void __exit tipc_exit(void)tipc_core_stop_net ();tipc_core_stop ();info ("Deactivated\n" ); -tipc_log_resize (0 ); }module_init (tipc_init);
Signature · 1 line
1.7.2.1
PATCH 2/14 tipc: add SO_RCVLOWAT support to stream socket receive path
In reply to Paul GortmakerFrom: Florian Westphal <[email protected]>
Add support for the SO_RCVLOWAT socket option to TIPC's stream socket type.
--- net/tipc/socket.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
net/tipc/socket.c +4 -3
@@ -1026,9 +1026,8 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock,struct sk_buff *buf;struct tipc_msg *msg;unsigned int sz; -int sz_to_copy; +int sz_to_copy, target, needed;int sz_copied =0 ; -int needed;char __user *crs = m->msg_iov->iov_base;unsigned char *buf_crs;u32 err;
@@ -1050,6 +1049,8 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock, goto exit; } + target =sock_rcvlowat (sk, flags &MSG_WAITALL , buf_len); + restart:/* Look for a message in receive queue; wait if necessary */
@@ -1138,7 +1139,7 @@ restart:if ((sz_copied < buf_len) &&/* didn't get all requested data */ (!skb_queue_empty (&sk->sk_receive_queue) || - (flags &MSG_WAITALL )) &&/* and more is ready or required */ + (sz_copied < target)) &&/* and more is ready or required */ (!(flags &MSG_PEEK )) &&/* and aren't just peeking at data */ (!err))/* and haven't reached a FIN */ goto restart;
Signature · 1 line
1.7.2.1
PATCH 3/14 tipc: Provide correct error code for unsupported connect() operation
In reply to Paul GortmakerFrom: Allan Stephens <[email protected]>
Modify TIPC to return EOPNOTSUPP if an application attempts to perform
a non-blocking connect() operation, which is not supported by TIPC.
--- net/tipc/socket.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net/tipc/socket.c +1 -1
@@ -1380,7 +1380,7 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,/* For now, TIPC does not support the non-blocking form of connect() */ if (flags &O_NONBLOCK ) { - res = -EWOULDBLOCK ; + res = -EOPNOTSUPP ; goto exit; }
Signature · 1 line
1.7.2.1
PATCH 4/14 tipc: correct problems with misleading flags returned using poll()
In reply to Paul GortmakerFrom: Allan Stephens <[email protected]>
Prevent TIPC from incorrectly setting returned flags to poll() in the following cases:
- an unconnected socket no longer indicates that it is always readable
- an unconnected, connecting, or listening socket no longer indicates that it is always writable
--- net/tipc/socket.c | 61 ++++++++++++++++++++++++++++++++++------------------ 1 files changed, 40 insertions(+), 21 deletions(-)
net/tipc/socket.c +40 -21
@@ -429,36 +429,55 @@ static int get_name(struct socket *sock, struct sockaddr *uaddr,* to handle any preventable race conditions, so TIPC will do the same ... * * TIPC sets the returned events as follows: -* a) POLLRDNORM and POLLIN are set if the socket's receive queue is non-empty -* or if a connection-oriented socket is does not have an active connection -* (i.e. a read operation will not block). -* b) POLLOUT is set except when a socket's connection has been terminated -* (i.e. a write operation will not block). -* c) POLLHUP is set when a socket's connection has been terminated. -* -* IMPORTANT: The fact that a read or write operation will not block does NOT -* imply that the operation will succeed! +* +* socket state flags set +* ------------ --------- +* unconnected no read flags +* no write flags +* +* connecting POLLIN/POLLRDNORM if ACK/NACK in rx queue +* no write flags +* +* connected POLLIN/POLLRDNORM if data in rx queue +* POLLOUT if port is not congested +* +* disconnecting POLLIN/POLLRDNORM/POLLHUP +* no write flags +* +* listening POLLIN if SYN in rx queue +* no write flags +* +* ready POLLIN/POLLRDNORM if data in rx queue +* [connectionless] POLLOUT (since port cannot be congested) +* +* IMPORTANT: The fact that a read or write operation is indicated does NOT +* imply that the operation will succeed, merely that it should be performed +* and will not block. */ static unsigned int poll (struct file *file,struct socket *sock,poll_table *wait) {struct sock *sk = sock->sk; -u32 mask; +u32 mask =0 ;poll_wait (file,sk_sleep (sk), wait); -if (!skb_queue_empty (&sk->sk_receive_queue) || - (sock->state ==SS_UNCONNECTED ) || - (sock->state ==SS_DISCONNECTING )) - mask = (POLLRDNORM |POLLIN ); -else - mask =0 ; - -if (sock->state ==SS_DISCONNECTING ) - mask |=POLLHUP ; -else - mask |=POLLOUT ; +switch ((int )sock->state) { +case SS_READY : +case SS_CONNECTED : +if (!tipc_sk_port (sk)->congested) + mask |=POLLOUT ; +/* fall thru' */ +case SS_CONNECTING : +case SS_LISTENING : +if (!skb_queue_empty (&sk->sk_receive_queue)) + mask |= (POLLIN |POLLRDNORM ); +break ; +case SS_DISCONNECTING : + mask = (POLLIN |POLLRDNORM |POLLHUP ); +break ; + }return mask; }
Signature · 1 line
1.7.2.1
PATCH 5/14 tipc: Check for disabled bearer when processing incoming messages
In reply to Paul GortmakerFrom: Allan Stephens <[email protected]>
Add a check to tipc_recv_msg() to ensure it discards messages arriving on a newly disabled bearer. This is needed to deal with a race condition that can arise if the bearer is in the midst of being disabled when it receives a message. Performing the check after tipc_net_lock has been taken ensures that TIPC's bearers are in a stable state while the message is being processed.
--- net/tipc/link.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
net/tipc/link.c +14 -0
@@ -1802,6 +1802,15 @@ static int link_recv_buf_validate(struct sk_buff *buf)return pskb_may_pull (buf, hdr_size); } +/** +* tipc_recv_msg - process TIPC messages arriving from off-node +* @head: pointer to message buffer chain +* @tb_ptr: pointer to bearer message arrived on +* +* Invoked with no locks held. Bearer pointer must point to a valid bearer +* structure (i.e. cannot be NULL), but bearer can be inactive. +*/ +void tipc_recv_msg (struct sk_buff *head,struct tipc_bearer *tb_ptr) {read_lock_bh (&tipc_net_lock);
@@ -1819,6 +1828,11 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr) head = head->next; +/* Ensure bearer is still enabled */ + +if (unlikely (!b_ptr->active)) + goto cont; +/* Ensure message is well-formed */ if (unlikely (!link_recv_buf_validate (buf)))
Signature · 1 line
1.7.2.1
PATCH 6/14 tipc: Prevent crash when broadcast link cannot send to all nodes
In reply to Paul GortmakerFrom: Allan Stephens <[email protected]>
Allow TIPC's broadcast link to continue operation when it is unable to send a message to all nodes in the cluster. Previously, the broadcast link attempted to put the broadcast pseudo-bearer into a blocked state; however, this caused a crash because the associated bearer structure is only partially initialized. Further investigation has revealed some conceptual problems with blocking the pseudo-bearer; consequently, this functionality has been disabled for the time being and the undelivered message is eventually resent by the broadcast link's existing message retransmission mechanism (if possible).
--- net/tipc/bcast.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-)
net/tipc/bcast.c +6 -4
@@ -609,11 +609,13 @@ static int tipc_bcbearer_send(struct sk_buff *buf, bcbearer->remains = bcbearer->remains_new; } -/* Unable to reach all targets */ +/* +* Unable to reach all targets (indicate success, since currently +* there isn't code in place to properly block & unblock the +* pseudo-bearer used by the broadcast link) +*/ - bcbearer->bearer.publ.blocked =1 ; - bcl->stats.bearer_congs++; -return 1 ; +return TIPC_OK ; }/**
Signature · 1 line
1.7.2.1
PATCH 7/14 tipc: Fix premature broadcast advertisement by sending node
In reply to Paul GortmakerFrom: Allan Stephens <[email protected]>
Prevent a TIPC node from sending out a LINK_STATE message advertising a broadcast message that it is in the process of sending, but has not yet actually sent. Previously, it was possible for a link timeout to occur in between the time the broadcast link updated its "last message sent" counter and the time the broadcast message was passed to the broadcast bearer for transmission. This ensures that the code which issues the LINK_STATE message isn't informed of the new message until the broadcast bearer has had a chance to send it.
Note: The "last message sent" value is stored in the "fsm_msg_count" field of the link structure used by the broadcast link. Since the broadcast link doesn't utilize the normal link FSM, this field can be re-used rather than adding a new field to the broadcast link.
--- net/tipc/bcast.c | 30 +++++++++++++++++++----------- 1 files changed, 19 insertions(+), 11 deletions(-)
net/tipc/bcast.c +19 -11
@@ -143,6 +143,19 @@ static void bcbuf_decr_acks(struct sk_buff *buf) } +static void bclink_set_last_sent (void ) +{ +if (bcl->next_out) + bcl->fsm_msg_cnt =mod (buf_seqno (bcl->next_out) -1 ); +else + bcl->fsm_msg_cnt =mod (bcl->next_out_no -1 ); +} + +u32 tipc_bclink_get_last_sent (void ) +{ +return bcl->fsm_msg_cnt; +} +/** * bclink_set_gap - set gap according to contents of current deferred pkt queue *
@@ -237,8 +250,10 @@ void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked)/* Try resolving broadcast link congestion, if necessary */ -if (unlikely (bcl->next_out)) +if (unlikely (bcl->next_out)) {tipc_link_push_queue (bcl); +bclink_set_last_sent (); + }if (unlikely (released && !list_empty (&bcl->waiting_ports)))tipc_link_wakeup_ports (bcl,0 );spin_unlock_bh (&bc_lock);
@@ -394,8 +409,10 @@ int tipc_bclink_send_msg(struct sk_buff *buf) res =tipc_link_send_buf (bcl, buf);if (unlikely (res == -ELINKCONG ))buf_discard (buf); -else +else { bcl->stats.sent_info++; +bclink_set_last_sent (); + }if (bcl->out_queue_size > bcl->stats.max_queue_sz) bcl->stats.max_queue_sz = bcl->out_queue_size;
@@ -529,15 +546,6 @@ receive:tipc_node_unlock (node); } -u32 tipc_bclink_get_last_sent (void ) -{ -u32 last_sent =mod (bcl->next_out_no -1 ); - -if (bcl->next_out) - last_sent =mod (buf_seqno (bcl->next_out) -1 ); -return last_sent; -} -u32 tipc_bclink_acks_missing (struct tipc_node *n_ptr) { return (n_ptr->bclink.supported &&
Signature · 1 line
1.7.2.1
PATCH 8/14 tipc: Fix bug in broadcast link transmit statistics computation
In reply to Paul GortmakerFrom: Allan Stephens <[email protected]>
Modify TIPC's broadcast link so that it counts each piece of a fragmented message individually, rather than as treating the group as a single message. This ensures that proper correlation of sent and received traffic can be done when the broadcast link statistics are displayed, and is consistent with the way fragments are counted by TIPC's unicast links.
--- net/tipc/bcast.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
net/tipc/bcast.c +2 -3
@@ -409,10 +409,8 @@ int tipc_bclink_send_msg(struct sk_buff *buf) res =tipc_link_send_buf (bcl, buf);if (unlikely (res == -ELINKCONG ))buf_discard (buf); -else { - bcl->stats.sent_info++; +else bclink_set_last_sent (); - }if (bcl->out_queue_size > bcl->stats.max_queue_sz) bcl->stats.max_queue_sz = bcl->out_queue_size;
@@ -578,6 +576,7 @@ static int tipc_bcbearer_send(struct sk_buff *buf, msg =buf_msg (buf);msg_set_non_seq (msg,1 );msg_set_mc_netid (msg, tipc_net_id); + bcl->stats.sent_info++; }/* Send buffer over bearers until all targets reached */
Signature · 1 line
1.7.2.1
PATCH 9/14 tipc: Remove per-connection sequence number logic
In reply to Paul GortmakerFrom: Allan Stephens <[email protected]>
Remove validation of the per-connection sequence numbers on routable connections, since routable connections are not supported by TIPC.
--- net/tipc/port.c | 15 +++------------ 1 files changed, 3 insertions(+), 12 deletions(-)
net/tipc/port.c +3 -12
@@ -588,19 +588,10 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf)if (!p_ptr) { err =TIPC_ERR_NO_PORT ; }else if (p_ptr->publ.connected) { -if (port_peernode (p_ptr) !=msg_orignode (msg)) +if ((port_peernode (p_ptr) !=msg_orignode (msg)) || + (port_peerport (p_ptr) !=msg_origport (msg))) { err =TIPC_ERR_NO_PORT ; -if (port_peerport (p_ptr) !=msg_origport (msg)) - err =TIPC_ERR_NO_PORT ; -if (!err &&msg_routed (msg)) { -u32 seqno =msg_transp_seqno (msg); -u32 myno = ++p_ptr->last_in_seqno; -if (seqno != myno) { - err =TIPC_ERR_NO_PORT ; - abort_buf =port_build_self_abort_msg (p_ptr, err); - } - } -if (msg_type (msg) ==CONN_ACK ) { + }else if (msg_type (msg) ==CONN_ACK ) {int wakeup =tipc_port_congested (p_ptr) && p_ptr->publ.congested && p_ptr->wakeup;
Signature · 1 line
1.7.2.1
PATCH 10/14 tipc: Optimize tipc_node_has_active_links()
In reply to Paul GortmakerFrom: Allan Stephens <[email protected]>
Eliminate unnecessary checking for null node pointer and redundant check of second active link array entry.
--- net/tipc/node.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
net/tipc/node.c +1 -2
@@ -237,8 +237,7 @@ void tipc_node_link_down(struct tipc_node *n_ptr, struct link *l_ptr)int tipc_node_has_active_links (struct tipc_node *n_ptr) { -return (n_ptr && - ((n_ptr->active_links[0 ]) || (n_ptr->active_links[1 ]))); +return n_ptr->active_links[0 ] !=NULL ; }int tipc_node_has_redundant_links (struct tipc_node *n_ptr)
Signature · 1 line
1.7.2.1
PATCH 11/14 tipc: Eliminate useless linked list initialization
In reply to Paul GortmakerFrom: Allan Stephens <[email protected]>
Eliminate the initialization of the port_list field of a newly created TIPC port, since the port is immediately added to TIPC's global list of ports (which alters the port_list field).
--- net/tipc/port.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
net/tipc/port.c +0 -1
@@ -253,7 +253,6 @@ struct tipc_port *tipc_createport_raw(void *usr_handle,k_init_timer (&p_ptr->timer, (Handler )port_timeout, ref);spin_lock_bh (&tipc_port_list_lock);INIT_LIST_HEAD (&p_ptr->publications); -INIT_LIST_HEAD (&p_ptr->port_list);list_add_tail (&p_ptr->port_list, &ports);spin_unlock_bh (&tipc_port_list_lock);return &(p_ptr->publ);
Signature · 1 line
1.7.2.1
David Miller
maintainerRe: [PATCH net-next 11/14] tipc: Eliminate useless linked list initialization
From: Paul Gortmaker <[email protected]>
Date: Tue, 17 Aug 2010 17:00:13 -0400
Quoted 8 lines
From: Allan Stephens <[email protected]>
Eliminate the initialization of the
port_listfield of a newly created TIPC port, since the port is immediately added to TIPC's global list of ports (which alters theport_listfield).Signed-off-by Allan Stephens <[email protected]>Signed-off-by Paul Gortmaker <[email protected]>
This is not correct.
INIT_LIST_HEAD() is mandatory for all new objects, since it may initialize debugging knobs and whatnot inside of the list_head object when certain debugging options are enabled.
Therefore it may never be elided.
Re: [PATCH net-next 11/14] tipc: Eliminate useless linked list initialization
Quoted 12 lines · David Miller
From: Paul Gortmaker<[email protected]>
Date: Tue, 17 Aug 2010 17:00:13 -0400Quoted 8 lines
From: Allan Stephens<[email protected]>
Eliminate the initialization of the
port_listfield of a newly created TIPC port, since the port is immediately added to TIPC's global list of ports (which alters theport_listfield).Signed-off-by Allan Stephens<[email protected]>Signed-off-by Paul Gortmaker<[email protected]>
Quoted 7 lines
This is not correct.
INIT_LIST_HEAD()is mandatory for all new objects, since it may initialize debugging knobs and whatnot inside of thelist_headobject when certain debugging options are enabled.Therefore it may never be elided.
Thanks, I should have come to the same conclusion when I was looking at that one.
P.
PATCH 12/14 tipc: Minor enhancements to name table display format
In reply to Paul GortmakerFrom: Allan Stephens <[email protected]>
Eliminate printing of dashes after name table column headers (to adhere more closely to the standard format used in tipc-config), and simplify name table display logic using array lookups rather than if-then-else logic.
--- net/tipc/name_table.c | 44 ++++++++++++++++---------------------------- 1 files changed, 16 insertions(+), 28 deletions(-)
net/tipc/name_table.c +16 -28
@@ -877,7 +877,7 @@ static void subseq_list(struct sub_seq *sseq, struct print_buf *buf, u32 depth, u32 index) {char portIdStr[27 ]; -char *scopeStr; +const char *scope_str[] = {"" ," zone" ," cluster" ," node" };struct publication *publ = sseq->zone_list;tipc_printf (buf,"%-10u %-10u " , sseq->lower, sseq->upper);
@@ -893,15 +893,8 @@ static void subseq_list(struct sub_seq *sseq, struct print_buf *buf, u32 depth, tipc_node(publ->node), publ->ref);tipc_printf (buf,"%-26s " , portIdStr);if (depth >3 ) { -if (publ->node != tipc_own_addr) - scopeStr ="" ; -else if (publ->scope ==TIPC_NODE_SCOPE ) - scopeStr ="node" ; -else if (publ->scope ==TIPC_CLUSTER_SCOPE ) - scopeStr ="cluster" ; -else - scopeStr ="zone" ; -tipc_printf (buf,"%-10u %s" , publ->key, scopeStr); +tipc_printf (buf,"%-10u %s" , publ->key, + scope_str[publ->scope]); } publ = publ->zone_list_next;
@@ -951,24 +944,19 @@ static void nameseq_list(struct name_seq *seq, struct print_buf *buf, u32 depth,static void nametbl_header (struct print_buf *buf,u32 depth) { -tipc_printf (buf,"Type " ); - -if (depth >1 ) -tipc_printf (buf,"Lower Upper " ); -if (depth >2 ) -tipc_printf (buf,"Port Identity " ); -if (depth >3 ) -tipc_printf (buf,"Publication" ); - -tipc_printf (buf,"\n-----------" ); - -if (depth >1 ) -tipc_printf (buf,"--------------------- " ); -if (depth >2 ) -tipc_printf (buf,"-------------------------- " ); -if (depth >3 ) -tipc_printf (buf,"------------------" ); - +const char *header[] = { +"Type " , +"Lower Upper " , +"Port Identity " , +"Publication Scope" + }; + +int i; + +if (depth >4 ) + depth =4 ; +for (i =0 ; i < depth; i++) +tipc_printf (buf, header[i]);tipc_printf (buf,"\n" ); }
Signature · 1 line
1.7.2.1
PATCH 13/14 tipc: Allow connect() to wait indefinitely
In reply to Paul GortmakerFrom: Allan Stephens <[email protected]>
Cause a socket whose TIPC_CONN_TIMEOUT option is zero to wait indefinitely for a response to a connection request using connect(). Previously, specifying a timeout of 0 ms resulted in an immediate timeout, which was inconsistent with the behavior specified by Posix for a socket's receive and send timeout.
--- net/tipc/socket.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-)
net/tipc/socket.c +7 -4
@@ -64,6 +64,7 @@ struct tipc_sock {struct sock sk;struct tipc_port *p;struct tipc_portid peer_name; +long conn_timeout; };#define tipc_sk (sk) ((struct tipc_sock *)(sk))
@@ -240,9 +241,9 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol, sock->state = state;sock_init_data (sock, sk); - sk->sk_rcvtimeo =msecs_to_jiffies (CONN_TIMEOUT_DEFAULT ); sk->sk_backlog_rcv = backlog_rcv;tipc_sk (sk)->p = tp_ptr; +tipc_sk (sk)->conn_timeout =msecs_to_jiffies (CONN_TIMEOUT_DEFAULT );spin_unlock_bh (tp_ptr->lock);
@@ -1385,6 +1386,7 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,struct msghdr m = {NULL ,};struct sk_buff *buf;struct tipc_msg *msg; +long timeout;int res;lock_sock (sk);
@@ -1445,11 +1447,12 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,/* Wait until an 'ACK' or 'RST' arrives, or a timeout occurs */ + timeout =tipc_sk (sk)->conn_timeout;release_sock (sk); res =wait_event_interruptible_timeout (*sk_sleep (sk), (!skb_queue_empty (&sk->sk_receive_queue) || (sock->state !=SS_CONNECTING )), - sk->sk_rcvtimeo); + timeout ? timeout :MAX_SCHEDULE_TIMEOUT );lock_sock (sk);if (res >0 ) {
@@ -1712,7 +1715,7 @@ static int setsockopt(struct socket *sock, res =tipc_set_portunreturnable (tport->ref, value);break ;case TIPC_CONN_TIMEOUT : - sk->sk_rcvtimeo =msecs_to_jiffies (value); +tipc_sk (sk)->conn_timeout =msecs_to_jiffies (value);/* no need to set "res", since already 0 at this point */ break ;default :
@@ -1767,7 +1770,7 @@ static int getsockopt(struct socket *sock, res =tipc_portunreturnable (tport->ref, &value);break ;case TIPC_CONN_TIMEOUT : - value =jiffies_to_msecs (sk->sk_rcvtimeo); + value =jiffies_to_msecs (tipc_sk (sk)->conn_timeout);/* no need to set "res", since already 0 at this point */ break ;case TIPC_NODE_RECVQ_DEPTH :
Signature · 1 line
1.7.2.1
PATCH 14/14 tipc: Prevent missing name table entries when link flip-flops rapidly
In reply to Paul GortmakerFrom: Allan Stephens <[email protected]>
Ensure that TIPC does not re-establish communication with a neighboring node until it has finished updating all data structures containing information about that node to reflect the earlier loss of contact. Previously, it was possible for TIPC to perform its purge of name table entries relating to the node once contact had already been re-established, resulting in the unwanted removal of valid name table entries.
--- net/tipc/discover.c | 8 ++++++++ net/tipc/link.c | 11 ++++++++++- net/tipc/node.c | 19 +++++++++++++++++++ net/tipc/node.h | 2 ++ 4 files changed, 39 insertions(+), 1 deletions(-)
net/tipc/discover.c +8 -0
@@ -203,6 +203,14 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct bearer *b_ptr)return ; }spin_lock_bh (&n_ptr->lock); + +/* Don't talk to neighbor during cleanup after last session */ + +if (n_ptr->cleanup_required) { +spin_unlock_bh (&n_ptr->lock); +return ; + } + link = n_ptr->links[b_ptr->identity];if (!link) {dbg ("creating link\n" );
net/tipc/link.c +10 -1
@@ -1869,13 +1869,22 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr) goto cont; } -/* Locate unicast link endpoint that should handle message */ +/* Locate neighboring node that sent message */ n_ptr =tipc_node_find (msg_prevnode (msg));if (unlikely (!n_ptr)) goto cont;tipc_node_lock (n_ptr); +/* Don't talk to neighbor during cleanup after last session */ + +if (n_ptr->cleanup_required) { +tipc_node_unlock (n_ptr); + goto cont; + } + +/* Locate unicast link endpoint that should handle message */ + l_ptr = n_ptr->links[b_ptr->identity];if (unlikely (!l_ptr)) {tipc_node_unlock (n_ptr);
net/tipc/node.c +19 -0
@@ -383,6 +383,20 @@ static void node_established_contact(struct tipc_node *n_ptr) tipc_highest_allowed_slave); } +static void node_cleanup_finished (unsigned long node_addr) +{ +struct tipc_node *n_ptr; + +read_lock_bh (&tipc_net_lock); + n_ptr =tipc_node_find (node_addr); +if (n_ptr) { +tipc_node_lock (n_ptr); + n_ptr->cleanup_required =0 ; +tipc_node_unlock (n_ptr); + } +read_unlock_bh (&tipc_net_lock); +} +static void node_lost_contact (struct tipc_node *n_ptr) {struct cluster *c_ptr;
@@ -457,6 +471,11 @@ static void node_lost_contact(struct tipc_node *n_ptr)tipc_k_signal ((Handler )ns->handle_node_down, (unsigned long )ns->usr_handle); } + +/* Prevent re-contact with node until all cleanup is done */ + + n_ptr->cleanup_required =1 ; +tipc_k_signal ((Handler )node_cleanup_finished, n_ptr->addr); }/**
net/tipc/node.h +2 -0
@@ -52,6 +52,7 @@* @active_links: pointers to active links to node * @links: pointers to all links to node * @working_links: number of working links to node (both active and standby) +* @cleanup_required: non-zero if cleaning up after a prior loss of contact * @link_cnt: number of links to node * @permit_changeover: non-zero if node has redundant links to this system * @routers: bitmap (used for multicluster communication)
@@ -78,6 +79,7 @@ struct tipc_node {struct link *links[MAX_BEARERS ];int link_cnt;int working_links; +int cleanup_required;int permit_changeover;u32 routers[512 /32 ];int last_router;
Signature · 1 line
1.7.2.1
David Miller
maintainerFrom: Paul Gortmaker <[email protected]>
Date: Tue, 17 Aug 2010 17:00:02 -0400
Quoted 9 lines
With net-next reopened, here is another batch of TIPC patches primarily from the out-of-kernel repo. There is no real binding between any of the commits aside from taking what appear to be stand-alone bits and migrating them across and fixing up minor coding style things etc. I believe there will be a chance to get a lot more of this done in this dev window, so hopefully this will be just one batch of several that I end up sending.
Basic runtime sanity test done on v2.6.36-rc1, and all patches git am cleanly on the net-next of today as well.
All applied except patch #11, as explained in my reply to that patch posting.