Skip to content

Commit

Permalink
Merge branch 'tipc-May10-2011' of git://git.kernel.org/pub/scm/linux/…
Browse files Browse the repository at this point in the history
…kernel/git/paulg/net-next-2.6
  • Loading branch information
David S. Miller committed May 11, 2011
2 parents 1fc19af + 972a77f commit 0074820
Show file tree
Hide file tree
Showing 15 changed files with 321 additions and 310 deletions.
2 changes: 1 addition & 1 deletion include/linux/tipc.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static inline unsigned int tipc_node(__u32 addr)
* Limiting values for messages
*/

#define TIPC_MAX_USER_MSG_SIZE 66000
#define TIPC_MAX_USER_MSG_SIZE 66000U

/*
* Message importance levels
Expand Down
7 changes: 5 additions & 2 deletions net/tipc/addr.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@
#ifndef _TIPC_ADDR_H
#define _TIPC_ADDR_H

#define TIPC_ZONE_MASK 0xff000000u
#define TIPC_CLUSTER_MASK 0xfffff000u

static inline u32 tipc_zone_mask(u32 addr)
{
return addr & 0xff000000u;
return addr & TIPC_ZONE_MASK;
}

static inline u32 tipc_cluster_mask(u32 addr)
{
return addr & 0xfffff000u;
return addr & TIPC_CLUSTER_MASK;
}

static inline int in_own_cluster(u32 addr)
Expand Down
22 changes: 1 addition & 21 deletions net/tipc/bcast.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@

#define BCLINK_WIN_DEFAULT 20 /* bcast link window size (default) */

/*
* Loss rate for incoming broadcast frames; used to test retransmission code.
* Set to N to cause every N'th frame to be discarded; 0 => don't discard any.
*/

#define TIPC_BCAST_LOSS_RATE 0

/**
* struct bcbearer_pair - a pair of bearers used by broadcast link
* @primary: pointer to primary bearer
Expand Down Expand Up @@ -414,9 +407,7 @@ int tipc_bclink_send_msg(struct sk_buff *buf)
spin_lock_bh(&bc_lock);

res = tipc_link_send_buf(bcl, buf);
if (unlikely(res == -ELINKCONG))
buf_discard(buf);
else
if (likely(res > 0))
bclink_set_last_sent();

bcl->stats.queue_sz_counts++;
Expand All @@ -434,9 +425,6 @@ int tipc_bclink_send_msg(struct sk_buff *buf)

void tipc_bclink_recv_pkt(struct sk_buff *buf)
{
#if (TIPC_BCAST_LOSS_RATE)
static int rx_count;
#endif
struct tipc_msg *msg = buf_msg(buf);
struct tipc_node *node = tipc_node_find(msg_prevnode(msg));
u32 next_in;
Expand Down Expand Up @@ -470,14 +458,6 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf)
return;
}

#if (TIPC_BCAST_LOSS_RATE)
if (++rx_count == TIPC_BCAST_LOSS_RATE) {
rx_count = 0;
buf_discard(buf);
return;
}
#endif

tipc_node_lock(node);
receive:
deferred = node->bclink.deferred_head;
Expand Down
45 changes: 29 additions & 16 deletions net/tipc/bearer.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ static u32 media_count;

struct tipc_bearer tipc_bearers[MAX_BEARERS];

static void bearer_disable(struct tipc_bearer *b_ptr);

/**
* media_name_valid - validate media name
*
Expand Down Expand Up @@ -342,15 +344,15 @@ struct sk_buff *tipc_bearer_get_names(void)
void tipc_bearer_add_dest(struct tipc_bearer *b_ptr, u32 dest)
{
tipc_nmap_add(&b_ptr->nodes, dest);
tipc_disc_update_link_req(b_ptr->link_req);
tipc_bcbearer_sort();
tipc_disc_add_dest(b_ptr->link_req);
}

void tipc_bearer_remove_dest(struct tipc_bearer *b_ptr, u32 dest)
{
tipc_nmap_remove(&b_ptr->nodes, dest);
tipc_disc_update_link_req(b_ptr->link_req);
tipc_bcbearer_sort();
tipc_disc_remove_dest(b_ptr->link_req);
}

/*
Expand Down Expand Up @@ -493,8 +495,15 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
warn("Bearer <%s> rejected, illegal name\n", name);
return -EINVAL;
}
if (!tipc_addr_domain_valid(disc_domain) ||
!tipc_in_scope(disc_domain, tipc_own_addr)) {
if (tipc_addr_domain_valid(disc_domain) &&
(disc_domain != tipc_own_addr)) {
if (tipc_in_scope(disc_domain, tipc_own_addr)) {
disc_domain = tipc_own_addr & TIPC_CLUSTER_MASK;
res = 0; /* accept any node in own cluster */
} else if (in_own_cluster(disc_domain))
res = 0; /* accept specified node in own cluster */
}
if (res) {
warn("Bearer <%s> rejected, illegal discovery domain\n", name);
return -EINVAL;
}
Expand All @@ -511,7 +520,7 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
if (!m_ptr) {
warn("Bearer <%s> rejected, media <%s> not registered\n", name,
b_name.media_name);
goto failed;
goto exit;
}

if (priority == TIPC_MEDIA_LINK_PRI)
Expand All @@ -527,14 +536,14 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
}
if (!strcmp(name, tipc_bearers[i].name)) {
warn("Bearer <%s> rejected, already enabled\n", name);
goto failed;
goto exit;
}
if ((tipc_bearers[i].priority == priority) &&
(++with_this_prio > 2)) {
if (priority-- == 0) {
warn("Bearer <%s> rejected, duplicate priority\n",
name);
goto failed;
goto exit;
}
warn("Bearer <%s> priority adjustment required %u->%u\n",
name, priority + 1, priority);
Expand All @@ -544,15 +553,15 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
if (bearer_id >= MAX_BEARERS) {
warn("Bearer <%s> rejected, bearer limit reached (%u)\n",
name, MAX_BEARERS);
goto failed;
goto exit;
}

b_ptr = &tipc_bearers[bearer_id];
strcpy(b_ptr->name, name);
res = m_ptr->enable_bearer(b_ptr);
if (res) {
warn("Bearer <%s> rejected, enable failure (%d)\n", name, -res);
goto failed;
goto exit;
}

b_ptr->identity = bearer_id;
Expand All @@ -562,14 +571,18 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
b_ptr->priority = priority;
INIT_LIST_HEAD(&b_ptr->cong_links);
INIT_LIST_HEAD(&b_ptr->links);
b_ptr->link_req = tipc_disc_init_link_req(b_ptr, &m_ptr->bcast_addr,
disc_domain);
spin_lock_init(&b_ptr->lock);
write_unlock_bh(&tipc_net_lock);

res = tipc_disc_create(b_ptr, &m_ptr->bcast_addr, disc_domain);
if (res) {
bearer_disable(b_ptr);
warn("Bearer <%s> rejected, discovery object creation failed\n",
name);
goto exit;
}
info("Enabled bearer <%s>, discovery domain %s, priority %u\n",
name, tipc_addr_string_fill(addr_string, disc_domain), priority);
return 0;
failed:
exit:
write_unlock_bh(&tipc_net_lock);
return res;
}
Expand Down Expand Up @@ -620,14 +633,14 @@ static void bearer_disable(struct tipc_bearer *b_ptr)
struct link *temp_l_ptr;

info("Disabling bearer <%s>\n", b_ptr->name);
tipc_disc_stop_link_req(b_ptr->link_req);
spin_lock_bh(&b_ptr->lock);
b_ptr->link_req = NULL;
b_ptr->blocked = 1;
b_ptr->media->disable_bearer(b_ptr);
list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) {
tipc_link_delete(l_ptr);
}
if (b_ptr->link_req)
tipc_disc_delete(b_ptr->link_req);
spin_unlock_bh(&b_ptr->lock);
memset(b_ptr, 0, sizeof(struct tipc_bearer));
}
Expand Down
3 changes: 1 addition & 2 deletions net/tipc/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ static int __init tipc_init(void)
if (tipc_log_resize(CONFIG_TIPC_LOG) != 0)
warn("Unable to create log buffer\n");

info("Activated (version " TIPC_MOD_VER
" compiled " __DATE__ " " __TIME__ ")\n");
info("Activated (version " TIPC_MOD_VER ")\n");

tipc_own_addr = 0;
tipc_remote_management = 1;
Expand Down
Loading

0 comments on commit 0074820

Please sign in to comment.