Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 187930
b: refs/heads/master
c: d0021b2
h: refs/heads/master
v: v3
  • Loading branch information
Neil Horman authored and David S. Miller committed Mar 4, 2010
1 parent c82cf51 commit 2d6d92d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 54 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: 6d55cb91a0020ac0d78edcad61efd6c8cf5785a3
refs/heads/master: d0021b252eaf65ca07ed14f0d66425dd9ccab9a6
37 changes: 6 additions & 31 deletions trunk/net/tipc/bearer.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@

#define MAX_ADDR_STR 32

static struct media *media_list = NULL;
static struct media media_list[MAX_MEDIA];
static u32 media_count = 0;

struct bearer *tipc_bearers = NULL;
struct bearer tipc_bearers[MAX_BEARERS];

/**
* media_name_valid - validate media name
Expand Down Expand Up @@ -108,9 +108,11 @@ int tipc_register_media(u32 media_type,
int res = -EINVAL;

write_lock_bh(&tipc_net_lock);
if (!media_list)
goto exit;

if (tipc_mode != TIPC_NET_MODE) {
warn("Media <%s> rejected, not in networked mode yet\n", name);
goto exit;
}
if (!media_name_valid(name)) {
warn("Media <%s> rejected, illegal name\n", name);
goto exit;
Expand Down Expand Up @@ -660,33 +662,10 @@ int tipc_disable_bearer(const char *name)



int tipc_bearer_init(void)
{
int res;

write_lock_bh(&tipc_net_lock);
tipc_bearers = kcalloc(MAX_BEARERS, sizeof(struct bearer), GFP_ATOMIC);
media_list = kcalloc(MAX_MEDIA, sizeof(struct media), GFP_ATOMIC);
if (tipc_bearers && media_list) {
res = 0;
} else {
kfree(tipc_bearers);
kfree(media_list);
tipc_bearers = NULL;
media_list = NULL;
res = -ENOMEM;
}
write_unlock_bh(&tipc_net_lock);
return res;
}

void tipc_bearer_stop(void)
{
u32 i;

if (!tipc_bearers)
return;

for (i = 0; i < MAX_BEARERS; i++) {
if (tipc_bearers[i].active)
tipc_bearers[i].publ.blocked = 1;
Expand All @@ -695,10 +674,6 @@ void tipc_bearer_stop(void)
if (tipc_bearers[i].active)
bearer_disable(tipc_bearers[i].publ.name);
}
kfree(tipc_bearers);
kfree(media_list);
tipc_bearers = NULL;
media_list = NULL;
media_count = 0;
}

Expand Down
2 changes: 1 addition & 1 deletion trunk/net/tipc/bearer.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ struct bearer_name {

struct link;

extern struct bearer *tipc_bearers;
extern struct bearer tipc_bearers[];

void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a);
struct sk_buff *tipc_media_get_names(void);
Expand Down
25 changes: 4 additions & 21 deletions trunk/net/tipc/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@
*/

DEFINE_RWLOCK(tipc_net_lock);
struct network tipc_net = { NULL };
struct _zone *tipc_zones[256] = { NULL, };
struct network tipc_net = { tipc_zones };

struct tipc_node *tipc_net_select_remote_node(u32 addr, u32 ref)
{
Expand Down Expand Up @@ -158,28 +159,12 @@ void tipc_net_send_external_routes(u32 dest)
}
}

static int net_init(void)
{
memset(&tipc_net, 0, sizeof(tipc_net));
tipc_net.zones = kcalloc(tipc_max_zones + 1, sizeof(struct _zone *), GFP_ATOMIC);
if (!tipc_net.zones) {
return -ENOMEM;
}
return 0;
}

static void net_stop(void)
{
u32 z_num;

if (!tipc_net.zones)
return;

for (z_num = 1; z_num <= tipc_max_zones; z_num++) {
for (z_num = 1; z_num <= tipc_max_zones; z_num++)
tipc_zone_delete(tipc_net.zones[z_num]);
}
kfree(tipc_net.zones);
tipc_net.zones = NULL;
}

static void net_route_named_msg(struct sk_buff *buf)
Expand Down Expand Up @@ -282,9 +267,7 @@ int tipc_net_start(u32 addr)
tipc_named_reinit();
tipc_port_reinit();

if ((res = tipc_bearer_init()) ||
(res = net_init()) ||
(res = tipc_cltr_init()) ||
if ((res = tipc_cltr_init()) ||
(res = tipc_bclink_init())) {
return res;
}
Expand Down

0 comments on commit 2d6d92d

Please sign in to comment.