* [PATCH net-next 00/16] tipc: publication lists and zero node handling
@ 2012-04-20 21:05 Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 01/16] tipc: introduce publication lists struct Paul Gortmaker
` (16 more replies)
0 siblings, 17 replies; 20+ messages in thread
From: Paul Gortmaker @ 2012-04-20 21:05 UTC (permalink / raw)
To: davem; +Cc: netdev, allan.stephens, ying.xue
Hi Dave,
This series of commits largely focuses on two things. The 1st is
to categorize the TIPC publication lists, so better control over
the publications can be achieved. The 2nd is largely to improve
corner cases around the tipc address changes and how the <0.0.0>
tipc address is interpreted.
What remains after this, is less than 10 commits originating from
what was salvaged from the tipc-1.7 sourceforge fork, so I'm happy to
see the end of this task so close. I'll be looking at those shortly.
The tipc tests (tipcTS <--> tipcTC) have been used in both directions
between a 32bit and a 64bit machine to do runtime testing, and the
entire series has been confirmed to be compile time bisectable too.
Credit to Al for all the heavy lifting. I've just refactored things
a bit and made minor changes here and there.
Thanks,
Paul
---
The following changes since commit 798ec84d45754403571d6387396236e877965c5a:
net/core:Remove memleak reports by kmemleak_not_leak. (2012-04-18 00:20:28 -0400)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux.git tipc_net-next
for you to fetch changes up to 9d52ce4bd3fa9e0cf1658791f2c680e20e0598a1:
tipc: Ensure network address change doesn't impact configuration service (2012-04-19 15:46:50 -0400)
----------------------------------------------------------------
Allan Stephens (16):
tipc: introduce publication lists struct
tipc: Factor out name publication code to a separate function
tipc: Separate cluster-scope and zone-scope names into distinct lists
tipc: Update node-scope publications when network address is assigned
tipc: Don't record failed publication attempt as a success
tipc: Add routines for safe checking of node's network address
tipc: Ensure network address change doesn't impact name table updates
tipc: Optimize re-initialization of port message header templates
tipc: Ensure network address change doesn't impact new port
tipc: delete duplicate peerport/peernode helper functions
tipc: Ensure network address change doesn't impact local connections
tipc: take lock while updating node network address
tipc: properly handle off-node send requests with invalid addr
tipc: handle <0.0.0> as an alias for this node on outgoing msgs
tipc: Ensure network address change doesn't impact rejected message
tipc: Ensure network address change doesn't impact configuration
service
net/tipc/addr.h | 20 +++++++-
net/tipc/bearer.c | 2 +-
net/tipc/config.c | 2 +-
net/tipc/name_distr.c | 119 ++++++++++++++++++++++++++++++++----------------
net/tipc/name_table.c | 14 +++---
net/tipc/net.c | 3 +-
net/tipc/node.c | 2 +-
net/tipc/node_subscr.c | 2 +-
net/tipc/port.c | 101 ++++++++++++++++++++++------------------
net/tipc/port.h | 11 +----
net/tipc/socket.c | 3 +-
11 files changed, 172 insertions(+), 107 deletions(-)
--
1.7.9.3
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH net-next 01/16] tipc: introduce publication lists struct
2012-04-20 21:05 [PATCH net-next 00/16] tipc: publication lists and zero node handling Paul Gortmaker
@ 2012-04-20 21:05 ` Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 02/16] tipc: Factor out name publication code to a separate function Paul Gortmaker
` (15 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Paul Gortmaker @ 2012-04-20 21:05 UTC (permalink / raw)
To: davem; +Cc: netdev, allan.stephens, ying.xue
From: Allan Stephens <allan.stephens@windriver.com>
There is currently a single list that is containing both cluster-scope and
zone-scope publications, and the list count is a separate free floating
variable. Create a struct to bind the count to the list, and to pave
the way for factoring out the publications into zone/cluster/node scope.
The current "publ_root" most matches what will be the cluster scope
list, so it is named accordingly in this commit.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
net/tipc/name_distr.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
index d57da61..870a001 100644
--- a/net/tipc/name_distr.c
+++ b/net/tipc/name_distr.c
@@ -68,12 +68,19 @@ struct distr_item {
};
/**
- * List of externally visible publications by this node --
- * that is, all publications having scope > TIPC_NODE_SCOPE.
+ * struct publ_list - list of publications made by this node
+ * @list: circular list of publications
+ * @list_size: number of entries in list
*/
+struct publ_list {
+ struct list_head list;
+ u32 size;
+};
-static LIST_HEAD(publ_root);
-static u32 publ_cnt;
+static struct publ_list publ_cluster = {
+ .list = LIST_HEAD_INIT(publ_cluster.list),
+ .size = 0,
+};
/**
* publ_to_item - add publication info to a publication message
@@ -132,8 +139,8 @@ void tipc_named_publish(struct publication *publ)
struct sk_buff *buf;
struct distr_item *item;
- list_add_tail(&publ->local_list, &publ_root);
- publ_cnt++;
+ list_add_tail(&publ->local_list, &publ_cluster.list);
+ publ_cluster.size++;
buf = named_prepare_buf(PUBLICATION, ITEM_SIZE, 0);
if (!buf) {
@@ -156,7 +163,7 @@ void tipc_named_withdraw(struct publication *publ)
struct distr_item *item;
list_del(&publ->local_list);
- publ_cnt--;
+ publ_cluster.size--;
buf = named_prepare_buf(WITHDRAWAL, ITEM_SIZE, 0);
if (!buf) {
@@ -207,9 +214,9 @@ void tipc_named_node_up(unsigned long nodearg)
INIT_LIST_HEAD(&message_list);
read_lock_bh(&tipc_nametbl_lock);
- rest = publ_cnt * ITEM_SIZE;
+ rest = publ_cluster.size * ITEM_SIZE;
- list_for_each_entry(publ, &publ_root, local_list) {
+ list_for_each_entry(publ, &publ_cluster.list, local_list) {
if (!buf) {
left = (rest <= max_item_buf) ? rest : max_item_buf;
rest -= left;
@@ -329,7 +336,7 @@ void tipc_named_reinit(void)
write_lock_bh(&tipc_nametbl_lock);
- list_for_each_entry(publ, &publ_root, local_list)
+ list_for_each_entry(publ, &publ_cluster.list, local_list)
publ->node = tipc_own_addr;
write_unlock_bh(&tipc_nametbl_lock);
--
1.7.9.3
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 02/16] tipc: Factor out name publication code to a separate function
2012-04-20 21:05 [PATCH net-next 00/16] tipc: publication lists and zero node handling Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 01/16] tipc: introduce publication lists struct Paul Gortmaker
@ 2012-04-20 21:05 ` Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 03/16] tipc: Separate cluster-scope and zone-scope names into distinct lists Paul Gortmaker
` (14 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Paul Gortmaker @ 2012-04-20 21:05 UTC (permalink / raw)
To: davem; +Cc: netdev, allan.stephens, ying.xue
From: Allan Stephens <allan.stephens@windriver.com>
This is done so that it can be reused with differing publication
lists, instead of being hard coded to the cluster publicaton list.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
net/tipc/name_distr.c | 61 +++++++++++++++++++++++++++----------------------
1 file changed, 34 insertions(+), 27 deletions(-)
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
index 870a001..3be0eb9 100644
--- a/net/tipc/name_distr.c
+++ b/net/tipc/name_distr.c
@@ -176,6 +176,39 @@ void tipc_named_withdraw(struct publication *publ)
named_cluster_distribute(buf);
}
+/*
+ * named_distribute - prepare name info for bulk distribution to another node
+ */
+static void named_distribute(struct list_head *message_list, u32 node,
+ struct publ_list *pls, u32 max_item_buf)
+{
+ struct publication *publ;
+ struct sk_buff *buf = NULL;
+ struct distr_item *item = NULL;
+ u32 left = 0;
+ u32 rest = pls->size * ITEM_SIZE;
+
+ list_for_each_entry(publ, &pls->list, local_list) {
+ if (!buf) {
+ left = (rest <= max_item_buf) ? rest : max_item_buf;
+ rest -= left;
+ buf = named_prepare_buf(PUBLICATION, left, node);
+ if (!buf) {
+ warn("Bulk publication failure\n");
+ return;
+ }
+ item = (struct distr_item *)msg_data(buf_msg(buf));
+ }
+ publ_to_item(item, publ);
+ item++;
+ left -= ITEM_SIZE;
+ if (!left) {
+ list_add_tail((struct list_head *)buf, message_list);
+ buf = NULL;
+ }
+ }
+}
+
/**
* tipc_named_node_up - tell specified node about all publications by this node
*/
@@ -184,13 +217,8 @@ void tipc_named_node_up(unsigned long nodearg)
{
struct tipc_node *n_ptr;
struct tipc_link *l_ptr;
- struct publication *publ;
- struct distr_item *item = NULL;
- struct sk_buff *buf = NULL;
struct list_head message_list;
u32 node = (u32)nodearg;
- u32 left = 0;
- u32 rest;
u32 max_item_buf = 0;
/* compute maximum amount of publication data to send per message */
@@ -214,28 +242,7 @@ void tipc_named_node_up(unsigned long nodearg)
INIT_LIST_HEAD(&message_list);
read_lock_bh(&tipc_nametbl_lock);
- rest = publ_cluster.size * ITEM_SIZE;
-
- list_for_each_entry(publ, &publ_cluster.list, local_list) {
- if (!buf) {
- left = (rest <= max_item_buf) ? rest : max_item_buf;
- rest -= left;
- buf = named_prepare_buf(PUBLICATION, left, node);
- if (!buf) {
- warn("Bulk publication distribution failure\n");
- goto exit;
- }
- item = (struct distr_item *)msg_data(buf_msg(buf));
- }
- publ_to_item(item, publ);
- item++;
- left -= ITEM_SIZE;
- if (!left) {
- list_add_tail((struct list_head *)buf, &message_list);
- buf = NULL;
- }
- }
-exit:
+ named_distribute(&message_list, node, &publ_cluster, max_item_buf);
read_unlock_bh(&tipc_nametbl_lock);
tipc_link_send_names(&message_list, (u32)node);
--
1.7.9.3
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 03/16] tipc: Separate cluster-scope and zone-scope names into distinct lists
2012-04-20 21:05 [PATCH net-next 00/16] tipc: publication lists and zero node handling Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 01/16] tipc: introduce publication lists struct Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 02/16] tipc: Factor out name publication code to a separate function Paul Gortmaker
@ 2012-04-20 21:05 ` Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 04/16] tipc: Update node-scope publications when network address is assigned Paul Gortmaker
` (13 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Paul Gortmaker @ 2012-04-20 21:05 UTC (permalink / raw)
To: davem; +Cc: netdev, allan.stephens, ying.xue
From: Allan Stephens <allan.stephens@windriver.com>
Utilizes distinct lists to track zone-scope and cluster-scope names
published by a node. For now, TIPC continues to process the entries
in both lists in the same way; however, an upcoming patch will utilize
the existence of the lists to prevent the sending of cluster-scope names
to nodes that are not part of the local cluster.
To achieve this, an array of publication lists is introduced, so
that they can be iterated over and accessed via publ->scope as
an index where convenient.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
net/tipc/name_distr.c | 31 ++++++++++++++++++++++++++-----
1 file changed, 26 insertions(+), 5 deletions(-)
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
index 3be0eb9..8751ea5 100644
--- a/net/tipc/name_distr.c
+++ b/net/tipc/name_distr.c
@@ -77,11 +77,29 @@ struct publ_list {
u32 size;
};
+static struct publ_list publ_zone = {
+ .list = LIST_HEAD_INIT(publ_zone.list),
+ .size = 0,
+};
+
static struct publ_list publ_cluster = {
.list = LIST_HEAD_INIT(publ_cluster.list),
.size = 0,
};
+static struct publ_list publ_node = {
+ .list = LIST_HEAD_INIT(publ_node.list),
+ .size = 0,
+};
+
+static struct publ_list *publ_lists[] = {
+ NULL,
+ &publ_zone, /* publ_lists[TIPC_ZONE_SCOPE] */
+ &publ_cluster, /* publ_lists[TIPC_CLUSTER_SCOPE] */
+ &publ_node /* publ_lists[TIPC_NODE_SCOPE] */
+};
+
+
/**
* publ_to_item - add publication info to a publication message
*/
@@ -139,8 +157,8 @@ void tipc_named_publish(struct publication *publ)
struct sk_buff *buf;
struct distr_item *item;
- list_add_tail(&publ->local_list, &publ_cluster.list);
- publ_cluster.size++;
+ list_add_tail(&publ->local_list, &publ_lists[publ->scope]->list);
+ publ_lists[publ->scope]->size++;
buf = named_prepare_buf(PUBLICATION, ITEM_SIZE, 0);
if (!buf) {
@@ -163,7 +181,7 @@ void tipc_named_withdraw(struct publication *publ)
struct distr_item *item;
list_del(&publ->local_list);
- publ_cluster.size--;
+ publ_lists[publ->scope]->size--;
buf = named_prepare_buf(WITHDRAWAL, ITEM_SIZE, 0);
if (!buf) {
@@ -243,6 +261,7 @@ void tipc_named_node_up(unsigned long nodearg)
read_lock_bh(&tipc_nametbl_lock);
named_distribute(&message_list, node, &publ_cluster, max_item_buf);
+ named_distribute(&message_list, node, &publ_zone, max_item_buf);
read_unlock_bh(&tipc_nametbl_lock);
tipc_link_send_names(&message_list, (u32)node);
@@ -340,11 +359,13 @@ void tipc_named_recv(struct sk_buff *buf)
void tipc_named_reinit(void)
{
struct publication *publ;
+ int scope;
write_lock_bh(&tipc_nametbl_lock);
- list_for_each_entry(publ, &publ_cluster.list, local_list)
- publ->node = tipc_own_addr;
+ for (scope = TIPC_ZONE_SCOPE; scope <= TIPC_CLUSTER_SCOPE; scope++)
+ list_for_each_entry(publ, &publ_lists[scope]->list, local_list)
+ publ->node = tipc_own_addr;
write_unlock_bh(&tipc_nametbl_lock);
}
--
1.7.9.3
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 04/16] tipc: Update node-scope publications when network address is assigned
2012-04-20 21:05 [PATCH net-next 00/16] tipc: publication lists and zero node handling Paul Gortmaker
` (2 preceding siblings ...)
2012-04-20 21:05 ` [PATCH net-next 03/16] tipc: Separate cluster-scope and zone-scope names into distinct lists Paul Gortmaker
@ 2012-04-20 21:05 ` Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 05/16] tipc: Don't record failed publication attempt as a success Paul Gortmaker
` (12 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Paul Gortmaker @ 2012-04-20 21:05 UTC (permalink / raw)
To: davem; +Cc: netdev, allan.stephens, ying.xue
From: Allan Stephens <allan.stephens@windriver.com>
Ensures that node-scope name publications that exist prior to the
configuration of a node's network address are properly re-initialized
with that address when it is assigned. TIPC's node-scope publications
are now tracked using a publications list like the lists used for
cluster-scope and zone-scope publications so they can be easily updated
when required.
The inclusion of node scope name publications in a conventional publication
list means that they must now also be withdrawn, just like cluster and zone
scope publications are currently withdrawn. So some conditional tests on
scope ==/!= TIPC_NODE_SCOPE are inserted/removed accordingly.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
net/tipc/name_distr.c | 14 ++++++++++----
net/tipc/name_table.c | 5 ++---
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
index 8751ea5..211c172 100644
--- a/net/tipc/name_distr.c
+++ b/net/tipc/name_distr.c
@@ -160,6 +160,9 @@ void tipc_named_publish(struct publication *publ)
list_add_tail(&publ->local_list, &publ_lists[publ->scope]->list);
publ_lists[publ->scope]->size++;
+ if (publ->scope == TIPC_NODE_SCOPE)
+ return;
+
buf = named_prepare_buf(PUBLICATION, ITEM_SIZE, 0);
if (!buf) {
warn("Publication distribution failure\n");
@@ -183,6 +186,9 @@ void tipc_named_withdraw(struct publication *publ)
list_del(&publ->local_list);
publ_lists[publ->scope]->size--;
+ if (publ->scope == TIPC_NODE_SCOPE)
+ return;
+
buf = named_prepare_buf(WITHDRAWAL, ITEM_SIZE, 0);
if (!buf) {
warn("Withdrawal distribution failure\n");
@@ -349,11 +355,11 @@ void tipc_named_recv(struct sk_buff *buf)
}
/**
- * tipc_named_reinit - re-initialize local publication list
+ * tipc_named_reinit - re-initialize local publications
*
* This routine is called whenever TIPC networking is enabled.
- * All existing publications by this node that have "cluster" or "zone" scope
- * are updated to reflect the node's new network address.
+ * All name table entries published by this node are updated to reflect
+ * the node's new network address.
*/
void tipc_named_reinit(void)
@@ -363,7 +369,7 @@ void tipc_named_reinit(void)
write_lock_bh(&tipc_nametbl_lock);
- for (scope = TIPC_ZONE_SCOPE; scope <= TIPC_CLUSTER_SCOPE; scope++)
+ for (scope = TIPC_ZONE_SCOPE; scope <= TIPC_NODE_SCOPE; scope++)
list_for_each_entry(publ, &publ_lists[scope]->list, local_list)
publ->node = tipc_own_addr;
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index c6a1ae3..bd80d80 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -698,7 +698,7 @@ struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper,
table.local_publ_count++;
publ = tipc_nametbl_insert_publ(type, lower, upper, scope,
tipc_own_addr, port_ref, key);
- if (publ && (scope != TIPC_NODE_SCOPE))
+ if (likely(publ))
tipc_named_publish(publ);
write_unlock_bh(&tipc_nametbl_lock);
return publ;
@@ -716,8 +716,7 @@ int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key)
publ = tipc_nametbl_remove_publ(type, lower, tipc_own_addr, ref, key);
if (likely(publ)) {
table.local_publ_count--;
- if (publ->scope != TIPC_NODE_SCOPE)
- tipc_named_withdraw(publ);
+ tipc_named_withdraw(publ);
write_unlock_bh(&tipc_nametbl_lock);
list_del_init(&publ->pport_list);
kfree(publ);
--
1.7.9.3
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 05/16] tipc: Don't record failed publication attempt as a success
2012-04-20 21:05 [PATCH net-next 00/16] tipc: publication lists and zero node handling Paul Gortmaker
` (3 preceding siblings ...)
2012-04-20 21:05 ` [PATCH net-next 04/16] tipc: Update node-scope publications when network address is assigned Paul Gortmaker
@ 2012-04-20 21:05 ` Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 06/16] tipc: Add routines for safe checking of node's network address Paul Gortmaker
` (11 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Paul Gortmaker @ 2012-04-20 21:05 UTC (permalink / raw)
To: davem; +Cc: netdev, allan.stephens, ying.xue
From: Allan Stephens <allan.stephens@windriver.com>
No longer increments counter of number of publications by a node
if an attempt to add a new publication fails. This prevents TIPC from
incorrectly blocking future publications because the configured maximum
number of publications has been reached.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
net/tipc/name_table.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index bd80d80..5d70042 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -695,11 +695,12 @@ struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper,
}
write_lock_bh(&tipc_nametbl_lock);
- table.local_publ_count++;
publ = tipc_nametbl_insert_publ(type, lower, upper, scope,
tipc_own_addr, port_ref, key);
- if (likely(publ))
+ if (likely(publ)) {
+ table.local_publ_count++;
tipc_named_publish(publ);
+ }
write_unlock_bh(&tipc_nametbl_lock);
return publ;
}
--
1.7.9.3
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 06/16] tipc: Add routines for safe checking of node's network address
2012-04-20 21:05 [PATCH net-next 00/16] tipc: publication lists and zero node handling Paul Gortmaker
` (4 preceding siblings ...)
2012-04-20 21:05 ` [PATCH net-next 05/16] tipc: Don't record failed publication attempt as a success Paul Gortmaker
@ 2012-04-20 21:05 ` Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 07/16] tipc: Ensure network address change doesn't impact name table updates Paul Gortmaker
` (10 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Paul Gortmaker @ 2012-04-20 21:05 UTC (permalink / raw)
To: davem; +Cc: netdev, allan.stephens, ying.xue
From: Allan Stephens <allan.stephens@windriver.com>
Introduces routines that test whether a given network address is
equal to a node's own network address or if it lies within the node's
own network cluster, and which work properly regardless of whether
the node is using the default network address <0.0.0> or a non-zero
network address that is assigned later on. In essence, these routines
ensure that address <0.0.0> is treated as an alias for "this node",
regardless of which network address the node is actually using.
Old users of the pre-existing more strict match in_own_cluster()
have been accordingly redirected to what is now called
in_own_cluster_exact() --- which does not extend matching to <0,0,0>.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
net/tipc/addr.h | 20 +++++++++++++++++++-
net/tipc/bearer.c | 2 +-
net/tipc/name_table.c | 6 +++---
net/tipc/node.c | 2 +-
4 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/net/tipc/addr.h b/net/tipc/addr.h
index e4f35af..d706a1d 100644
--- a/net/tipc/addr.h
+++ b/net/tipc/addr.h
@@ -50,12 +50,30 @@ static inline u32 tipc_cluster_mask(u32 addr)
return addr & TIPC_CLUSTER_MASK;
}
-static inline int in_own_cluster(u32 addr)
+static inline int in_own_cluster_exact(u32 addr)
{
return !((addr ^ tipc_own_addr) >> 12);
}
/**
+ * in_own_node - test for node inclusion; <0.0.0> always matches
+ */
+
+static inline int in_own_node(u32 addr)
+{
+ return (addr == tipc_own_addr) || !addr;
+}
+
+/**
+ * in_own_cluster - test for cluster inclusion; <0.0.0> always matches
+ */
+
+static inline int in_own_cluster(u32 addr)
+{
+ return in_own_cluster_exact(addr) || !addr;
+}
+
+/**
* addr_domain - convert 2-bit scope value to equivalent message lookup domain
*
* Needed when address of a named message must be looked up a second time
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 5dfd89c..0bfdeba 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -449,7 +449,7 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
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))
+ } else if (in_own_cluster_exact(disc_domain))
res = 0; /* accept specified node in own cluster */
}
if (res) {
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index 5d70042..1e0518d 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -342,7 +342,7 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
list_add(&publ->zone_list, &info->zone_list);
info->zone_list_size++;
- if (in_own_cluster(node)) {
+ if (in_own_cluster_exact(node)) {
list_add(&publ->cluster_list, &info->cluster_list);
info->cluster_list_size++;
}
@@ -411,7 +411,7 @@ found:
/* Remove publication from cluster scope list, if present */
- if (in_own_cluster(node)) {
+ if (in_own_cluster_exact(node)) {
list_del(&publ->cluster_list);
info->cluster_list_size--;
}
@@ -604,7 +604,7 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode)
publ = list_first_entry(&info->node_list, struct publication,
node_list);
list_move_tail(&publ->node_list, &info->node_list);
- } else if (in_own_cluster(*destnode)) {
+ } else if (in_own_cluster_exact(*destnode)) {
if (list_empty(&info->cluster_list))
goto no_match;
publ = list_first_entry(&info->cluster_list, struct publication,
diff --git a/net/tipc/node.c b/net/tipc/node.c
index a34cabc..6a71bea 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -72,7 +72,7 @@ struct tipc_node *tipc_node_find(u32 addr)
struct tipc_node *node;
struct hlist_node *pos;
- if (unlikely(!in_own_cluster(addr)))
+ if (unlikely(!in_own_cluster_exact(addr)))
return NULL;
hlist_for_each_entry(node, pos, &node_htable[tipc_hashfn(addr)], hash) {
--
1.7.9.3
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 07/16] tipc: Ensure network address change doesn't impact name table updates
2012-04-20 21:05 [PATCH net-next 00/16] tipc: publication lists and zero node handling Paul Gortmaker
` (5 preceding siblings ...)
2012-04-20 21:05 ` [PATCH net-next 06/16] tipc: Add routines for safe checking of node's network address Paul Gortmaker
@ 2012-04-20 21:05 ` Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 08/16] tipc: Optimize re-initialization of port message header templates Paul Gortmaker
` (9 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Paul Gortmaker @ 2012-04-20 21:05 UTC (permalink / raw)
To: davem; +Cc: netdev, allan.stephens, ying.xue
From: Allan Stephens <allan.stephens@windriver.com>
Revises routines that add and remove an entry from a node's name table
so that the publication scope lists are updated properly even if the
node's network address is changed in mid-operation. The routines now
recognize the default node address of <0.0.0> as an alias for "this node"
even after a new network address has been assigned.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
net/tipc/name_table.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index 1e0518d..25c2975 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -342,12 +342,12 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
list_add(&publ->zone_list, &info->zone_list);
info->zone_list_size++;
- if (in_own_cluster_exact(node)) {
+ if (in_own_cluster(node)) {
list_add(&publ->cluster_list, &info->cluster_list);
info->cluster_list_size++;
}
- if (node == tipc_own_addr) {
+ if (in_own_node(node)) {
list_add(&publ->node_list, &info->node_list);
info->node_list_size++;
}
@@ -411,14 +411,14 @@ found:
/* Remove publication from cluster scope list, if present */
- if (in_own_cluster_exact(node)) {
+ if (in_own_cluster(node)) {
list_del(&publ->cluster_list);
info->cluster_list_size--;
}
/* Remove publication from node scope list, if present */
- if (node == tipc_own_addr) {
+ if (in_own_node(node)) {
list_del(&publ->node_list);
info->node_list_size--;
}
--
1.7.9.3
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 08/16] tipc: Optimize re-initialization of port message header templates
2012-04-20 21:05 [PATCH net-next 00/16] tipc: publication lists and zero node handling Paul Gortmaker
` (6 preceding siblings ...)
2012-04-20 21:05 ` [PATCH net-next 07/16] tipc: Ensure network address change doesn't impact name table updates Paul Gortmaker
@ 2012-04-20 21:05 ` Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 09/16] tipc: Ensure network address change doesn't impact new port Paul Gortmaker
` (8 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Paul Gortmaker @ 2012-04-20 21:05 UTC (permalink / raw)
To: davem; +Cc: netdev, allan.stephens, ying.xue
From: Allan Stephens <allan.stephens@windriver.com>
Removes an unnecessary check in the logic that updates the message
header template for existing ports when a node's network address is
first assigned. There is no longer any need to check to see if the
node's network address has actually changed since the calling routine
has already verified that this is so.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
net/tipc/port.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/net/tipc/port.c b/net/tipc/port.c
index 94d2904..6156c67 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -646,8 +646,6 @@ void tipc_port_reinit(void)
spin_lock_bh(&tipc_port_list_lock);
list_for_each_entry(p_ptr, &ports, port_list) {
msg = &p_ptr->phdr;
- if (msg_orignode(msg) == tipc_own_addr)
- break;
msg_set_prevnode(msg, tipc_own_addr);
msg_set_orignode(msg, tipc_own_addr);
}
--
1.7.9.3
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 09/16] tipc: Ensure network address change doesn't impact new port
2012-04-20 21:05 [PATCH net-next 00/16] tipc: publication lists and zero node handling Paul Gortmaker
` (7 preceding siblings ...)
2012-04-20 21:05 ` [PATCH net-next 08/16] tipc: Optimize re-initialization of port message header templates Paul Gortmaker
@ 2012-04-20 21:05 ` Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 10/16] tipc: delete duplicate peerport/peernode helper functions Paul Gortmaker
` (7 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Paul Gortmaker @ 2012-04-20 21:05 UTC (permalink / raw)
To: davem; +Cc: netdev, allan.stephens, ying.xue
From: Allan Stephens <allan.stephens@windriver.com>
Re-orders port creation logic so that the initialization of a new
port's message header template occurs while the port list lock is
held. This ensures that a change to the node's network address that
occurs at the same time as the port is being created does not result
in the template identifying the sender using the former network
address. The new approach guarantees that the new port's template is
using the current network address or that it will be updated when
the address changes.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
net/tipc/port.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/net/tipc/port.c b/net/tipc/port.c
index 6156c67..3b7162c 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -221,18 +221,25 @@ struct tipc_port *tipc_createport_raw(void *usr_handle,
p_ptr->usr_handle = usr_handle;
p_ptr->max_pkt = MAX_PKT_DEFAULT;
p_ptr->ref = ref;
- msg = &p_ptr->phdr;
- tipc_msg_init(msg, importance, TIPC_NAMED_MSG, NAMED_H_SIZE, 0);
- msg_set_origport(msg, ref);
INIT_LIST_HEAD(&p_ptr->wait_list);
INIT_LIST_HEAD(&p_ptr->subscription.nodesub_list);
p_ptr->dispatcher = dispatcher;
p_ptr->wakeup = wakeup;
p_ptr->user_port = NULL;
k_init_timer(&p_ptr->timer, (Handler)port_timeout, ref);
- spin_lock_bh(&tipc_port_list_lock);
INIT_LIST_HEAD(&p_ptr->publications);
INIT_LIST_HEAD(&p_ptr->port_list);
+
+ /*
+ * Must hold port list lock while initializing message header template
+ * to ensure a change to node's own network address doesn't result
+ * in template containing out-dated network address information
+ */
+
+ spin_lock_bh(&tipc_port_list_lock);
+ msg = &p_ptr->phdr;
+ tipc_msg_init(msg, importance, TIPC_NAMED_MSG, NAMED_H_SIZE, 0);
+ msg_set_origport(msg, ref);
list_add_tail(&p_ptr->port_list, &ports);
spin_unlock_bh(&tipc_port_list_lock);
return p_ptr;
--
1.7.9.3
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 10/16] tipc: delete duplicate peerport/peernode helper functions
2012-04-20 21:05 [PATCH net-next 00/16] tipc: publication lists and zero node handling Paul Gortmaker
` (8 preceding siblings ...)
2012-04-20 21:05 ` [PATCH net-next 09/16] tipc: Ensure network address change doesn't impact new port Paul Gortmaker
@ 2012-04-20 21:05 ` Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 11/16] tipc: Ensure network address change doesn't impact local connections Paul Gortmaker
` (6 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Paul Gortmaker @ 2012-04-20 21:05 UTC (permalink / raw)
To: davem; +Cc: netdev, allan.stephens, ying.xue
From: Allan Stephens <allan.stephens@windriver.com>
Prior to commit 23dd4cce387124ec3ea06ca30d17854ae4d9b772
"tipc: Combine port structure with tipc_port structure"
there was a need for the two sets of helper functions. But
now they are just duplicates. Remove the globally visible
ones, and mark the remaining ones as inline.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
net/tipc/port.c | 8 ++++----
net/tipc/port.h | 10 ----------
2 files changed, 4 insertions(+), 14 deletions(-)
diff --git a/net/tipc/port.c b/net/tipc/port.c
index 3b7162c..f1f6b33 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -59,12 +59,12 @@ static struct sk_buff *port_build_peer_abort_msg(struct tipc_port *, u32 err);
static void port_timeout(unsigned long ref);
-static u32 port_peernode(struct tipc_port *p_ptr)
+static inline u32 port_peernode(struct tipc_port *p_ptr)
{
return msg_destnode(&p_ptr->phdr);
}
-static u32 port_peerport(struct tipc_port *p_ptr)
+static inline u32 port_peerport(struct tipc_port *p_ptr)
{
return msg_destport(&p_ptr->phdr);
}
@@ -1159,9 +1159,9 @@ int tipc_port_recv_msg(struct sk_buff *buf)
if (likely(p_ptr)) {
if (likely(p_ptr->connected)) {
if ((unlikely(msg_origport(msg) !=
- tipc_peer_port(p_ptr))) ||
+ port_peerport(p_ptr))) ||
(unlikely(msg_orignode(msg) !=
- tipc_peer_node(p_ptr))) ||
+ port_peernode(p_ptr))) ||
(unlikely(!msg_connected(msg)))) {
err = TIPC_ERR_NO_PORT;
tipc_port_unlock(p_ptr);
diff --git a/net/tipc/port.h b/net/tipc/port.h
index 9b88531..0a632a6 100644
--- a/net/tipc/port.h
+++ b/net/tipc/port.h
@@ -257,16 +257,6 @@ static inline struct tipc_port *tipc_port_deref(u32 ref)
return (struct tipc_port *)tipc_ref_deref(ref);
}
-static inline u32 tipc_peer_port(struct tipc_port *p_ptr)
-{
- return msg_destport(&p_ptr->phdr);
-}
-
-static inline u32 tipc_peer_node(struct tipc_port *p_ptr)
-{
- return msg_destnode(&p_ptr->phdr);
-}
-
static inline int tipc_port_congested(struct tipc_port *p_ptr)
{
return (p_ptr->sent - p_ptr->acked) >= (TIPC_FLOW_CONTROL_WIN * 2);
--
1.7.9.3
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 11/16] tipc: Ensure network address change doesn't impact local connections
2012-04-20 21:05 [PATCH net-next 00/16] tipc: publication lists and zero node handling Paul Gortmaker
` (9 preceding siblings ...)
2012-04-20 21:05 ` [PATCH net-next 10/16] tipc: delete duplicate peerport/peernode helper functions Paul Gortmaker
@ 2012-04-20 21:05 ` Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 12/16] tipc: take lock while updating node network address Paul Gortmaker
` (5 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Paul Gortmaker @ 2012-04-20 21:05 UTC (permalink / raw)
To: davem; +Cc: netdev, allan.stephens, ying.xue
From: Allan Stephens <allan.stephens@windriver.com>
Revises routines that deal with connections between two ports on
the same node to ensure the connection is not impacted if the node's
network address is changed in mid-operation. The routines now treat
the default node address of <0.0.0> as an alias for "this node" in
the following situations:
1) Incoming messages destined to a connected port now handle the alias
properly when validating that the message was sent by the expected
peer port, ensuring that the message will be accepted regardless of
whether it specifies the node's old network address or it's current one.
2) The code which completes connection establishment now handles the
alias properly when determining if the peer port is on the same node
as the connected port.
An added benefit of addressing issue 1) is that some peer port
validation code has been relocated to TIPC's socket subsystem, which
means that validation is no longer done twice when a message is
sent to a non-socket port (such as TIPC's configuration service or
network topology service).
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
net/tipc/node_subscr.c | 2 +-
net/tipc/port.c | 59 ++++++++++++++++++++++++------------------------
net/tipc/port.h | 1 +
net/tipc/socket.c | 3 ++-
4 files changed, 34 insertions(+), 31 deletions(-)
diff --git a/net/tipc/node_subscr.c b/net/tipc/node_subscr.c
index c3c2815..327ffbb 100644
--- a/net/tipc/node_subscr.c
+++ b/net/tipc/node_subscr.c
@@ -45,7 +45,7 @@
void tipc_nodesub_subscribe(struct tipc_node_subscr *node_sub, u32 addr,
void *usr_handle, net_ev_handler handle_down)
{
- if (addr == tipc_own_addr) {
+ if (in_own_node(addr)) {
node_sub->node = NULL;
return;
}
diff --git a/net/tipc/port.c b/net/tipc/port.c
index f1f6b33..616c72f 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -69,6 +69,28 @@ static inline u32 port_peerport(struct tipc_port *p_ptr)
return msg_destport(&p_ptr->phdr);
}
+/*
+ * tipc_port_peer_msg - verify message was sent by connected port's peer
+ *
+ * Handles cases where the node's network address has changed from
+ * the default of <0.0.0> to its configured setting.
+ */
+
+int tipc_port_peer_msg(struct tipc_port *p_ptr, struct tipc_msg *msg)
+{
+ u32 peernode;
+ u32 orignode;
+
+ if (msg_origport(msg) != port_peerport(p_ptr))
+ return 0;
+
+ orignode = msg_orignode(msg);
+ peernode = port_peernode(p_ptr);
+ return (orignode == peernode) ||
+ (!orignode && (peernode == tipc_own_addr)) ||
+ (!peernode && (orignode == tipc_own_addr));
+}
+
/**
* tipc_multicast - send a multicast message to local and remote destinations
*/
@@ -526,25 +548,21 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf)
struct tipc_msg *msg = buf_msg(buf);
struct tipc_port *p_ptr;
struct sk_buff *r_buf = NULL;
- u32 orignode = msg_orignode(msg);
- u32 origport = msg_origport(msg);
u32 destport = msg_destport(msg);
int wakeable;
/* Validate connection */
p_ptr = tipc_port_lock(destport);
- if (!p_ptr || !p_ptr->connected ||
- (port_peernode(p_ptr) != orignode) ||
- (port_peerport(p_ptr) != origport)) {
+ if (!p_ptr || !p_ptr->connected || !tipc_port_peer_msg(p_ptr, msg)) {
r_buf = tipc_buf_acquire(BASIC_H_SIZE);
if (r_buf) {
msg = buf_msg(r_buf);
tipc_msg_init(msg, TIPC_HIGH_IMPORTANCE, TIPC_CONN_MSG,
- BASIC_H_SIZE, orignode);
+ BASIC_H_SIZE, msg_orignode(msg));
msg_set_errcode(msg, TIPC_ERR_NO_PORT);
msg_set_origport(msg, destport);
- msg_set_destport(msg, origport);
+ msg_set_destport(msg, msg_origport(msg));
}
if (p_ptr)
tipc_port_unlock(p_ptr);
@@ -681,6 +699,7 @@ static void port_dispatcher_sigh(void *dummy)
struct tipc_name_seq dseq;
void *usr_handle;
int connected;
+ int peer_invalid;
int published;
u32 message_type;
@@ -701,6 +720,7 @@ static void port_dispatcher_sigh(void *dummy)
up_ptr = p_ptr->user_port;
usr_handle = up_ptr->usr_handle;
connected = p_ptr->connected;
+ peer_invalid = connected && !tipc_port_peer_msg(p_ptr, msg);
published = p_ptr->published;
if (unlikely(msg_errcode(msg)))
@@ -710,8 +730,6 @@ static void port_dispatcher_sigh(void *dummy)
case TIPC_CONN_MSG:{
tipc_conn_msg_event cb = up_ptr->conn_msg_cb;
- u32 peer_port = port_peerport(p_ptr);
- u32 peer_node = port_peernode(p_ptr);
u32 dsz;
tipc_port_unlock(p_ptr);
@@ -720,8 +738,7 @@ static void port_dispatcher_sigh(void *dummy)
if (unlikely(!connected)) {
if (tipc_connect2port(dref, &orig))
goto reject;
- } else if ((msg_origport(msg) != peer_port) ||
- (msg_orignode(msg) != peer_node))
+ } else if (peer_invalid)
goto reject;
dsz = msg_data_sz(msg);
if (unlikely(dsz &&
@@ -773,14 +790,9 @@ err:
case TIPC_CONN_MSG:{
tipc_conn_shutdown_event cb =
up_ptr->conn_err_cb;
- u32 peer_port = port_peerport(p_ptr);
- u32 peer_node = port_peernode(p_ptr);
tipc_port_unlock(p_ptr);
- if (!cb || !connected)
- break;
- if ((msg_origport(msg) != peer_port) ||
- (msg_orignode(msg) != peer_node))
+ if (!cb || !connected || peer_invalid)
break;
tipc_disconnect(dref);
skb_pull(buf, msg_hdr_sz(msg));
@@ -1157,17 +1169,6 @@ int tipc_port_recv_msg(struct sk_buff *buf)
/* validate destination & pass to port, otherwise reject message */
p_ptr = tipc_port_lock(destport);
if (likely(p_ptr)) {
- if (likely(p_ptr->connected)) {
- if ((unlikely(msg_origport(msg) !=
- port_peerport(p_ptr))) ||
- (unlikely(msg_orignode(msg) !=
- port_peernode(p_ptr))) ||
- (unlikely(!msg_connected(msg)))) {
- err = TIPC_ERR_NO_PORT;
- tipc_port_unlock(p_ptr);
- goto reject;
- }
- }
err = p_ptr->dispatcher(p_ptr, buf);
tipc_port_unlock(p_ptr);
if (likely(!err))
@@ -1175,7 +1176,7 @@ int tipc_port_recv_msg(struct sk_buff *buf)
} else {
err = TIPC_ERR_NO_PORT;
}
-reject:
+
return tipc_reject_msg(buf, err);
}
diff --git a/net/tipc/port.h b/net/tipc/port.h
index 0a632a6..301e1bd 100644
--- a/net/tipc/port.h
+++ b/net/tipc/port.h
@@ -201,6 +201,7 @@ int tipc_shutdown(u32 ref);
* The following routines require that the port be locked on entry
*/
int tipc_disconnect_port(struct tipc_port *tp_ptr);
+int tipc_port_peer_msg(struct tipc_port *p_ptr, struct tipc_msg *msg);
/*
* TIPC messaging routines
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index bcb3314..c19fc4a 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -1236,7 +1236,8 @@ static u32 filter_rcv(struct sock *sk, struct sk_buff *buf)
if (msg_mcast(msg))
return TIPC_ERR_NO_PORT;
if (sock->state == SS_CONNECTED) {
- if (!msg_connected(msg))
+ if (!msg_connected(msg) ||
+ !tipc_port_peer_msg(tipc_sk_port(sk), msg))
return TIPC_ERR_NO_PORT;
} else if (sock->state == SS_CONNECTING) {
if (!msg_connected(msg) && (msg_errcode(msg) == 0))
--
1.7.9.3
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 12/16] tipc: take lock while updating node network address
2012-04-20 21:05 [PATCH net-next 00/16] tipc: publication lists and zero node handling Paul Gortmaker
` (10 preceding siblings ...)
2012-04-20 21:05 ` [PATCH net-next 11/16] tipc: Ensure network address change doesn't impact local connections Paul Gortmaker
@ 2012-04-20 21:05 ` Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 13/16] tipc: properly handle off-node send requests with invalid addr Paul Gortmaker
` (4 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Paul Gortmaker @ 2012-04-20 21:05 UTC (permalink / raw)
To: davem; +Cc: netdev, allan.stephens, ying.xue
From: Allan Stephens <allan.stephens@windriver.com>
The routine that changes the node's network address now takes TIPC's
network lock in write mode while the main address variable and associated
data structures are being changed; this is needed to ensure that the
link subsystem won't attempt to send a message off-node until the sending
port's message header template has been updated with the node's new
network address.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
net/tipc/net.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/tipc/net.c b/net/tipc/net.c
index d4531b0..5fab4ff 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -178,11 +178,12 @@ int tipc_net_start(u32 addr)
tipc_subscr_stop();
tipc_cfg_stop();
+ write_lock_bh(&tipc_net_lock);
tipc_own_addr = addr;
tipc_named_reinit();
tipc_port_reinit();
-
tipc_bclink_init();
+ write_unlock_bh(&tipc_net_lock);
tipc_k_signal((Handler)tipc_subscr_start, 0);
tipc_k_signal((Handler)tipc_cfg_init, 0);
--
1.7.9.3
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 13/16] tipc: properly handle off-node send requests with invalid addr
2012-04-20 21:05 [PATCH net-next 00/16] tipc: publication lists and zero node handling Paul Gortmaker
` (11 preceding siblings ...)
2012-04-20 21:05 ` [PATCH net-next 12/16] tipc: take lock while updating node network address Paul Gortmaker
@ 2012-04-20 21:05 ` Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 14/16] tipc: handle <0.0.0> as an alias for this node on outgoing msgs Paul Gortmaker
` (3 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Paul Gortmaker @ 2012-04-20 21:05 UTC (permalink / raw)
To: davem; +Cc: netdev, allan.stephens, ying.xue
From: Allan Stephens <allan.stephens@windriver.com>
There are two send routines that might conceivably be asked by an
application to send a message off-node when the node is still using
the default network address. These now have an added check that
detects this and rejects the message gracefully.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
net/tipc/port.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/net/tipc/port.c b/net/tipc/port.c
index 616c72f..dc7f916 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -1270,10 +1270,14 @@ int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain,
if (likely(destnode == tipc_own_addr))
res = tipc_port_recv_sections(p_ptr, num_sect,
msg_sect, total_len);
- else
+ else if (tipc_own_addr)
res = tipc_link_send_sections_fast(p_ptr, msg_sect,
num_sect, total_len,
destnode);
+ else
+ res = tipc_port_reject_sections(p_ptr, msg, msg_sect,
+ num_sect, total_len,
+ TIPC_ERR_NO_NODE);
if (likely(res != -ELINKCONG)) {
if (res > 0)
p_ptr->sent++;
@@ -1314,9 +1318,12 @@ int tipc_send2port(u32 ref, struct tipc_portid const *dest,
if (dest->node == tipc_own_addr)
res = tipc_port_recv_sections(p_ptr, num_sect, msg_sect,
total_len);
- else
+ else if (tipc_own_addr)
res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect,
total_len, dest->node);
+ else
+ res = tipc_port_reject_sections(p_ptr, msg, msg_sect, num_sect,
+ total_len, TIPC_ERR_NO_NODE);
if (likely(res != -ELINKCONG)) {
if (res > 0)
p_ptr->sent++;
--
1.7.9.3
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 14/16] tipc: handle <0.0.0> as an alias for this node on outgoing msgs
2012-04-20 21:05 [PATCH net-next 00/16] tipc: publication lists and zero node handling Paul Gortmaker
` (12 preceding siblings ...)
2012-04-20 21:05 ` [PATCH net-next 13/16] tipc: properly handle off-node send requests with invalid addr Paul Gortmaker
@ 2012-04-20 21:05 ` Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 15/16] tipc: Ensure network address change doesn't impact rejected message Paul Gortmaker
` (2 subsequent siblings)
16 siblings, 0 replies; 20+ messages in thread
From: Paul Gortmaker @ 2012-04-20 21:05 UTC (permalink / raw)
To: davem; +Cc: netdev, allan.stephens, ying.xue
From: Allan Stephens <allan.stephens@windriver.com>
Revises handling of send routines for payload messages to ensure that
they are processed properly even if the node's network address is
changed in mid-operation. The routines now treat the default node
address of <0.0.0> as an alias for "this node" when determining where
to send an outgoing message.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
net/tipc/port.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/tipc/port.c b/net/tipc/port.c
index dc7f916..c50819b 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -1217,7 +1217,7 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect,
p_ptr->congested = 1;
if (!tipc_port_congested(p_ptr)) {
destnode = port_peernode(p_ptr);
- if (likely(destnode != tipc_own_addr))
+ if (likely(!in_own_node(destnode)))
res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect,
total_len, destnode);
else
@@ -1267,7 +1267,7 @@ int tipc_send2name(u32 ref, struct tipc_name const *name, unsigned int domain,
msg_set_destport(msg, destport);
if (likely(destport || destnode)) {
- if (likely(destnode == tipc_own_addr))
+ if (likely(in_own_node(destnode)))
res = tipc_port_recv_sections(p_ptr, num_sect,
msg_sect, total_len);
else if (tipc_own_addr)
@@ -1315,7 +1315,7 @@ int tipc_send2port(u32 ref, struct tipc_portid const *dest,
msg_set_destport(msg, dest->ref);
msg_set_hdr_sz(msg, BASIC_H_SIZE);
- if (dest->node == tipc_own_addr)
+ if (in_own_node(dest->node))
res = tipc_port_recv_sections(p_ptr, num_sect, msg_sect,
total_len);
else if (tipc_own_addr)
@@ -1362,7 +1362,7 @@ int tipc_send_buf2port(u32 ref, struct tipc_portid const *dest,
skb_push(buf, BASIC_H_SIZE);
skb_copy_to_linear_data(buf, msg, BASIC_H_SIZE);
- if (dest->node == tipc_own_addr)
+ if (in_own_node(dest->node))
res = tipc_port_recv_msg(buf);
else
res = tipc_send_buf_fast(buf, dest->node);
--
1.7.9.3
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 15/16] tipc: Ensure network address change doesn't impact rejected message
2012-04-20 21:05 [PATCH net-next 00/16] tipc: publication lists and zero node handling Paul Gortmaker
` (13 preceding siblings ...)
2012-04-20 21:05 ` [PATCH net-next 14/16] tipc: handle <0.0.0> as an alias for this node on outgoing msgs Paul Gortmaker
@ 2012-04-20 21:05 ` Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 16/16] tipc: Ensure network address change doesn't impact configuration service Paul Gortmaker
2012-04-21 0:45 ` [PATCH net-next 00/16] tipc: publication lists and zero node handling David Miller
16 siblings, 0 replies; 20+ messages in thread
From: Paul Gortmaker @ 2012-04-20 21:05 UTC (permalink / raw)
To: davem; +Cc: netdev, allan.stephens, ying.xue
From: Allan Stephens <allan.stephens@windriver.com>
Revises handling of a rejected message to ensure that a locally
originated message is returned properly even if the node's network
address is changed in mid-operation. The routine now treats the
default node address of <0.0.0> as an alias for "this node" when
determining where to send a returned message.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
net/tipc/port.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/tipc/port.c b/net/tipc/port.c
index c50819b..0f40b10 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -444,7 +444,7 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
/* send returned message & dispose of rejected message */
src_node = msg_prevnode(msg);
- if (src_node == tipc_own_addr)
+ if (in_own_node(src_node))
tipc_port_recv_msg(rbuf);
else
tipc_link_send(rbuf, src_node, msg_link_selector(rmsg));
--
1.7.9.3
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 16/16] tipc: Ensure network address change doesn't impact configuration service
2012-04-20 21:05 [PATCH net-next 00/16] tipc: publication lists and zero node handling Paul Gortmaker
` (14 preceding siblings ...)
2012-04-20 21:05 ` [PATCH net-next 15/16] tipc: Ensure network address change doesn't impact rejected message Paul Gortmaker
@ 2012-04-20 21:05 ` Paul Gortmaker
2012-04-21 0:45 ` [PATCH net-next 00/16] tipc: publication lists and zero node handling David Miller
16 siblings, 0 replies; 20+ messages in thread
From: Paul Gortmaker @ 2012-04-20 21:05 UTC (permalink / raw)
To: davem; +Cc: netdev, allan.stephens, ying.xue
From: Allan Stephens <allan.stephens@windriver.com>
Enhances command validation done by TIPC's configuration service so
that it works properly even if the node's network address is changed in
mid-operation. The default node address of <0.0.0> is now recognized as an
alias for "this node" even after a new network address has been assigned.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
net/tipc/config.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/tipc/config.c b/net/tipc/config.c
index f76d3b1..f5458ed 100644
--- a/net/tipc/config.c
+++ b/net/tipc/config.c
@@ -290,7 +290,7 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area
/* Check command authorization */
- if (likely(orig_node == tipc_own_addr)) {
+ if (likely(in_own_node(orig_node))) {
/* command is permitted */
} else if (cmd >= 0x8000) {
rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
--
1.7.9.3
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH net-next 00/16] tipc: publication lists and zero node handling
2012-04-20 21:05 [PATCH net-next 00/16] tipc: publication lists and zero node handling Paul Gortmaker
` (15 preceding siblings ...)
2012-04-20 21:05 ` [PATCH net-next 16/16] tipc: Ensure network address change doesn't impact configuration service Paul Gortmaker
@ 2012-04-21 0:45 ` David Miller
2012-04-23 14:49 ` [PATCH net-next] tipc: remove inline instances from C source files Paul Gortmaker
16 siblings, 1 reply; 20+ messages in thread
From: David Miller @ 2012-04-21 0:45 UTC (permalink / raw)
To: paul.gortmaker; +Cc: netdev, allan.stephens, ying.xue
From: Paul Gortmaker <paul.gortmaker@windriver.com>
Date: Fri, 20 Apr 2012 17:05:08 -0400
> This series of commits largely focuses on two things. The 1st is
> to categorize the TIPC publication lists, so better control over
> the publications can be achieved. The 2nd is largely to improve
> corner cases around the tipc address changes and how the <0.0.0>
> tipc address is interpreted.
>
> What remains after this, is less than 10 commits originating from
> what was salvaged from the tipc-1.7 sourceforge fork, so I'm happy to
> see the end of this task so close. I'll be looking at those shortly.
>
> The tipc tests (tipcTS <--> tipcTC) have been used in both directions
> between a 32bit and a 64bit machine to do runtime testing, and the
> entire series has been confirmed to be compile time bisectable too.
>
> Credit to Al for all the heavy lifting. I've just refactored things
> a bit and made minor changes here and there.
Pulled, thanks Paul.
Please remove the inline tags from static functions, let the compiler
decide what to do. The only spot appropriate to use inline tags these
days is helper functions defined in header files.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH net-next] tipc: remove inline instances from C source files.
2012-04-21 0:45 ` [PATCH net-next 00/16] tipc: publication lists and zero node handling David Miller
@ 2012-04-23 14:49 ` Paul Gortmaker
2012-04-24 4:41 ` David Miller
0 siblings, 1 reply; 20+ messages in thread
From: Paul Gortmaker @ 2012-04-23 14:49 UTC (permalink / raw)
To: davem; +Cc: netdev, allan.stephens
Untie gcc's hands and let it do what it wants within the
individual source files. There are two files, node.c and
port.c -- only the latter effectively changes (gcc-4.5.2).
Objdump shows gcc deciding to not inline port_peernode().
Suggested-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 6a71bea..76565c9 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -58,7 +58,7 @@ static atomic_t tipc_num_links = ATOMIC_INIT(0);
* entries has been chosen so that no hash chain exceeds 8 nodes and will
* usually be much smaller (typically only a single node).
*/
-static inline unsigned int tipc_hashfn(u32 addr)
+static unsigned int tipc_hashfn(u32 addr)
{
return addr & (NODE_HTABLE_SIZE - 1);
}
diff --git a/net/tipc/port.c b/net/tipc/port.c
index 0f40b10..4aede40 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -59,12 +59,12 @@ static struct sk_buff *port_build_peer_abort_msg(struct tipc_port *, u32 err);
static void port_timeout(unsigned long ref);
-static inline u32 port_peernode(struct tipc_port *p_ptr)
+static u32 port_peernode(struct tipc_port *p_ptr)
{
return msg_destnode(&p_ptr->phdr);
}
-static inline u32 port_peerport(struct tipc_port *p_ptr)
+static u32 port_peerport(struct tipc_port *p_ptr)
{
return msg_destport(&p_ptr->phdr);
}
--
1.7.9.3
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH net-next] tipc: remove inline instances from C source files.
2012-04-23 14:49 ` [PATCH net-next] tipc: remove inline instances from C source files Paul Gortmaker
@ 2012-04-24 4:41 ` David Miller
0 siblings, 0 replies; 20+ messages in thread
From: David Miller @ 2012-04-24 4:41 UTC (permalink / raw)
To: paul.gortmaker; +Cc: netdev, allan.stephens
From: Paul Gortmaker <paul.gortmaker@windriver.com>
Date: Mon, 23 Apr 2012 10:49:13 -0400
> Untie gcc's hands and let it do what it wants within the
> individual source files. There are two files, node.c and
> port.c -- only the latter effectively changes (gcc-4.5.2).
> Objdump shows gcc deciding to not inline port_peernode().
>
> Suggested-by: David S. Miller <davem@davemloft.net>
> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Applied, thanks Paul.
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2012-04-24 4:41 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-20 21:05 [PATCH net-next 00/16] tipc: publication lists and zero node handling Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 01/16] tipc: introduce publication lists struct Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 02/16] tipc: Factor out name publication code to a separate function Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 03/16] tipc: Separate cluster-scope and zone-scope names into distinct lists Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 04/16] tipc: Update node-scope publications when network address is assigned Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 05/16] tipc: Don't record failed publication attempt as a success Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 06/16] tipc: Add routines for safe checking of node's network address Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 07/16] tipc: Ensure network address change doesn't impact name table updates Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 08/16] tipc: Optimize re-initialization of port message header templates Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 09/16] tipc: Ensure network address change doesn't impact new port Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 10/16] tipc: delete duplicate peerport/peernode helper functions Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 11/16] tipc: Ensure network address change doesn't impact local connections Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 12/16] tipc: take lock while updating node network address Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 13/16] tipc: properly handle off-node send requests with invalid addr Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 14/16] tipc: handle <0.0.0> as an alias for this node on outgoing msgs Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 15/16] tipc: Ensure network address change doesn't impact rejected message Paul Gortmaker
2012-04-20 21:05 ` [PATCH net-next 16/16] tipc: Ensure network address change doesn't impact configuration service Paul Gortmaker
2012-04-21 0:45 ` [PATCH net-next 00/16] tipc: publication lists and zero node handling David Miller
2012-04-23 14:49 ` [PATCH net-next] tipc: remove inline instances from C source files Paul Gortmaker
2012-04-24 4:41 ` 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).