tipc: multicast and internal users to new send functions
Subsystems (3)
cover tipc: multicast and internal users to new send functions
We move the remaining data transmit users: multicast, name table distributor, and link internal protocols to use the new data transmission framework introduced in a previous commit series ("tipc: new unicast transmission code").
Finally, we remove the code obsoleted by the new functions.
Jon Maloy (7):
tipc: make name table distributor use new send function
tipc: let internal link users call the new link send function
tipc: add new functions for multicast and broadcast distribution
tipc: start using the new multicast functions
tipc: remove unreferenced functions
tipc: rename temporarily named functions
tipc: ensure sequential message delivery across dual bearers
net/tipc/bcast.c | 87 ++++++++------ net/tipc/bcast.h | 5 +- net/tipc/link.c | 307 ++----------------------------------------------- net/tipc/link.h | 9 +- net/tipc/msg.c | 79 +++++++------ net/tipc/msg.h | 9 +- net/tipc/name_distr.c | 76 ++++++------ net/tipc/name_distr.h | 2 +- net/tipc/node.c | 13 +-- net/tipc/port.c | 122 +------------------- net/tipc/port.h | 10 -- net/tipc/socket.c | 148 ++++++++++++++++-------- net/tipc/socket.h | 2 + 13 files changed, 268 insertions(+), 601 deletions(-)
Signature · 1 line
1.7.9.5
PATCH 1/7 tipc: make name table distributor use new send function
In a previous commit series ("tipc: new unicast transmission code") we introduced a new message sending function, tipc_link_xmit2(), and moved the unicast data users over to use that function. We now let the internal name table distributor do the same.
The interaction between the name distributor and the node/link layer also becomes significantly simpler, so we can eliminate the function tipc_link_names_xmit().
--- net/tipc/link.c | 41 -------------------------- net/tipc/link.h | 1 - net/tipc/name_distr.c | 76 ++++++++++++++++++++++++++++--------------------- net/tipc/name_distr.h | 2 +- net/tipc/node.c | 13 ++------- 5 files changed, 48 insertions(+), 85 deletions(-)
net/tipc/link.c +0 -41
@@ -1033,47 +1033,6 @@ static void tipc_link_sync_rcv(struct tipc_node *n, struct sk_buff *buf) }/* -* tipc_link_names_xmit - send name table entries to new neighbor -* -* Send routine for bulk delivery of name table messages when contact -* with a new neighbor occurs. No link congestion checking is performed -* because name table messages *must* be delivered. The messages must be -* small enough not to require fragmentation. -* Called without any locks held. -*/ -void tipc_link_names_xmit (struct list_head *message_list,u32 dest) -{ -struct tipc_node *n_ptr; -struct tipc_link *l_ptr; -struct sk_buff *buf; -struct sk_buff *temp_buf; - -if (list_empty (message_list)) -return ; - - n_ptr =tipc_node_find (dest); -if (n_ptr) { -tipc_node_lock (n_ptr); - l_ptr = n_ptr->active_links[0 ]; -if (l_ptr) { -/* convert circular list to linear list */ - ((struct sk_buff *)message_list->prev)->next =NULL ; -link_add_chain_to_outqueue (l_ptr, - (struct sk_buff *)message_list->next,0 ); -tipc_link_push_queue (l_ptr); -INIT_LIST_HEAD (message_list); - } -tipc_node_unlock (n_ptr); - } - -/* discard the messages if they couldn't be sent */ -list_for_each_safe (buf, temp_buf, ((struct sk_buff *)message_list)) { -list_del ((struct list_head *)buf); -kfree_skb (buf); - } -} - -/* * tipc_link_push_packet: Push one unsent packet to the media */ static u32 tipc_link_push_packet (struct tipc_link *l_ptr)
net/tipc/link.h +0 -1
@@ -228,7 +228,6 @@ void tipc_link_reset(struct tipc_link *l_ptr);void tipc_link_reset_list (unsigned int bearer_id);int tipc_link_xmit (struct sk_buff *buf,u32 dest,u32 selector);int tipc_link_xmit2 (struct sk_buff *buf,u32 dest,u32 selector); -void tipc_link_names_xmit (struct list_head *message_list,u32 dest);int __tipc_link_xmit (struct tipc_link *l_ptr,struct sk_buff *buf);int __tipc_link_xmit2 (struct tipc_link *link,struct sk_buff *buf);int tipc_link_send_buf (struct tipc_link *l_ptr,struct sk_buff *buf);
net/tipc/name_distr.c +44 -32
118 lines not on this page · raw message
net/tipc/name_distr.h +1 -1
@@ -70,7 +70,7 @@ struct distr_item {struct sk_buff *tipc_named_publish (struct publication *publ);struct sk_buff *tipc_named_withdraw (struct publication *publ);void named_cluster_distribute (struct sk_buff *buf); -void tipc_named_node_up (u32 max_item_buf,u32 node); +void tipc_named_node_up (u32 dnode);void tipc_named_rcv (struct sk_buff *buf);void tipc_named_reinit (void );
net/tipc/node.c +3 -10
@@ -474,8 +474,6 @@ int tipc_node_get_linkname(u32 bearer_id, u32 addr, char *linkname, size_t len)void tipc_node_unlock (struct tipc_node *node) {LIST_HEAD (nsub_list); -struct tipc_link *link; -int pkt_sz =0 ;u32 addr =0 ;if (likely (!node->action_flags)) {
@@ -488,18 +486,13 @@ void tipc_node_unlock(struct tipc_node *node) node->action_flags &= ~TIPC_NOTIFY_NODE_DOWN ; }if (node->action_flags &TIPC_NOTIFY_NODE_UP ) { - link = node->active_links[0 ]; node->action_flags &= ~TIPC_NOTIFY_NODE_UP ; -if (link) { - pkt_sz = ((link->max_pkt -INT_H_SIZE ) /ITEM_SIZE ) * -ITEM_SIZE ; - addr = node->addr; - } + addr = node->addr; }spin_unlock_bh (&node->lock);if (!list_empty (&nsub_list))tipc_nodesub_notify (&nsub_list); -if (pkt_sz) -tipc_named_node_up (pkt_sz, addr); +if (addr) +tipc_named_node_up (addr); }
Signature · 1 line
1.7.9.5
PATCH 2/7 tipc: let internal link users call the new link send function
In reply to Jon MaloyWe convert the link internal users (changeover protocol, broadcast synchronization) to use the new packet send function.
--- net/tipc/link.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
net/tipc/link.c +7 -8
@@ -999,7 +999,7 @@ int tipc_link_xmit2(struct sk_buff *buf, u32 dnode, u32 selector)* * Called with node locked */ -static void tipc_link_sync_xmit (struct tipc_link *l) +static void tipc_link_sync_xmit (struct tipc_link *link) {struct sk_buff *buf;struct tipc_msg *msg;
@@ -1009,10 +1009,9 @@ static void tipc_link_sync_xmit(struct tipc_link *l)return ; msg =buf_msg (buf); -tipc_msg_init (msg,BCAST_PROTOCOL ,STATE_MSG ,INT_H_SIZE , l->addr); -msg_set_last_bcast (msg, l->owner->bclink.acked); -link_add_chain_to_outqueue (l, buf,0 ); -tipc_link_push_queue (l); +tipc_msg_init (msg,BCAST_PROTOCOL ,STATE_MSG ,INT_H_SIZE , link->addr); +msg_set_last_bcast (msg, link->owner->bclink.acked); +__tipc_link_xmit2 (link, buf); }/*
@@ -1859,7 +1858,7 @@ static void tipc_link_tunnel_xmit(struct tipc_link *l_ptr, }skb_copy_to_linear_data (buf, tunnel_hdr,INT_H_SIZE );skb_copy_to_linear_data_offset (buf,INT_H_SIZE , msg, length); -__tipc_link_xmit (tunnel, buf); +__tipc_link_xmit2 (tunnel, buf); }
@@ -1892,7 +1891,7 @@ void tipc_link_failover_send_queue(struct tipc_link *l_ptr)if (buf) {skb_copy_to_linear_data (buf, &tunnel_hdr,INT_H_SIZE );msg_set_size (&tunnel_hdr,INT_H_SIZE ); -__tipc_link_xmit (tunnel, buf); +__tipc_link_xmit2 (tunnel, buf); }else {pr_warn ("%sunable to send changeover msg\n" , link_co_err);
@@ -1965,7 +1964,7 @@ void tipc_link_dup_queue_xmit(struct tipc_link *l_ptr,skb_copy_to_linear_data (outbuf, &tunnel_hdr,INT_H_SIZE );skb_copy_to_linear_data_offset (outbuf,INT_H_SIZE , iter->data, length); -__tipc_link_xmit (tunnel, outbuf); +__tipc_link_xmit2 (tunnel, outbuf);if (!tipc_link_is_up (l_ptr))return ; iter = iter->next;
Signature · 9 lines
1.7.9.5 ------------------------------------------------------------------------------ Want fast and easy access to all the code in your enterprise? Index and search up to 200,000 lines of code with a free copy of Black Duck Code Sight - the same software that powers the world's largest code search on Ohloh, the Black Duck Open Hub! Try it now. http://p.sf.net/sfu/bds
PATCH 3/7 tipc: add new functions for multicast and broadcast distribution
In reply to Jon MaloyWe add a new broadcast link transmit function in bclink.c and a new receive function in socket.c. The purpose is to move the branching between external and internal destination down to the link layer, just as we have done with unicast in earlier commits. We also make use of the new link-independent fragmentation support that was introduced in an earlier commit series.
This gives a shorter and simpler code path, and makes it possible to obtain copy-free buffer delivery to all node local destination sockets.
The new transmission code is added in parallel with the existing one, and will be used by the socket multicast send function in the next commit in this series.
--- net/tipc/bcast.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++- net/tipc/bcast.h | 4 +++- net/tipc/msg.c | 38 ++++++++++++++++++++++++++++++++++++ net/tipc/msg.h | 2 ++ net/tipc/socket.c | 40 ++++++++++++++++++++++++++++++++++++++ net/tipc/socket.h | 2 ++ 6 files changed, 139 insertions(+), 2 deletions(-)
net/tipc/bcast.c +54 -1
@@ -1,7 +1,7 @@/* * net/tipc/bcast.c: TIPC broadcast code * -* Copyright (c) 2004-2006, Ericsson AB +* Copyright (c) 2004-2006, 2014, Ericsson AB * Copyright (c) 2004, Intel Corporation. * Copyright (c) 2005, 2010-2011, Wind River Systems * All rights reserved.
@@ -38,6 +38,8 @@#include "core.h" #include "link.h" #include "port.h" +#include "socket.h" +#include "msg.h" #include "bcast.h" #include "name_distr.h"
@@ -138,6 +140,11 @@ static void tipc_bclink_unlock(void)tipc_link_reset_all (node); } +uint tipc_bclink_get_mtu (void ) +{ +return MAX_PKT_DEFAULT_MCAST ; +} +void tipc_bclink_set_flags (unsigned int flags) { bclink->flags |= flags;
@@ -408,6 +415,52 @@ exit:return res; } +/* tipc_bclink_xmit2 - broadcast buffer chain to all nodes in cluster +* and to identified node local sockets +* @buf: chain of buffers containing message +* Consumes the buffer chain, except when returning -ELINKCONG +* Returns 0 if success, otherwise errno: -ELINKCONG,-EHOSTUNREACH,-EMSGSIZE +*/ +int tipc_bclink_xmit2 (struct sk_buff *buf) +{ +int rc =0 ; +int bc =0 ; +struct sk_buff *clbuf; + +/* Prepare clone of message for local node */ + clbuf =tipc_msg_reassemble (buf); +if (unlikely (!clbuf)) { +kfree_skb_list (buf); +return -EHOSTUNREACH ; + } + +/* Broadcast to all other nodes */ +if (likely (bclink)) { +tipc_bclink_lock (); +if (likely (bclink->bcast_nodes.count)) { + rc =__tipc_link_xmit (bcl, buf); +if (likely (!rc)) { +bclink_set_last_sent (); + bcl->stats.queue_sz_counts++; + bcl->stats.accu_queue_sz += bcl->out_queue_size; + } + bc =1 ; + } +tipc_bclink_unlock (); + } + +if (unlikely (!bc)) +kfree_skb_list (buf); + +/* Deliver message clone */ +if (likely (!rc)) +tipc_sk_mcast_rcv (clbuf); +else +kfree_skb (clbuf); + +return rc; +} +/** * bclink_accept_pkt - accept an incoming, in-sequence broadcast packet *
net/tipc/bcast.h +3 -1
@@ -1,7 +1,7 @@/* * net/tipc/bcast.h: Include file for TIPC broadcast code * -* Copyright (c) 2003-2006, Ericsson AB +* Copyright (c) 2003-2006, 2014, Ericsson AB * Copyright (c) 2005, 2010-2011, Wind River Systems * All rights reserved. *
@@ -98,5 +98,7 @@ int tipc_bclink_stats(char *stats_buf, const u32 buf_size);int tipc_bclink_reset_stats (void );int tipc_bclink_set_queue_limits (u32 limit);void tipc_bcbearer_sort (struct tipc_node_map *nm_ptr,u32 node,bool action); +uint tipc_bclink_get_mtu (void ); +int tipc_bclink_xmit2 (struct sk_buff *buf);#endif
net/tipc/msg.c +38 -0
@@ -412,3 +412,41 @@ int tipc_msg_eval(struct sk_buff *buf, u32 *dnode)msg_set_destport (msg, dport);return TIPC_OK ; } + +/* tipc_msg_reassemble() - clone a buffer chain of fragments and +* reassemble the clones into one message +*/ +struct sk_buff *tipc_msg_reassemble (struct sk_buff *chain) +{ +struct sk_buff *buf = chain; +struct sk_buff *frag = buf; +struct sk_buff *head =NULL ; +int hdr_sz; + +/* Copy header if single buffer */ +if (!buf->next) { + hdr_sz =skb_headroom (buf) +msg_hdr_sz (buf_msg (buf)); + head =__pskb_copy (buf, hdr_sz,GFP_ATOMIC ); +if (likely (head)) +return head; +return NULL ; + } + +/* Clone all fragments and reassemble */ +while (buf) { + frag =skb_clone (buf,GFP_ATOMIC ); +if (!frag) + goto error; + frag->next =NULL ; +if (tipc_buf_append (&head, &frag)) +break ; +if (!head) + goto error; + buf = buf->next; + } +return frag; +error: +pr_warn ("Failed do clone local mcast rcv buffer\n" ); +kfree_skb (head); +return NULL ; +}
net/tipc/msg.h +2 -0
@@ -744,4 +744,6 @@ bool tipc_msg_make_bundle(struct sk_buff **buf, u32 mtu, u32 dnode);int tipc_msg_build2 (struct tipc_msg *mhdr,struct iovec const *iov,int offset,int dsz,int mtu ,struct sk_buff **chain); +struct sk_buff *tipc_msg_reassemble (struct sk_buff *chain); +#endif
net/tipc/socket.c +40 -0
@@ -534,6 +534,46 @@ static unsigned int tipc_poll(struct file *file, struct socket *sock,return mask; } +/* tipc_sk_mcast_rcv - Deliver multicast message to all destination sockets +*/ +void tipc_sk_mcast_rcv (struct sk_buff *buf) +{ +struct tipc_msg *msg =buf_msg (buf); +struct tipc_port_list dports = {0 ,NULL , }; +struct tipc_port_list *item; +struct sk_buff *b; +uint i, last, dst =0 ; +u32 scope =TIPC_CLUSTER_SCOPE ; + +if (in_own_node (msg_orignode (msg))) + scope =TIPC_NODE_SCOPE ; + +/* Create destination port list: */ +tipc_nametbl_mc_translate (msg_nametype (msg), +msg_namelower (msg), +msg_nameupper (msg), + scope, + &dports); + last = dports.count; +if (!last) { +kfree_skb (buf); +return ; + } + +for (item = &dports; item; item = item->next) { +for (i =0 ; i <PLSIZE && ++dst <= last; i++) { + b = (dst != last) ?skb_clone (buf,GFP_ATOMIC ) : buf; +if (!b) { +pr_warn ("Failed do clone mcast rcv buffer\n" ); +continue ; + } +msg_set_destport (msg, item->ports[i]); +tipc_sk_rcv (b); + } + } +tipc_port_list_free (&dports); +} +/** * tipc_sk_proto_rcv - receive a connection mng protocol message * @tsk: receiving socket
net/tipc/socket.h +2 -0
@@ -85,4 +85,6 @@ static inline int tipc_sk_conn_cong(struct tipc_sock *tsk)int tipc_sk_rcv (struct sk_buff *buf); +void tipc_sk_mcast_rcv (struct sk_buff *buf); +#endif
Signature · 1 line
1.7.9.5
PATCH 4/7 tipc: start using the new multicast functions
In reply to Jon MaloyIn this commit, we convert the socket multicast send function to directly call the new multicast/broadcast function (tipc_bclink_xmit2()) introduced in the previous commit. We do this instead of letting the call go via the now obsolete tipc_port_mcast_xmit(), hence saving a call level and some code complexity.
We also remove the initial destination lookup at the message sending side, and replace that with an unconditional lookup at the receiving side, including on the sending node itself. This makes the destination lookup and message transfer more uniform than before.
--- net/tipc/bcast.c | 7 ++--- net/tipc/socket.c | 90 +++++++++++++++++++++++++++++++---------------------- 2 files changed, 56 insertions(+), 41 deletions(-)
net/tipc/bcast.c +3 -4
@@ -496,7 +496,7 @@ void tipc_bclink_rcv(struct sk_buff *buf)struct tipc_node *node;u32 next_in;u32 seqno; -int deferred; +int deferred =0 ;/* Screen out unwanted broadcast messages */
@@ -547,7 +547,7 @@ receive:tipc_bclink_unlock ();tipc_node_unlock (node);if (likely (msg_mcast (msg))) -tipc_port_mcast_rcv (buf,NULL ); +tipc_sk_mcast_rcv (buf);else kfree_skb (buf); }else if (msg_user (msg) ==MSG_BUNDLER ) {
@@ -625,8 +625,7 @@ receive: node->bclink.deferred_size += deferred;bclink_update_last_sent (node, seqno); buf =NULL ; - }else - deferred =0 ; + }tipc_bclink_lock ();
net/tipc/socket.c +53 -37
108 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 5/7 tipc: remove unreferenced functions
In reply to Jon MaloyWe can now remove a number of functions which have become obsolete and unreferenced through this commit series. There are no functional changes in this commit.
--- net/tipc/bcast.c | 26 ------ net/tipc/bcast.h | 1 - net/tipc/link.c | 247 ------------------------------------------------------ net/tipc/link.h | 6 -- net/tipc/msg.c | 35 -------- net/tipc/msg.h | 3 - net/tipc/port.c | 112 ------------------------- net/tipc/port.h | 10 --- 8 files changed, 440 deletions(-)
net/tipc/bcast.c +0 -26
@@ -389,32 +389,6 @@ static void bclink_peek_nack(struct tipc_msg *msg)tipc_node_unlock (n_ptr); } -/* -* tipc_bclink_xmit - broadcast a packet to all nodes in cluster -*/ -int tipc_bclink_xmit (struct sk_buff *buf) -{ -int res; - -tipc_bclink_lock (); - -if (!bclink->bcast_nodes.count) { - res =msg_data_sz (buf_msg (buf)); -kfree_skb (buf); - goto exit; - } - - res =__tipc_link_xmit (bcl, buf); -if (likely (res >=0 )) { -bclink_set_last_sent (); - bcl->stats.queue_sz_counts++; - bcl->stats.accu_queue_sz += bcl->out_queue_size; - } -exit: -tipc_bclink_unlock (); -return res; -} -/* tipc_bclink_xmit2 - broadcast buffer chain to all nodes in cluster * and to identified node local sockets * @buf: chain of buffers containing message
net/tipc/bcast.h +0 -1
@@ -89,7 +89,6 @@ void tipc_bclink_add_node(u32 addr);void tipc_bclink_remove_node (u32 addr);struct tipc_node *tipc_bclink_retransmit_to (void );void tipc_bclink_acknowledge (struct tipc_node *n_ptr,u32 acked); -int tipc_bclink_xmit (struct sk_buff *buf);void tipc_bclink_rcv (struct sk_buff *buf);u32 tipc_bclink_get_last_sent (void );u32 tipc_bclink_acks_missing (struct tipc_node *n_ptr);
net/tipc/link.c +0 -247
265 lines not on this page · raw message
net/tipc/link.h +0 -6
@@ -226,15 +226,9 @@ struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area,void tipc_link_reset_all (struct tipc_node *node);void tipc_link_reset (struct tipc_link *l_ptr);void tipc_link_reset_list (unsigned int bearer_id); -int tipc_link_xmit (struct sk_buff *buf,u32 dest,u32 selector);int tipc_link_xmit2 (struct sk_buff *buf,u32 dest,u32 selector); -int __tipc_link_xmit (struct tipc_link *l_ptr,struct sk_buff *buf);int __tipc_link_xmit2 (struct tipc_link *link,struct sk_buff *buf); -int tipc_link_send_buf (struct tipc_link *l_ptr,struct sk_buff *buf);u32 tipc_link_get_max_pkt (u32 dest,u32 selector); -int tipc_link_iovec_xmit_fast (struct tipc_port *sender, -struct iovec const *msg_sect, -unsigned int len,u32 destnode);void tipc_link_bundle_rcv (struct sk_buff *buf);void tipc_link_proto_xmit (struct tipc_link *l_ptr,u32 msg_typ,int prob,u32 gap,u32 tolerance,u32 priority,u32 acked_mtu);
net/tipc/msg.c +0 -35
@@ -60,41 +60,6 @@ void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, u32 hsize,msg_set_destnode (m, destnode); } -/** -* tipc_msg_build - create message using specified header and data -* -* Note: Caller must not hold any locks in case copy_from_user() is interrupted! -* -* Returns message data size or errno -*/ -int tipc_msg_build (struct tipc_msg *hdr,struct iovec const *msg_sect, -unsigned int len,int max_size,struct sk_buff **buf) -{ -int dsz, sz, hsz; -unsigned char *to; - - dsz = len; - hsz =msg_hdr_sz (hdr); - sz = hsz + dsz; -msg_set_size (hdr, sz); -if (unlikely (sz > max_size)) { - *buf =NULL ; -return dsz; - } - - *buf =tipc_buf_acquire (sz); -if (!(*buf)) -return -ENOMEM ; -skb_copy_to_linear_data (*buf, hdr, hsz); - to = (*buf)->data + hsz; -if (len &&memcpy_fromiovecend (to, msg_sect,0 , dsz)) { -kfree_skb (*buf); - *buf =NULL ; -return -EFAULT ; - } -return dsz; -} -/* tipc_buf_append(): Append a buffer to the fragment list of another buffer * Let first buffer become head buffer * Returns 1 and sets *buf to headbuf if chain is complete, otherwise 0
net/tipc/msg.h +0 -3
@@ -732,9 +732,6 @@ int tipc_msg_eval(struct sk_buff *buf, u32 *dnode);void tipc_msg_init (struct tipc_msg *m,u32 user,u32 type,u32 hsize,u32 destnode); -int tipc_msg_build (struct tipc_msg *hdr,struct iovec const *msg_sect, -unsigned int len,int max_size,struct sk_buff **buf); -int tipc_buf_append (struct sk_buff **headbuf,struct sk_buff **buf);bool tipc_msg_bundle (struct sk_buff *bbuf,struct sk_buff *buf,u32 mtu);
net/tipc/port.c +0 -112
118 lines not on this page · raw message
net/tipc/port.h +0 -10
@@ -120,17 +120,7 @@ int __tipc_port_connect(u32 ref, struct tipc_port *p_ptr, struct tipc_portid const *peer);int tipc_port_peer_msg (struct tipc_port *p_ptr,struct tipc_msg *msg); -/* -* TIPC messaging routines -*/ - -int tipc_port_mcast_xmit (struct tipc_port *port, -struct tipc_name_seq const *seq, -struct iovec const *msg, -unsigned int len); -struct sk_buff *tipc_port_get_ports (void ); -void tipc_port_mcast_rcv (struct sk_buff *buf,struct tipc_port_list *dp);void tipc_port_reinit (void );/**
Signature · 1 line
1.7.9.5
PATCH 6/7 tipc: rename temporarily named functions
In reply to Jon MaloyAfter the previous commit, we can now give the functions with temporary names, such as tipc_link_xmit2(), tipc_msg_build2() etc., their proper names.
There are no functional changes in this commit.
--- net/tipc/bcast.c | 6 +++--- net/tipc/bcast.h | 2 +- net/tipc/link.c | 18 +++++++++--------- net/tipc/link.h | 4 ++-- net/tipc/msg.c | 6 +++--- net/tipc/msg.h | 4 ++-- net/tipc/name_distr.c | 4 ++-- net/tipc/port.c | 10 +++++----- net/tipc/socket.c | 20 ++++++++++---------- 9 files changed, 37 insertions(+), 37 deletions(-)
net/tipc/bcast.c +3 -3
@@ -389,13 +389,13 @@ static void bclink_peek_nack(struct tipc_msg *msg)tipc_node_unlock (n_ptr); } -/* tipc_bclink_xmit2 - broadcast buffer chain to all nodes in cluster -* and to identified node local sockets +/* tipc_bclink_xmit - broadcast buffer chain to all nodes in cluster +* and to identified node local sockets * @buf: chain of buffers containing message * Consumes the buffer chain, except when returning -ELINKCONG * Returns 0 if success, otherwise errno: -ELINKCONG,-EHOSTUNREACH,-EMSGSIZE */ -int tipc_bclink_xmit2 (struct sk_buff *buf) +int tipc_bclink_xmit (struct sk_buff *buf) {int rc =0 ;int bc =0 ;
net/tipc/bcast.h +1 -1
@@ -98,6 +98,6 @@ int tipc_bclink_reset_stats(void);int tipc_bclink_set_queue_limits (u32 limit);void tipc_bcbearer_sort (struct tipc_node_map *nm_ptr,u32 node,bool action);uint tipc_bclink_get_mtu (void ); -int tipc_bclink_xmit2 (struct sk_buff *buf); +int tipc_bclink_xmit (struct sk_buff *buf);#endif
net/tipc/link.c +9 -9
@@ -706,7 +706,7 @@ static int tipc_link_cong(struct tipc_link *link, struct sk_buff *buf) }/** -* __tipc_link_xmit2(): same as tipc_link_xmit2, but destlink is known & locked +* __tipc_link_xmit(): same as tipc_link_xmit, but destlink is known & locked * @link: link to use * @buf: chain of buffers containing message * Consumes the buffer chain, except when returning -ELINKCONG
@@ -715,7 +715,7 @@ static int tipc_link_cong(struct tipc_link *link, struct sk_buff *buf)* Only the socket functions tipc_send_stream() and tipc_send_packet() need * to act on the return value, since they may need to do more send attempts. */ -int __tipc_link_xmit2 (struct tipc_link *link,struct sk_buff *buf) +int __tipc_link_xmit (struct tipc_link *link,struct sk_buff *buf) {struct tipc_msg *msg =buf_msg (buf);uint psz =msg_size (msg);
@@ -783,7 +783,7 @@ int __tipc_link_xmit2(struct tipc_link *link, struct sk_buff *buf) }/** -* tipc_link_xmit2() is the general link level function for message sending +* tipc_link_xmit() is the general link level function for message sending * @buf: chain of buffers containing message * @dsz: amount of user data to be sent * @dnode: address of destination node
@@ -791,7 +791,7 @@ int __tipc_link_xmit2(struct tipc_link *link, struct sk_buff *buf)* Consumes the buffer chain, except when returning -ELINKCONG * Returns 0 if success, otherwise errno: -ELINKCONG,-EHOSTUNREACH,-EMSGSIZE */ -int tipc_link_xmit2 (struct sk_buff *buf,u32 dnode,u32 selector) +int tipc_link_xmit (struct sk_buff *buf,u32 dnode,u32 selector) {struct tipc_link *link =NULL ;struct tipc_node *node;
@@ -802,7 +802,7 @@ int tipc_link_xmit2(struct sk_buff *buf, u32 dnode, u32 selector)tipc_node_lock (node); link = node->active_links[selector &1 ];if (link) - rc =__tipc_link_xmit2 (link, buf); + rc =__tipc_link_xmit (link, buf);tipc_node_unlock (node); }
@@ -836,7 +836,7 @@ static void tipc_link_sync_xmit(struct tipc_link *link) msg =buf_msg (buf);tipc_msg_init (msg,BCAST_PROTOCOL ,STATE_MSG ,INT_H_SIZE , link->addr);msg_set_last_bcast (msg, link->owner->bclink.acked); -__tipc_link_xmit2 (link, buf); +__tipc_link_xmit (link, buf); }/*
@@ -1683,7 +1683,7 @@ static void tipc_link_tunnel_xmit(struct tipc_link *l_ptr, }skb_copy_to_linear_data (buf, tunnel_hdr,INT_H_SIZE );skb_copy_to_linear_data_offset (buf,INT_H_SIZE , msg, length); -__tipc_link_xmit2 (tunnel, buf); +__tipc_link_xmit (tunnel, buf); }
@@ -1716,7 +1716,7 @@ void tipc_link_failover_send_queue(struct tipc_link *l_ptr)if (buf) {skb_copy_to_linear_data (buf, &tunnel_hdr,INT_H_SIZE );msg_set_size (&tunnel_hdr,INT_H_SIZE ); -__tipc_link_xmit2 (tunnel, buf); +__tipc_link_xmit (tunnel, buf); }else {pr_warn ("%sunable to send changeover msg\n" , link_co_err);
@@ -1789,7 +1789,7 @@ void tipc_link_dup_queue_xmit(struct tipc_link *l_ptr,skb_copy_to_linear_data (outbuf, &tunnel_hdr,INT_H_SIZE );skb_copy_to_linear_data_offset (outbuf,INT_H_SIZE , iter->data, length); -__tipc_link_xmit2 (tunnel, outbuf); +__tipc_link_xmit (tunnel, outbuf);if (!tipc_link_is_up (l_ptr))return ; iter = iter->next;
net/tipc/link.h +2 -2
@@ -226,8 +226,8 @@ struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area,void tipc_link_reset_all (struct tipc_node *node);void tipc_link_reset (struct tipc_link *l_ptr);void tipc_link_reset_list (unsigned int bearer_id); -int tipc_link_xmit2 (struct sk_buff *buf,u32 dest,u32 selector); -int __tipc_link_xmit2 (struct tipc_link *link,struct sk_buff *buf); +int tipc_link_xmit (struct sk_buff *buf,u32 dest,u32 selector); +int __tipc_link_xmit (struct tipc_link *link,struct sk_buff *buf);u32 tipc_link_get_max_pkt (u32 dest,u32 selector);void tipc_link_bundle_rcv (struct sk_buff *buf); void tipc_link_proto_xmit(struct tipc_link *l_ptr, u32 msg_typ, int prob,
net/tipc/msg.c +3 -3
@@ -115,7 +115,7 @@ out_free:/** -* tipc_msg_build2 - create buffer chain containing specified header and data +* tipc_msg_build - create buffer chain containing specified header and data * @mhdr: Message header, to be prepended to data * @iov: User data * @offset: Posision in iov to start copying from
@@ -124,8 +124,8 @@ out_free:* @chain: Buffer or chain of buffers to be returned to caller * Returns message data size or errno: -ENOMEM, -EFAULT */ -int tipc_msg_build2 (struct tipc_msg *mhdr,struct iovec const *iov, -int offset,int dsz,int pktmax ,struct sk_buff **chain) +int tipc_msg_build (struct tipc_msg *mhdr,struct iovec const *iov, +int offset,int dsz,int pktmax ,struct sk_buff **chain) {int mhsz =msg_hdr_sz (mhdr);int msz = mhsz + dsz;
net/tipc/msg.h +2 -2
@@ -738,8 +738,8 @@ bool tipc_msg_bundle(struct sk_buff *bbuf, struct sk_buff *buf, u32 mtu);bool tipc_msg_make_bundle (struct sk_buff **buf,u32 mtu,u32 dnode); -int tipc_msg_build2 (struct tipc_msg *mhdr,struct iovec const *iov, -int offset,int dsz,int mtu ,struct sk_buff **chain); +int tipc_msg_build (struct tipc_msg *mhdr,struct iovec const *iov, +int offset,int dsz,int mtu ,struct sk_buff **chain);struct sk_buff *tipc_msg_reassemble (struct sk_buff *chain);
net/tipc/name_distr.c +2 -2
@@ -116,7 +116,7 @@ void named_cluster_distribute(struct sk_buff *buf)if (!obuf)break ;msg_set_destnode (buf_msg (obuf), dnode); -tipc_link_xmit2 (obuf, dnode, dnode); +tipc_link_xmit (obuf, dnode, dnode); }rcu_read_unlock ();
@@ -232,7 +232,7 @@ void tipc_named_node_up(u32 dnode)/* Convert circular list to linear list and send: */ buf_chain = (struct sk_buff *)msg_list.next; ((struct sk_buff *)msg_list.prev)->next =NULL ; -tipc_link_xmit2 (buf_chain, dnode, dnode); +tipc_link_xmit (buf_chain, dnode, dnode); }/**
net/tipc/port.c +5 -5
@@ -130,7 +130,7 @@ void tipc_port_destroy(struct tipc_port *p_ptr)tipc_nodesub_unsubscribe (&p_ptr->subscription); msg =buf_msg (buf); peer =msg_destnode (msg); -tipc_link_xmit2 (buf, peer,msg_link_selector (msg)); +tipc_link_xmit (buf, peer,msg_link_selector (msg)); }spin_lock_bh (&tipc_port_list_lock);list_del (&p_ptr->port_list);
@@ -187,7 +187,7 @@ static void port_timeout(unsigned long ref) }tipc_port_unlock (p_ptr); msg =buf_msg (buf); -tipc_link_xmit2 (buf,msg_destnode (msg),msg_link_selector (msg)); +tipc_link_xmit (buf,msg_destnode (msg),msg_link_selector (msg)); }
@@ -202,7 +202,7 @@ static void port_handle_node_down(unsigned long ref) buf =port_build_self_abort_msg (p_ptr,TIPC_ERR_NO_NODE );tipc_port_unlock (p_ptr); msg =buf_msg (buf); -tipc_link_xmit2 (buf,msg_destnode (msg),msg_link_selector (msg)); +tipc_link_xmit (buf,msg_destnode (msg),msg_link_selector (msg)); }
@@ -347,7 +347,7 @@ void tipc_acknowledge(u32 ref, u32 ack)if (!buf)return ; msg =buf_msg (buf); -tipc_link_xmit2 (buf,msg_destnode (msg),msg_link_selector (msg)); +tipc_link_xmit (buf,msg_destnode (msg),msg_link_selector (msg)); } int tipc_publish(struct tipc_port *p_ptr, unsigned int scope,
@@ -509,6 +509,6 @@ int tipc_port_shutdown(u32 ref) buf =port_build_peer_abort_msg (p_ptr,TIPC_CONN_SHUTDOWN );tipc_port_unlock (p_ptr); msg =buf_msg (buf); -tipc_link_xmit2 (buf,msg_destnode (msg),msg_link_selector (msg)); +tipc_link_xmit (buf,msg_destnode (msg),msg_link_selector (msg));return tipc_port_disconnect (ref); }
net/tipc/socket.c +10 -10
@@ -131,7 +131,7 @@ static void reject_rx_queue(struct sock *sk)while ((buf =__skb_dequeue (&sk->sk_receive_queue))) {if (tipc_msg_reverse (buf, &dnode,TIPC_ERR_NO_PORT )) -tipc_link_xmit2 (buf, dnode,0 ); +tipc_link_xmit (buf, dnode,0 ); } }
@@ -341,7 +341,7 @@ static int tipc_release(struct socket *sock)tipc_port_disconnect (port->ref); }if (tipc_msg_reverse (buf, &dnode,TIPC_ERR_NO_PORT )) -tipc_link_xmit2 (buf, dnode,0 ); +tipc_link_xmit (buf, dnode,0 ); } }
@@ -566,7 +566,7 @@ static int tipc_sendmcast(struct socket *sock, struct tipc_name_seq *seq, new_mtu: mtu =tipc_bclink_get_mtu (); - rc =tipc_msg_build2 (mhdr, iov,0 , dsz, mtu, &buf); + rc =tipc_msg_build (mhdr, iov,0 , dsz, mtu, &buf);if (unlikely (rc <0 ))return rc;
@@ -821,12 +821,12 @@ static int tipc_sendmsg(struct kiocb *iocb, struct socket *sock, new_mtu: mtu =tipc_node_get_mtu (dnode, tsk->port.ref); - rc =tipc_msg_build2 (mhdr, iov,0 , dsz, mtu, &buf); + rc =tipc_msg_build (mhdr, iov,0 , dsz, mtu, &buf);if (rc <0 ) goto exit; do { - rc = tipc_link_xmit2(buf, dnode, tsk->port.ref); + rc = tipc_link_xmit(buf, dnode, tsk->port.ref); if (likely(rc >= 0)) { if (sock->state != SS_READY) sock->state = SS_CONNECTING;
@@ -934,12 +934,12 @@ static int tipc_send_stream(struct kiocb *iocb, struct socket *sock, next: mtu = port->max_pkt; send =min_t (uint, dsz - sent,TIPC_MAX_USER_MSG_SIZE ); - rc =tipc_msg_build2 (mhdr, m->msg_iov, sent, send, mtu, &buf); + rc =tipc_msg_build (mhdr, m->msg_iov, sent, send, mtu, &buf);if (unlikely (rc <0 )) goto exit; do { if (likely(!tipc_sk_conn_cong(tsk))) { - rc = tipc_link_xmit2(buf, dnode, ref); + rc = tipc_link_xmit(buf, dnode, ref); if (likely(!rc)) { tsk->sent_unacked++; sent += send;
@@ -1571,7 +1571,7 @@ static int tipc_backlog_rcv(struct sock *sk, struct sk_buff *buf)if ((rc <0 ) && !tipc_msg_reverse (buf, &onode, -rc))return 0 ; -tipc_link_xmit2 (buf, onode,0 ); +tipc_link_xmit (buf, onode,0 );return 0 ; }
@@ -1623,7 +1623,7 @@ exit:if ((rc <0 ) && !tipc_msg_reverse (buf, &dnode, -rc))return -EHOSTUNREACH ; -tipc_link_xmit2 (buf, dnode,0 ); +tipc_link_xmit (buf, dnode,0 );return (rc <0 ) ? -EHOSTUNREACH :0 ; }
@@ -1910,7 +1910,7 @@ restart: }tipc_port_disconnect (port->ref);if (tipc_msg_reverse (buf, &peer,TIPC_CONN_SHUTDOWN )) -tipc_link_xmit2 (buf, peer,0 ); +tipc_link_xmit (buf, peer,0 ); }else {tipc_port_shutdown (port->ref); }
Signature · 1 line
1.7.9.5
PATCH 7/7 tipc: ensure sequential message delivery across dual bearers
In reply to Jon MaloyWhen we run broadcast packets over dual bearers/interfaces, the current transmission code is flipping bearers between each sent packet, with the purpose of leveraging the double bandwidth available. The receiving bclink is resequencing the packets if needed, so all messages are delivered upwards from the broadcast link in the correct order, even if they may arrive in concurrent interrupts.
However, at the moment of delivery upwards to the socket, we release all spinlocks (bclink_lock, node_lock), so it is still possible that arriving messages bypass each other before they reach the socket queue.
We fix this by applying the same technique we are using for unicast traffic. We use a link selector (i.e., the last bit of sending port number) to ensure that messages from the same sender socket always are sent over the same bearer. This guarantees sequential delivery between socket pairs, which is sufficient to satisfy the protocol spec, as well as all known user requirements.
--- net/tipc/bcast.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)
net/tipc/bcast.c +5 -12
@@ -636,6 +636,7 @@ static int tipc_bcbearer_send(struct sk_buff *buf, struct tipc_bearer *unused1, struct tipc_media_addr *unused2) {int bp_index; +struct tipc_msg *msg =buf_msg (buf);/* Prepare broadcast link message for reliable transmission, * if first time trying to send it;
@@ -643,10 +644,7 @@ static int tipc_bcbearer_send(struct sk_buff *buf, struct tipc_bearer *unused1,* since they are sent in an unreliable manner and don't need it */ if (likely (!msg_non_seq (buf_msg (buf)))) { -struct tipc_msg *msg; -bcbuf_set_acks (buf, bclink->bcast_nodes.count); - msg =buf_msg (buf);msg_set_non_seq (msg,1 );msg_set_mc_netid (msg, tipc_net_id); bcl->stats.sent_info++;
@@ -663,12 +661,14 @@ static int tipc_bcbearer_send(struct sk_buff *buf, struct tipc_bearer *unused1,for (bp_index =0 ; bp_index <MAX_BEARERS ; bp_index++) {struct tipc_bearer *p = bcbearer->bpairs[bp_index].primary;struct tipc_bearer *s = bcbearer->bpairs[bp_index].secondary; -struct tipc_bearer *b = p; +struct tipc_bearer *bp[2 ] = {p, s}; +struct tipc_bearer *b = bp[msg_link_selector (msg)];struct sk_buff *tbuf;if (!p)break ;/* No more bearers to try */ - +if (!b) + b = p;tipc_nmap_diff (&bcbearer->remains, &b->nodes, &bcbearer->remains_new);if (bcbearer->remains_new.count == bcbearer->remains.count)
@@ -685,13 +685,6 @@ static int tipc_bcbearer_send(struct sk_buff *buf, struct tipc_bearer *unused1,tipc_bearer_send (b->identity, tbuf, &b->bcast_addr);kfree_skb (tbuf);/* Bearer keeps a clone */ } - -/* Swap bearers for next packet */ -if (s) { - bcbearer->bpairs[bp_index].primary = s; - bcbearer->bpairs[bp_index].secondary = p; - } -if (bcbearer->remains_new.count ==0 )break ;/* All targets reached */
Signature · 9 lines
1.7.9.5 ------------------------------------------------------------------------------ Want fast and easy access to all the code in your enterprise? Index and search up to 200,000 lines of code with a free copy of Black Duck Code Sight - the same software that powers the world's largest code search on Ohloh, the Black Duck Open Hub! Try it now. http://p.sf.net/sfu/bds