Skip to content

Commit a00344b

Browse files
committed
Merge branch 'tipc-comm-groups'
Jon Maloy says: ==================== 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. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 2d0d21c + 04d7b57 commit a00344b

File tree

16 files changed

+1997
-283
lines changed

16 files changed

+1997
-283
lines changed

include/uapi/linux/tipc.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,21 @@ struct sockaddr_tipc {
231231
#define TIPC_SOCK_RECVQ_DEPTH 132 /* Default: none (read only) */
232232
#define TIPC_MCAST_BROADCAST 133 /* Default: TIPC selects. No arg */
233233
#define TIPC_MCAST_REPLICAST 134 /* Default: TIPC selects. No arg */
234+
#define TIPC_GROUP_JOIN 135 /* Takes struct tipc_group_req* */
235+
#define TIPC_GROUP_LEAVE 136 /* No argument */
236+
237+
/*
238+
* Flag values
239+
*/
240+
#define TIPC_GROUP_LOOPBACK 0x1 /* Receive copy of sent msg when match */
241+
#define TIPC_GROUP_MEMBER_EVTS 0x2 /* Receive membership events in socket */
242+
243+
struct tipc_group_req {
244+
__u32 type; /* group id */
245+
__u32 instance; /* member id */
246+
__u32 scope; /* zone/cluster/node */
247+
__u32 flags;
248+
};
234249

235250
/*
236251
* Maximum sizes of TIPC bearer-related names (including terminating NULL)

net/tipc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ tipc-y += addr.o bcast.o bearer.o \
88
core.o link.o discover.o msg.o \
99
name_distr.o subscr.o monitor.o name_table.o net.o \
1010
netlink.o netlink_compat.o node.o socket.o eth_media.o \
11-
server.o socket.o
11+
server.o socket.o group.o
1212

1313
tipc-$(CONFIG_TIPC_MEDIA_UDP) += udp_media.o
1414
tipc-$(CONFIG_TIPC_MEDIA_IB) += ib_media.o

net/tipc/bcast.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,20 +258,20 @@ static int tipc_bcast_xmit(struct net *net, struct sk_buff_head *pkts,
258258
static int tipc_rcast_xmit(struct net *net, struct sk_buff_head *pkts,
259259
struct tipc_nlist *dests, u16 *cong_link_cnt)
260260
{
261+
struct tipc_dest *dst, *tmp;
261262
struct sk_buff_head _pkts;
262-
struct u32_item *n, *tmp;
263-
u32 dst, selector;
263+
u32 dnode, selector;
264264

265265
selector = msg_link_selector(buf_msg(skb_peek(pkts)));
266266
skb_queue_head_init(&_pkts);
267267

268-
list_for_each_entry_safe(n, tmp, &dests->list, list) {
269-
dst = n->value;
270-
if (!tipc_msg_pskb_copy(dst, pkts, &_pkts))
268+
list_for_each_entry_safe(dst, tmp, &dests->list, list) {
269+
dnode = dst->node;
270+
if (!tipc_msg_pskb_copy(dnode, pkts, &_pkts))
271271
return -ENOMEM;
272272

273273
/* Any other return value than -ELINKCONG is ignored */
274-
if (tipc_node_xmit(net, &_pkts, dst, selector) == -ELINKCONG)
274+
if (tipc_node_xmit(net, &_pkts, dnode, selector) == -ELINKCONG)
275275
(*cong_link_cnt)++;
276276
}
277277
return 0;
@@ -554,21 +554,21 @@ void tipc_nlist_add(struct tipc_nlist *nl, u32 node)
554554
{
555555
if (node == nl->self)
556556
nl->local = true;
557-
else if (u32_push(&nl->list, node))
557+
else if (tipc_dest_push(&nl->list, node, 0))
558558
nl->remote++;
559559
}
560560

561561
void tipc_nlist_del(struct tipc_nlist *nl, u32 node)
562562
{
563563
if (node == nl->self)
564564
nl->local = false;
565-
else if (u32_del(&nl->list, node))
565+
else if (tipc_dest_del(&nl->list, node, 0))
566566
nl->remote--;
567567
}
568568

569569
void tipc_nlist_purge(struct tipc_nlist *nl)
570570
{
571-
u32_list_purge(&nl->list);
571+
tipc_dest_list_purge(&nl->list);
572572
nl->remote = 0;
573573
nl->local = 0;
574574
}

net/tipc/core.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ static inline struct list_head *tipc_nodes(struct net *net)
132132
return &tipc_net(net)->node_list;
133133
}
134134

135+
static inline struct tipc_server *tipc_topsrv(struct net *net)
136+
{
137+
return tipc_net(net)->topsrv;
138+
}
139+
135140
static inline unsigned int tipc_hashfn(u32 addr)
136141
{
137142
return addr & (NODE_HTABLE_SIZE - 1);

0 commit comments

Comments
 (0)