1
0
Fork 0

Merge branch 'tipc-dad-fixes'

Jon Maloy says:

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

commit 25b0b9c4e8 ("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: David S. Miller <davem@davemloft.net>
hifive-unleashed-5.1
David S. Miller 2018-07-07 19:49:02 +09:00
commit 7f978e859f
3 changed files with 27 additions and 15 deletions

View File

@ -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
* 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,
struct tipc_media_addr *maddr,
@ -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);
}
/* Accept regular link requests/responses only after trial period */
if (mtyp != DSC_TRIAL_MSG)
return false;
return trial;
sugg_addr = tipc_node_try_addr(net, peer_id, src);
if (sugg_addr)
@ -284,7 +287,6 @@ static void tipc_disc_timeout(struct timer_list *t)
{
struct tipc_discoverer *d = from_timer(d, t, timer);
struct tipc_net *tn = tipc_net(d->net);
u32 self = tipc_own_addr(d->net);
struct tipc_media_addr maddr;
struct sk_buff *skb = NULL;
struct net *net = d->net;
@ -298,12 +300,14 @@ static void tipc_disc_timeout(struct timer_list *t)
goto exit;
}
/* Did we just leave the address trial period ? */
if (!self && !time_before(jiffies, tn->addr_trial_end)) {
self = tn->trial_addr;
tipc_net_finalize(net, self);
msg_set_prevnode(buf_msg(d->skb), self);
/* Trial period over ? */
if (!time_before(jiffies, tn->addr_trial_end)) {
/* Did we just leave it ? */
if (!tipc_own_addr(net))
tipc_net_finalize(net, tn->trial_addr);
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 */

View File

@ -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)
{
tipc_set_node_addr(net, addr);
smp_mb();
tipc_named_reinit(net);
tipc_sk_reinit(net);
tipc_nametbl_publish(net, TIPC_CFG_SRV, addr, addr,
TIPC_CLUSTER_SCOPE, 0, 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_named_reinit(net);
tipc_sk_reinit(net);
tipc_nametbl_publish(net, TIPC_CFG_SRV, addr, addr,
TIPC_CLUSTER_SCOPE, 0, addr);
}
spin_unlock_bh(&tn->node_list_lock);
}
void tipc_net_stop(struct net *net)

View File

@ -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
* Returns suggested address if any, otherwise 0
*/
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) {
addr = n->addr;
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)
return tipc_node_suggest_addr(net, addr);
return addr;
return 0;
}
void tipc_node_check_dest(struct net *net, u32 addr,