Skip to content

Commit f70d37b

Browse files
Jon Maloydavem330
authored andcommitted
tipc: add new function for sending multiple small messages
We 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. Signed-off-by: Jon Maloy <[email protected]> Acked-by: Ying Xue <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 64ac5f5 commit f70d37b

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

net/tipc/node.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,22 @@ int tipc_node_xmit_skb(struct net *net, struct sk_buff *skb, u32 dnode,
12541254
return 0;
12551255
}
12561256

1257+
/* tipc_node_distr_xmit(): send single buffer msgs to individual destinations
1258+
* Note: this is only for SYSTEM_IMPORTANCE messages, which cannot be rejected
1259+
*/
1260+
int tipc_node_distr_xmit(struct net *net, struct sk_buff_head *xmitq)
1261+
{
1262+
struct sk_buff *skb;
1263+
u32 selector, dnode;
1264+
1265+
while ((skb = __skb_dequeue(xmitq))) {
1266+
selector = msg_origport(buf_msg(skb));
1267+
dnode = msg_destnode(buf_msg(skb));
1268+
tipc_node_xmit_skb(net, skb, dnode, selector);
1269+
}
1270+
return 0;
1271+
}
1272+
12571273
void tipc_node_broadcast(struct net *net, struct sk_buff *skb)
12581274
{
12591275
struct sk_buff *txskb;

net/tipc/node.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ int tipc_node_get_linkname(struct net *net, u32 bearer_id, u32 node,
6868
char *linkname, size_t len);
6969
int tipc_node_xmit(struct net *net, struct sk_buff_head *list, u32 dnode,
7070
int selector);
71+
int tipc_node_distr_xmit(struct net *net, struct sk_buff_head *list);
7172
int tipc_node_xmit_skb(struct net *net, struct sk_buff *skb, u32 dest,
7273
u32 selector);
7374
void tipc_node_subscribe(struct net *net, struct list_head *subscr, u32 addr);

net/tipc/socket.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,14 +1740,11 @@ static void tipc_sk_filter_rcv(struct sock *sk, struct sk_buff *skb,
17401740
* @skb: message
17411741
*
17421742
* Caller must hold socket lock
1743-
*
1744-
* Returns 0
17451743
*/
17461744
static int tipc_sk_backlog_rcv(struct sock *sk, struct sk_buff *skb)
17471745
{
17481746
unsigned int before = sk_rmem_alloc_get(sk);
17491747
struct sk_buff_head xmitq;
1750-
u32 dnode, selector;
17511748
unsigned int added;
17521749

17531750
__skb_queue_head_init(&xmitq);
@@ -1757,11 +1754,7 @@ static int tipc_sk_backlog_rcv(struct sock *sk, struct sk_buff *skb)
17571754
atomic_add(added, &tipc_sk(sk)->dupl_rcvcnt);
17581755

17591756
/* Send pending response/rejected messages, if any */
1760-
while ((skb = __skb_dequeue(&xmitq))) {
1761-
selector = msg_origport(buf_msg(skb));
1762-
dnode = msg_destnode(buf_msg(skb));
1763-
tipc_node_xmit_skb(sock_net(sk), skb, dnode, selector);
1764-
}
1757+
tipc_node_distr_xmit(sock_net(sk), &xmitq);
17651758
return 0;
17661759
}
17671760

@@ -1840,10 +1833,7 @@ void tipc_sk_rcv(struct net *net, struct sk_buff_head *inputq)
18401833
spin_unlock_bh(&sk->sk_lock.slock);
18411834
}
18421835
/* Send pending response/rejected messages, if any */
1843-
while ((skb = __skb_dequeue(&xmitq))) {
1844-
dnode = msg_destnode(buf_msg(skb));
1845-
tipc_node_xmit_skb(net, skb, dnode, dport);
1846-
}
1836+
tipc_node_distr_xmit(sock_net(sk), &xmitq);
18471837
sock_put(sk);
18481838
continue;
18491839
}

0 commit comments

Comments
 (0)