Commit 7f978e85 authored by David S. Miller's avatar David S. Miller

Merge branch 'tipc-dad-fixes'

Jon Maloy says:

====================
tipc: fixes in duplicate address discovery function

commit 25b0b9c4 ("tipc: handle collisions of 32-bit node address
hash values") introduced new functionality that has turned out to
contain several bugs and weaknesses.

We address those in this series.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 0f62aeec 9faa89d4
...@@ -133,6 +133,8 @@ static void disc_dupl_alert(struct tipc_bearer *b, u32 node_addr, ...@@ -133,6 +133,8 @@ static void disc_dupl_alert(struct tipc_bearer *b, u32 node_addr,
} }
/* tipc_disc_addr_trial(): - handle an address uniqueness trial from peer /* tipc_disc_addr_trial(): - handle an address uniqueness trial from peer
* Returns true if message should be dropped by caller, i.e., if it is a
* trial message or we are inside trial period. Otherwise false.
*/ */
static bool tipc_disc_addr_trial_msg(struct tipc_discoverer *d, static bool tipc_disc_addr_trial_msg(struct tipc_discoverer *d,
struct tipc_media_addr *maddr, struct tipc_media_addr *maddr,
...@@ -168,8 +170,9 @@ static bool tipc_disc_addr_trial_msg(struct tipc_discoverer *d, ...@@ -168,8 +170,9 @@ static bool tipc_disc_addr_trial_msg(struct tipc_discoverer *d,
msg_set_type(buf_msg(d->skb), DSC_REQ_MSG); msg_set_type(buf_msg(d->skb), DSC_REQ_MSG);
} }
/* Accept regular link requests/responses only after trial period */
if (mtyp != DSC_TRIAL_MSG) if (mtyp != DSC_TRIAL_MSG)
return false; return trial;
sugg_addr = tipc_node_try_addr(net, peer_id, src); sugg_addr = tipc_node_try_addr(net, peer_id, src);
if (sugg_addr) if (sugg_addr)
...@@ -284,7 +287,6 @@ static void tipc_disc_timeout(struct timer_list *t) ...@@ -284,7 +287,6 @@ static void tipc_disc_timeout(struct timer_list *t)
{ {
struct tipc_discoverer *d = from_timer(d, t, timer); struct tipc_discoverer *d = from_timer(d, t, timer);
struct tipc_net *tn = tipc_net(d->net); struct tipc_net *tn = tipc_net(d->net);
u32 self = tipc_own_addr(d->net);
struct tipc_media_addr maddr; struct tipc_media_addr maddr;
struct sk_buff *skb = NULL; struct sk_buff *skb = NULL;
struct net *net = d->net; struct net *net = d->net;
...@@ -298,12 +300,14 @@ static void tipc_disc_timeout(struct timer_list *t) ...@@ -298,12 +300,14 @@ static void tipc_disc_timeout(struct timer_list *t)
goto exit; goto exit;
} }
/* Did we just leave the address trial period ? */ /* Trial period over ? */
if (!self && !time_before(jiffies, tn->addr_trial_end)) { if (!time_before(jiffies, tn->addr_trial_end)) {
self = tn->trial_addr; /* Did we just leave it ? */
tipc_net_finalize(net, self); if (!tipc_own_addr(net))
msg_set_prevnode(buf_msg(d->skb), self); tipc_net_finalize(net, tn->trial_addr);
msg_set_type(buf_msg(d->skb), DSC_REQ_MSG); msg_set_type(buf_msg(d->skb), DSC_REQ_MSG);
msg_set_prevnode(buf_msg(d->skb), tipc_own_addr(net));
} }
/* Adjust timeout interval according to discovery phase */ /* Adjust timeout interval according to discovery phase */
......
...@@ -121,12 +121,17 @@ int tipc_net_init(struct net *net, u8 *node_id, u32 addr) ...@@ -121,12 +121,17 @@ int tipc_net_init(struct net *net, u8 *node_id, u32 addr)
void tipc_net_finalize(struct net *net, u32 addr) void tipc_net_finalize(struct net *net, u32 addr)
{ {
struct tipc_net *tn = tipc_net(net);
spin_lock_bh(&tn->node_list_lock);
if (!tipc_own_addr(net)) {
tipc_set_node_addr(net, addr); tipc_set_node_addr(net, addr);
smp_mb();
tipc_named_reinit(net); tipc_named_reinit(net);
tipc_sk_reinit(net); tipc_sk_reinit(net);
tipc_nametbl_publish(net, TIPC_CFG_SRV, addr, addr, tipc_nametbl_publish(net, TIPC_CFG_SRV, addr, addr,
TIPC_CLUSTER_SCOPE, 0, addr); TIPC_CLUSTER_SCOPE, 0, addr);
}
spin_unlock_bh(&tn->node_list_lock);
} }
void tipc_net_stop(struct net *net) void tipc_net_stop(struct net *net)
......
...@@ -797,6 +797,7 @@ static u32 tipc_node_suggest_addr(struct net *net, u32 addr) ...@@ -797,6 +797,7 @@ static u32 tipc_node_suggest_addr(struct net *net, u32 addr)
} }
/* tipc_node_try_addr(): Check if addr can be used by peer, suggest other if not /* tipc_node_try_addr(): Check if addr can be used by peer, suggest other if not
* Returns suggested address if any, otherwise 0
*/ */
u32 tipc_node_try_addr(struct net *net, u8 *id, u32 addr) u32 tipc_node_try_addr(struct net *net, u8 *id, u32 addr)
{ {
...@@ -819,12 +820,14 @@ u32 tipc_node_try_addr(struct net *net, u8 *id, u32 addr) ...@@ -819,12 +820,14 @@ u32 tipc_node_try_addr(struct net *net, u8 *id, u32 addr)
if (n) { if (n) {
addr = n->addr; addr = n->addr;
tipc_node_put(n); tipc_node_put(n);
return addr;
} }
/* Even this node may be in trial phase */
/* Even this node may be in conflict */
if (tn->trial_addr == addr) if (tn->trial_addr == addr)
return tipc_node_suggest_addr(net, addr); return tipc_node_suggest_addr(net, addr);
return addr; return 0;
} }
void tipc_node_check_dest(struct net *net, u32 addr, void tipc_node_check_dest(struct net *net, u32 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