tipc: Introduce Communcation Group feature
Subsystems (3)
v2 cover tipc: Introduce Communcation Group feature
With this commit series we introduce a 'Group Communication' feature in order to resolve the datagram and multicast flow control problem. This new feature makes it possible for a user to instantiate multiple private virtual brokerless message buses by just creating and joining member sockets.
The main features are as follows:
---------------------------------
- Sockets can join a group via a new setsockopt() call TIPC_GROUP_JOIN. If it is the first socket of the group this implies creation of the group. This call takes four parameters: 'type' serves as group identifier, 'instance' serves as member identifier, and 'scope' indicates the visibility of the group (node/cluster/zone). Finally, 'flags' indicates different options for the socket joining the group. For the time being, there are only two such flags: 1) 'LOOPBACK' indicates if the creator of the socket wants to receive a copy of broadcast or multicast messages it sends to the group, 2) EVENTS indicates if it wants to receive membership (JOINED/LEFT) events for the other members of the group.
- Groups are closed, i.e., sockets which have not joined a group will not be able to send messages to or receive messages from members of the group, and vice versa. A socket can only be member of one group at a time.
- There are four transmission modes.
1: Unicast. The sender transmits a message using the port identity
(node:port tuple) of the receiving socket.
2: Anycast. The sender transmits a message using a port name (type:
instance:scope) of one of the receiving sockets. If more than one member socket matches the given address a destination is selected according to a round-robin algorithm, but also considering the destination load (advertised window size) as an additional criteria.
3: Multicast. The sender transmits a message using a port name
(type:instance:scope) of one or more of the receiving sockets. All sockets in the group matching the given address will receive a copy of the message.
4: Broadcast. The sender transmits a message using the primtive
send(). All members of the group, irrespective of their member identity (instance) number receive a copy of the message.
- TIPC broadcast is used for carrying messages in mode 3 or 4 when this is deemed more efficient, i.e., depending on number of actual destinations.
- All transmission modes are flow controlled, so that messages never are dropped or rejected, just like we are used to from connection oriented communication. A special algorithm guarantees that this is true even for multipoint-to-point communication, i.e., at occasions where many source sockets may decide to send simultaneously towards the same destination socket.
- Sequence order is always guaranteed, even between the different transmission modes.
- Member join/leave events are received in all other member sockets in guaranteed order. I.e., a 'JOINED' (an empty message with the OOB bit set) will always be received before the first data message from a new member, and a 'LEAVE' (like 'JOINED', but with EOR bit set) will always arrive after the last data message from a leaving member.
-----
v2: Reordered variable declarations in descending length order, as per
feedback from David Miller. This was done as far as permitted by the the initialization order.
Jon Maloy (18):
tipc: add ability to order and receive topology events in driver
tipc: improve address sanity check in tipc_connect()
tipc: add ability to obtain node availability status from other files
tipc: refactor function filter_rcv()
tipc: add new function for sending multiple small messages
tipc: improve destination linked list
tipc: introduce communication groups
tipc: add second source address to recvmsg()/recvfrom()
tipc: receive group membership events via member socket
tipc: introduce flow control for group broadcast messages
tipc: introduce group unicast messaging
tipc: introduce group anycast messaging
tipc: introduce group multicast messaging
tipc: guarantee group unicast doesn't bypass group broadcast
tipc: guarantee that group broadcast doesn't bypass group unicast
tipc: guarantee delivery of UP event before first broadcast
tipc: guarantee delivery of last broadcast before DOWN event
tipc: add multipoint-to-point flow control
include/uapi/linux/tipc.h | 15 + net/tipc/Makefile | 2 +- net/tipc/bcast.c | 18 +- net/tipc/core.h | 5 + net/tipc/group.c | 871 ++++++++++++++++++++++++++++++++++++++++++++++ net/tipc/group.h | 73 ++++ net/tipc/link.c | 9 +- net/tipc/msg.c | 7 + net/tipc/msg.h | 118 ++++++- net/tipc/name_table.c | 174 ++++++--- net/tipc/name_table.h | 28 +- net/tipc/node.c | 42 ++- net/tipc/node.h | 5 +- net/tipc/server.c | 121 +++++-- net/tipc/server.h | 5 +- net/tipc/socket.c | 787 ++++++++++++++++++++++++++++++++--------- 16 files changed, 1997 insertions(+), 283 deletions(-) create mode 100644 net/tipc/group.c create mode 100644 net/tipc/group.h
Signature · 1 line
2.1.4
PATCH v2 1/18 tipc: add ability to order and receive topology events in driver
As preparation for introducing communication groups, we add the ability to issue topology subscriptions and receive topology events from kernel space. This will make it possible for group member sockets to keep track of other group members.
--- net/tipc/core.h | 5 +++ net/tipc/msg.h | 1 + net/tipc/server.c | 121 ++++++++++++++++++++++++++++++++++++++++++------------ net/tipc/server.h | 5 ++- net/tipc/socket.c | 32 +++++++++------ 5 files changed, 124 insertions(+), 40 deletions(-)
net/tipc/core.h +5 -0
@@ -132,6 +132,11 @@ static inline struct list_head *tipc_nodes(struct net *net)return &tipc_net (net)->node_list; } +static inline struct tipc_server *tipc_topsrv (struct net *net) +{ +return tipc_net (net)->topsrv; +} +static inline unsigned int tipc_hashfn (u32 addr) {return addr & (NODE_HTABLE_SIZE -1 );
net/tipc/msg.h +1 -0
@@ -78,6 +78,7 @@ struct plist;#define MSG_FRAGMENTER 12#define LINK_CONFIG 13#define SOCK_WAKEUP 14/* pseudo user */ +#define TOP_SRV 15/* pseudo user */ /* * Message header sizes
net/tipc/server.c +94 -27
166 lines not on this page · raw message
net/tipc/server.h +4 -1
@@ -83,13 +83,16 @@ struct tipc_server {int tipc_conn_sendmsg (struct tipc_server *s,int conid,struct sockaddr_tipc *addr,void *data,size_t len); +bool tipc_topsrv_kern_subscr (struct net *net,u32 port,u32 type, +u32 lower,u32 upper,int *conid); +void tipc_topsrv_kern_unsubscr (struct net *net,int conid); +/** * tipc_conn_terminate - terminate connection with server * * Note: Must call it in process context since it might sleep */ void tipc_conn_terminate (struct tipc_server *s,int conid); -int tipc_server_start (struct tipc_server *s);void tipc_server_stop (struct tipc_server *s);
net/tipc/socket.c +20 -12
@@ -896,6 +896,10 @@ static void tipc_sk_proto_rcv(struct tipc_sock *tsk, struct sk_buff *skb,kfree_skb (skb); } +static void tipc_sk_top_evt (struct tipc_sock *tsk,struct tipc_event *evt) +{ +} +/** * tipc_sendmsg - send message in connectionless manner * @sock: socket structure
@@ -1671,20 +1675,24 @@ static bool filter_rcv(struct sock *sk, struct sk_buff *skb,struct tipc_msg *hdr =buf_msg (skb);unsigned int limit =rcvbuf_limit (sk, skb);int err =TIPC_OK ; -int usr =msg_user (hdr); -u32 onode; - -if (unlikely (msg_user (hdr) ==CONN_MANAGER )) { -tipc_sk_proto_rcv (tsk, skb, xmitq); -return false; - } -if (unlikely (usr ==SOCK_WAKEUP )) { - onode =msg_orignode (hdr); +if (unlikely (!msg_isdata (hdr))) { +switch (msg_user (hdr)) { +case CONN_MANAGER : +tipc_sk_proto_rcv (tsk, skb, xmitq); +return false; +case SOCK_WAKEUP : +u32_del (&tsk->cong_links,msg_orignode (hdr)); + tsk->cong_link_cnt--; + sk->sk_write_space (sk); +break ; +case TOP_SRV : +tipc_sk_top_evt (tsk, (void *)msg_data (hdr)); +break ; +default : +break ; + }kfree_skb (skb); -u32_del (&tsk->cong_links, onode); - tsk->cong_link_cnt--; - sk->sk_write_space (sk);return false; }
Signature · 1 line
2.1.4
PATCH v2 4/18 tipc: refactor function filter_rcv()
In reply to Jon MaloyIn the following commits we will need to handle multiple incoming and rejected/returned buffers in the function socket.c::filter_rcv(). As a preparation for this, we generalize the function by handling buffer queues instead of individual buffers. We also introduce a help function tipc_skb_reject(), and rename filter_rcv() to tipc_sk_filter_rcv() in line with other functions in socket.c.
--- net/tipc/msg.c | 7 +++ net/tipc/msg.h | 2 + net/tipc/socket.c | 161 +++++++++++++++++++++++++++--------------------------- 3 files changed, 89 insertions(+), 81 deletions(-)
net/tipc/msg.c +7 -0
@@ -666,3 +666,10 @@ void __tipc_skb_queue_sorted(struct sk_buff_head *list, u16 seqno, }kfree_skb (skb); } + +void tipc_skb_reject (struct net *net,int err,struct sk_buff *skb, +struct sk_buff_head *xmitq) +{ +if (tipc_msg_reverse (tipc_own_addr (net), &skb, err)) +__skb_queue_tail (xmitq, skb); +}
net/tipc/msg.h +2 -0
@@ -819,6 +819,8 @@ static inline bool msg_is_reset(struct tipc_msg *hdr)struct sk_buff *tipc_buf_acquire (u32 size,gfp_t gfp);bool tipc_msg_validate (struct sk_buff *skb);bool tipc_msg_reverse (u32 own_addr,struct sk_buff **skb,int err); +void tipc_skb_reject (struct net *net,int err,struct sk_buff *skb, +struct sk_buff_head *xmitq);void tipc_msg_init (u32 own_addr,struct tipc_msg *m,u32 user,u32 type,u32 hsize,u32 destnode); struct sk_buff *tipc_msg_create(uint user, uint type, uint hdr_sz,
net/tipc/socket.c +80 -81
240 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 6/18 tipc: improve destination linked list
In reply to Jon MaloyWe often see a need for a linked list of destination identities, sometimes containing a port number, sometimes a node identity, and sometimes both. The currently defined struct u32_list is not generic enough to cover all cases, so we extend it to contain two u32 integers and rename it to struct tipc_dest_list.
--- net/tipc/bcast.c | 18 +++++------ net/tipc/name_table.c | 89 ++++++++++++++++++++++++++------------------------- net/tipc/name_table.h | 22 ++++++++----- net/tipc/socket.c | 12 +++---- 4 files changed, 74 insertions(+), 67 deletions(-)
net/tipc/bcast.c +9 -9
@@ -258,20 +258,20 @@ static int tipc_bcast_xmit(struct net *net, struct sk_buff_head *pkts,static int tipc_rcast_xmit (struct net *net,struct sk_buff_head *pkts,struct tipc_nlist *dests,u16 *cong_link_cnt) { +struct tipc_dest *dst, *tmp;struct sk_buff_head _pkts; -struct u32_item *n, *tmp; -u32 dst, selector; +u32 dnode, selector; selector =msg_link_selector (buf_msg (skb_peek (pkts)));skb_queue_head_init (&_pkts); -list_for_each_entry_safe (n, tmp, &dests->list, list) { - dst = n->value; -if (!tipc_msg_pskb_copy (dst, pkts, &_pkts)) +list_for_each_entry_safe (dst, tmp, &dests->list, list) { + dnode = dst->node; +if (!tipc_msg_pskb_copy (dnode, pkts, &_pkts))return -ENOMEM ;/* Any other return value than -ELINKCONG is ignored */ -if (tipc_node_xmit (net, &_pkts, dst, selector) == -ELINKCONG ) +if (tipc_node_xmit (net, &_pkts, dnode, selector) == -ELINKCONG ) (*cong_link_cnt)++; }return 0 ;
@@ -554,7 +554,7 @@ void tipc_nlist_add(struct tipc_nlist *nl, u32 node) {if (node == nl->self) nl->local = true; -else if (u32_push (&nl->list, node)) +else if (tipc_dest_push (&nl->list, node,0 )) nl->remote++; }
@@ -562,13 +562,13 @@ void tipc_nlist_del(struct tipc_nlist *nl, u32 node) {if (node == nl->self) nl->local = false; -else if (u32_del (&nl->list, node)) +else if (tipc_dest_del (&nl->list, node,0 )) nl->remote--; }void tipc_nlist_purge (struct tipc_nlist *nl) { -u32_list_purge (&nl->list); +tipc_dest_list_purge (&nl->list); nl->remote =0 ; nl->local =0 ; }
net/tipc/name_table.c +45 -44
130 lines not on this page · raw message
net/tipc/name_table.h +14 -8
@@ -120,16 +120,22 @@ void tipc_nametbl_unsubscribe(struct tipc_subscription *s);int tipc_nametbl_init (struct net *net);void tipc_nametbl_stop (struct net *net); -struct u32_item { +struct tipc_dest {struct list_head list; -u32 value; +union { +struct { +u32 port; +u32 node; + }; +u64 value; + }; }; -bool u32_push (struct list_head *l,u32 value); -u32 u32_pop (struct list_head *l); -bool u32_find (struct list_head *l,u32 value); -bool u32_del (struct list_head *l,u32 value); -void u32_list_purge (struct list_head *l); -int u32_list_len (struct list_head *l); +struct tipc_dest *tipc_dest_find (struct list_head *l,u32 node,u32 port); +bool tipc_dest_push (struct list_head *l,u32 node,u32 port); +bool tipc_dest_pop (struct list_head *l,u32 *node,u32 *port); +bool tipc_dest_del (struct list_head *l,u32 node,u32 port); +void tipc_dest_list_purge (struct list_head *l); +int tipc_dest_list_len (struct list_head *l);#endif
net/tipc/socket.c +6 -6
@@ -565,7 +565,7 @@ static int tipc_release(struct socket *sock)/* Reject any messages that accumulated in backlog queue */ release_sock (sk); -u32_list_purge (&tsk->cong_links); +tipc_dest_list_purge (&tsk->cong_links); tsk->cong_link_cnt =0 ;call_rcu (&tsk->rcu, tipc_sk_callback); sock->sk =NULL ;
@@ -826,8 +826,7 @@ void tipc_sk_mcast_rcv(struct net *net, struct sk_buff_head *arrvq,tipc_nametbl_mc_translate (net,msg_nametype (msg),msg_namelower (msg),msg_nameupper (msg), scope, &dports); - portid =u32_pop (&dports); -for (; portid; portid =u32_pop (&dports)) { +while (tipc_dest_pop (&dports,NULL , &portid)) { _skb =__pskb_copy (skb, hsz,GFP_ATOMIC );if (_skb) {msg_set_destport (buf_msg (_skb), portid);
@@ -1000,7 +999,8 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen) }/* Block or return if destination link is congested */ - rc =tipc_wait_for_cond (sock, &timeout, !u32_find (clinks, dnode)); + rc =tipc_wait_for_cond (sock, &timeout, + !tipc_dest_find (clinks, dnode,0 ));if (unlikely (rc))return rc;
@@ -1012,7 +1012,7 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen) rc =tipc_node_xmit (net, &pkts, dnode, tsk->portid);if (unlikely (rc == -ELINKCONG )) { -u32_push (clinks, dnode); +tipc_dest_push (clinks, dnode,0 ); tsk->cong_link_cnt++; rc =0 ; }
@@ -1549,7 +1549,7 @@ static void tipc_sk_proto_rcv(struct sock *sk,tipc_sk_conn_proto_rcv (tsk, skb, xmitq);return ;case SOCK_WAKEUP : -u32_del (&tsk->cong_links,msg_orignode (hdr)); +tipc_dest_del (&tsk->cong_links,msg_orignode (hdr),0 ); tsk->cong_link_cnt--; sk->sk_write_space (sk);break ;
Signature · 1 line
2.1.4
PATCH v2 2/18 tipc: improve address sanity check in tipc_connect()
In reply to Jon MaloyThe address given to tipc_connect() is not completely sanity checked, under the assumption that this will be done later in the function __tipc_sendmsg() when the address is used there.
However, the latter functon will in the next commits serve as caller to several other send functions, so we want to move the corresponding sanity check there to the beginning of that function, before we possibly need to grab the address stored by tipc_connect(). We must therefore be able to trust that this address already has been thoroughly checked.
We do this in this commit.
--- net/tipc/socket.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-)
net/tipc/socket.c +15 -16
@@ -1911,28 +1911,27 @@ static int tipc_connect(struct socket *sock, struct sockaddr *dest,int previous;int res =0 ; +if (destlen !=sizeof (struct sockaddr_tipc )) +return -EINVAL ; +lock_sock (sk); -/* DGRAM/RDM connect(), just save the destaddr */ -if (tipc_sk_type_connectionless (sk)) { -if (dst->family ==AF_UNSPEC ) { -memset (&tsk->peer,0 ,sizeof (struct sockaddr_tipc )); - }else if (destlen !=sizeof (struct sockaddr_tipc )) { +if (dst->family ==AF_UNSPEC ) { +memset (&tsk->peer,0 ,sizeof (struct sockaddr_tipc )); +if (!tipc_sk_type_connectionless (sk)) res = -EINVAL ; - }else { -memcpy (&tsk->peer, dest, destlen); - } goto exit; + }else if (dst->family !=AF_TIPC ) { + res = -EINVAL ; } - -/* -* Reject connection attempt using multicast address -* -* Note: send_msg() validates the rest of the address fields, -* so there's no need to do it here -*/ -if (dst->addrtype ==TIPC_ADDR_MCAST ) { +if (dst->addrtype !=TIPC_ADDR_ID && dst->addrtype !=TIPC_ADDR_NAME ) res = -EINVAL ; +if (res) + goto exit; + +/* DGRAM/RDM connect(), just save the destaddr */ +if (tipc_sk_type_connectionless (sk)) { +memcpy (&tsk->peer, dest, destlen); goto exit; }
Signature · 1 line
2.1.4
PATCH v2 3/18 tipc: add ability to obtain node availability status from other files
In reply to Jon MaloyIn the coming commits, functions at the socket level will need the ability to read the availability status of a given node. We therefore introduce a new function for this purpose, while renaming the existing static function currently having the wanted name.
--- net/tipc/node.c | 26 +++++++++++++++++++++----- net/tipc/node.h | 1 + 2 files changed, 22 insertions(+), 5 deletions(-)
net/tipc/node.c +21 -5
@@ -157,7 +157,7 @@ static void tipc_node_timeout(unsigned long data);static void tipc_node_fsm_evt (struct tipc_node *n,int evt);static struct tipc_node *tipc_node_find (struct net *net,u32 addr);static void tipc_node_put (struct tipc_node *node); -static bool tipc_node_is_up (struct tipc_node *n); +static bool node_is_up (struct tipc_node *n);struct tipc_sock_conn {u32 port;
@@ -657,7 +657,7 @@ static void __tipc_node_link_down(struct tipc_node *n, int *bearer_id, *slot1 = i; } -if (!tipc_node_is_up (n)) { +if (!node_is_up (n)) {if (tipc_link_peer_is_down (l))tipc_node_fsm_evt (n,PEER_LOST_CONTACT_EVT );tipc_node_fsm_evt (n,SELF_LOST_CONTACT_EVT );
@@ -717,11 +717,27 @@ static void tipc_node_link_down(struct tipc_node *n, int bearer_id, bool delete)tipc_sk_rcv (n->net, &le->inputq); } -static bool tipc_node_is_up (struct tipc_node *n) +static bool node_is_up (struct tipc_node *n) {return n->active_links[0 ] !=INVALID_BEARER_ID ; } +bool tipc_node_is_up (struct net *net,u32 addr) +{ +struct tipc_node *n; +bool retval = false; + +if (in_own_node (net, addr)) +return true; + + n =tipc_node_find (net, addr); +if (!n) +return false; + retval =node_is_up (n); +tipc_node_put (n); +return retval; +} + void tipc_node_check_dest(struct net *net, u32 onode, struct tipc_bearer *b, u16 capabilities, u32 signature,
@@ -1149,7 +1165,7 @@ static int __tipc_nl_add_node(struct tipc_nl_msg *msg, struct tipc_node *node)if (nla_put_u32 (msg->skb,TIPC_NLA_NODE_ADDR , node->addr)) goto attr_msg_full; -if (tipc_node_is_up (node)) +if (node_is_up (node))if (nla_put_flag (msg->skb,TIPC_NLA_NODE_UP )) goto attr_msg_full;
@@ -1249,7 +1265,7 @@ void tipc_node_broadcast(struct net *net, struct sk_buff *skb) dst = n->addr;if (in_own_node (net, dst))continue ; -if (!tipc_node_is_up (n)) +if (!node_is_up (n))continue ; txskb =pskb_copy (skb,GFP_ATOMIC );if (!txskb)
net/tipc/node.h +1 -0
@@ -76,6 +76,7 @@ void tipc_node_broadcast(struct net *net, struct sk_buff *skb);int tipc_node_add_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 tipc_node_is_up (struct net *net,u32 addr);u16 tipc_node_get_capabilities (struct net *net,u32 addr);int tipc_nl_node_dump (struct sk_buff *skb,struct netlink_callback *cb);int tipc_nl_node_dump_link (struct sk_buff *skb,struct netlink_callback *cb);
Signature · 1 line
2.1.4
PATCH v2 8/18 tipc: add second source address to recvmsg()/recvfrom()
In reply to Jon MaloyWith group communication, it becomes important for a message receiver to identify not only from which socket (identfied by a node:port tuple) the message was sent, but also the logical identity (type:instance) of the sending member.
We fix this by adding a second instance of struct sockaddr_tipc to the source address area when a message is read. The extra address struct is filled in with data found in the received message header (type,) and in the local member representation struct (instance.)
--- net/tipc/group.c | 3 +++ net/tipc/msg.h | 1 + net/tipc/socket.c | 53 +++++++++++++++++++++++++++++++++++------------------ 3 files changed, 39 insertions(+), 18 deletions(-)
net/tipc/group.c +3 -0
@@ -61,6 +61,7 @@ struct tipc_member {struct list_head list;u32 node;u32 port; +u32 instance;enum mbr_state state;u16 bc_rcv_nxt; };
@@ -282,6 +283,7 @@ void tipc_group_filter_msg(struct tipc_group *grp, struct sk_buff_head *inputq,if (!tipc_group_is_receiver (m)) goto drop; +TIPC_SKB_CB (skb)->orig_member = m->instance;__skb_queue_tail (inputq, skb); m->bc_rcv_nxt =msg_grp_bc_seqno (hdr) +1 ;
@@ -388,6 +390,7 @@ void tipc_group_member_evt(struct tipc_group *grp, m->state =MBR_PUBLISHED ; else m->state = MBR_JOINED; + m->instance = evt->found_lower;tipc_group_proto_xmit (grp, m,GRP_JOIN_MSG , xmitq); }else if (evt->event ==TIPC_WITHDRAWN ) {if (!m)
net/tipc/msg.h +1 -0
@@ -100,6 +100,7 @@ struct plist;struct tipc_skb_cb {u32 bytes_read; +u32 orig_member;struct sk_buff *tail;bool validated;u16 chain_imp;
net/tipc/socket.c +35 -18
81 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 16/18 tipc: guarantee delivery of UP event before first broadcast
In reply to Jon MaloyThe following scenario is possible:
- A user joins a group, and immediately sends out a broadcast message to its members.
- The broadcast message, following a different data path than the initial JOIN message sent out during the joining procedure, arrives to a receiver before the latter..
- The receiver drops the message, since it is not ready to accept any messages until the JOIN has arrived.
We avoid this by treating group protocol JOIN messages like unicast messages.
- We let them pass through the recipient's multicast input queue, just like ordinary unicasts.
- We force the first following broadacst to be sent as replicated unicast and being acknowledged by the recipient before accepting any more broadcast transmissions.
--- net/tipc/link.c | 7 +++++-- net/tipc/socket.c | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-)
net/tipc/link.c +5 -2
@@ -1039,6 +1039,7 @@ int tipc_link_retrans(struct tipc_link *l, struct tipc_link *nacker,static bool tipc_data_input (struct tipc_link *l,struct sk_buff *skb,struct sk_buff_head *inputq) { +struct sk_buff_head *mc_inputq = l->bc_rcvlink->inputq;struct tipc_msg *hdr =buf_msg (skb);switch (msg_user (hdr)) {
@@ -1047,12 +1048,14 @@ static bool tipc_data_input(struct tipc_link *l, struct sk_buff *skb,case TIPC_HIGH_IMPORTANCE :case TIPC_CRITICAL_IMPORTANCE :if (unlikely (msg_in_group (hdr) ||msg_mcast (hdr))) { -skb_queue_tail (l->bc_rcvlink->inputq, skb); +skb_queue_tail (mc_inputq, skb);return true; } -case GROUP_PROTOCOL :case CONN_MANAGER :return true; +case GROUP_PROTOCOL : +skb_queue_tail (mc_inputq, skb); +return true;case NAME_DISTRIBUTOR : l->bc_rcvlink->state =LINK_ESTABLISHED ;skb_queue_tail (l->namedq, skb);
net/tipc/socket.c +4 -0
@@ -2762,6 +2762,10 @@ static int tipc_sk_join(struct tipc_sock *tsk, struct tipc_group_req *mreq) rc =tipc_sk_publish (tsk, mreq->scope, &seq);if (rc)tipc_group_delete (net, grp); + +/* Eliminate any risk that a broadcast overtakes the sent JOIN */ + tsk->mc_method.rcast = true; + tsk->mc_method.mandatory = true;return rc; }
Signature · 1 line
2.1.4
PATCH v2 9/18 tipc: receive group membership events via member socket
In reply to Jon MaloyLike with any other service, group members' availability can be subscribed for by connecting to be topology server. However, because the events arrive via a different socket than the member socket, there is a real risk that membership events my arrive out of synch with the actual JOIN/LEAVE action. I.e., it is possible to receive the first messages from a new member before the corresponding JOIN event arrives, just as it is possible to receive the last messages from a leaving member after the LEAVE event has already been received.
Since each member socket is internally also subscribing for membership events, we now fix this problem by passing those events on to the user via the member socket. We leverage the already present member synch- ronization protocol to guarantee correct message/event order. An event is delivered to the user as an empty message where the two source addresses identify the new/lost member. Furthermore, we set the MSG_OOB bit in the message flags to mark it as an event. If the event is an indication about a member loss we also set the MSG_EOR bit, so it can be distinguished from a member addition event.
--- include/uapi/linux/tipc.h | 1 + net/tipc/group.c | 60 +++++++++++++++++++++++++++++++++++++---------- net/tipc/group.h | 2 ++ net/tipc/msg.h | 22 +++++++++++++++-- net/tipc/socket.c | 49 ++++++++++++++++++++++++-------------- 5 files changed, 101 insertions(+), 33 deletions(-)
include/uapi/linux/tipc.h +1 -0
@@ -238,6 +238,7 @@ struct sockaddr_tipc {* Flag values */ #define TIPC_GROUP_LOOPBACK 0x1/* Receive copy of sent msg when match */ +#define TIPC_GROUP_MEMBER_EVTS 0x2/* Receive membership events in socket */ struct tipc_group_req {__u32 type;/* group id */
net/tipc/group.c +47 -13
141 lines not on this page · raw message
net/tipc/group.h +2 -0
@@ -54,9 +54,11 @@ void tipc_group_filter_msg(struct tipc_group *grp, struct sk_buff_head *xmitq);void tipc_group_member_evt (struct tipc_group *grp,struct sk_buff *skb, +struct sk_buff_head *inputq,struct sk_buff_head *xmitq);void tipc_group_proto_rcv (struct tipc_group *grp,struct tipc_msg *hdr, +struct sk_buff_head *inputq,struct sk_buff_head *xmitq);void tipc_group_update_bc_members (struct tipc_group *grp);u16 tipc_group_bc_snd_nxt (struct tipc_group *grp);
net/tipc/msg.h +20 -2
@@ -65,7 +65,8 @@ struct plist;#define TIPC_MCAST_MSG 1#define TIPC_NAMED_MSG 2#define TIPC_DIRECT_MSG 3 -#define TIPC_GRP_BCAST_MSG 4 +#define TIPC_GRP_MEMBER_EVT 4 +#define TIPC_GRP_BCAST_MSG 5/* * Internal message users
@@ -258,7 +259,14 @@ static inline void msg_set_type(struct tipc_msg *m, u32 n)static inline int msg_in_group (struct tipc_msg *m) { -return (msg_type (m) ==TIPC_GRP_BCAST_MSG ); +int mtyp =msg_type (m); + +return (mtyp ==TIPC_GRP_BCAST_MSG ) || (mtyp ==TIPC_GRP_MEMBER_EVT ); +} + +static inline bool msg_is_grp_evt (struct tipc_msg *m) +{ +return msg_type (m) ==TIPC_GRP_MEMBER_EVT ; }static inline u32 msg_named (struct tipc_msg *m)
@@ -824,6 +832,16 @@ static inline void msg_set_grp_bc_syncpt(struct tipc_msg *m, u16 n)/* Word 10 */ +static inline u16 msg_grp_evt (struct tipc_msg *m) +{ +return msg_bits (m,10 ,0 ,0x3 ); +} + +static inline void msg_set_grp_evt (struct tipc_msg *m,int n) +{ +msg_set_bits (m,10 ,0 ,0x3 , n); +} +static inline u16 msg_grp_bc_seqno (struct tipc_msg *m) {return msg_bits (m,10 ,16 ,0xffff );
net/tipc/socket.c +31 -18
110 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 5/18 tipc: add new function for sending multiple small messages
In reply to Jon MaloyWe see an increasing need to send multiple single-buffer messages of TIPC_SYSTEM_IMPORTANCE to different individual destination nodes. Instead of looping over the send queue and sending each buffer individually, as we do now, we add a new help function tipc_node_distr_xmit() to do this.
--- net/tipc/node.c | 16 ++++++++++++++++ net/tipc/node.h | 1 + net/tipc/socket.c | 14 ++------------ 3 files changed, 19 insertions(+), 12 deletions(-)
net/tipc/node.c +16 -0
@@ -1254,6 +1254,22 @@ int tipc_node_xmit_skb(struct net *net, struct sk_buff *skb, u32 dnode,return 0 ; } +/* tipc_node_distr_xmit(): send single buffer msgs to individual destinations +* Note: this is only for SYSTEM_IMPORTANCE messages, which cannot be rejected +*/ +int tipc_node_distr_xmit (struct net *net,struct sk_buff_head *xmitq) +{ +struct sk_buff *skb; +u32 selector, dnode; + +while ((skb =__skb_dequeue (xmitq))) { + selector =msg_origport (buf_msg (skb)); + dnode =msg_destnode (buf_msg (skb)); +tipc_node_xmit_skb (net, skb, dnode, selector); + } +return 0 ; +} +void tipc_node_broadcast (struct net *net,struct sk_buff *skb) {struct sk_buff *txskb;
net/tipc/node.h +1 -0
@@ -68,6 +68,7 @@ int tipc_node_get_linkname(struct net *net, u32 bearer_id, u32 node, char *linkname, size_t len);int tipc_node_xmit (struct net *net,struct sk_buff_head *list,u32 dnode,int selector); +int tipc_node_distr_xmit (struct net *net,struct sk_buff_head *list);int tipc_node_xmit_skb (struct net *net,struct sk_buff *skb,u32 dest,u32 selector);void tipc_node_subscribe (struct net *net,struct list_head *subscr,u32 addr);
net/tipc/socket.c +2 -12
@@ -1740,14 +1740,11 @@ static void tipc_sk_filter_rcv(struct sock *sk, struct sk_buff *skb,* @skb: message * * Caller must hold socket lock -* -* Returns 0 */ static int tipc_sk_backlog_rcv (struct sock *sk,struct sk_buff *skb) {unsigned int before =sk_rmem_alloc_get (sk);struct sk_buff_head xmitq; -u32 dnode, selector;unsigned int added;__skb_queue_head_init (&xmitq);
@@ -1757,11 +1754,7 @@ static int tipc_sk_backlog_rcv(struct sock *sk, struct sk_buff *skb)atomic_add (added, &tipc_sk (sk)->dupl_rcvcnt);/* Send pending response/rejected messages, if any */ -while ((skb =__skb_dequeue (&xmitq))) { - selector =msg_origport (buf_msg (skb)); - dnode =msg_destnode (buf_msg (skb)); -tipc_node_xmit_skb (sock_net (sk), skb, dnode, selector); - } +tipc_node_distr_xmit (sock_net (sk), &xmitq);return 0 ; }
@@ -1840,10 +1833,7 @@ void tipc_sk_rcv(struct net *net, struct sk_buff_head *inputq)spin_unlock_bh (&sk->sk_lock.slock); }/* Send pending response/rejected messages, if any */ -while ((skb =__skb_dequeue (&xmitq))) { - dnode =msg_destnode (buf_msg (skb)); -tipc_node_xmit_skb (net, skb, dnode, dport); - } +tipc_node_distr_xmit (sock_net (sk), &xmitq);sock_put (sk);continue ; }
Signature · 1 line
2.1.4
PATCH v2 10/18 tipc: introduce flow control for group broadcast messages
In reply to Jon MaloyWe introduce an end-to-end flow control mechanism for group broadcast messages. This ensures that no messages are ever lost because of destination receive buffer overflow, with minimal impact on performance. For now, the algorithm is based on the assumption that there is only one active transmitter at any moment in time.
--- net/tipc/group.c | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- net/tipc/group.h | 11 ++-- net/tipc/msg.h | 5 +- net/tipc/socket.c | 48 +++++++++++++----- 4 files changed, 190 insertions(+), 22 deletions(-)
net/tipc/group.c +144 -4
@@ -46,6 +46,7 @@#define ADV_UNIT (((MAX_MSG_SIZE + MAX_H_SIZE) / FLOWCTL_BLK_SZ) + 1)#define ADV_IDLE ADV_UNIT +#define ADV_ACTIVE (ADV_UNIT * 12)enum mbr_state {MBR_QUARANTINED ,
@@ -59,16 +60,22 @@ enum mbr_state {struct tipc_member {struct rb_node tree_node;struct list_head list; +struct list_head congested;struct sk_buff *event_msg; +struct tipc_group *group;u32 node;u32 port;u32 instance;enum mbr_state state; +u16 advertised; +u16 window;u16 bc_rcv_nxt; +bool usr_pending; };struct tipc_group {struct rb_root members; +struct list_head congested;struct tipc_nlist dests;struct net *net;int subid;
@@ -86,11 +93,24 @@ struct tipc_group {static void tipc_group_proto_xmit (struct tipc_group *grp,struct tipc_member *m,int mtyp,struct sk_buff_head *xmitq); +static int tipc_group_rcvbuf_limit (struct tipc_group *grp) +{ +int mcnt = grp->member_cnt +1 ; + +/* Scale to bytes, considering worst-case truesize/msgsize ratio */ +return mcnt *ADV_ACTIVE *FLOWCTL_BLK_SZ *4 ; +} +u16 tipc_group_bc_snd_nxt (struct tipc_group *grp) {return grp->bc_snd_nxt; } +static bool tipc_group_is_enabled (struct tipc_member *m) +{ +return m->state !=MBR_QUARANTINED && m->state !=MBR_LEAVING ; +} +static bool tipc_group_is_receiver (struct tipc_member *m) {return m && m->state >=MBR_JOINED ;
@@ -111,6 +131,7 @@ struct tipc_group *tipc_group_create(struct net *net, u32 portid,if (!grp)return NULL ;tipc_nlist_init (&grp->dests,tipc_own_addr (net)); +INIT_LIST_HEAD (&grp->congested); grp->members =RB_ROOT ; grp->net = net; grp->portid = portid;
@@ -213,6 +234,8 @@ static struct tipc_member *tipc_group_create_member(struct tipc_group *grp,if (!m)return NULL ;INIT_LIST_HEAD (&m->list); +INIT_LIST_HEAD (&m->congested); + m->group = grp; m->node = node; m->port = port; grp->member_cnt++;
@@ -233,6 +256,7 @@ static void tipc_group_delete_member(struct tipc_group *grp,rb_erase (&m->tree_node, &grp->members); grp->member_cnt--;list_del_init (&m->list); +list_del_init (&m->congested);/* If last member on a node, remove node from dest list */ if (!tipc_group_find_node (grp, m->node))
@@ -255,11 +279,59 @@ void tipc_group_self(struct tipc_group *grp, struct tipc_name_seq *seq, *scope = grp->scope; } -void tipc_group_update_bc_members (struct tipc_group *grp) +void tipc_group_update_member (struct tipc_member *m,int len) +{ +struct tipc_group *grp = m->group; +struct tipc_member *_m, *tmp; + +if (!tipc_group_is_enabled (m)) +return ; + + m->window -= len; + +if (m->window >=ADV_IDLE ) +return ; + +if (!list_empty (&m->congested)) +return ; + +/* Sort member into congested members' list */ +list_for_each_entry_safe (_m, tmp, &grp->congested, congested) { +if (m->window > _m->window) +continue ; +list_add_tail (&m->congested, &_m->congested); +return ; + } +list_add_tail (&m->congested, &grp->congested); +} + +void tipc_group_update_bc_members (struct tipc_group *grp,int len) { +struct tipc_member *m; +struct rb_node *n; + +for (n =rb_first (&grp->members); n; n =rb_next (n)) { + m = container_of(n, struct tipc_member, tree_node); +if (tipc_group_is_enabled (m)) +tipc_group_update_member (m, len); + } grp->bc_snd_nxt++; } +bool tipc_group_bc_cong (struct tipc_group *grp,int len) +{ +struct tipc_member *m; + +if (list_empty (&grp->congested)) +return false; + + m = list_first_entry(&grp->congested, struct tipc_member, congested); +if (m->window >= len) +return false; + +return true; +} +/* tipc_group_filter_msg() - determine if we should accept arriving message */ void tipc_group_filter_msg(struct tipc_group *grp, struct sk_buff_head *inputq,
@@ -302,11 +374,36 @@ void tipc_group_filter_msg(struct tipc_group *grp, struct sk_buff_head *inputq,kfree_skb (skb); } +void tipc_group_update_rcv_win (struct tipc_group *grp,int blks,u32 node, +u32 port,struct sk_buff_head *xmitq) +{ +struct tipc_member *m; + + m =tipc_group_find_member (grp, node, port); +if (!m) +return ; + + m->advertised -= blks; + +switch (m->state) { +case MBR_JOINED : +if (m->advertised <= (ADV_ACTIVE -ADV_UNIT )) +tipc_group_proto_xmit (grp, m,GRP_ADV_MSG , xmitq); +break ; +case MBR_DISCOVERED : +case MBR_JOINING : +case MBR_LEAVING : +default : +break ; + } +} +static void tipc_group_proto_xmit (struct tipc_group *grp,struct tipc_member *m,int mtyp,struct sk_buff_head *xmitq) {struct tipc_msg *hdr;struct sk_buff *skb; +int adv =0 ; skb = tipc_msg_create(GROUP_PROTOCOL, mtyp, INT_H_SIZE, 0, m->node, tipc_own_addr(grp->net),
@@ -314,14 +411,24 @@ static void tipc_group_proto_xmit(struct tipc_group *grp, struct tipc_member *m,if (!skb)return ; +if (m->state ==MBR_JOINED ) + adv =ADV_ACTIVE - m->advertised; + hdr =buf_msg (skb); -if (mtyp ==GRP_JOIN_MSG ) + +if (mtyp ==GRP_JOIN_MSG ) {msg_set_grp_bc_syncpt (hdr, grp->bc_snd_nxt); +msg_set_adv_win (hdr, adv); + m->advertised += adv; + }else if (mtyp ==GRP_ADV_MSG ) { +msg_set_adv_win (hdr, adv); + m->advertised += adv; + }__skb_queue_tail (xmitq, skb); } -void tipc_group_proto_rcv (struct tipc_group *grp,struct tipc_msg *hdr, -struct sk_buff_head *inputq, +void tipc_group_proto_rcv (struct tipc_group *grp,bool *usr_wakeup, +struct tipc_msg *hdr,struct sk_buff_head *inputq,struct sk_buff_head *xmitq) {u32 node =msg_orignode (hdr);
@@ -341,14 +448,22 @@ void tipc_group_proto_rcv(struct tipc_group *grp, struct tipc_msg *hdr,if (!m)return ; m->bc_rcv_nxt =msg_grp_bc_syncpt (hdr); + m->window +=msg_adv_win (hdr);/* Wait until PUBLISH event is received */ if (m->state ==MBR_DISCOVERED ) { m->state =MBR_JOINING ; }else if (m->state ==MBR_PUBLISHED ) { m->state =MBR_JOINED ; + *usr_wakeup = true; + m->usr_pending = false; +tipc_group_proto_xmit (grp, m,GRP_ADV_MSG , xmitq);__skb_queue_tail (inputq, m->event_msg); } +if (m->window <ADV_IDLE ) +tipc_group_update_member (m,0 ); +else +list_del_init (&m->congested);return ;case GRP_LEAVE_MSG :if (!m)
@@ -361,14 +476,28 @@ void tipc_group_proto_rcv(struct tipc_group *grp, struct tipc_msg *hdr, }/* Otherwise deliver already received WITHDRAW event */ __skb_queue_tail (inputq, m->event_msg); + *usr_wakeup = m->usr_pending;tipc_group_delete_member (grp, m); +list_del_init (&m->congested); +return ; +case GRP_ADV_MSG : +if (!m) +return ; + m->window +=msg_adv_win (hdr); + *usr_wakeup = m->usr_pending; + m->usr_pending = false; +list_del_init (&m->congested);return ;default :pr_warn ("Received unknown GROUP_PROTO message\n" ); } } +/* tipc_group_member_evt() - receive and handle a member up/down event +*/ void tipc_group_member_evt (struct tipc_group *grp, +bool *usr_wakeup, +int *sk_rcvbuf,struct sk_buff *skb,struct sk_buff_head *inputq,struct sk_buff_head *xmitq)
@@ -416,16 +545,25 @@ void tipc_group_member_evt(struct tipc_group *grp, }else {__skb_queue_tail (inputq, skb); m->state =MBR_JOINED ; + *usr_wakeup = true; + m->usr_pending = false; } m->instance = instance;TIPC_SKB_CB (skb)->orig_member = m->instance;tipc_group_proto_xmit (grp, m,GRP_JOIN_MSG , xmitq); +if (m->window <ADV_IDLE ) +tipc_group_update_member (m,0 ); +else +list_del_init (&m->congested); }else if (event ==TIPC_WITHDRAWN ) {if (!m) goto drop;TIPC_SKB_CB (skb)->orig_member = m->instance; + *usr_wakeup = m->usr_pending; + m->usr_pending = false; +/* Hold back event if more messages might be expected */ if (m->state !=MBR_LEAVING &&tipc_node_is_up (net, node)) { m->event_msg = skb;
@@ -434,7 +572,9 @@ void tipc_group_member_evt(struct tipc_group *grp,__skb_queue_tail (inputq, skb);tipc_group_delete_member (grp, m); } +list_del_init (&m->congested); } + *sk_rcvbuf =tipc_group_rcvbuf_limit (grp);return ; drop:kfree_skb (skb);
net/tipc/group.h +7 -4
@@ -52,15 +52,18 @@ void tipc_group_self(struct tipc_group *grp, struct tipc_name_seq *seq,void tipc_group_filter_msg (struct tipc_group *grp,struct sk_buff_head *inputq,struct sk_buff_head *xmitq); -void tipc_group_member_evt (struct tipc_group *grp, -struct sk_buff *skb, +void tipc_group_member_evt (struct tipc_group *grp,bool *wakeup, +int *sk_rcvbuf,struct sk_buff *skb,struct sk_buff_head *inputq,struct sk_buff_head *xmitq); -void tipc_group_proto_rcv (struct tipc_group *grp, +void tipc_group_proto_rcv (struct tipc_group *grp,bool *wakeup,struct tipc_msg *hdr,struct sk_buff_head *inputq,struct sk_buff_head *xmitq); -void tipc_group_update_bc_members (struct tipc_group *grp); +void tipc_group_update_bc_members (struct tipc_group *grp,int len); +bool tipc_group_bc_cong (struct tipc_group *grp,int len); +void tipc_group_update_rcv_win (struct tipc_group *grp,int blks,u32 node, +u32 port,struct sk_buff_head *xmitq);u16 tipc_group_bc_snd_nxt (struct tipc_group *grp);int tipc_group_size (struct tipc_group *grp);#endif
net/tipc/msg.h +3 -2
@@ -538,6 +538,7 @@ static inline void msg_set_nameupper(struct tipc_msg *m, u32 n)*/ #define GRP_JOIN_MSG 0#define GRP_LEAVE_MSG 1 +#define GRP_ADV_MSG 2/* * Word 1
@@ -790,12 +791,12 @@ static inline void msg_set_conn_ack(struct tipc_msg *m, u32 n)msg_set_bits (m,9 ,16 ,0xffff , n); } -static inline u32 msg_adv_win (struct tipc_msg *m) +static inline u16 msg_adv_win (struct tipc_msg *m) {return msg_bits (m,9 ,0 ,0xffff ); } -static inline void msg_set_adv_win (struct tipc_msg *m,u32 n) +static inline void msg_set_adv_win (struct tipc_msg *m,u16 n) {msg_set_bits (m,9 ,0 ,0xffff , n); }
net/tipc/socket.c +36 -12
135 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 7/18 tipc: introduce communication groups
In reply to Jon MaloyAs a preparation for introducing flow control for multicast and datagram messaging we need a more strictly defined framework than we have now. A socket must be able keep track of exactly how many and which other sockets it is allowed to communicate with at any moment, and keep the necessary state for those.
We therefore introduce a new concept we have named Communication Group. Sockets can join a group via a new setsockopt() call TIPC_GROUP_JOIN. The call takes four parameters: 'type' serves as group identifier, 'instance' serves as an logical member identifier, and 'scope' indicates the visibility of the group (node/cluster/zone). Finally, 'flags' makes it possible to set certain properties for the member. For now, there is only one flag, indicating if the creator of the socket wants to receive a copy of broadcast or multicast messages it is sending via the socket, and if wants to be eligible as destination for its own anycasts.
A group is closed, i.e., sockets which have not joined a group will not be able to send messages to or receive messages from members of the group, and vice versa.
Any member of a group can send multicast ('group broadcast') messages to all group members, optionally including itself, using the primitive send(). The messages are received via the recvmsg() primitive. A socket can only be member of one group at a time.
--- include/uapi/linux/tipc.h | 14 ++ net/tipc/Makefile | 2 +- net/tipc/group.c | 404 ++++++++++++++++++++++++++++++++++++++++++++++ net/tipc/group.h | 64 ++++++++ net/tipc/link.c | 3 +- net/tipc/msg.h | 50 +++++- net/tipc/name_table.c | 44 +++-- net/tipc/name_table.h | 3 + net/tipc/node.h | 3 +- net/tipc/socket.c | 209 ++++++++++++++++++++---- 10 files changed, 748 insertions(+), 48 deletions(-) create mode 100644 net/tipc/group.c create mode 100644 net/tipc/group.h
include/uapi/linux/tipc.h +14 -0
@@ -231,6 +231,20 @@ struct sockaddr_tipc {#define TIPC_SOCK_RECVQ_DEPTH 132/* Default: none (read only) */ #define TIPC_MCAST_BROADCAST 133/* Default: TIPC selects. No arg */ #define TIPC_MCAST_REPLICAST 134/* Default: TIPC selects. No arg */ +#define TIPC_GROUP_JOIN 135/* Takes struct tipc_group_req* */ +#define TIPC_GROUP_LEAVE 136/* No argument */ + +/* +* Flag values +*/ +#define TIPC_GROUP_LOOPBACK 0x1/* Receive copy of sent msg when match */ + +struct tipc_group_req { +__u32 type;/* group id */ +__u32 instance;/* member id */ +__u32 scope;/* zone/cluster/node */ +__u32 flags; +};/* * Maximum sizes of TIPC bearer-related names (including terminating NULL)
net/tipc/Makefile +1 -1
@@ -8,7 +8,7 @@ tipc-y += addr.o bcast.o bearer.o \ core.o link.o discover.o msg.o \ name_distr.o subscr.o monitor.o name_table.o net.o \ netlink.o netlink_compat.o node.o socket.o eth_media.o \ - server.o socket.o + server.o socket.o group.o tipc-$(CONFIG_TIPC_MEDIA_UDP) += udp_media.o tipc-$(CONFIG_TIPC_MEDIA_IB) += ib_media.o
net/tipc/group.c new file +404 -0
404 lines not on this page · raw message
net/tipc/group.h new file +64 -0
64 lines not on this page · raw message
net/tipc/link.c +2 -1
@@ -1046,11 +1046,12 @@ static bool tipc_data_input(struct tipc_link *l, struct sk_buff *skb,case TIPC_MEDIUM_IMPORTANCE :case TIPC_HIGH_IMPORTANCE :case TIPC_CRITICAL_IMPORTANCE : -if (unlikely (msg_type (hdr) ==TIPC_MCAST_MSG )) { +if (unlikely (msg_mcast (hdr))) {skb_queue_tail (l->bc_rcvlink->inputq, skb);return true; }case CONN_MANAGER : +case GROUP_PROTOCOL :skb_queue_tail (inputq, skb);return true;case NAME_DISTRIBUTOR :
net/tipc/msg.h +44 -6
98 lines not on this page · raw message
net/tipc/name_table.c +32 -12
62 lines not on this page · raw message
net/tipc/name_table.h +3 -0
@@ -40,6 +40,7 @@struct tipc_subscription ;struct tipc_plist ;struct tipc_nlist ; +struct tipc_group ;/* * TIPC name types reserved for internal TIPC use (both current and planned)
@@ -101,6 +102,8 @@ int tipc_nl_name_table_dump(struct sk_buff *skb, struct netlink_callback *cb);u32 tipc_nametbl_translate (struct net *net,u32 type,u32 instance,u32 *node);int tipc_nametbl_mc_translate (struct net *net,u32 type,u32 lower,u32 upper,u32 limit,struct list_head *dports); +void tipc_nametbl_build_group (struct net *net,struct tipc_group *grp, +u32 type,u32 domain);void tipc_nametbl_lookup_dst_nodes (struct net *net,u32 type,u32 lower,u32 upper,u32 domain,struct tipc_nlist *nodes);
net/tipc/node.h +2 -1
@@ -48,7 +48,8 @@ enum {TIPC_BCAST_SYNCH = (1 <<1 ),TIPC_BCAST_STATE_NACK = (1 <<2 ),TIPC_BLOCK_FLOWCTL = (1 <<3 ), - TIPC_BCAST_RCAST = (1 << 4) +TIPC_BCAST_RCAST = (1 <<4 ), + TIPC_MCAST_GROUPS = (1 << 5) };#define TIPC_NODE_CAPABILITIES (TIPC_BCAST_SYNCH | \
net/tipc/socket.c +182 -27
390 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 11/18 tipc: introduce group unicast messaging
In reply to Jon MaloyWe now make it possible to send connectionless unicast messages within a communication group. To send a message, the sender can use either a direct port address, aka port identity, or an indirect port name to be looked up.
This type of messages are subject to the same start synchronization and flow control mechanism as group broadcast messages.
--- net/tipc/group.c | 45 +++++++++++++++++++++- net/tipc/group.h | 3 ++ net/tipc/msg.h | 3 +- net/tipc/socket.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++----- 4 files changed, 150 insertions(+), 13 deletions(-)
net/tipc/group.c +43 -2
@@ -186,6 +186,17 @@ struct tipc_member *tipc_group_find_member(struct tipc_group *grp,return NULL ; } +static struct tipc_member *tipc_group_find_dest (struct tipc_group *grp, +u32 node,u32 port) +{ +struct tipc_member *m; + + m =tipc_group_find_member (grp, node, port); +if (m &&tipc_group_is_enabled (m)) +return m; +return NULL ; +} +static struct tipc_member *tipc_group_find_node (struct tipc_group *grp,u32 node) {
@@ -318,9 +329,39 @@ void tipc_group_update_bc_members(struct tipc_group *grp, int len) grp->bc_snd_nxt++; } -bool tipc_group_bc_cong (struct tipc_group *grp,int len) +bool tipc_group_cong (struct tipc_group *grp,u32 dnode,u32 dport, +int len,struct tipc_member **mbr) { +struct sk_buff_head xmitq;struct tipc_member *m; +int adv, state; + + m =tipc_group_find_dest (grp, dnode, dport); + *mbr = m; +if (!m) +return false; +if (m->usr_pending) +return true; +if (m->window >= len) +return false; + m->usr_pending = true; + +/* If not fully advertised, do it now to prevent mutual blocking */ + adv = m->advertised; + state = m->state; +if (state <MBR_JOINED ) +return true; +if (state ==MBR_JOINED && adv ==ADV_IDLE ) +return true; +skb_queue_head_init (&xmitq); +tipc_group_proto_xmit (grp, m,GRP_ADV_MSG , &xmitq); +tipc_node_distr_xmit (grp->net, &xmitq); +return true; +} + +bool tipc_group_bc_cong (struct tipc_group *grp,int len) +{ +struct tipc_member *m =NULL ;if (list_empty (&grp->congested))return false;
@@ -329,7 +370,7 @@ bool tipc_group_bc_cong(struct tipc_group *grp, int len)if (m->window >= len)return false; -return true; +return tipc_group_cong (grp, m->node, m->port, len, &m); }/* tipc_group_filter_msg() - determine if we should accept arriving message
net/tipc/group.h +3 -0
@@ -61,9 +61,12 @@ void tipc_group_proto_rcv(struct tipc_group *grp, bool *wakeup,struct sk_buff_head *inputq, struct sk_buff_head *xmitq);void tipc_group_update_bc_members (struct tipc_group *grp,int len); +bool tipc_group_cong (struct tipc_group *grp,u32 dnode,u32 dport, +int len,struct tipc_member **m);bool tipc_group_bc_cong (struct tipc_group *grp,int len);void tipc_group_update_rcv_win (struct tipc_group *grp,int blks,u32 node,u32 port,struct sk_buff_head *xmitq);u16 tipc_group_bc_snd_nxt (struct tipc_group *grp); +void tipc_group_update_member (struct tipc_member *m,int len);int tipc_group_size (struct tipc_group *grp);#endif
net/tipc/msg.h +2 -1
@@ -67,6 +67,7 @@ struct plist;#define TIPC_DIRECT_MSG 3#define TIPC_GRP_MEMBER_EVT 4#define TIPC_GRP_BCAST_MSG 5 +#define TIPC_GRP_UCAST_MSG 6/* * Internal message users
@@ -261,7 +262,7 @@ static inline int msg_in_group(struct tipc_msg *m) {int mtyp =msg_type (m); -return (mtyp ==TIPC_GRP_BCAST_MSG ) || (mtyp ==TIPC_GRP_MEMBER_EVT ); +return mtyp >=TIPC_GRP_MEMBER_EVT && mtyp <=TIPC_GRP_UCAST_MSG ; }static inline bool msg_is_grp_evt (struct tipc_msg *m)
net/tipc/socket.c +102 -10
142 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 17/18 tipc: guarantee delivery of last broadcast before DOWN event
In reply to Jon MaloyThe following scenario is possible:
- A user sends a broadcast message, and thereafter immediately leaves the group.
- The LEAVE message, following a different path than the broadcast, arrives ahead of the broadcast, and the sending member is removed from the receiver's list.
- The broadcast message arrives, but is dropped because the sender now is unknown to the receipient.
We fix this by sequence numbering membership events, just like ordinary unicast messages. Currently, when a JOIN is sent to a peer, it contains a synchronization point, - the sequence number of the next sent broadcast, in order to give the receiver a start synchronization point. We now let even LEAVE messages contain such an "end synchronization" point, so that the recipient can delay the removal of the sending member until it knows that all messages have been received.
The received synchronization points are added as sequence numbers to the generated membership events, making it possible to handle them almost the same way as regular unicasts in the receiving filter function. In particular, a DOWN event with a too high sequence number will be kept in the reordering queue until the missing broadcast(s) arrive and have been delivered.
--- net/tipc/group.c | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-)
net/tipc/group.c +32 -13
@@ -71,6 +71,7 @@ struct tipc_member {u16 advertised;u16 window;u16 bc_rcv_nxt; +u16 bc_syncpt;u16 bc_acked;bool usr_pending; };
@@ -410,7 +411,7 @@ static void tipc_group_sort_msg(struct sk_buff *skb, struct sk_buff_head *defq)struct sk_buff *_skb, *tmp;int mtyp =msg_type (hdr); -/* Bcast may be bypassed by unicast or other bcast, - sort it in */ +/* Bcast/mcast may be bypassed by ucast or other bcast, - sort it in */ if (mtyp ==TIPC_GRP_BCAST_MSG || mtyp ==TIPC_GRP_MCAST_MSG ) { skb_queue_walk_safe(defq, _skb, tmp) { _hdr =buf_msg (_skb);
@@ -431,7 +432,7 @@ void tipc_group_filter_msg(struct tipc_group *grp, struct sk_buff_head *inputq, struct sk_buff_head *xmitq) {struct sk_buff *skb =__skb_dequeue (inputq); -bool ack, deliver, update; +bool ack, deliver, update, leave = false;struct sk_buff_head *defq;struct tipc_member *m;struct tipc_msg *hdr;
@@ -448,13 +449,6 @@ void tipc_group_filter_msg(struct tipc_group *grp, struct sk_buff_head *inputq,if (!msg_in_group (hdr)) goto drop; -if (msg_is_grp_evt (hdr)) { -if (!grp->events) - goto drop; -__skb_queue_tail (inputq, skb); -return ; - } - m =tipc_group_find_member (grp, node, port);if (!tipc_group_is_receiver (m)) goto drop;
@@ -490,6 +484,12 @@ void tipc_group_filter_msg(struct tipc_group *grp, struct sk_buff_head *inputq,break ;case TIPC_GRP_UCAST_MSG :break ; +case TIPC_GRP_MEMBER_EVT : +if (m->state ==MBR_LEAVING ) + leave = true; +if (!grp->events) + deliver = false; +break ;default :break ; }
@@ -504,6 +504,11 @@ void tipc_group_filter_msg(struct tipc_group *grp, struct sk_buff_head *inputq,if (ack)tipc_group_proto_xmit (grp, m,GRP_ACK_MSG , xmitq); +if (leave) { +tipc_group_delete_member (grp, m); +__skb_queue_purge (defq); +break ; + }if (!update)continue ;
@@ -561,6 +566,8 @@ static void tipc_group_proto_xmit(struct tipc_group *grp, struct tipc_member *m,msg_set_grp_bc_syncpt (hdr, grp->bc_snd_nxt);msg_set_adv_win (hdr, adv); m->advertised += adv; + }else if (mtyp ==GRP_LEAVE_MSG ) { +msg_set_grp_bc_syncpt (hdr, grp->bc_snd_nxt); }else if (mtyp ==GRP_ADV_MSG ) {msg_set_adv_win (hdr, adv); m->advertised += adv;
@@ -577,6 +584,7 @@ void tipc_group_proto_rcv(struct tipc_group *grp, bool *usr_wakeup,u32 node =msg_orignode (hdr);u32 port =msg_origport (hdr);struct tipc_member *m; +struct tipc_msg *ehdr;if (!grp)return ;
@@ -590,7 +598,8 @@ void tipc_group_proto_rcv(struct tipc_group *grp, bool *usr_wakeup, MBR_QUARANTINED);if (!m)return ; - m->bc_rcv_nxt =msg_grp_bc_syncpt (hdr); + m->bc_syncpt =msg_grp_bc_syncpt (hdr); + m->bc_rcv_nxt = m->bc_syncpt; m->window +=msg_adv_win (hdr);/* Wait until PUBLISH event is received */
@@ -601,6 +610,8 @@ void tipc_group_proto_rcv(struct tipc_group *grp, bool *usr_wakeup, *usr_wakeup = true; m->usr_pending = false;tipc_group_proto_xmit (grp, m,GRP_ADV_MSG , xmitq); + ehdr =buf_msg (m->event_msg); +msg_set_grp_bc_seqno (ehdr, m->bc_syncpt);__skb_queue_tail (inputq, m->event_msg); }if (m->window <ADV_IDLE )
@@ -611,6 +622,7 @@ void tipc_group_proto_rcv(struct tipc_group *grp, bool *usr_wakeup,case GRP_LEAVE_MSG :if (!m)return ; + m->bc_syncpt =msg_grp_bc_syncpt (hdr);/* Wait until WITHDRAW event is received */ if (m->state !=MBR_LEAVING ) {
@@ -618,9 +630,10 @@ void tipc_group_proto_rcv(struct tipc_group *grp, bool *usr_wakeup,return ; }/* Otherwise deliver already received WITHDRAW event */ + ehdr =buf_msg (m->event_msg); +msg_set_grp_bc_seqno (ehdr, m->bc_syncpt);__skb_queue_tail (inputq, m->event_msg); *usr_wakeup = true; -tipc_group_delete_member (grp, m);list_del_init (&m->congested);return ;case GRP_ADV_MSG :
@@ -662,6 +675,7 @@ void tipc_group_member_evt(struct tipc_group *grp,int event = evt->event;struct tipc_member *m;struct net *net; +bool node_up;u32 self;if (!grp)
@@ -695,6 +709,7 @@ void tipc_group_member_evt(struct tipc_group *grp, m->event_msg = skb; m->state =MBR_PUBLISHED ; }else { +msg_set_grp_bc_seqno (hdr, m->bc_syncpt);__skb_queue_tail (inputq, skb); m->state =MBR_JOINED ; *usr_wakeup = true;
@@ -715,14 +730,18 @@ void tipc_group_member_evt(struct tipc_group *grp, *usr_wakeup = true; m->usr_pending = false; + node_up =tipc_node_is_up (net, node);/* Hold back event if more messages might be expected */ -if (m->state !=MBR_LEAVING &&tipc_node_is_up (net, node)) { +if (m->state !=MBR_LEAVING && node_up) { m->event_msg = skb; m->state =MBR_LEAVING ; }else { +if (node_up) +msg_set_grp_bc_seqno (hdr, m->bc_syncpt); +else +msg_set_grp_bc_seqno (hdr, m->bc_rcv_nxt);__skb_queue_tail (inputq, skb); -tipc_group_delete_member (grp, m); }list_del_init (&m->congested); }
Signature · 1 line
2.1.4
PATCH v2 12/18 tipc: introduce group anycast messaging
In reply to Jon MaloyIn this commit, we make it possible to send connectionless unicast messages to any member corresponding to the given member identity, when there is more than one such member. The sender must use a TIPC_ADDR_NAME address to achieve this effect.
We also perform load balancing between the destinations, i.e., we primarily select one which has advertised sufficient send window to not cause a block/EAGAIN delay, if any. This mechanism is overlayed on the always present round-robin selection.
Anycast messages are subject to the same start synchronization and flow control mechanism as group broadcast messages.
--- net/tipc/group.c | 7 +++++ net/tipc/group.h | 3 ++ net/tipc/name_table.c | 41 +++++++++++++++++++++++++ net/tipc/name_table.h | 3 ++ net/tipc/socket.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 138 insertions(+)
net/tipc/group.c +7 -0
@@ -116,6 +116,13 @@ static bool tipc_group_is_receiver(struct tipc_member *m)return m && m->state >=MBR_JOINED ; } +u32 tipc_group_exclude (struct tipc_group *grp) +{ +if (!grp->loopback) +return grp->portid; +return 0 ; +} +int tipc_group_size (struct tipc_group *grp) {return grp->member_cnt;
net/tipc/group.h +3 -0
@@ -49,6 +49,7 @@ void tipc_group_add_member(struct tipc_group *grp, u32 node, u32 port);struct tipc_nlist *tipc_group_dests (struct tipc_group *grp);void tipc_group_self (struct tipc_group *grp,struct tipc_name_seq *seq,int *scope); +u32 tipc_group_exclude (struct tipc_group *grp);void tipc_group_filter_msg (struct tipc_group *grp,struct sk_buff_head *inputq,struct sk_buff_head *xmitq);
@@ -68,5 +69,7 @@ void tipc_group_update_rcv_win(struct tipc_group *grp, int blks, u32 node, u32 port, struct sk_buff_head *xmitq);u16 tipc_group_bc_snd_nxt (struct tipc_group *grp);void tipc_group_update_member (struct tipc_member *m,int len); +struct tipc_member *tipc_group_find_sender (struct tipc_group *grp, +u32 node,u32 port);int tipc_group_size (struct tipc_group *grp);#endif
net/tipc/name_table.c +41 -0
47 lines not on this page · raw message
net/tipc/name_table.h +3 -0
@@ -107,6 +107,9 @@ void tipc_nametbl_build_group(struct net *net, struct tipc_group *grp,void tipc_nametbl_lookup_dst_nodes (struct net *net,u32 type,u32 lower,u32 upper,u32 domain,struct tipc_nlist *nodes); +bool tipc_nametbl_lookup (struct net *net,u32 type,u32 instance,u32 domain, +struct list_head *dsts,int *dstcnt,u32 exclude, +bool all);struct publication *tipc_nametbl_publish (struct net *net,u32 type,u32 lower,u32 upper,u32 scope,u32 port_ref,u32 key);
net/tipc/socket.c +84 -0
96 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 13/18 tipc: introduce group multicast messaging
In reply to Jon MaloyThe previously introduced message transport to all group members is based on the tipc multicast service, but is logically a broadcast service within the group, and that is what we call it.
We now add functionality for sending messages to all group members having a certain identity. Correspondingly, we call this feature 'group multicast'. The service is using unicast when only one destination is found, otherwise it will use the bearer broadcast service to transfer the messages. In the latter case, the receiving members filter arriving messages by looking at the intended destination instance. If there is no match, the message will be dropped, while still being considered received and read as seen by the flow control mechanism.
--- net/tipc/group.c | 14 +++++++++++++- net/tipc/msg.h | 11 +++++++++-- net/tipc/socket.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 74 insertions(+), 7 deletions(-)
net/tipc/group.c +13 -1
@@ -413,10 +413,22 @@ void tipc_group_filter_msg(struct tipc_group *grp, struct sk_buff_head *inputq,if (!tipc_group_is_receiver (m)) goto drop; + m->bc_rcv_nxt =msg_grp_bc_seqno (hdr) +1 ; + +/* Drop multicast here if not for this member */ +if (mtyp ==TIPC_GRP_MCAST_MSG ) { +if (msg_nameinst (hdr) != grp->instance) { + m->bc_rcv_nxt =msg_grp_bc_seqno (hdr) +1 ; +tipc_group_update_rcv_win (grp,msg_blocks (hdr), + node, port, xmitq); +kfree_skb (skb); +return ; + } + } +TIPC_SKB_CB (skb)->orig_member = m->instance;__skb_queue_tail (inputq, skb); - m->bc_rcv_nxt =msg_grp_bc_seqno (hdr) +1 ;return ; drop:kfree_skb (skb);
net/tipc/msg.h +9 -2
@@ -67,7 +67,8 @@ struct plist;#define TIPC_DIRECT_MSG 3#define TIPC_GRP_MEMBER_EVT 4#define TIPC_GRP_BCAST_MSG 5 -#define TIPC_GRP_UCAST_MSG 6 +#define TIPC_GRP_MCAST_MSG 6 +#define TIPC_GRP_UCAST_MSG 7/* * Internal message users
@@ -195,6 +196,11 @@ static inline u32 msg_size(struct tipc_msg *m)return msg_bits (m,0 ,0 ,0x1ffff ); } +static inline u32 msg_blocks (struct tipc_msg *m) +{ +return (msg_size (m) /1024 ) +1 ; +} +static inline u32 msg_data_sz (struct tipc_msg *m) {return msg_size (m) -msg_hdr_sz (m);
@@ -279,7 +285,8 @@ static inline u32 msg_mcast(struct tipc_msg *m) {int mtyp =msg_type (m); -return ((mtyp ==TIPC_MCAST_MSG ) || (mtyp ==TIPC_GRP_BCAST_MSG )); +return ((mtyp ==TIPC_MCAST_MSG ) || (mtyp ==TIPC_GRP_BCAST_MSG ) || + (mtyp ==TIPC_GRP_MCAST_MSG )); }static inline u32 msg_connected (struct tipc_msg *m)
net/tipc/socket.c +52 -4
89 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 14/18 tipc: guarantee group unicast doesn't bypass group broadcast
In reply to Jon MaloyGroup unicast messages don't follow the same path as broadcast messages, and there is a high risk that unicasts sent from a socket might bypass previously sent broadcasts from the same socket.
We fix this by letting all unicast messages carry the sequence number of the next sent broadcast from the same node, but without updating this number at the receiver. This way, a receiver can check and if necessary re-order such messages before they are added to the socket receive buffer.
--- net/tipc/group.c | 87 +++++++++++++++++++++++++++++++++++++++++++++---------- net/tipc/socket.c | 2 ++ 2 files changed, 74 insertions(+), 15 deletions(-)
net/tipc/group.c +72 -15
@@ -62,6 +62,7 @@ struct tipc_member {struct list_head list;struct list_head congested;struct sk_buff *event_msg; +struct sk_buff_head deferredq;struct tipc_group *group;u32 node;u32 port;
@@ -253,6 +254,7 @@ static struct tipc_member *tipc_group_create_member(struct tipc_group *grp,return NULL ;INIT_LIST_HEAD (&m->list);INIT_LIST_HEAD (&m->congested); +__skb_queue_head_init (&m->deferredq); m->group = grp; m->node = node; m->port = port;
@@ -380,29 +382,54 @@ bool tipc_group_bc_cong(struct tipc_group *grp, int len)return tipc_group_cong (grp, m->node, m->port, len, &m); } +/* tipc_group_sort_msg() - sort msg into queue by bcast sequence number +*/ +static void tipc_group_sort_msg (struct sk_buff *skb,struct sk_buff_head *defq) +{ +struct tipc_msg *_hdr, *hdr =buf_msg (skb); +u16 bc_seqno =msg_grp_bc_seqno (hdr); +struct sk_buff *_skb, *tmp; +int mtyp =msg_type (hdr); + +/* Bcast may be bypassed by unicast, - sort it in */ +if (mtyp ==TIPC_GRP_BCAST_MSG || mtyp ==TIPC_GRP_MCAST_MSG ) { + skb_queue_walk_safe(defq, _skb, tmp) { + _hdr =buf_msg (_skb); +if (!less (bc_seqno,msg_grp_bc_seqno (_hdr))) +continue ; +__skb_queue_before (defq, _skb, skb); +return ; + } +/* Bcast was not bypassed, - add to tail */ + } +/* Unicasts are never bypassed, - always add to tail */ +__skb_queue_tail (defq, skb); +} +/* tipc_group_filter_msg() - determine if we should accept arriving message */ void tipc_group_filter_msg (struct tipc_group *grp,struct sk_buff_head *inputq,struct sk_buff_head *xmitq) {struct sk_buff *skb =__skb_dequeue (inputq); +struct sk_buff_head *defq;struct tipc_member *m;struct tipc_msg *hdr; +bool deliver, update;u32 node, port; -int mtyp; +int mtyp, blks;if (!skb)return ; hdr =buf_msg (skb); - mtyp =msg_type (hdr); node =msg_orignode (hdr); port =msg_origport (hdr);if (!msg_in_group (hdr)) goto drop; -if (mtyp ==TIPC_GRP_MEMBER_EVT ) { +if (msg_is_grp_evt (hdr)) {if (!grp->events) goto drop;__skb_queue_tail (inputq, skb);
@@ -413,22 +440,52 @@ void tipc_group_filter_msg(struct tipc_group *grp, struct sk_buff_head *inputq,if (!tipc_group_is_receiver (m)) goto drop; - m->bc_rcv_nxt =msg_grp_bc_seqno (hdr) +1 ; +if (less (msg_grp_bc_seqno (hdr), m->bc_rcv_nxt)) + goto drop; -/* Drop multicast here if not for this member */ -if (mtyp ==TIPC_GRP_MCAST_MSG ) { -if (msg_nameinst (hdr) != grp->instance) { - m->bc_rcv_nxt =msg_grp_bc_seqno (hdr) +1 ; -tipc_group_update_rcv_win (grp,msg_blocks (hdr), - node, port, xmitq); -kfree_skb (skb); -return ; +TIPC_SKB_CB (skb)->orig_member = m->instance; + defq = &m->deferredq; +tipc_group_sort_msg (skb, defq); + +while ((skb =skb_peek (defq))) { + hdr =buf_msg (skb); + mtyp =msg_type (hdr); + deliver = true; + update = false; + +if (more (msg_grp_bc_seqno (hdr), m->bc_rcv_nxt)) +break ; + +/* Decide what to do with message */ +switch (mtyp) { +case TIPC_GRP_MCAST_MSG : +if (msg_nameinst (hdr) != grp->instance) { + update = true; + deliver = false; + } +/* Fall thru */ +case TIPC_GRP_BCAST_MSG : + m->bc_rcv_nxt++; +break ; +case TIPC_GRP_UCAST_MSG : +break ; +default : +break ; } - } -TIPC_SKB_CB (skb)->orig_member = m->instance; -__skb_queue_tail (inputq, skb); +/* Execute decisions */ +__skb_dequeue (defq); +if (deliver) +__skb_queue_tail (inputq, skb); +else +kfree_skb (skb); + +if (!update) +continue ; + blks =msg_blocks (hdr); +tipc_group_update_rcv_win (grp, blks, node, port, xmitq); + }return ; drop:kfree_skb (skb);
net/tipc/socket.c +2 -0
@@ -830,6 +830,7 @@ static int tipc_send_group_msg(struct net *net, struct tipc_sock *tsk, struct msghdr *m, struct tipc_member *mb, u32 dnode, u32 dport, int dlen) { + u16 bc_snd_nxt = tipc_group_bc_snd_nxt(tsk->group);int blks =tsk_blocks (GROUP_H_SIZE + dlen);struct tipc_msg *hdr = &tsk->phdr;struct sk_buff_head pkts;
@@ -840,6 +841,7 @@ static int tipc_send_group_msg(struct net *net, struct tipc_sock *tsk,msg_set_hdr_sz (hdr,GROUP_H_SIZE );msg_set_destport (hdr, dport);msg_set_destnode (hdr, dnode); +msg_set_grp_bc_seqno (hdr, bc_snd_nxt);/* Build message as chain of buffers */ skb_queue_head_init (&pkts);
Signature · 1 line
2.1.4
PATCH v2 15/18 tipc: guarantee that group broadcast doesn't bypass group unicast
In reply to Jon MaloyWe need a mechanism guaranteeing that group unicasts sent out from a socket are not bypassed by later sent broadcasts from the same socket. We do this as follows:
- Each time a unicast is sent, we set a the broadcast method for the socket to "replicast" and "mandatory". This forces the first subsequent broadcast message to follow the same network and data path as the preceding unicast to a destination, hence preventing it from overtaking the latter.
- In order to make the 'same data path' statement above true, we let group unicasts pass through the multicast link input queue, instead of as previously through the unicast link input queue.
- In the first broadcast following a unicast, we set a new header flag, requiring all recipients to immediately acknowledge its reception.
- During the period before all the expected acknowledges are received, the socket refuses to accept any more broadcast attempts, i.e., by blocking or returning EAGAIN. This period should typically not be longer than a few microseconds.
- When all acknowledges have been received, the sending socket will open up for subsequent broadcasts, this time giving the link layer freedom to itself select the best transmission method.
- The forced and/or abrupt transmission method changes described above may lead to broadcasts arriving out of order to the recipients. We remedy this by introducing code that checks and if necessary re-orders such messages at the receiving end.
--- net/tipc/group.c | 47 +++++++++++++++++++++++++++++++++++++++++------ net/tipc/group.h | 4 +--- net/tipc/link.c | 5 ++--- net/tipc/msg.h | 21 +++++++++++++++++++++ net/tipc/socket.c | 34 +++++++++++++++++++++++++++++----- 5 files changed, 94 insertions(+), 17 deletions(-)
net/tipc/group.c +41 -6
@@ -71,6 +71,7 @@ struct tipc_member {u16 advertised;u16 window;u16 bc_rcv_nxt; +u16 bc_acked;bool usr_pending; };
@@ -87,6 +88,7 @@ struct tipc_group {u32 portid;u16 member_cnt;u16 bc_snd_nxt; +u16 bc_ackers;bool loopback;bool events; };
@@ -258,6 +260,7 @@ static struct tipc_member *tipc_group_create_member(struct tipc_group *grp, m->group = grp; m->node = node; m->port = port; + m->bc_acked = grp->bc_snd_nxt -1 ; grp->member_cnt++;tipc_group_add_to_tree (grp, m);tipc_nlist_add (&grp->dests, m->node);
@@ -275,6 +278,11 @@ static void tipc_group_delete_member(struct tipc_group *grp, {rb_erase (&m->tree_node, &grp->members); grp->member_cnt--; + +/* Check if we were waiting for replicast ack from this member */ +if (grp->bc_ackers &&less (m->bc_acked, grp->bc_snd_nxt -1 )) + grp->bc_ackers--; +list_del_init (&m->list);list_del_init (&m->congested);
@@ -325,16 +333,23 @@ void tipc_group_update_member(struct tipc_member *m, int len)list_add_tail (&m->congested, &grp->congested); } -void tipc_group_update_bc_members (struct tipc_group *grp,int len) +void tipc_group_update_bc_members (struct tipc_group *grp,int len,bool ack) { +u16 prev = grp->bc_snd_nxt -1 ;struct tipc_member *m;struct rb_node *n;for (n =rb_first (&grp->members); n; n =rb_next (n)) { m = container_of(n, struct tipc_member, tree_node); -if (tipc_group_is_enabled (m)) +if (tipc_group_is_enabled (m)) {tipc_group_update_member (m, len); + m->bc_acked = prev; + } } + +/* Mark number of acknowledges to expect, if any */ +if (ack) + grp->bc_ackers = grp->member_cnt; grp->bc_snd_nxt++; }
@@ -372,6 +387,10 @@ bool tipc_group_bc_cong(struct tipc_group *grp, int len) {struct tipc_member *m =NULL ; +/* If prev bcast was replicast, reject until all receivers have acked */ +if (grp->bc_ackers) +return true; +if (list_empty (&grp->congested))return false;
@@ -391,7 +410,7 @@ static void tipc_group_sort_msg(struct sk_buff *skb, struct sk_buff_head *defq)struct sk_buff *_skb, *tmp;int mtyp =msg_type (hdr); -/* Bcast may be bypassed by unicast, - sort it in */ +/* Bcast may be bypassed by unicast or other bcast, - sort it in */ if (mtyp ==TIPC_GRP_BCAST_MSG || mtyp ==TIPC_GRP_MCAST_MSG ) { skb_queue_walk_safe(defq, _skb, tmp) { _hdr =buf_msg (_skb);
@@ -412,10 +431,10 @@ void tipc_group_filter_msg(struct tipc_group *grp, struct sk_buff_head *inputq, struct sk_buff_head *xmitq) {struct sk_buff *skb =__skb_dequeue (inputq); +bool ack, deliver, update;struct sk_buff_head *defq;struct tipc_member *m;struct tipc_msg *hdr; -bool deliver, update;u32 node, port;int mtyp, blks;
@@ -451,6 +470,7 @@ void tipc_group_filter_msg(struct tipc_group *grp, struct sk_buff_head *inputq, hdr =buf_msg (skb); mtyp =msg_type (hdr); deliver = true; + ack = false; update = false;if (more (msg_grp_bc_seqno (hdr), m->bc_rcv_nxt))
@@ -466,6 +486,7 @@ void tipc_group_filter_msg(struct tipc_group *grp, struct sk_buff_head *inputq,/* Fall thru */ case TIPC_GRP_BCAST_MSG : m->bc_rcv_nxt++; + ack =msg_grp_bc_ack_req (hdr);break ;case TIPC_GRP_UCAST_MSG :break ;
@@ -480,6 +501,9 @@ void tipc_group_filter_msg(struct tipc_group *grp, struct sk_buff_head *inputq,else kfree_skb (skb); +if (ack) +tipc_group_proto_xmit (grp, m,GRP_ACK_MSG , xmitq); +if (!update)continue ;
@@ -540,6 +564,8 @@ static void tipc_group_proto_xmit(struct tipc_group *grp, struct tipc_member *m, }else if (mtyp ==GRP_ADV_MSG ) {msg_set_adv_win (hdr, adv); m->advertised += adv; + }else if (mtyp ==GRP_ACK_MSG ) { +msg_set_grp_bc_acked (hdr, m->bc_rcv_nxt); }__skb_queue_tail (xmitq, skb); }
@@ -593,7 +619,7 @@ void tipc_group_proto_rcv(struct tipc_group *grp, bool *usr_wakeup, }/* Otherwise deliver already received WITHDRAW event */ __skb_queue_tail (inputq, m->event_msg); - *usr_wakeup = m->usr_pending; + *usr_wakeup = true;tipc_group_delete_member (grp, m);list_del_init (&m->congested);return ;
@@ -605,6 +631,15 @@ void tipc_group_proto_rcv(struct tipc_group *grp, bool *usr_wakeup, m->usr_pending = false;list_del_init (&m->congested);return ; +case GRP_ACK_MSG : +if (!m) +return ; + m->bc_acked =msg_grp_bc_acked (hdr); +if (--grp->bc_ackers) +break ; + *usr_wakeup = true; + m->usr_pending = false; +return ;default :pr_warn ("Received unknown GROUP_PROTO message\n" ); }
@@ -678,7 +713,7 @@ void tipc_group_member_evt(struct tipc_group *grp,TIPC_SKB_CB (skb)->orig_member = m->instance; - *usr_wakeup = m->usr_pending; + *usr_wakeup = true; m->usr_pending = false;/* Hold back event if more messages might be expected */
net/tipc/group.h +1 -3
@@ -61,7 +61,7 @@ void tipc_group_proto_rcv(struct tipc_group *grp, bool *wakeup,struct tipc_msg *hdr, struct sk_buff_head *inputq, struct sk_buff_head *xmitq); -void tipc_group_update_bc_members (struct tipc_group *grp,int len); +void tipc_group_update_bc_members (struct tipc_group *grp,int len,bool ack);bool tipc_group_cong (struct tipc_group *grp,u32 dnode,u32 dport,int len,struct tipc_member **m);bool tipc_group_bc_cong (struct tipc_group *grp,int len);
@@ -69,7 +69,5 @@ void tipc_group_update_rcv_win(struct tipc_group *grp, int blks, u32 node, u32 port, struct sk_buff_head *xmitq);u16 tipc_group_bc_snd_nxt (struct tipc_group *grp);void tipc_group_update_member (struct tipc_member *m,int len); -struct tipc_member *tipc_group_find_sender (struct tipc_group *grp, -u32 node,u32 port);int tipc_group_size (struct tipc_group *grp);#endif
net/tipc/link.c +2 -3
@@ -1046,13 +1046,12 @@ static bool tipc_data_input(struct tipc_link *l, struct sk_buff *skb,case TIPC_MEDIUM_IMPORTANCE :case TIPC_HIGH_IMPORTANCE :case TIPC_CRITICAL_IMPORTANCE : -if (unlikely (msg_mcast (hdr))) { +if (unlikely (msg_in_group (hdr) ||msg_mcast (hdr))) {skb_queue_tail (l->bc_rcvlink->inputq, skb);return true; } -case CONN_MANAGER :case GROUP_PROTOCOL : -skb_queue_tail (inputq, skb); +case CONN_MANAGER :return true;case NAME_DISTRIBUTOR : l->bc_rcvlink->state =LINK_ESTABLISHED ;
net/tipc/msg.h +21 -0
@@ -547,6 +547,7 @@ static inline void msg_set_nameupper(struct tipc_msg *m, u32 n)#define GRP_JOIN_MSG 0#define GRP_LEAVE_MSG 1#define GRP_ADV_MSG 2 +#define GRP_ACK_MSG 3/* * Word 1
@@ -839,6 +840,16 @@ static inline void msg_set_grp_bc_syncpt(struct tipc_msg *m, u16 n)msg_set_bits (m,9 ,16 ,0xffff , n); } +static inline u16 msg_grp_bc_acked (struct tipc_msg *m) +{ +return msg_bits (m,9 ,16 ,0xffff ); +} + +static inline void msg_set_grp_bc_acked (struct tipc_msg *m,u16 n) +{ +msg_set_bits (m,9 ,16 ,0xffff , n); +} +/* Word 10 */ static inline u16 msg_grp_evt (struct tipc_msg *m)
@@ -851,6 +862,16 @@ static inline void msg_set_grp_evt(struct tipc_msg *m, int n)msg_set_bits (m,10 ,0 ,0x3 , n); } +static inline u16 msg_grp_bc_ack_req (struct tipc_msg *m) +{ +return msg_bits (m,10 ,0 ,0x1 ); +} + +static inline void msg_set_grp_bc_ack_req (struct tipc_msg *m,bool n) +{ +msg_set_bits (m,10 ,0 ,0x1 , n); +} +static inline u16 msg_grp_bc_seqno (struct tipc_msg *m) {return msg_bits (m,10 ,16 ,0xffff );
net/tipc/socket.c +29 -5
@@ -831,6 +831,7 @@ static int tipc_send_group_msg(struct net *net, struct tipc_sock *tsk, u32 dnode, u32 dport, int dlen) { u16 bc_snd_nxt = tipc_group_bc_snd_nxt(tsk->group); +struct tipc_mc_method *method = &tsk->mc_method;int blks =tsk_blocks (GROUP_H_SIZE + dlen);struct tipc_msg *hdr = &tsk->phdr;struct sk_buff_head pkts;
@@ -857,9 +858,12 @@ static int tipc_send_group_msg(struct net *net, struct tipc_sock *tsk, tsk->cong_link_cnt++; } -/* Update send window and sequence number */ +/* Update send window */ tipc_group_update_member (mb, blks); +/* A broadcast sent within next EXPIRE period must follow same path */ + method->rcast = true; + method->mandatory = true;return dlen; }
@@ -1008,6 +1012,7 @@ static int tipc_send_group_bcast(struct socket *sock, struct msghdr *m,struct tipc_group *grp = tsk->group;struct tipc_nlist *dsts =tipc_group_dests (grp);struct tipc_mc_method *method = &tsk->mc_method; +bool ack = method->mandatory && method->rcast;int blks =tsk_blocks (MCAST_H_SIZE + dlen);struct tipc_msg *hdr = &tsk->phdr;int mtu =tipc_bcast_get_mtu (net);
@@ -1036,6 +1041,9 @@ static int tipc_send_group_bcast(struct socket *sock, struct msghdr *m,msg_set_destnode (hdr,0 );msg_set_grp_bc_seqno (hdr,tipc_group_bc_snd_nxt (grp)); +/* Avoid getting stuck with repeated forced replicasts */ +msg_set_grp_bc_ack_req (hdr, ack); +/* Build message as chain of buffers */ skb_queue_head_init (&pkts); rc =tipc_msg_build (hdr, m,0 , dlen, mtu, &pkts);
@@ -1043,13 +1051,17 @@ static int tipc_send_group_bcast(struct socket *sock, struct msghdr *m,return rc;/* Send message */ - rc =tipc_mcast_xmit (net, &pkts, method, dsts, - &tsk->cong_link_cnt); + rc =tipc_mcast_xmit (net, &pkts, method, dsts, &tsk->cong_link_cnt);if (unlikely (rc))return rc;/* Update broadcast sequence number and send windows */ -tipc_group_update_bc_members (tsk->group, blks); +tipc_group_update_bc_members (tsk->group, blks, ack); + +/* Broadcast link is now free to choose method for next broadcast */ + method->mandatory = false; + method->expires = jiffies; +return dlen; }
@@ -1113,7 +1125,7 @@ void tipc_sk_mcast_rcv(struct net *net, struct sk_buff_head *arrvq,u32 portid, oport, onode;struct list_head dports;struct tipc_msg *msg; -int hsz; +int user, mtyp, hsz;__skb_queue_head_init (&tmpq);INIT_LIST_HEAD (&dports);
@@ -1121,6 +1133,18 @@ void tipc_sk_mcast_rcv(struct net *net, struct sk_buff_head *arrvq, skb =tipc_skb_peek (arrvq, &inputq->lock);for (; skb; skb =tipc_skb_peek (arrvq, &inputq->lock)) { msg =buf_msg (skb); + user =msg_user (msg); + mtyp =msg_type (msg); +if (mtyp ==TIPC_GRP_UCAST_MSG || user ==GROUP_PROTOCOL ) { +spin_lock_bh (&inputq->lock); +if (skb_peek (arrvq) == skb) { +__skb_dequeue (arrvq); +__skb_queue_tail (inputq, skb); + } +refcount_dec (&skb->users); +spin_unlock_bh (&inputq->lock); +continue ; + } hsz =skb_headroom (skb) +msg_hdr_sz (msg); oport =msg_origport (msg); onode =msg_orignode (msg);
Signature · 1 line
2.1.4
PATCH v2 18/18 tipc: add multipoint-to-point flow control
In reply to Jon MaloyWe already have point-to-multipoint flow control within a group. But we even need the opposite; -a scheme which can handle that potentially hundreds of sources may try to send messages to the same destination simultaneously without causing buffer overflow at the recipient. This commit adds such a mechanism.
The algorithm works as follows:
- When a member detects a new, joining member, it initially set its state to JOINED and advertises a minimum window to the new member. This window is chosen so that the new member can send exactly one maximum sized message, or several smaller ones, to the recipient before it must stop and wait for an additional advertisement. This minimum window ADV_IDLE is set to 65 1kB blocks.
- When a member receives the first data message from a JOINED member, it changes the state of the latter to ACTIVE, and advertises a larger window ADV_ACTIVE = 12 x ADV_IDLE blocks to the sender, so it can continue sending with minimal disturbances to the data flow.
- The active members are kept in a dedicated linked list. Each time a message is received from an active member, it will be moved to the tail of that list. This way, we keep a record of which members have been most (tail) and least (head) recently active.
- There is a maximum number (16) of permitted simultaneous active senders per receiver. When this limit is reached, the receiver will not advertise anything immediately to a new sender, but instead put it in a PENDING state, and add it to a corresponding queue. At the same time, it will pick the least recently active member, send it an advertisement RECLAIM message, and set this member to state RECLAIMING.
- The reclaimee member has to respond with a REMIT message, meaning that it goes back to a send window of ADV_IDLE, and returns its unused advertised blocks beyond that value to the reclaiming member.
- When the reclaiming member receives the REMIT message, it unlinks the reclaimee from its active list, resets its state to JOINED, and notes that it is now back at ADV_IDLE advertised blocks to that member. If there are still unread data messages sent out by reclaimee before the REMIT, the member goes into an intermediate state REMITTED, where it stays until the said messages have been consumed.
- The returned advertised blocks can now be re-advertised to the pending member, which is now set to state ACTIVE and added to the active member list.
- To be proactive, i.e., to minimize the risk that any member will end up in the pending queue, we start reclaiming resources already when the number of active members exceeds 3/4 of the permitted maximum.
--- net/tipc/group.c | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- net/tipc/msg.h | 12 ++++++ 2 files changed, 136 insertions(+), 5 deletions(-)
net/tipc/group.c +124 -5
@@ -54,6 +54,10 @@ enum mbr_state {MBR_JOINING ,MBR_PUBLISHED ,MBR_JOINED , +MBR_PENDING , +MBR_ACTIVE , +MBR_RECLAIMING , +MBR_REMITTED , MBR_LEAVING };
@@ -79,6 +83,9 @@ struct tipc_member {struct tipc_group {struct rb_root members;struct list_head congested; +struct list_head pending; +struct list_head active; +struct list_head reclaiming;struct tipc_nlist dests;struct net *net;int subid;
@@ -88,6 +95,8 @@ struct tipc_group {u32 scope;u32 portid;u16 member_cnt; +u16 active_cnt; +u16 max_active;u16 bc_snd_nxt;u16 bc_ackers;bool loopback;
@@ -97,12 +106,29 @@ struct tipc_group {static void tipc_group_proto_xmit (struct tipc_group *grp,struct tipc_member *m,int mtyp,struct sk_buff_head *xmitq); +static void tipc_group_decr_active (struct tipc_group *grp, +struct tipc_member *m) +{ +if (m->state ==MBR_ACTIVE || m->state ==MBR_RECLAIMING ) + grp->active_cnt--; +} +static int tipc_group_rcvbuf_limit (struct tipc_group *grp) { +int max_active, active_pool, idle_pool;int mcnt = grp->member_cnt +1 ; +/* Limit simultaneous reception from other members */ + max_active =min (mcnt /8 ,64 ); + max_active =max (max_active,16 ); + grp->max_active = max_active; + +/* Reserve blocks for active and idle members */ + active_pool = max_active *ADV_ACTIVE ; + idle_pool = (mcnt - max_active) *ADV_IDLE ; +/* Scale to bytes, considering worst-case truesize/msgsize ratio */ -return mcnt *ADV_ACTIVE *FLOWCTL_BLK_SZ *4 ; +return (active_pool + idle_pool) *FLOWCTL_BLK_SZ *4 ; }u16 tipc_group_bc_snd_nxt (struct tipc_group *grp)
@@ -143,6 +169,9 @@ struct tipc_group *tipc_group_create(struct net *net, u32 portid,return NULL ;tipc_nlist_init (&grp->dests,tipc_own_addr (net));INIT_LIST_HEAD (&grp->congested); +INIT_LIST_HEAD (&grp->active); +INIT_LIST_HEAD (&grp->pending); +INIT_LIST_HEAD (&grp->reclaiming); grp->members =RB_ROOT ; grp->net = net; grp->portid = portid;
@@ -286,6 +315,7 @@ static void tipc_group_delete_member(struct tipc_group *grp,list_del_init (&m->list);list_del_init (&m->congested); +tipc_group_decr_active (grp, m);/* If last member on a node, remove node from dest list */ if (!tipc_group_find_node (grp, m->node))
@@ -378,6 +408,10 @@ bool tipc_group_cong(struct tipc_group *grp, u32 dnode, u32 dport,return true;if (state ==MBR_JOINED && adv ==ADV_IDLE )return true; +if (state ==MBR_ACTIVE && adv ==ADV_ACTIVE ) +return true; +if (state ==MBR_PENDING && adv ==ADV_IDLE ) +return true;skb_queue_head_init (&xmitq);tipc_group_proto_xmit (grp, m,GRP_ADV_MSG , &xmitq);tipc_node_distr_xmit (grp->net, &xmitq);
@@ -523,7 +557,11 @@ void tipc_group_filter_msg(struct tipc_group *grp, struct sk_buff_head *inputq,void tipc_group_update_rcv_win (struct tipc_group *grp,int blks,u32 node,u32 port,struct sk_buff_head *xmitq) { -struct tipc_member *m; +struct list_head *active = &grp->active; +int max_active = grp->max_active; +int reclaim_limit = max_active *3 /4 ; +int active_cnt = grp->active_cnt; +struct tipc_member *m, *rm; m =tipc_group_find_member (grp, node, port);if (!m)
@@ -533,9 +571,41 @@ void tipc_group_update_rcv_win(struct tipc_group *grp, int blks, u32 node,switch (m->state) {case MBR_JOINED : -if (m->advertised <= (ADV_ACTIVE -ADV_UNIT )) +/* Reclaim advertised space from least active member */ +if (!list_empty (active) && active_cnt >= reclaim_limit) { + rm = list_first_entry(active, struct tipc_member, list); + rm->state =MBR_RECLAIMING ; +list_move_tail (&rm->list, &grp->reclaiming); +tipc_group_proto_xmit (grp, rm,GRP_RECLAIM_MSG , xmitq); + } +/* If max active, become pending and wait for reclaimed space */ +if (active_cnt >= max_active) { + m->state =MBR_PENDING ; +list_add_tail (&m->list, &grp->pending); +break ; + } +/* Otherwise become active */ + m->state =MBR_ACTIVE ; +list_add_tail (&m->list, &grp->active); + grp->active_cnt++; +/* Fall through */ +case MBR_ACTIVE : +if (!list_is_last (&m->list, &grp->active)) +list_move_tail (&m->list, &grp->active); +if (m->advertised > (ADV_ACTIVE *3 /4 )) +break ; +tipc_group_proto_xmit (grp, m,GRP_ADV_MSG , xmitq); +break ; +case MBR_REMITTED : +if (m->advertised >ADV_IDLE ) +break ; + m->state =MBR_JOINED ; +if (m->advertised <ADV_IDLE ) { +pr_warn_ratelimited ("Rcv unexpected msg after REMIT\n" );tipc_group_proto_xmit (grp, m,GRP_ADV_MSG , xmitq); + }break ; +case MBR_RECLAIMING :case MBR_DISCOVERED :case MBR_JOINING :case MBR_LEAVING :
@@ -557,8 +627,10 @@ static void tipc_group_proto_xmit(struct tipc_group *grp, struct tipc_member *m,if (!skb)return ; -if (m->state ==MBR_JOINED ) +if (m->state ==MBR_ACTIVE ) adv =ADV_ACTIVE - m->advertised; +else if (m->state ==MBR_JOINED || m->state ==MBR_PENDING ) + adv =ADV_IDLE - m->advertised; hdr =buf_msg (skb);
@@ -573,6 +645,8 @@ static void tipc_group_proto_xmit(struct tipc_group *grp, struct tipc_member *m, m->advertised += adv; }else if (mtyp ==GRP_ACK_MSG ) {msg_set_grp_bc_acked (hdr, m->bc_rcv_nxt); + }else if (mtyp ==GRP_REMIT_MSG ) { +msg_set_grp_remitted (hdr, m->window); }__skb_queue_tail (xmitq, skb); }
@@ -583,8 +657,9 @@ void tipc_group_proto_rcv(struct tipc_group *grp, bool *usr_wakeup, {u32 node =msg_orignode (hdr);u32 port =msg_origport (hdr); -struct tipc_member *m; +struct tipc_member *m, *pm;struct tipc_msg *ehdr; +u16 remitted, in_flight;if (!grp)return ;
@@ -626,6 +701,7 @@ void tipc_group_proto_rcv(struct tipc_group *grp, bool *usr_wakeup,/* Wait until WITHDRAW event is received */ if (m->state !=MBR_LEAVING ) { +tipc_group_decr_active (grp, m); m->state =MBR_LEAVING ;return ; }
@@ -653,6 +729,48 @@ void tipc_group_proto_rcv(struct tipc_group *grp, bool *usr_wakeup, *usr_wakeup = true; m->usr_pending = false;return ; +case GRP_RECLAIM_MSG : +if (!m) +return ; + *usr_wakeup = m->usr_pending; + m->usr_pending = false; +tipc_group_proto_xmit (grp, m,GRP_REMIT_MSG , xmitq); + m->window =ADV_IDLE ; +return ; +case GRP_REMIT_MSG : +if (!m || m->state !=MBR_RECLAIMING ) +return ; + +list_del_init (&m->list); + grp->active_cnt--; + remitted =msg_grp_remitted (hdr); + +/* Messages preceding the REMIT still in receive queue */ +if (m->advertised > remitted) { + m->state =MBR_REMITTED ; + in_flight = m->advertised - remitted; + } +/* All messages preceding the REMIT have been read */ +if (m->advertised <= remitted) { + m->state =MBR_JOINED ; + in_flight =0 ; + } +/* ..and the REMIT overtaken by more messages => re-advertise */ +if (m->advertised < remitted) +tipc_group_proto_xmit (grp, m,GRP_ADV_MSG , xmitq); + + m->advertised =ADV_IDLE + in_flight; + +/* Set oldest pending member to active and advertise */ +if (list_empty (&grp->pending)) +return ; + pm = list_first_entry(&grp->pending, struct tipc_member, list); + pm->state =MBR_ACTIVE ; +list_move_tail (&pm->list, &grp->active); + grp->active_cnt++; +if (pm->advertised <= (ADV_ACTIVE *3 /4 )) +tipc_group_proto_xmit (grp, pm,GRP_ADV_MSG , xmitq); +return ;default :pr_warn ("Received unknown GROUP_PROTO message\n" ); }
@@ -735,6 +853,7 @@ void tipc_group_member_evt(struct tipc_group *grp,/* Hold back event if more messages might be expected */ if (m->state !=MBR_LEAVING && node_up) { m->event_msg = skb; +tipc_group_decr_active (grp, m); m->state =MBR_LEAVING ; }else {if (node_up)
net/tipc/msg.h +12 -0
@@ -548,6 +548,8 @@ static inline void msg_set_nameupper(struct tipc_msg *m, u32 n)#define GRP_LEAVE_MSG 1#define GRP_ADV_MSG 2#define GRP_ACK_MSG 3 +#define GRP_RECLAIM_MSG 4 +#define GRP_REMIT_MSG 5/* * Word 1
@@ -850,6 +852,16 @@ static inline void msg_set_grp_bc_acked(struct tipc_msg *m, u16 n)msg_set_bits (m,9 ,16 ,0xffff , n); } +static inline u16 msg_grp_remitted (struct tipc_msg *m) +{ +return msg_bits (m,9 ,16 ,0xffff ); +} + +static inline void msg_set_grp_remitted (struct tipc_msg *m,u16 n) +{ +msg_set_bits (m,9 ,16 ,0xffff , n); +} +/* Word 10 */ static inline u16 msg_grp_evt (struct tipc_msg *m)
Signature · 1 line
2.1.4
David Miller
maintainerFrom: Jon Maloy <[email protected]>
Date: Fri, 13 Oct 2017 11:04:16 +0200
Quoted 5 lines
With this commit series we introduce a 'Group Communication' feature in order to resolve the datagram and multicast flow control problem. This new feature makes it possible for a user to instantiate multiple private virtual brokerless message buses by just creating and joining member sockets.
Series applied.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot