Commit cd3decdf authored by Allan Stephens's avatar Allan Stephens Committed by Paul Gortmaker

tipc: Ensure broadcast link spinlock is held when updating node map

Fixes oversight that allowed broadcast link node map to be updated without
first taking the broadcast link spinlock that protects the map. As part
of this fix the node map has been incorporated into the broadcast link
structure to make the need for such protection more evident.
Signed-off-by: default avatarAllan Stephens <allan.stephens@windriver.com>
Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
parent c47e9b91
...@@ -87,6 +87,7 @@ struct bcbearer { ...@@ -87,6 +87,7 @@ struct bcbearer {
* struct bclink - link used for broadcast messages * struct bclink - link used for broadcast messages
* @link: (non-standard) broadcast link structure * @link: (non-standard) broadcast link structure
* @node: (non-standard) node structure representing b'cast link's peer node * @node: (non-standard) node structure representing b'cast link's peer node
* @bcast_nodes: map of broadcast-capable nodes
* @retransmit_to: node that most recently requested a retransmit * @retransmit_to: node that most recently requested a retransmit
* *
* Handles sequence numbering, fragmentation, bundling, etc. * Handles sequence numbering, fragmentation, bundling, etc.
...@@ -95,6 +96,7 @@ struct bcbearer { ...@@ -95,6 +96,7 @@ struct bcbearer {
struct bclink { struct bclink {
struct link link; struct link link;
struct tipc_node node; struct tipc_node node;
struct tipc_node_map bcast_nodes;
struct tipc_node *retransmit_to; struct tipc_node *retransmit_to;
}; };
...@@ -107,9 +109,6 @@ static struct link *bcl = &bcast_link.link; ...@@ -107,9 +109,6 @@ static struct link *bcl = &bcast_link.link;
static DEFINE_SPINLOCK(bc_lock); static DEFINE_SPINLOCK(bc_lock);
/* broadcast-capable node map */
struct tipc_node_map tipc_bcast_nmap;
const char tipc_bclink_name[] = "broadcast-link"; const char tipc_bclink_name[] = "broadcast-link";
static void tipc_nmap_diff(struct tipc_node_map *nm_a, static void tipc_nmap_diff(struct tipc_node_map *nm_a,
...@@ -136,6 +135,19 @@ static void bcbuf_decr_acks(struct sk_buff *buf) ...@@ -136,6 +135,19 @@ static void bcbuf_decr_acks(struct sk_buff *buf)
bcbuf_set_acks(buf, bcbuf_acks(buf) - 1); bcbuf_set_acks(buf, bcbuf_acks(buf) - 1);
} }
void tipc_bclink_add_node(u32 addr)
{
spin_lock_bh(&bc_lock);
tipc_nmap_add(&bclink->bcast_nodes, addr);
spin_unlock_bh(&bc_lock);
}
void tipc_bclink_remove_node(u32 addr)
{
spin_lock_bh(&bc_lock);
tipc_nmap_remove(&bclink->bcast_nodes, addr);
spin_unlock_bh(&bc_lock);
}
static void bclink_set_last_sent(void) static void bclink_set_last_sent(void)
{ {
...@@ -575,13 +587,13 @@ static int tipc_bcbearer_send(struct sk_buff *buf, ...@@ -575,13 +587,13 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
if (likely(!msg_non_seq(buf_msg(buf)))) { if (likely(!msg_non_seq(buf_msg(buf)))) {
struct tipc_msg *msg; struct tipc_msg *msg;
bcbuf_set_acks(buf, tipc_bcast_nmap.count); bcbuf_set_acks(buf, bclink->bcast_nodes.count);
msg = buf_msg(buf); msg = buf_msg(buf);
msg_set_non_seq(msg, 1); msg_set_non_seq(msg, 1);
msg_set_mc_netid(msg, tipc_net_id); msg_set_mc_netid(msg, tipc_net_id);
bcl->stats.sent_info++; bcl->stats.sent_info++;
if (WARN_ON(!tipc_bcast_nmap.count)) { if (WARN_ON(!bclink->bcast_nodes.count)) {
dump_stack(); dump_stack();
return 0; return 0;
} }
...@@ -589,7 +601,7 @@ static int tipc_bcbearer_send(struct sk_buff *buf, ...@@ -589,7 +601,7 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
/* Send buffer over bearers until all targets reached */ /* Send buffer over bearers until all targets reached */
bcbearer->remains = tipc_bcast_nmap; bcbearer->remains = bclink->bcast_nodes;
for (bp_index = 0; bp_index < MAX_BEARERS; bp_index++) { for (bp_index = 0; bp_index < MAX_BEARERS; bp_index++) {
struct tipc_bearer *p = bcbearer->bpairs[bp_index].primary; struct tipc_bearer *p = bcbearer->bpairs[bp_index].primary;
......
...@@ -51,8 +51,6 @@ struct tipc_node_map { ...@@ -51,8 +51,6 @@ struct tipc_node_map {
u32 map[MAX_NODES / WSIZE]; u32 map[MAX_NODES / WSIZE];
}; };
extern struct tipc_node_map tipc_bcast_nmap;
#define PLSIZE 32 #define PLSIZE 32
/** /**
...@@ -90,6 +88,8 @@ void tipc_port_list_free(struct port_list *pl_ptr); ...@@ -90,6 +88,8 @@ void tipc_port_list_free(struct port_list *pl_ptr);
void tipc_bclink_init(void); void tipc_bclink_init(void);
void tipc_bclink_stop(void); void tipc_bclink_stop(void);
void tipc_bclink_add_node(u32 addr);
void tipc_bclink_remove_node(u32 addr);
struct tipc_node *tipc_bclink_retransmit_to(void); struct tipc_node *tipc_bclink_retransmit_to(void);
void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked); void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked);
int tipc_bclink_send_msg(struct sk_buff *buf); int tipc_bclink_send_msg(struct sk_buff *buf);
......
...@@ -307,7 +307,7 @@ static void node_established_contact(struct tipc_node *n_ptr) ...@@ -307,7 +307,7 @@ static void node_established_contact(struct tipc_node *n_ptr)
n_ptr->bclink.acked = tipc_bclink_get_last_sent(); n_ptr->bclink.acked = tipc_bclink_get_last_sent();
if (n_ptr->bclink.supported) { if (n_ptr->bclink.supported) {
tipc_nmap_add(&tipc_bcast_nmap, n_ptr->addr); tipc_bclink_add_node(n_ptr->addr);
if (n_ptr->addr < tipc_own_addr) if (n_ptr->addr < tipc_own_addr)
tipc_own_tag++; tipc_own_tag++;
} }
...@@ -350,7 +350,7 @@ static void node_lost_contact(struct tipc_node *n_ptr) ...@@ -350,7 +350,7 @@ static void node_lost_contact(struct tipc_node *n_ptr)
n_ptr->bclink.defragm = NULL; n_ptr->bclink.defragm = NULL;
} }
tipc_nmap_remove(&tipc_bcast_nmap, n_ptr->addr); tipc_bclink_remove_node(n_ptr->addr);
tipc_bclink_acknowledge(n_ptr, tipc_bclink_acknowledge(n_ptr,
mod(n_ptr->bclink.acked + 10000)); mod(n_ptr->bclink.acked + 10000));
if (n_ptr->addr < tipc_own_addr) if (n_ptr->addr < tipc_own_addr)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment