Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 195031
b: refs/heads/master
c: 43608ed
h: refs/heads/master
i:
  195029: b7dfb4c
  195027: 20f61a1
  195023: fdd9c94
v: v3
  • Loading branch information
Allan Stephens authored and David S. Miller committed May 13, 2010
1 parent 3902603 commit d89ac12
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 51 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3e22e62b6204414cf31c414d5a91897e2b718135
refs/heads/master: 43608edc2dbe83057544cf76b765ecdf63d59e8c
50 changes: 50 additions & 0 deletions trunk/net/tipc/bcast.c
Original file line number Diff line number Diff line change
Expand Up @@ -882,3 +882,53 @@ void tipc_nmap_diff(struct tipc_node_map *nm_a, struct tipc_node_map *nm_b,
}
}
}

/**
* tipc_port_list_add - add a port to a port list, ensuring no duplicates
*/

void tipc_port_list_add(struct port_list *pl_ptr, u32 port)
{
struct 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) {
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 port_list *pl_ptr)
{
struct port_list *item;
struct port_list *next;

for (item = pl_ptr->next; item; item = next) {
next = item->next;
kfree(item);
}
}

52 changes: 2 additions & 50 deletions trunk/net/tipc/bcast.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,56 +87,8 @@ static inline int tipc_nmap_equal(struct tipc_node_map *nm_a, struct tipc_node_m
void tipc_nmap_diff(struct tipc_node_map *nm_a, struct tipc_node_map *nm_b,
struct tipc_node_map *nm_diff);

/**
* tipc_port_list_add - add a port to a port list, ensuring no duplicates
*/

static inline void tipc_port_list_add(struct port_list *pl_ptr, u32 port)
{
struct 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) {
warn("Incomplete multicast delivery, no memory\n");
return;
}
item->next->next = NULL;
}
}
}

/**
* tipc_port_list_free - free dynamically created entries in port_list chain
*
* Note: First item is on stack, so it doesn't need to be released
*/

static inline void tipc_port_list_free(struct port_list *pl_ptr)
{
struct port_list *item;
struct port_list *next;

for (item = pl_ptr->next; item; item = next) {
next = item->next;
kfree(item);
}
}

void tipc_port_list_add(struct port_list *pl_ptr, u32 port);
void tipc_port_list_free(struct port_list *pl_ptr);

int tipc_bclink_init(void);
void tipc_bclink_stop(void);
Expand Down

0 comments on commit d89ac12

Please sign in to comment.