* [net 0/4] tipc: fixes in duplicate address discovery function
@ 2018-07-06 18:10 Jon Maloy
2018-07-06 18:10 ` [net 1/4] tipc: fix wrong return value from function tipc_node_try_addr() Jon Maloy
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Jon Maloy @ 2018-07-06 18:10 UTC (permalink / raw)
To: davem, netdev
Cc: gordan.mihaljevic, tung.q.nguyen, hoang.h.le, jon.maloy,
canh.d.luu, ying.xue, tipc-discussion
commit 25b0b9c4e835 ("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.
Jon Maloy (4):
tipc: fix wrong return value from function tipc_node_try_addr()
tipc: correct discovery message handling during address trial period
tipc: fix correct setting of message type in second discoverer
tipc: make function tipc_net_finalize() thread safe
net/tipc/discover.c | 18 +++++++++++-------
net/tipc/net.c | 17 +++++++++++------
net/tipc/node.c | 7 +++++--
3 files changed, 27 insertions(+), 15 deletions(-)
--
2.1.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [net 1/4] tipc: fix wrong return value from function tipc_node_try_addr()
2018-07-06 18:10 [net 0/4] tipc: fixes in duplicate address discovery function Jon Maloy
@ 2018-07-06 18:10 ` Jon Maloy
2018-07-06 18:10 ` [net 2/4] tipc: correct discovery message handling during address trial period Jon Maloy
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Jon Maloy @ 2018-07-06 18:10 UTC (permalink / raw)
To: davem, netdev
Cc: gordan.mihaljevic, tung.q.nguyen, hoang.h.le, jon.maloy,
canh.d.luu, ying.xue, tipc-discussion
The function for checking if there is an node address conflict is
supposed to return a suggestion for a new address if it finds a
conflict, and zero otherwise. But in case the peer being checked
is previously unknown it does instead return a "suggestion" for
the checked address itself. This results in a DSC_TRIAL_FAIL_MSG
being sent unecessarily to the peer, and sometimes makes the trial
period starting over again.
Fixes: 25b0b9c4e835 ("tipc: handle collisions of 32-bit node address hash values")
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
---
net/tipc/node.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 6a44eb8..0453bd4 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -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,
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [net 2/4] tipc: correct discovery message handling during address trial period
2018-07-06 18:10 [net 0/4] tipc: fixes in duplicate address discovery function Jon Maloy
2018-07-06 18:10 ` [net 1/4] tipc: fix wrong return value from function tipc_node_try_addr() Jon Maloy
@ 2018-07-06 18:10 ` Jon Maloy
2018-07-06 18:10 ` [net 3/4] tipc: fix correct setting of message type in second discoverer Jon Maloy
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Jon Maloy @ 2018-07-06 18:10 UTC (permalink / raw)
To: davem, netdev
Cc: gordan.mihaljevic, tung.q.nguyen, hoang.h.le, jon.maloy,
canh.d.luu, ying.xue, tipc-discussion
With the duplicate address discovery protocol for tipc nodes addresses
we introduced a one second trial period before a node is allocated a
hash number to use as address.
Unfortunately, we miss to handle the case when a regular LINK REQUEST/
RESPONSE arrives from a cluster node during the trial period. Such
messages are not ignored as they should be, leading to links setup
attempts while the node still has no address.
Fixes: 25b0b9c4e835 ("tipc: handle collisions of 32-bit node address hash values")
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
---
net/tipc/discover.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/tipc/discover.c b/net/tipc/discover.c
index 9f666e0..dcadc10 100644
--- a/net/tipc/discover.c
+++ b/net/tipc/discover.c
@@ -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)
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [net 3/4] tipc: fix correct setting of message type in second discoverer
2018-07-06 18:10 [net 0/4] tipc: fixes in duplicate address discovery function Jon Maloy
2018-07-06 18:10 ` [net 1/4] tipc: fix wrong return value from function tipc_node_try_addr() Jon Maloy
2018-07-06 18:10 ` [net 2/4] tipc: correct discovery message handling during address trial period Jon Maloy
@ 2018-07-06 18:10 ` Jon Maloy
2018-07-06 18:10 ` [net 4/4] tipc: make function tipc_net_finalize() thread safe Jon Maloy
2018-07-07 11:03 ` [net 0/4] tipc: fixes in duplicate address discovery function David Miller
4 siblings, 0 replies; 6+ messages in thread
From: Jon Maloy @ 2018-07-06 18:10 UTC (permalink / raw)
To: davem, netdev
Cc: gordan.mihaljevic, tung.q.nguyen, hoang.h.le, jon.maloy,
canh.d.luu, ying.xue, tipc-discussion
The duplicate address discovery protocol is not safe against two
discoverers running in parallel. The one executing first after the
trial period is over will set the node address and change its own
message type to DSC_REQ_MSG. The one executing last may find that the
node address is already set, and never change message type, with the
result that its links may never be established.
In this commmit we ensure that the message type always is set correctly
after the trial period is over.
Fixes: 25b0b9c4e835 ("tipc: handle collisions of 32-bit node address hash values")
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
---
net/tipc/discover.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/net/tipc/discover.c b/net/tipc/discover.c
index dcadc10..2830709 100644
--- a/net/tipc/discover.c
+++ b/net/tipc/discover.c
@@ -287,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;
@@ -301,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 */
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [net 4/4] tipc: make function tipc_net_finalize() thread safe
2018-07-06 18:10 [net 0/4] tipc: fixes in duplicate address discovery function Jon Maloy
` (2 preceding siblings ...)
2018-07-06 18:10 ` [net 3/4] tipc: fix correct setting of message type in second discoverer Jon Maloy
@ 2018-07-06 18:10 ` Jon Maloy
2018-07-07 11:03 ` [net 0/4] tipc: fixes in duplicate address discovery function David Miller
4 siblings, 0 replies; 6+ messages in thread
From: Jon Maloy @ 2018-07-06 18:10 UTC (permalink / raw)
To: davem, netdev; +Cc: tipc-discussion, gordan.mihaljevic
The setting of the node address is not thread safe, meaning that
two discoverers may decide to set it simultanously, with a duplicate
entry in the name table as result. We fix that with this commit.
Fixes: 25b0b9c4e835 ("tipc: handle collisions of 32-bit node address hash values")
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
---
net/tipc/net.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/net/tipc/net.c b/net/tipc/net.c
index 4fbaa04..a7f6964 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -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)
--
2.1.4
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [net 0/4] tipc: fixes in duplicate address discovery function
2018-07-06 18:10 [net 0/4] tipc: fixes in duplicate address discovery function Jon Maloy
` (3 preceding siblings ...)
2018-07-06 18:10 ` [net 4/4] tipc: make function tipc_net_finalize() thread safe Jon Maloy
@ 2018-07-07 11:03 ` David Miller
4 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2018-07-07 11:03 UTC (permalink / raw)
To: jon.maloy
Cc: netdev, gordan.mihaljevic, tung.q.nguyen, hoang.h.le, canh.d.luu,
ying.xue, tipc-discussion
From: Jon Maloy <jon.maloy@ericsson.com>
Date: Fri, 6 Jul 2018 20:10:02 +0200
> commit 25b0b9c4e835 ("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.
Series applied and queued up for -stable, thanks!
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-07-07 11:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-06 18:10 [net 0/4] tipc: fixes in duplicate address discovery function Jon Maloy
2018-07-06 18:10 ` [net 1/4] tipc: fix wrong return value from function tipc_node_try_addr() Jon Maloy
2018-07-06 18:10 ` [net 2/4] tipc: correct discovery message handling during address trial period Jon Maloy
2018-07-06 18:10 ` [net 3/4] tipc: fix correct setting of message type in second discoverer Jon Maloy
2018-07-06 18:10 ` [net 4/4] tipc: make function tipc_net_finalize() thread safe Jon Maloy
2018-07-07 11:03 ` [net 0/4] tipc: fixes in duplicate address discovery function David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).