tipc: simplify socket multicast reception
The structure 'tipc_port_list' is used to collect port numbers representing multicast destination socket on a receiving node. The list is not based on a standard linked list, and is in reality optimized for the uncommon case that there are more than one multicast destinations per node. This makes the list handling unecessarily complex, and as a consequence, even the socket multicast reception becomes more complex. In this commit, we replace 'tipc_port_list' with a new 'struct tipc_plist', which is based on a standard list. We give the new list stack (push/pop) semantics, someting that simplifies the implementation of the function tipc_sk_mcast_rcv(). Reviewed-by: Ying Xue <ying.xue@windriver.com> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
708ac32cb5
commit
3c724acdd5
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* net/tipc/bcast.c: TIPC broadcast code
|
||||
*
|
||||
* Copyright (c) 2004-2006, 2014, Ericsson AB
|
||||
* Copyright (c) 2004-2006, 2014-2015, Ericsson AB
|
||||
* Copyright (c) 2004, Intel Corporation.
|
||||
* Copyright (c) 2005, 2010-2011, Wind River Systems
|
||||
* All rights reserved.
|
||||
@@ -1037,50 +1037,3 @@ static void tipc_nmap_diff(struct tipc_node_map *nm_a,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* tipc_port_list_add - add a port to a port list, ensuring no duplicates
|
||||
*/
|
||||
void tipc_port_list_add(struct tipc_port_list *pl_ptr, u32 port)
|
||||
{
|
||||
struct tipc_port_list *item = pl_ptr;
|
||||
int i;
|
||||
int item_sz = PLSIZE;
|
||||
int cnt = pl_ptr->count;
|
||||
|
||||
for (; ; cnt -= item_sz, item = item->next) {
|
||||
if (cnt < PLSIZE)
|
||||
item_sz = cnt;
|
||||
for (i = 0; i < item_sz; i++)
|
||||
if (item->ports[i] == port)
|
||||
return;
|
||||
if (i < PLSIZE) {
|
||||
item->ports[i] = port;
|
||||
pl_ptr->count++;
|
||||
return;
|
||||
}
|
||||
if (!item->next) {
|
||||
item->next = kmalloc(sizeof(*item), GFP_ATOMIC);
|
||||
if (!item->next) {
|
||||
pr_warn("Incomplete multicast delivery, no memory\n");
|
||||
return;
|
||||
}
|
||||
item->next->next = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* tipc_port_list_free - free dynamically created entries in port_list chain
|
||||
*
|
||||
*/
|
||||
void tipc_port_list_free(struct tipc_port_list *pl_ptr)
|
||||
{
|
||||
struct tipc_port_list *item;
|
||||
struct tipc_port_list *next;
|
||||
|
||||
for (item = pl_ptr->next; item; item = next) {
|
||||
next = item->next;
|
||||
kfree(item);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user