Skip to contentSkip to conversation

TIPC: Updates for what will be v3.3

PATCH In review Paul Gortmaker 2 participants 26 messages Dec 27, 2011 – Dec 28, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover TIPC: Updates for what will be v3.3

Hi Dave,

Here are some more updates for TIPC, based on the backlog of stuff that was unfortunately stacked away in sourceforge a while ago.

Given the timing, please feel free to defer these to the for-3.4 net-next if there isn't a convenient opportunity to process it before 3.2 is officially released. I can easily resend later.

Fortunately, the SF backlog will finally be 100% gone with the pending stuff that will be sent in the next year for the 3.4 net-next, so that will be nice to have that task closed out.

I just finished testing this over the wire between an x86-32 and an x86-64 box, with both taking turns being server and client.

Thanks,
Paul.

---
The following changes since commit 1ba9ac7c35b30d6b958a30240e21ddaea8d21b35:

bonding: document undocumented active_slave sysfs entry. (2011-12-26 20:09:35 -0500)

are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux.git tipc-Dec27-2011

Allan Stephens (23):
tipc: Enable use by containers having their own network namespace
tipc: Register new media using pre-compiled structure
tipc: Optimize detection of duplicate media registration
tipc: Eliminate duplication of media structures
tipc: Streamline media registration error checking
tipc: Improve handling of media address printing errors
tipc: Add new address conversion routines for Ethernet media
tipc: Hide media-specific addressing details from generic bearer code
tipc: Ignore neighbor discovery messages containing invalid address
tipc: Allow run-time alteration of default link settings
tipc: Revise comment justifying release of configuration spinlock
tipc: Minor optimization to deactivation of Ethernet media suppot
tipc: Do timely cleanup of disabled Ethernet bearer resources
tipc: Eliminate useless memset operations in Ethernet media support
tipc: Minor correction to TIPC module unloading
tipc: Eliminate useless check when network address is assigned
tipc: Eliminate dynamic allocation of broadcast link data structures
tipc: Ensure broadcast link spinlock is held when updating node map
tipc: Handle broadcast attempt when no neighboring nodes exist
tipc: Minor optimization of broadcast link transmit queue statistic
tipc: Flush unsent broadcast messages when contact with last node is lost
tipc: Ignore broadcast acknowledgements that are out-of-range
tipc: Allow use of buf_seqno() helper routine by unicast links

 net/tipc/bcast.c      |  125 +++++++++++++++++++------------
 net/tipc/bcast.h      |    6 +-
 net/tipc/bearer.c     |  158 ++++++++++++++-------------------------
 net/tipc/bearer.h     |   58 +++++++++------
 net/tipc/config.c     |   13 ++--
 net/tipc/core.c       |    2 +-
 net/tipc/discover.c   |    7 +-
 net/tipc/eth_media.c  |  159 ++++++++++++++++++++++++++++++----------
 net/tipc/link.c       |  195 ++++++++++++++++++++++++++++++++----------------
 net/tipc/link.h       |   11 +++
 net/tipc/msg.c        |    9 ++-
 net/tipc/msg.h        |   16 ++---
 net/tipc/name_distr.c |   12 +--
 net/tipc/net.c        |    7 +-
 net/tipc/node.c       |    7 +-
 net/tipc/socket.c     |    3 -
 16 files changed, 466 insertions(+), 322 deletions(-)
Signature · 1 line
1.7.4.4
#1 lore raw

PATCH 1/23 tipc: Enable use by containers having their own network namespace

From: Allan Stephens <[email protected]>

Permits a Linux container to use TIPC sockets even when it has its own network namespace defined by removing the check that prohibits such use. This makes it possible for users who wish to isolate their container network traffic from normal network traffic to utilize TIPC.

---
 net/tipc/socket.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
net/tipc/socket.c +0 -3
index 42b8324..e2f7c5d 100644
@@ -185,9 +185,6 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol,
 
 	/* Validate arguments */
 
-	if (!net_eq(net, &init_net))
-		return -EAFNOSUPPORT;
-
 	if (unlikely(protocol != 0))
 		return -EPROTONOSUPPORT;
 
Signature · 1 line
1.7.4.4
#2 lore raw

PATCH 2/23 tipc: Register new media using pre-compiled structure

In reply to Paul Gortmaker

From: Allan Stephens <[email protected]>

Speeds up the registration of TIPC media types by passing in a structure containing the required information, rather than by passing in the various fields describing the media type individually.

---
 net/tipc/bearer.c    |   70 ++++++++++++++++++--------------------------------
 net/tipc/bearer.h    |   11 +-------
 net/tipc/eth_media.c |   30 +++++++++++++--------
 3 files changed, 45 insertions(+), 66 deletions(-)
net/tipc/bearer.c +25 -45
index e2202de..75af271 100644
@@ -86,21 +86,8 @@ static struct media *media_find(const char *name)
  * Bearers for this media type must be activated separately at a later stage.
  */
 
-int  tipc_register_media(u32 media_type,
-			 char *name,
-			 int (*enable)(struct tipc_bearer *),
-			 void (*disable)(struct tipc_bearer *),
-			 int (*send_msg)(struct sk_buff *,
-					 struct tipc_bearer *,
-					 struct tipc_media_addr *),
-			 char *(*addr2str)(struct tipc_media_addr *a,
-					   char *str_buf, int str_size),
-			 struct tipc_media_addr *bcast_addr,
-			 const u32 bearer_priority,
-			 const u32 link_tolerance,  /* [ms] */
-			 const u32 send_window_limit)
+int  tipc_register_media(struct media *m_ptr)
 {
-	struct media *m_ptr;
 	u32 media_id;
 	u32 i;
 	int res = -EINVAL;
@@ -108,62 +95,55 @@ int  tipc_register_media(u32 media_type,
 	write_lock_bh(&tipc_net_lock);
 
 	if (tipc_mode != TIPC_NET_MODE) {
-		warn("Media <%s> rejected, not in networked mode yet\n", name);
+		warn("Media <%s> rejected, not in networked mode yet\n",
+		     m_ptr->name);
 		goto exit;
 	}
-	if (!media_name_valid(name)) {
-		warn("Media <%s> rejected, illegal name\n", name);
+	if (!media_name_valid(m_ptr->name)) {
+		warn("Media <%s> rejected, illegal name\n", m_ptr->name);
 		goto exit;
 	}
-	if (!bcast_addr) {
-		warn("Media <%s> rejected, no broadcast address\n", name);
+	if (m_ptr->bcast_addr.type != htonl(m_ptr->type_id)) {
+		warn("Media <%s> rejected, illegal broadcast address\n",
+		     m_ptr->name);
 		goto exit;
 	}
-	if ((bearer_priority < TIPC_MIN_LINK_PRI) ||
-	    (bearer_priority > TIPC_MAX_LINK_PRI)) {
-		warn("Media <%s> rejected, illegal priority (%u)\n", name,
-		     bearer_priority);
+	if ((m_ptr->priority < TIPC_MIN_LINK_PRI) ||
+	    (m_ptr->priority > TIPC_MAX_LINK_PRI)) {
+		warn("Media <%s> rejected, illegal priority (%u)\n",
+		     m_ptr->name, m_ptr->priority);
 		goto exit;
 	}
-	if ((link_tolerance < TIPC_MIN_LINK_TOL) ||
-	    (link_tolerance > TIPC_MAX_LINK_TOL)) {
-		warn("Media <%s> rejected, illegal tolerance (%u)\n", name,
-		     link_tolerance);
+	if ((m_ptr->tolerance < TIPC_MIN_LINK_TOL) ||
+	    (m_ptr->tolerance > TIPC_MAX_LINK_TOL)) {
+		warn("Media <%s> rejected, illegal tolerance (%u)\n",
+		     m_ptr->name, m_ptr->tolerance);
 		goto exit;
 	}
 
 	media_id = media_count++;
 	if (media_id >= MAX_MEDIA) {
-		warn("Media <%s> rejected, media limit reached (%u)\n", name,
-		     MAX_MEDIA);
+		warn("Media <%s> rejected, media limit reached (%u)\n",
+		     m_ptr->name, MAX_MEDIA);
 		media_count--;
 		goto exit;
 	}
 	for (i = 0; i < media_id; i++) {
-		if (media_list[i].type_id == media_type) {
-			warn("Media <%s> rejected, duplicate type (%u)\n", name,
-			     media_type);
+		if (media_list[i].type_id == m_ptr->type_id) {
+			warn("Media <%s> rejected, duplicate type (%u)\n",
+			     m_ptr->name, m_ptr->type_id);
 			media_count--;
 			goto exit;
 		}
-		if (!strcmp(name, media_list[i].name)) {
-			warn("Media <%s> rejected, duplicate name\n", name);
+		if (!strcmp(m_ptr->name, media_list[i].name)) {
+			warn("Media <%s> rejected, duplicate name\n",
+			     m_ptr->name);
 			media_count--;
 			goto exit;
 		}
 	}
 
-	m_ptr = &media_list[media_id];
-	m_ptr->type_id = media_type;
-	m_ptr->send_msg = send_msg;
-	m_ptr->enable_bearer = enable;
-	m_ptr->disable_bearer = disable;
-	m_ptr->addr2str = addr2str;
-	memcpy(&m_ptr->bcast_addr, bcast_addr, sizeof(*bcast_addr));
-	strcpy(m_ptr->name, name);
-	m_ptr->priority = bearer_priority;
-	m_ptr->tolerance = link_tolerance;
-	m_ptr->window = send_window_limit;
+	media_list[media_id] = *m_ptr;
 	res = 0;
 exit:
 	write_unlock_bh(&tipc_net_lock);
net/tipc/bearer.h +1 -10
index d696f9e..148ed04 100644
@@ -145,16 +145,7 @@ extern struct tipc_bearer tipc_bearers[];
 /*
  * TIPC routines available to supported media types
  */
-int tipc_register_media(u32 media_type,
-		 char *media_name, int (*enable)(struct tipc_bearer *),
-		 void (*disable)(struct tipc_bearer *),
-		 int (*send_msg)(struct sk_buff *,
-			struct tipc_bearer *, struct tipc_media_addr *),
-		 char *(*addr2str)(struct tipc_media_addr *a,
-			char *str_buf, int str_size),
-		 struct tipc_media_addr *bcast_addr, const u32 bearer_priority,
-		 const u32 link_tolerance,  /* [ms] */
-		 const u32 send_window_limit);
+int tipc_register_media(struct media *m_ptr);
 
 void tipc_recv_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr);
 
net/tipc/eth_media.c +19 -11
index e728d4c..15c685b 100644
@@ -38,9 +38,6 @@
 #include "bearer.h"
 
 #define MAX_ETH_BEARERS		MAX_BEARERS
-#define ETH_LINK_PRIORITY	TIPC_DEF_LINK_PRI
-#define ETH_LINK_TOLERANCE	TIPC_DEF_LINK_TOL
-#define ETH_LINK_WINDOW		TIPC_DEF_LINK_WIN
 
 /**
  * struct eth_bearer - Ethernet bearer data structure
@@ -257,6 +254,24 @@ static char *eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size
 	return str_buf;
 }
 
+/*
+ * Ethernet media registration info
+ */
+
+static struct media eth_media_info = {
+	.send_msg	= send_msg,
+	.enable_bearer	= enable_bearer,
+	.disable_bearer	= disable_bearer,
+	.addr2str	= eth_addr2str,
+	.bcast_addr	= { htonl(TIPC_MEDIA_TYPE_ETH),
+			    { {0xff, 0xff, 0xff, 0xff, 0xff, 0xff} } },
+	.priority	= TIPC_DEF_LINK_PRI,
+	.tolerance	= TIPC_DEF_LINK_TOL,
+	.window		= TIPC_DEF_LINK_WIN,
+	.type_id	= TIPC_MEDIA_TYPE_ETH,
+	.name		= "eth"
+};
+
 /**
  * tipc_eth_media_start - activate Ethernet bearer support
  *
@@ -266,21 +281,14 @@ static char *eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size
 
 int tipc_eth_media_start(void)
 {
-	struct tipc_media_addr bcast_addr;
 	int res;
 
 	if (eth_started)
 		return -EINVAL;
 
-	bcast_addr.type = htonl(TIPC_MEDIA_TYPE_ETH);
-	memset(&bcast_addr.dev_addr, 0xff, ETH_ALEN);
-
 	memset(eth_bearers, 0, sizeof(eth_bearers));
 
-	res = tipc_register_media(TIPC_MEDIA_TYPE_ETH, "eth",
-				  enable_bearer, disable_bearer, send_msg,
-				  eth_addr2str, &bcast_addr, ETH_LINK_PRIORITY,
-				  ETH_LINK_TOLERANCE, ETH_LINK_WINDOW);
+	res = tipc_register_media(&eth_media_info);
 	if (res)
 		return res;
 
Signature · 1 line
1.7.4.4
#3 lore raw

PATCH 3/23 tipc: Optimize detection of duplicate media registration

In reply to Paul Gortmaker

From: Allan Stephens <[email protected]>

Streamlines the detection of an attempt to register a TIPC media structure using an already registered name or type identifier. The revised logic now reuses an existing routine to detect an existing name and no longer unnecessarily manipulates the media type counter during an unsuccessful registration attempt.

---
 net/tipc/bearer.c |   40 +++++++++++++++++++++-------------------
 1 files changed, 21 insertions(+), 19 deletions(-)
net/tipc/bearer.c +21 -19
index 75af271..9ff8920 100644
@@ -81,6 +81,21 @@ static struct media *media_find(const char *name)
 }
 
 /**
+ * media_find_id - locates specified media object by type identifier
+ */
+
+static struct media *media_find_id(u8 type)
+{
+	u32 i;
+
+	for (i = 0; i < media_count; i++) {
+		if (media_list[i].type_id == type)
+			return &media_list[i];
+	}
+	return NULL;
+}
+
+/**
  * tipc_register_media - register a media type
  *
  * Bearers for this media type must be activated separately at a later stage.
@@ -88,8 +103,6 @@ static struct media *media_find(const char *name)
 
 int  tipc_register_media(struct media *m_ptr)
 {
-	u32 media_id;
-	u32 i;
 	int res = -EINVAL;
 
 	write_lock_bh(&tipc_net_lock);
@@ -121,29 +134,18 @@ int  tipc_register_media(struct media *m_ptr)
 		goto exit;
 	}
 
-	media_id = media_count++;
-	if (media_id >= MAX_MEDIA) {
+	if (media_count >= MAX_MEDIA) {
 		warn("Media <%s> rejected, media limit reached (%u)\n",
 		     m_ptr->name, MAX_MEDIA);
-		media_count--;
 		goto exit;
 	}
-	for (i = 0; i < media_id; i++) {
-		if (media_list[i].type_id == m_ptr->type_id) {
-			warn("Media <%s> rejected, duplicate type (%u)\n",
-			     m_ptr->name, m_ptr->type_id);
-			media_count--;
-			goto exit;
-		}
-		if (!strcmp(m_ptr->name, media_list[i].name)) {
-			warn("Media <%s> rejected, duplicate name\n",
-			     m_ptr->name);
-			media_count--;
-			goto exit;
-		}
+	if (media_find(m_ptr->name) || media_find_id(m_ptr->type_id)) {
+		warn("Media <%s> rejected, already registered\n", m_ptr->name);
+		goto exit;
 	}
 
-	media_list[media_id] = *m_ptr;
+	media_list[media_count] = *m_ptr;
+	media_count++;
 	res = 0;
 exit:
 	write_unlock_bh(&tipc_net_lock);
Signature · 1 line
1.7.4.4
#4 lore raw

PATCH 4/23 tipc: Eliminate duplication of media structures

In reply to Paul Gortmaker

From: Allan Stephens <[email protected]>

Changes TIPC's list of registered media types from an array of media structures to an array of pointers to media structures. This eliminates the need to copy of the contents of the structure passed in during media registration.

---
 net/tipc/bearer.c |   35 +++++++++++++++--------------------
 1 files changed, 15 insertions(+), 20 deletions(-)
net/tipc/bearer.c +15 -20
index 9ff8920..9012a36 100644
@@ -41,7 +41,7 @@
 
 #define MAX_ADDR_STR 32
 
-static struct media media_list[MAX_MEDIA];
+static struct media *media_list[MAX_MEDIA];
 static u32 media_count;
 
 struct tipc_bearer tipc_bearers[MAX_BEARERS];
@@ -70,12 +70,11 @@ static int media_name_valid(const char *name)
 
 static struct media *media_find(const char *name)
 {
-	struct media *m_ptr;
 	u32 i;
 
-	for (i = 0, m_ptr = media_list; i < media_count; i++, m_ptr++) {
-		if (!strcmp(m_ptr->name, name))
-			return m_ptr;
+	for (i = 0; i < media_count; i++) {
+		if (!strcmp(media_list[i]->name, name))
+			return media_list[i];
 	}
 	return NULL;
 }
@@ -89,8 +88,8 @@ static struct media *media_find_id(u8 type)
 	u32 i;
 
 	for (i = 0; i < media_count; i++) {
-		if (media_list[i].type_id == type)
-			return &media_list[i];
+		if (media_list[i]->type_id == type)
+			return media_list[i];
 	}
 	return NULL;
 }
@@ -144,7 +143,7 @@ int  tipc_register_media(struct media *m_ptr)
 		goto exit;
 	}
 
-	media_list[media_count] = *m_ptr;
+	media_list[media_count] = m_ptr;
 	media_count++;
 	res = 0;
 exit:
@@ -163,12 +162,9 @@ void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a)
 	u32 i;
 
 	media_type = ntohl(a->type);
-	for (i = 0, m_ptr = media_list; i < media_count; i++, m_ptr++) {
-		if (m_ptr->type_id == media_type)
-			break;
-	}
+	m_ptr = media_find_id(media_type);
 
-	if ((i < media_count) && (m_ptr->addr2str != NULL)) {
+	if (m_ptr && (m_ptr->addr2str != NULL)) {
 		char addr_str[MAX_ADDR_STR];
 
 		tipc_printf(pb, "%s(%s)", m_ptr->name,
@@ -189,7 +185,6 @@ void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a)
 struct sk_buff *tipc_media_get_names(void)
 {
 	struct sk_buff *buf;
-	struct media *m_ptr;
 	int i;
 
 	buf = tipc_cfg_reply_alloc(MAX_MEDIA * TLV_SPACE(TIPC_MAX_MEDIA_NAME));
@@ -197,9 +192,10 @@ struct sk_buff *tipc_media_get_names(void)
 		return NULL;
 
 	read_lock_bh(&tipc_net_lock);
-	for (i = 0, m_ptr = media_list; i < media_count; i++, m_ptr++) {
-		tipc_cfg_append_tlv(buf, TIPC_TLV_MEDIA_NAME, m_ptr->name,
-				    strlen(m_ptr->name) + 1);
+	for (i = 0; i < media_count; i++) {
+		tipc_cfg_append_tlv(buf, TIPC_TLV_MEDIA_NAME,
+				    media_list[i]->name,
+				    strlen(media_list[i]->name) + 1);
 	}
 	read_unlock_bh(&tipc_net_lock);
 	return buf;
@@ -300,7 +296,6 @@ struct tipc_bearer *tipc_bearer_find_interface(const char *if_name)
 struct sk_buff *tipc_bearer_get_names(void)
 {
 	struct sk_buff *buf;
-	struct media *m_ptr;
 	struct tipc_bearer *b_ptr;
 	int i, j;
 
@@ -309,10 +304,10 @@ struct sk_buff *tipc_bearer_get_names(void)
 		return NULL;
 
 	read_lock_bh(&tipc_net_lock);
-	for (i = 0, m_ptr = media_list; i < media_count; i++, m_ptr++) {
+	for (i = 0; i < media_count; i++) {
 		for (j = 0; j < MAX_BEARERS; j++) {
 			b_ptr = &tipc_bearers[j];
-			if (b_ptr->active && (b_ptr->media == m_ptr)) {
+			if (b_ptr->active && (b_ptr->media == media_list[i])) {
 				tipc_cfg_append_tlv(buf, TIPC_TLV_BEARER_NAME,
 						    b_ptr->name,
 						    strlen(b_ptr->name) + 1);
Signature · 1 line
1.7.4.4
#5 lore raw

PATCH 5/23 tipc: Streamline media registration error checking

In reply to Paul Gortmaker

From: Allan Stephens <[email protected]>

Simplifies error handling performed during media registration, since TIPC no longer supports the dynamic addition of new media types that are potentially error-prone. These simplifications include the following:

1) No longer check for premature registration of a new media type.
2) No longer check for negative link priority values (which was pointless since such values are unsigned, and could cause a compiler warning).
3) No longer generate a warning describing the exact cause of any registration failure (just warns that overall registration failed).

---
 net/tipc/bearer.c |   37 ++++++++-----------------------------
 1 files changed, 8 insertions(+), 29 deletions(-)
net/tipc/bearer.c +8 -29
index 9012a36..f908b80 100644
@@ -106,48 +106,27 @@ int  tipc_register_media(struct media *m_ptr)
 
 	write_lock_bh(&tipc_net_lock);
 
-	if (tipc_mode != TIPC_NET_MODE) {
-		warn("Media <%s> rejected, not in networked mode yet\n",
-		     m_ptr->name);
+	if (!media_name_valid(m_ptr->name))
 		goto exit;
-	}
-	if (!media_name_valid(m_ptr->name)) {
-		warn("Media <%s> rejected, illegal name\n", m_ptr->name);
+	if (m_ptr->bcast_addr.type != htonl(m_ptr->type_id))
 		goto exit;
-	}
-	if (m_ptr->bcast_addr.type != htonl(m_ptr->type_id)) {
-		warn("Media <%s> rejected, illegal broadcast address\n",
-		     m_ptr->name);
-		goto exit;
-	}
-	if ((m_ptr->priority < TIPC_MIN_LINK_PRI) ||
-	    (m_ptr->priority > TIPC_MAX_LINK_PRI)) {
-		warn("Media <%s> rejected, illegal priority (%u)\n",
-		     m_ptr->name, m_ptr->priority);
+	if (m_ptr->priority > TIPC_MAX_LINK_PRI)
 		goto exit;
-	}
 	if ((m_ptr->tolerance < TIPC_MIN_LINK_TOL) ||
-	    (m_ptr->tolerance > TIPC_MAX_LINK_TOL)) {
-		warn("Media <%s> rejected, illegal tolerance (%u)\n",
-		     m_ptr->name, m_ptr->tolerance);
+	    (m_ptr->tolerance > TIPC_MAX_LINK_TOL))
 		goto exit;
-	}
-
-	if (media_count >= MAX_MEDIA) {
-		warn("Media <%s> rejected, media limit reached (%u)\n",
-		     m_ptr->name, MAX_MEDIA);
+	if (media_count >= MAX_MEDIA)
 		goto exit;
-	}
-	if (media_find(m_ptr->name) || media_find_id(m_ptr->type_id)) {
-		warn("Media <%s> rejected, already registered\n", m_ptr->name);
+	if (media_find(m_ptr->name) || media_find_id(m_ptr->type_id))
 		goto exit;
-	}
 
 	media_list[media_count] = m_ptr;
 	media_count++;
 	res = 0;
 exit:
 	write_unlock_bh(&tipc_net_lock);
+	if (res)
+		warn("Media <%s> registration error\n", m_ptr->name);
 	return res;
 }
 
Signature · 1 line
1.7.4.4
#6 lore raw

PATCH 6/23 tipc: Improve handling of media address printing errors

In reply to Paul Gortmaker

From: Allan Stephens <[email protected]>

Enhances conversion of a media address to printable form so that an unconvertable address will be displayed as a string of hex digits, rather than not being displayed at all. (Also removes a pointless check for the existence of the media-specific address conversion routine, since the routine is not optional.)

---
 net/tipc/bearer.c    |   12 +++++-------
 net/tipc/bearer.h    |    3 +--
 net/tipc/eth_media.c |   12 ++++++------
 3 files changed, 12 insertions(+), 15 deletions(-)
net/tipc/bearer.c +5 -7
index f908b80..17652f2 100644
@@ -136,20 +136,18 @@ exit:
 
 void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a)
 {
+	char addr_str[MAX_ADDR_STR];
 	struct media *m_ptr;
 	u32 media_type;
-	u32 i;
 
 	media_type = ntohl(a->type);
 	m_ptr = media_find_id(media_type);
 
-	if (m_ptr && (m_ptr->addr2str != NULL)) {
-		char addr_str[MAX_ADDR_STR];
-
-		tipc_printf(pb, "%s(%s)", m_ptr->name,
-			    m_ptr->addr2str(a, addr_str, sizeof(addr_str)));
-	} else {
+	if (m_ptr && !m_ptr->addr2str(a, addr_str, sizeof(addr_str)))
+		tipc_printf(pb, "%s(%s)", m_ptr->name, addr_str);
+	else {
 		unchar *addr = (unchar *)&a->dev_addr;
+		u32 i;
 
 		tipc_printf(pb, "UNKNOWN(%u)", media_type);
 		for (i = 0; i < (sizeof(*a) - sizeof(a->type)); i++)
net/tipc/bearer.h +1 -2
index 148ed04..4e9367f 100644
@@ -83,8 +83,7 @@ struct media {
 			struct tipc_media_addr *dest);
 	int (*enable_bearer)(struct tipc_bearer *b_ptr);
 	void (*disable_bearer)(struct tipc_bearer *b_ptr);
-	char *(*addr2str)(struct tipc_media_addr *a,
-			  char *str_buf, int str_size);
+	int (*addr2str)(struct tipc_media_addr *a, char *str_buf, int str_size);
 	struct tipc_media_addr bcast_addr;
 	u32 priority;
 	u32 tolerance;
net/tipc/eth_media.c +6 -6
index 15c685b..67f616a 100644
@@ -243,15 +243,15 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt,
  * eth_addr2str - convert Ethernet address to string
  */
 
-static char *eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size)
+static int eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size)
 {
 	unchar *addr = (unchar *)&a->dev_addr;
 
-	if (str_size < 18)
-		*str_buf = '\0';
-	else
-		sprintf(str_buf, "%pM", addr);
-	return str_buf;
+	if (str_size < 18)	/* 18 = strlen("aa:bb:cc:dd:ee:ff\0") */
+		return 1;
+
+	sprintf(str_buf, "%pM", addr);
+	return 0;
 }
 
 /*
Signature · 1 line
1.7.4.4
#7 lore raw

PATCH 7/23 tipc: Add new address conversion routines for Ethernet media

In reply to Paul Gortmaker

From: Allan Stephens <[email protected]>

Enhances TIPC's Ethernet media support to provide 3 new address conversion routines, which allow TIPC to interpret an address that is in string form and to convert an address to and from the 20 byte format used in TIPC's neighbor discovery messages.

These routines are pre-requisites to a follow on commit that hides all media-specific addressing details from TIPC's generic bearer code.

---
 net/tipc/bearer.h    |   19 ++++++++++++++-
 net/tipc/eth_media.c |   63 ++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 79 insertions(+), 3 deletions(-)
net/tipc/bearer.h +18 -1
index 4e9367f..41a61d2 100644
@@ -43,6 +43,17 @@
 #define MAX_MEDIA	2
 
 /*
+ * Identifiers associated with TIPC message header media address info
+ *
+ * - address info field is 20 bytes long
+ * - media type identifier located at offset 3
+ * - remaining bytes vary according to media type
+ */
+
+#define TIPC_MEDIA_ADDR_SIZE	20
+#define TIPC_MEDIA_TYPE_OFFSET	3
+
+/*
  * Identifiers of supported TIPC media types
  */
 #define TIPC_MEDIA_TYPE_ETH	1
@@ -68,7 +79,10 @@ struct tipc_bearer;
  * @send_msg: routine which handles buffer transmission
  * @enable_bearer: routine which enables a bearer
  * @disable_bearer: routine which disables a bearer
- * @addr2str: routine which converts bearer's address to string form
+ * @addr2str: routine which converts media address to string
+ * @str2addr: routine which converts media address from string
+ * @addr2msg: routine which converts media address to protocol message area
+ * @msg2addr: routine which converts media address from protocol message area
  * @bcast_addr: media address used in broadcasting
  * @priority: default link (and bearer) priority
  * @tolerance: default time (in ms) before declaring link failure
@@ -84,6 +98,9 @@ struct media {
 	int (*enable_bearer)(struct tipc_bearer *b_ptr);
 	void (*disable_bearer)(struct tipc_bearer *b_ptr);
 	int (*addr2str)(struct tipc_media_addr *a, char *str_buf, int str_size);
+	int (*str2addr)(struct tipc_media_addr *a, char *str_buf);
+	int (*addr2msg)(struct tipc_media_addr *a, char *msg_area);
+	int (*msg2addr)(struct tipc_media_addr *a, char *msg_area);
 	struct tipc_media_addr bcast_addr;
 	u32 priority;
 	u32 tolerance;
net/tipc/eth_media.c +61 -2

93 lines not on this page · raw message

Signature · 1 line
1.7.4.4
#8 lore raw

PATCH 8/23 tipc: Hide media-specific addressing details from generic bearer code

In reply to Paul Gortmaker

From: Allan Stephens <[email protected]>

Reworks TIPC's media address data structure and associated processing routines to transfer all media-specific details of address conversion to the associated TIPC media adaptation code. TIPC's generic bearer code now only needs to know which media type an address is associated with and whether or not it is a broadcast address, and totally ignores the "value" field that contains the actual media-specific addressing info.

These changes eliminate the need for a number of endianness conversion operations and will make it easier for TIPC to support new media types in the future.

---
 net/tipc/bearer.c    |   14 ++++++--------
 net/tipc/bearer.h    |   17 ++++++++---------
 net/tipc/discover.c  |    4 ++--
 net/tipc/eth_media.c |   22 +++++++++++++---------
 net/tipc/msg.c       |    9 ++++++---
 net/tipc/msg.h       |   16 ++++++----------
 6 files changed, 41 insertions(+), 41 deletions(-)
net/tipc/bearer.c +6 -8
index 17652f2..aa37261 100644
@@ -108,7 +108,8 @@ int  tipc_register_media(struct media *m_ptr)
 
 	if (!media_name_valid(m_ptr->name))
 		goto exit;
-	if (m_ptr->bcast_addr.type != htonl(m_ptr->type_id))
+	if ((m_ptr->bcast_addr.media_id != m_ptr->type_id) ||
+	    !m_ptr->bcast_addr.broadcast)
 		goto exit;
 	if (m_ptr->priority > TIPC_MAX_LINK_PRI)
 		goto exit;
@@ -138,20 +139,17 @@ void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a)
 {
 	char addr_str[MAX_ADDR_STR];
 	struct media *m_ptr;
-	u32 media_type;
 
-	media_type = ntohl(a->type);
-	m_ptr = media_find_id(media_type);
+	m_ptr = media_find_id(a->media_id);
 
 	if (m_ptr && !m_ptr->addr2str(a, addr_str, sizeof(addr_str)))
 		tipc_printf(pb, "%s(%s)", m_ptr->name, addr_str);
 	else {
-		unchar *addr = (unchar *)&a->dev_addr;
 		u32 i;
 
-		tipc_printf(pb, "UNKNOWN(%u)", media_type);
-		for (i = 0; i < (sizeof(*a) - sizeof(a->type)); i++)
-			tipc_printf(pb, "-%02x", addr[i]);
+		tipc_printf(pb, "UNKNOWN(%u)", a->media_id);
+		for (i = 0; i < sizeof(a->value); i++)
+			tipc_printf(pb, "-%02x", a->value[i]);
 	}
 }
 
net/tipc/bearer.h +8 -9
index 41a61d2..54a5a57 100644
@@ -59,17 +59,16 @@
 #define TIPC_MEDIA_TYPE_ETH	1
 
 /*
- * Destination address structure used by TIPC bearers when sending messages
- *
- * IMPORTANT: The fields of this structure MUST be stored using the specified
- * byte order indicated below, as the structure is exchanged between nodes
- * as part of a link setup process.
+ * struct tipc_media_addr - destination address used by TIPC bearers
+ * @value: address info (format defined by media)
+ * @media_id: TIPC media type identifier
+ * @broadcast: non-zero if address is a broadcast address
  */
+
 struct tipc_media_addr {
-	__be32  type;			/* bearer type (network byte order) */
-	union {
-		__u8   eth_addr[6];	/* 48 bit Ethernet addr (byte array) */
-	} dev_addr;
+	u8 value[TIPC_MEDIA_ADDR_SIZE];
+	u8 media_id;
+	u8 broadcast;
 };
 
 struct tipc_bearer;
net/tipc/discover.c +2 -2
index f2fb96e..1ea2d44 100644
@@ -84,7 +84,7 @@ static struct sk_buff *tipc_disc_init_msg(u32 type,
 		msg_set_non_seq(msg, 1);
 		msg_set_dest_domain(msg, dest_domain);
 		msg_set_bc_netid(msg, tipc_net_id);
-		msg_set_media_addr(msg, &b_ptr->addr);
+		b_ptr->media->addr2msg(&b_ptr->addr, msg_media_addr(msg));
 	}
 	return buf;
 }
@@ -130,7 +130,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr)
 	u32 type = msg_type(msg);
 	int link_fully_up;
 
-	msg_get_media_addr(msg, &media_addr);
+	b_ptr->media->msg2addr(&media_addr, msg_media_addr(msg));
 	buf_discard(buf);
 
 	/* Validate discovery message from requesting node */
net/tipc/eth_media.c +13 -9
index ebba0fc..3b75c0d 100644
@@ -54,18 +54,24 @@ struct eth_bearer {
 	struct packet_type tipc_packet_type;
 };
 
+static struct media eth_media_info;
 static struct eth_bearer eth_bearers[MAX_ETH_BEARERS];
 static int eth_started;
 static struct notifier_block notifier;
 
 /**
  * eth_media_addr_set - initialize Ethernet media address structure
+ *
+ * Media-dependent "value" field stores MAC address in first 6 bytes
+ * and zeroes out the remaining bytes.
  */
 
 static void eth_media_addr_set(struct tipc_media_addr *a, char *mac)
 {
-	a->type = htonl(TIPC_MEDIA_TYPE_ETH);
-	memcpy(&a->dev_addr.eth_addr, mac, ETH_ALEN);
+	memcpy(a->value, mac, ETH_ALEN);
+	memset(a->value + ETH_ALEN, 0, sizeof(a->value) - ETH_ALEN);
+	a->media_id = TIPC_MEDIA_TYPE_ETH;
+	a->broadcast = !memcmp(mac, eth_media_info.bcast_addr.value, ETH_ALEN);
 }
 
 /**
@@ -94,7 +100,7 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr,
 
 	skb_reset_network_header(clone);
 	clone->dev = dev;
-	dev_hard_header(clone, dev, ETH_P_TIPC, &dest->dev_addr.eth_addr,
+	dev_hard_header(clone, dev, ETH_P_TIPC, dest->value,
 			dev->dev_addr, clone->len);
 	dev_queue_xmit(clone);
 	return 0;
@@ -256,12 +262,10 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt,
 
 static int eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size)
 {
-	unchar *addr = (unchar *)&a->dev_addr;
-
 	if (str_size < 18)	/* 18 = strlen("aa:bb:cc:dd:ee:ff\0") */
 		return 1;
 
-	sprintf(str_buf, "%pM", addr);
+	sprintf(str_buf, "%pM", a->value);
 	return 0;
 }
 
@@ -293,7 +297,7 @@ static int eth_addr2msg(struct tipc_media_addr *a, char *msg_area)
 {
 	memset(msg_area, 0, TIPC_MEDIA_ADDR_SIZE);
 	msg_area[TIPC_MEDIA_TYPE_OFFSET] = TIPC_MEDIA_TYPE_ETH;
-	memcpy(msg_area + ETH_ADDR_OFFSET, a->dev_addr.eth_addr, ETH_ALEN);
+	memcpy(msg_area + ETH_ADDR_OFFSET, a->value, ETH_ALEN);
 	return 0;
 }
 
@@ -322,8 +326,8 @@ static struct media eth_media_info = {
 	.str2addr	= eth_str2addr,
 	.addr2msg	= eth_addr2msg,
 	.msg2addr	= eth_msg2addr,
-	.bcast_addr	= { htonl(TIPC_MEDIA_TYPE_ETH),
-			    { {0xff, 0xff, 0xff, 0xff, 0xff, 0xff} } },
+	.bcast_addr	= { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
+			    TIPC_MEDIA_TYPE_ETH, 1 },
 	.priority	= TIPC_DEF_LINK_PRI,
 	.tolerance	= TIPC_DEF_LINK_TOL,
 	.window		= TIPC_DEF_LINK_WIN,
net/tipc/msg.c +6 -3
index 83d5096..3e4d3e2 100644
@@ -333,11 +333,14 @@ void tipc_msg_dbg(struct print_buf *buf, struct tipc_msg *msg, const char *str)
 	}
 
 	if (msg_user(msg) ==  LINK_CONFIG) {
-		u32 *raw = (u32 *)msg;
-		struct tipc_media_addr *orig = (struct tipc_media_addr *)&raw[5];
+		struct tipc_media_addr orig;
+
 		tipc_printf(buf, ":DDOM(%x):", msg_dest_domain(msg));
 		tipc_printf(buf, ":NETID(%u):", msg_bc_netid(msg));
-		tipc_media_addr_printf(buf, orig);
+		memcpy(orig.value, msg_media_addr(msg), sizeof(orig.value));
+		orig.media_id = 0;
+		orig.broadcast = 0;
+		tipc_media_addr_printf(buf, &orig);
 	}
 	if (msg_user(msg) == BCAST_PROTOCOL) {
 		tipc_printf(buf, "BCNACK:AFTER(%u):", msg_bcgap_after(msg));
net/tipc/msg.h +6 -10
index d93178f..7b0cda1 100644
@@ -78,6 +78,8 @@
 
 #define MAX_MSG_SIZE (MAX_H_SIZE + TIPC_MAX_USER_MSG_SIZE)
 
+#define TIPC_MEDIA_ADDR_OFFSET	5
+
 
 struct tipc_msg {
 	__be32 hdr[15];
@@ -682,6 +684,10 @@ static inline void msg_set_redundant_link(struct tipc_msg *m, u32 r)
 	msg_set_bits(m, 5, 12, 0x1, r);
 }
 
+static inline char *msg_media_addr(struct tipc_msg *m)
+{
+	return (char *)&m->hdr[TIPC_MEDIA_ADDR_OFFSET];
+}
 
 /*
  * Word 9
@@ -734,14 +740,4 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
 		   u32 num_sect, unsigned int total_len,
 			    int max_size, int usrmem, struct sk_buff **buf);
 
-static inline void msg_set_media_addr(struct tipc_msg *m, struct tipc_media_addr *a)
-{
-	memcpy(&((int *)m)[5], a, sizeof(*a));
-}
-
-static inline void msg_get_media_addr(struct tipc_msg *m, struct tipc_media_addr *a)
-{
-	memcpy(a, &((int *)m)[5], sizeof(*a));
-}
-
 #endif
Signature · 1 line
1.7.4.4
#9 lore raw

PATCH 9/23 tipc: Ignore neighbor discovery messages containing invalid address

In reply to Paul Gortmaker

From: Allan Stephens <[email protected]>

Adds a check to ensure that TIPC ignores an incoming neighbor discovery message that specifies an invalid media address as its source. The check ensures that the source address is a valid, non-broadcast address that could legally be used by a neighboring link endpoint.

---
 net/tipc/discover.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
net/tipc/discover.c +3 -0
index 1ea2d44..420e032 100644
@@ -130,12 +130,15 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct tipc_bearer *b_ptr)
 	u32 type = msg_type(msg);
 	int link_fully_up;
 
+	media_addr.broadcast = 1;
 	b_ptr->media->msg2addr(&media_addr, msg_media_addr(msg));
 	buf_discard(buf);
 
 	/* Validate discovery message from requesting node */
 	if (net_id != tipc_net_id)
 		return;
+	if (media_addr.broadcast)
+		return;
 	if (!tipc_addr_domain_valid(dest))
 		return;
 	if (!tipc_addr_node_valid(orig))
Signature · 1 line
1.7.4.4
#10 lore raw

PATCH 10/23 tipc: Allow run-time alteration of default link settings

In reply to Paul Gortmaker

From: Allan Stephens <[email protected]>

Permits run-time alteration of default link settings on a per-media and per-bearer basis, in addition to the existing per-link basis. The following syntax can now be used:

    tipc-config -lt=<link-name|bearer-name|media-name>/<tolerance>
    tipc-config -lp=<link-name|bearer-name|media-name>/<priority>
    tipc-config -lw=<link-name|bearer-name|media-name>/<window>

Note that changes to the default settings for a given media type has no effect on the default settings used by existing bearers. Similarly, changes to default bearer settings has no effect on existing link endpoints that utilize that interface.

Thanks to Florian Westphal <[email protected]> for his contributions to the development of this enhancement.

---
 net/tipc/bearer.c |   18 ++++---
 net/tipc/bearer.h |    8 +++
 net/tipc/link.c   |  150 ++++++++++++++++++++++++++++++++++++++--------------
 3 files changed, 127 insertions(+), 49 deletions(-)
net/tipc/bearer.c +10 -8
index aa37261..b40e98a 100644
@@ -65,10 +65,10 @@ static int media_name_valid(const char *name)
 }
 
 /**
- * media_find - locates specified media object by name
+ * tipc_media_find - locates specified media object by name
  */
 
-static struct media *media_find(const char *name)
+struct media *tipc_media_find(const char *name)
 {
 	u32 i;
 
@@ -118,7 +118,7 @@ int  tipc_register_media(struct media *m_ptr)
 		goto exit;
 	if (media_count >= MAX_MEDIA)
 		goto exit;
-	if (media_find(m_ptr->name) || media_find_id(m_ptr->type_id))
+	if (tipc_media_find(m_ptr->name) || media_find_id(m_ptr->type_id))
 		goto exit;
 
 	media_list[media_count] = m_ptr;
@@ -229,10 +229,10 @@ static int bearer_name_validate(const char *name,
 }
 
 /**
- * bearer_find - locates bearer object with matching bearer name
+ * tipc_bearer_find - locates bearer object with matching bearer name
  */
 
-static struct tipc_bearer *bearer_find(const char *name)
+struct tipc_bearer *tipc_bearer_find(const char *name)
 {
 	struct tipc_bearer *b_ptr;
 	u32 i;
@@ -463,7 +463,7 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
 
 	write_lock_bh(&tipc_net_lock);
 
-	m_ptr = media_find(b_name.media_name);
+	m_ptr = tipc_media_find(b_name.media_name);
 	if (!m_ptr) {
 		warn("Bearer <%s> rejected, media <%s> not registered\n", name,
 		     b_name.media_name);
@@ -513,6 +513,8 @@ restart:
 
 	b_ptr->identity = bearer_id;
 	b_ptr->media = m_ptr;
+	b_ptr->tolerance = m_ptr->tolerance;
+	b_ptr->window = m_ptr->window;
 	b_ptr->net_plane = bearer_id + 'A';
 	b_ptr->active = 1;
 	b_ptr->priority = priority;
@@ -546,7 +548,7 @@ int tipc_block_bearer(const char *name)
 	struct link *temp_l_ptr;
 
 	read_lock_bh(&tipc_net_lock);
-	b_ptr = bearer_find(name);
+	b_ptr = tipc_bearer_find(name);
 	if (!b_ptr) {
 		warn("Attempt to block unknown bearer <%s>\n", name);
 		read_unlock_bh(&tipc_net_lock);
@@ -600,7 +602,7 @@ int tipc_disable_bearer(const char *name)
 	int res;
 
 	write_lock_bh(&tipc_net_lock);
-	b_ptr = bearer_find(name);
+	b_ptr = tipc_bearer_find(name);
 	if (b_ptr == NULL) {
 		warn("Attempt to disable unknown bearer <%s>\n", name);
 		res = -EINVAL;
net/tipc/bearer.h +8 -0
index 54a5a57..cfe77c4 100644
@@ -118,6 +118,8 @@ struct media {
  * @name: bearer name (format = media:interface)
  * @media: ptr to media structure associated with bearer
  * @priority: default link priority for bearer
+ * @window: default window size for bearer
+ * @tolerance: default link tolerance for bearer
  * @identity: array index of this bearer within TIPC bearer array
  * @link_req: ptr to (optional) structure making periodic link setup requests
  * @links: list of non-congested links associated with bearer
@@ -139,6 +141,8 @@ struct tipc_bearer {
 	spinlock_t lock;
 	struct media *media;
 	u32 priority;
+	u32 window;
+	u32 tolerance;
 	u32 identity;
 	struct link_req *link_req;
 	struct list_head links;
@@ -176,6 +180,8 @@ int tipc_disable_bearer(const char *name);
 int  tipc_eth_media_start(void);
 void tipc_eth_media_stop(void);
 
+int tipc_media_set_priority(const char *name, u32 new_value);
+int tipc_media_set_window(const char *name, u32 new_value);
 void tipc_media_addr_printf(struct print_buf *pb, struct tipc_media_addr *a);
 struct sk_buff *tipc_media_get_names(void);
 
@@ -183,7 +189,9 @@ struct sk_buff *tipc_bearer_get_names(void);
 void tipc_bearer_add_dest(struct tipc_bearer *b_ptr, u32 dest);
 void tipc_bearer_remove_dest(struct tipc_bearer *b_ptr, u32 dest);
 void tipc_bearer_schedule(struct tipc_bearer *b_ptr, struct link *l_ptr);
+struct tipc_bearer *tipc_bearer_find(const char *name);
 struct tipc_bearer *tipc_bearer_find_interface(const char *if_name);
+struct media *tipc_media_find(const char *name);
 int tipc_bearer_resolve_congestion(struct tipc_bearer *b_ptr, struct link *l_ptr);
 int tipc_bearer_congested(struct tipc_bearer *b_ptr, struct link *l_ptr);
 void tipc_bearer_stop(void);
net/tipc/link.c +109 -41

185 lines not on this page · raw message

Signature · 1 line
1.7.4.4
#11 lore raw

PATCH 11/23 tipc: Revise comment justifying release of configuration spinlock

In reply to Paul Gortmaker

From: Allan Stephens <[email protected]>

Comment-only change to better explain why TIPC's configuration lock is temporarily released while activating support for network interfaces, and why the existing activation code doesn't require rework.

---
 net/tipc/config.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)
net/tipc/config.c +6 -7
index b25a396..4785bf2 100644
@@ -184,13 +184,12 @@ static struct sk_buff *cfg_set_own_addr(void)
 						   " (cannot change node address once assigned)");
 
 	/*
-	 * Must release all spinlocks before calling start_net() because
-	 * Linux version of TIPC calls eth_media_start() which calls
-	 * register_netdevice_notifier() which may block!
-	 *
-	 * Temporarily releasing the lock should be harmless for non-Linux TIPC,
-	 * but Linux version of eth_media_start() should really be reworked
-	 * so that it can be called with spinlocks held.
+	 * Must temporarily release configuration spinlock while switching into
+	 * networking mode as it calls tipc_eth_media_start(), which may sleep.
+	 * Releasing the lock is harmless as other locally-issued configuration
+	 * commands won't occur until this one completes, and remotely-issued
+	 * configuration commands can't be received until a local configuration
+	 * command to enable the first bearer is received and processed.
 	 */
 
 	spin_unlock_bh(&config_lock);
Signature · 1 line
1.7.4.4
#12 lore raw

PATCH 12/23 tipc: Minor optimization to deactivation of Ethernet media suppot

In reply to Paul Gortmaker

From: Allan Stephens <[email protected]>

Change TIPC's shutdown code to deactivate generic networking support before terminating Ethernet media support. The deactivation of generic networking support causes all existing bearers to be destroyed, meaning the Ethernet media termination routine no longer has to bother marking them as unavailable.

---
 net/tipc/core.c      |    2 +-
 net/tipc/eth_media.c |    4 ----
 2 files changed, 1 insertions(+), 5 deletions(-)
net/tipc/core.c +1 -1
index c21331d..2691cd5 100644
@@ -99,8 +99,8 @@ struct sk_buff *tipc_buf_acquire(u32 size)
 
 static void tipc_core_stop_net(void)
 {
-	tipc_eth_media_stop();
 	tipc_net_stop();
+	tipc_eth_media_stop();
 }
 
 /**
net/tipc/eth_media.c +0 -4
index 3b75c0d..23bf67b 100644
@@ -376,10 +376,6 @@ void tipc_eth_media_stop(void)
 
 	unregister_netdevice_notifier(&notifier);
 	for (i = 0; i < MAX_ETH_BEARERS ; i++) {
-		if (eth_bearers[i].bearer) {
-			eth_bearers[i].bearer->blocked = 1;
-			eth_bearers[i].bearer = NULL;
-		}
 		if (eth_bearers[i].dev) {
 			dev_remove_pack(&eth_bearers[i].tipc_packet_type);
 			dev_put(eth_bearers[i].dev);
Signature · 1 line
1.7.4.4
#13 lore raw

PATCH 13/23 tipc: Do timely cleanup of disabled Ethernet bearer resources

In reply to Paul Gortmaker

From: Allan Stephens <[email protected]>

Modifies Ethernet bearer disable logic to break the association between the bearer and its device driver at the time the bearer is disabled, rather than when the TIPC module is unloaded. This allows the array entry used by the disabled bearer to be re-used if the same bearer (or a different one) is subsequently enabled.

---
 net/tipc/eth_media.c |   39 +++++++++++++++++++++++++++------------
 1 files changed, 27 insertions(+), 12 deletions(-)
net/tipc/eth_media.c +27 -12
index 23bf67b..236155c 100644
@@ -46,12 +46,14 @@
  * @bearer: ptr to associated "generic" bearer structure
  * @dev: ptr to associated Ethernet network device
  * @tipc_packet_type: used in binding TIPC to Ethernet driver
+ * @cleanup: work item used when disabling bearer
  */
 
 struct eth_bearer {
 	struct tipc_bearer *bearer;
 	struct net_device *dev;
 	struct packet_type tipc_packet_type;
+	struct work_struct cleanup;
 };
 
 static struct media eth_media_info;
@@ -192,16 +194,36 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
 }
 
 /**
+ * cleanup_bearer - break association between Ethernet bearer and interface
+ *
+ * This routine must be invoked from a work queue because it can sleep.
+ */
+
+static void cleanup_bearer(struct work_struct *work)
+{
+	struct eth_bearer *eb_ptr =
+		container_of(work, struct eth_bearer, cleanup);
+
+	dev_remove_pack(&eb_ptr->tipc_packet_type);
+	dev_put(eb_ptr->dev);
+	eb_ptr->dev = NULL;
+}
+
+/**
  * disable_bearer - detach TIPC bearer from an Ethernet interface
  *
- * We really should do dev_remove_pack() here, but this function can not be
- * called at tasklet level. => Use eth_bearer->bearer as a flag to throw away
- * incoming buffers, & postpone dev_remove_pack() to eth_media_stop() on exit.
+ * Mark Ethernet bearer as inactive so that incoming buffers are thrown away,
+ * then get worker thread to complete bearer cleanup.  (Can't do cleanup
+ * here because cleanup code needs to sleep and caller holds spinlocks.)
  */
 
 static void disable_bearer(struct tipc_bearer *tb_ptr)
 {
-	((struct eth_bearer *)tb_ptr->usr_handle)->bearer = NULL;
+	struct eth_bearer *eb_ptr = (struct eth_bearer *)tb_ptr->usr_handle;
+
+	eb_ptr->bearer = NULL;
+	INIT_WORK(&eb_ptr->cleanup, cleanup_bearer);
+	schedule_work(&eb_ptr->cleanup);
 }
 
 /**
@@ -369,18 +391,11 @@ int tipc_eth_media_start(void)
 
 void tipc_eth_media_stop(void)
 {
-	int i;
-
 	if (!eth_started)
 		return;
 
+	flush_scheduled_work();
 	unregister_netdevice_notifier(&notifier);
-	for (i = 0; i < MAX_ETH_BEARERS ; i++) {
-		if (eth_bearers[i].dev) {
-			dev_remove_pack(&eth_bearers[i].tipc_packet_type);
-			dev_put(eth_bearers[i].dev);
-		}
-	}
 	memset(&eth_bearers, 0, sizeof(eth_bearers));
 	eth_started = 0;
 }
Signature · 1 line
1.7.4.4
#14 lore raw

PATCH 14/23 tipc: Eliminate useless memset operations in Ethernet media support

In reply to Paul Gortmaker

From: Allan Stephens <[email protected]>

Gets rid of two pointless operations that zero out the array used to record information about TIPC's Ethernet bearers. There is no need to initialize the array on start up since it is a global variable that is already zero'd out, and there is no need to zero it out on exit because the array is never referenced again.

---
 net/tipc/eth_media.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
net/tipc/eth_media.c +0 -3
index 236155c..cd0a4b8 100644
@@ -371,8 +371,6 @@ int tipc_eth_media_start(void)
 	if (eth_started)
 		return -EINVAL;
 
-	memset(eth_bearers, 0, sizeof(eth_bearers));
-
 	res = tipc_register_media(&eth_media_info);
 	if (res)
 		return res;
@@ -396,6 +394,5 @@ void tipc_eth_media_stop(void)
 
 	flush_scheduled_work();
 	unregister_netdevice_notifier(&notifier);
-	memset(&eth_bearers, 0, sizeof(eth_bearers));
 	eth_started = 0;
 }
Signature · 1 line
1.7.4.4
#15 lore raw

PATCH 15/23 tipc: Minor correction to TIPC module unloading

In reply to Paul Gortmaker

From: Allan Stephens <[email protected]>

Modifies TIPC's module unloading logic to switch itself into "single node" mode before starting to terminate networking support. This helps to ensure that no operations that require TIPC to be in "networking" mode can initiate once unloading starts.

---
 net/tipc/net.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/tipc/net.c +1 -1
index fafef6c..e13162f 100644
@@ -207,8 +207,8 @@ void tipc_net_stop(void)
 	if (tipc_mode != TIPC_NET_MODE)
 		return;
 	write_lock_bh(&tipc_net_lock);
-	tipc_bearer_stop();
 	tipc_mode = TIPC_NODE_MODE;
+	tipc_bearer_stop();
 	tipc_bclink_stop();
 	list_for_each_entry_safe(node, t_node, &tipc_node_list, list)
 		tipc_node_delete(node);
Signature · 1 line
1.7.4.4
#16 lore raw

PATCH 16/23 tipc: Eliminate useless check when network address is assigned

In reply to Paul Gortmaker

From: Allan Stephens <[email protected]>

Gets rid of an unnecessary check in the routine that updates the port id of a node's name publications when the node is assigned a network address, since the routine is only invoked if the new address is different from the existing one.

---
 net/tipc/name_distr.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)
net/tipc/name_distr.c +5 -7
index b7ca1bd..be8306f 100644
@@ -322,10 +322,9 @@ void tipc_named_recv(struct sk_buff *buf)
 /**
  * tipc_named_reinit - re-initialize local publication list
  *
- * This routine is called whenever TIPC networking is (re)enabled.
+ * 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 current network address.
- * (If the node's address is unchanged, the update loop terminates immediately.)
+ * are updated to reflect the node's new network address.
  */
 
 void tipc_named_reinit(void)
@@ -333,10 +332,9 @@ void tipc_named_reinit(void)
 	struct publication *publ;
 
 	write_lock_bh(&tipc_nametbl_lock);
-	list_for_each_entry(publ, &publ_root, local_list) {
-		if (publ->node == tipc_own_addr)
-			break;
+
+	list_for_each_entry(publ, &publ_root, local_list)
 		publ->node = tipc_own_addr;
-	}
+
 	write_unlock_bh(&tipc_nametbl_lock);
 }
Signature · 1 line
1.7.4.4
#17 lore raw

PATCH 17/23 tipc: Eliminate dynamic allocation of broadcast link data structures

In reply to Paul Gortmaker

From: Allan Stephens <[email protected]>

Creates global variables to hold the broadcast link's pseudo-bearer and pseudo-link structures, rather than allocating them dynamically. There is only a single instance of each structure, and changing over to static allocation allows elimination of code to handle the cases where dynamic allocation was unsuccessful.

The memset in the teardown code may look like they aren't used, but the same teardown code is run when there is a non-fatal error at init-time, so that stale data isn't present when the user fixes the cause of the soft error.

---
 net/tipc/bcast.c |   37 +++++++++++--------------------------
 net/tipc/bcast.h |    2 +-
 net/tipc/net.c   |    5 +----
 3 files changed, 13 insertions(+), 31 deletions(-)
net/tipc/bcast.c +11 -26
index 28908f5..738cb64 100644
@@ -98,10 +98,13 @@ struct bclink {
 	struct tipc_node *retransmit_to;
 };
 
+static struct bcbearer bcast_bearer;
+static struct bclink bcast_link;
+
+static struct bcbearer *bcbearer = &bcast_bearer;
+static struct bclink *bclink = &bcast_link;
+static struct link *bcl = &bcast_link.link;
 
-static struct bcbearer *bcbearer;
-static struct bclink *bclink;
-static struct link *bcl;
 static DEFINE_SPINLOCK(bc_lock);
 
 /* broadcast-capable node map */
@@ -752,25 +755,13 @@ int tipc_bclink_set_queue_limits(u32 limit)
 	return 0;
 }
 
-int tipc_bclink_init(void)
+void tipc_bclink_init(void)
 {
-	bcbearer = kzalloc(sizeof(*bcbearer), GFP_ATOMIC);
-	bclink = kzalloc(sizeof(*bclink), GFP_ATOMIC);
-	if (!bcbearer || !bclink) {
-		warn("Broadcast link creation failed, no memory\n");
-		kfree(bcbearer);
-		bcbearer = NULL;
-		kfree(bclink);
-		bclink = NULL;
-		return -ENOMEM;
-	}
-
 	INIT_LIST_HEAD(&bcbearer->bearer.cong_links);
 	bcbearer->bearer.media = &bcbearer->media;
 	bcbearer->media.send_msg = tipc_bcbearer_send;
 	sprintf(bcbearer->media.name, "tipc-broadcast");
 
-	bcl = &bclink->link;
 	INIT_LIST_HEAD(&bcl->waiting_ports);
 	bcl->next_out_no = 1;
 	spin_lock_init(&bclink->node.lock);
@@ -780,22 +771,16 @@ int tipc_bclink_init(void)
 	bcl->b_ptr = &bcbearer->bearer;
 	bcl->state = WORKING_WORKING;
 	strlcpy(bcl->name, tipc_bclink_name, TIPC_MAX_LINK_NAME);
-
-	return 0;
 }
 
 void tipc_bclink_stop(void)
 {
 	spin_lock_bh(&bc_lock);
-	if (bcbearer) {
-		tipc_link_stop(bcl);
-		bcl = NULL;
-		kfree(bclink);
-		bclink = NULL;
-		kfree(bcbearer);
-		bcbearer = NULL;
-	}
+	tipc_link_stop(bcl);
 	spin_unlock_bh(&bc_lock);
+
+	memset(bclink, 0, sizeof(*bclink));
+	memset(bcbearer, 0, sizeof(*bcbearer));
 }
 
 
net/tipc/bcast.h +1 -1
index 06740da..0b04443 100644
@@ -88,7 +88,7 @@ static inline int tipc_nmap_equal(struct tipc_node_map *nm_a, struct tipc_node_m
 void tipc_port_list_add(struct port_list *pl_ptr, u32 port);
 void tipc_port_list_free(struct port_list *pl_ptr);
 
-int  tipc_bclink_init(void);
+void tipc_bclink_init(void);
 void tipc_bclink_stop(void);
 struct tipc_node *tipc_bclink_retransmit_to(void);
 void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked);
net/tipc/net.c +1 -4
index e13162f..61afee7 100644
@@ -174,7 +174,6 @@ void tipc_net_route_msg(struct sk_buff *buf)
 int tipc_net_start(u32 addr)
 {
 	char addr_string[16];
-	int res;
 
 	if (tipc_mode != TIPC_NODE_MODE)
 		return -ENOPROTOOPT;
@@ -187,9 +186,7 @@ int tipc_net_start(u32 addr)
 	tipc_named_reinit();
 	tipc_port_reinit();
 
-	res = tipc_bclink_init();
-	if (res)
-		return res;
+	tipc_bclink_init();
 
 	tipc_k_signal((Handler)tipc_subscr_start, 0);
 	tipc_k_signal((Handler)tipc_cfg_init, 0);
Signature · 1 line
1.7.4.4
#18 lore raw

PATCH 18/23 tipc: Ensure broadcast link spinlock is held when updating node map

In reply to Paul Gortmaker

From: Allan Stephens <[email protected]>

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.

---
 net/tipc/bcast.c |   24 ++++++++++++++++++------
 net/tipc/bcast.h |    4 ++--
 net/tipc/node.c  |    4 ++--
 3 files changed, 22 insertions(+), 10 deletions(-)
net/tipc/bcast.c +18 -6
index 738cb64..5ca8fdd 100644
@@ -87,6 +87,7 @@ struct bcbearer {
  * struct bclink - link used for broadcast messages
  * @link: (non-standard) broadcast link structure
  * @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
  *
  * Handles sequence numbering, fragmentation, bundling, etc.
@@ -95,6 +96,7 @@ struct bcbearer {
 struct bclink {
 	struct link link;
 	struct tipc_node node;
+	struct tipc_node_map bcast_nodes;
 	struct tipc_node *retransmit_to;
 };
 
@@ -107,9 +109,6 @@ static struct link *bcl = &bcast_link.link;
 
 static DEFINE_SPINLOCK(bc_lock);
 
-/* broadcast-capable node map */
-struct tipc_node_map tipc_bcast_nmap;
-
 const char tipc_bclink_name[] = "broadcast-link";
 
 static void tipc_nmap_diff(struct tipc_node_map *nm_a,
@@ -136,6 +135,19 @@ static void bcbuf_decr_acks(struct sk_buff *buf)
 	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)
 {
@@ -575,13 +587,13 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
 	if (likely(!msg_non_seq(buf_msg(buf)))) {
 		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_set_non_seq(msg, 1);
 		msg_set_mc_netid(msg, tipc_net_id);
 		bcl->stats.sent_info++;
 
-		if (WARN_ON(!tipc_bcast_nmap.count)) {
+		if (WARN_ON(!bclink->bcast_nodes.count)) {
 			dump_stack();
 			return 0;
 		}
@@ -589,7 +601,7 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
 
 	/* 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++) {
 		struct tipc_bearer *p = bcbearer->bpairs[bp_index].primary;
net/tipc/bcast.h +2 -2
index 0b04443..3c37fdb 100644
@@ -51,8 +51,6 @@ struct tipc_node_map {
 	u32 map[MAX_NODES / WSIZE];
 };
 
-extern struct tipc_node_map tipc_bcast_nmap;
-
 #define PLSIZE 32
 
 /**
@@ -90,6 +88,8 @@ void tipc_port_list_free(struct port_list *pl_ptr);
 
 void tipc_bclink_init(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);
 void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked);
 int  tipc_bclink_send_msg(struct sk_buff *buf);
net/tipc/node.c +2 -2
index 27b4bb0..1861ae9 100644
@@ -307,7 +307,7 @@ static void node_established_contact(struct tipc_node *n_ptr)
 	n_ptr->bclink.acked = tipc_bclink_get_last_sent();
 
 	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)
 			tipc_own_tag++;
 	}
@@ -350,7 +350,7 @@ static void node_lost_contact(struct tipc_node *n_ptr)
 			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,
 					mod(n_ptr->bclink.acked + 10000));
 		if (n_ptr->addr < tipc_own_addr)
Signature · 1 line
1.7.4.4
#19 lore raw

PATCH 19/23 tipc: Handle broadcast attempt when no neighboring nodes exist

In reply to Paul Gortmaker

From: Allan Stephens <[email protected]>

Adds a check to detect when an attempt is made to send a message via the broadcast link and no neighboring nodes are currently available to receive it. Rather than wasting effort passing the message to the broadcast link and broadcast bearer, who will only throw it away, TIPC now frees the message immediately and reports success (i.e. the message has been delivered to all available destinations).

---
 net/tipc/bcast.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
net/tipc/bcast.c +7 -1
index 5ca8fdd..8f58df2 100644
@@ -417,13 +417,19 @@ int tipc_bclink_send_msg(struct sk_buff *buf)
 
 	spin_lock_bh(&bc_lock);
 
+	if (!bclink->bcast_nodes.count) {
+		res = msg_data_sz(buf_msg(buf));
+		buf_discard(buf);
+		goto exit;
+	}
+
 	res = tipc_link_send_buf(bcl, buf);
 	if (likely(res > 0))
 		bclink_set_last_sent();
 
 	bcl->stats.queue_sz_counts++;
 	bcl->stats.accu_queue_sz += bcl->out_queue_size;
-
+exit:
 	spin_unlock_bh(&bc_lock);
 	return res;
 }
Signature · 1 line
1.7.4.4
#20 lore raw

PATCH 20/23 tipc: Minor optimization of broadcast link transmit queue statistic

In reply to Paul Gortmaker

From: Allan Stephens <[email protected]>

The two broadcast link statistics fields that are used to derive the average length of that link's transmit queue are now updated only after a successful attempt to send a broadcast message, since there is no need to update these values when an unsuccessful send attempt leaves the queue unchanged.

---
 net/tipc/bcast.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
net/tipc/bcast.c +4 -4
index 8f58df2..dd990b0 100644
@@ -424,11 +424,11 @@ int tipc_bclink_send_msg(struct sk_buff *buf)
 	}
 
 	res = tipc_link_send_buf(bcl, buf);
-	if (likely(res > 0))
+	if (likely(res >= 0)) {
 		bclink_set_last_sent();
-
-	bcl->stats.queue_sz_counts++;
-	bcl->stats.accu_queue_sz += bcl->out_queue_size;
+		bcl->stats.queue_sz_counts++;
+		bcl->stats.accu_queue_sz += bcl->out_queue_size;
+	}
 exit:
 	spin_unlock_bh(&bc_lock);
 	return res;
Signature · 1 line
1.7.4.4
#21 lore raw

PATCH 21/23 tipc: Flush unsent broadcast messages when contact with last node is lost

In reply to Paul Gortmaker

From: Allan Stephens <[email protected]>

Adds code to release any unsent broadcast messages in the broadcast link transmit queue if TIPC loses contact with its only neighboring node. Previously, a broadcast link that was in the congested state would hold on to the unsent messages, even though the messages were now undeliverable.

---
 net/tipc/bcast.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
net/tipc/bcast.c +11 -1
index dd990b0..4609819 100644
@@ -252,7 +252,17 @@ void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked)
 
 	while (crs && less_eq(buf_seqno(crs), acked)) {
 		next = crs->next;
-		bcbuf_decr_acks(crs);
+
+		if (crs != bcl->next_out)
+			bcbuf_decr_acks(crs);
+		else if (bclink->bcast_nodes.count)
+			break;
+		else {
+			bcbuf_set_acks(crs, 0);
+			bcl->next_out = next;
+			bclink_set_last_sent();
+		}
+
 		if (bcbuf_acks(crs) == 0) {
 			bcl->first_out = next;
 			bcl->out_queue_size--;
Signature · 1 line
1.7.4.4
#22 lore raw

PATCH 22/23 tipc: Ignore broadcast acknowledgements that are out-of-range

In reply to Paul Gortmaker

From: Allan Stephens <[email protected]>

Adds checks to TIPC's broadcast link so that it ignores any acknowledgement message containing a sequence number that does not correspond to an unacknowledged message currently in the broadcast link's transmit queue.

This change prevents the broadcast link from becoming stalled if a newly booted node receives stale broadcast link acknowledgement information from another node that has not yet fully synchronized its end of the broadcast link to reflect the current state of the new node's end.

---
 net/tipc/bcast.c |   35 ++++++++++++++++++++++++++++-------
 net/tipc/link.c  |    6 ++----
 net/tipc/link.h  |    6 ++++++
 net/tipc/node.c  |    3 +--
 4 files changed, 37 insertions(+), 13 deletions(-)
net/tipc/bcast.c +28 -7
index 4609819..15eb744 100644
@@ -237,14 +237,36 @@ void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked)
 	struct sk_buff *next;
 	unsigned int released = 0;
 
-	if (less_eq(acked, n_ptr->bclink.acked))
-		return;
-
 	spin_lock_bh(&bc_lock);
 
-	/* Skip over packets that node has previously acknowledged */
-
+	/* Bail out if tx queue is empty (no clean up is required) */
 	crs = bcl->first_out;
+	if (!crs)
+		goto exit;
+
+	/* Determine which messages need to be acknowledged */
+	if (acked == INVALID_LINK_SEQ) {
+		/*
+		 * Contact with specified node has been lost, so need to
+		 * acknowledge sent messages only (if other nodes still exist)
+		 * or both sent and unsent messages (otherwise)
+		 */
+		if (bclink->bcast_nodes.count)
+			acked = bcl->fsm_msg_cnt;
+		else
+			acked = bcl->next_out_no;
+	} else {
+		/*
+		 * Bail out if specified sequence number does not correspond
+		 * to a message that has been sent and not yet acknowledged
+		 */
+		if (less(acked, buf_seqno(crs)) ||
+		    less(bcl->fsm_msg_cnt, acked) ||
+		    less_eq(acked, n_ptr->bclink.acked))
+			goto exit;
+	}
+
+	/* Skip over packets that node has previously acknowledged */
 	while (crs && less_eq(buf_seqno(crs), n_ptr->bclink.acked))
 		crs = crs->next;
 
@@ -255,8 +277,6 @@ void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked)
 
 		if (crs != bcl->next_out)
 			bcbuf_decr_acks(crs);
-		else if (bclink->bcast_nodes.count)
-			break;
 		else {
 			bcbuf_set_acks(crs, 0);
 			bcl->next_out = next;
@@ -281,6 +301,7 @@ void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked)
 	}
 	if (unlikely(released && !list_empty(&bcl->waiting_ports)))
 		tipc_link_wakeup_ports(bcl, 0);
+exit:
 	spin_unlock_bh(&bc_lock);
 }
 
net/tipc/link.c +2 -4
index 332915e..4eff342 100644
@@ -1733,10 +1733,8 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr)
 
 		/* Release acked messages */
 
-		if (less(n_ptr->bclink.acked, msg_bcast_ack(msg))) {
-			if (tipc_node_is_up(n_ptr) && n_ptr->bclink.supported)
-				tipc_bclink_acknowledge(n_ptr, msg_bcast_ack(msg));
-		}
+		if (tipc_node_is_up(n_ptr) && n_ptr->bclink.supported)
+			tipc_bclink_acknowledge(n_ptr, msg_bcast_ack(msg));
 
 		crs = l_ptr->first_out;
 		while ((crs != l_ptr->next_out) &&
net/tipc/link.h +6 -0
index e56cb53..7879239 100644
@@ -45,6 +45,12 @@
 #define PUSH_FINISHED 2
 
 /*
+ * Out-of-range value for link sequence numbers
+ */
+
+#define INVALID_LINK_SEQ 0x10000
+
+/*
  * Link states
  */
 
net/tipc/node.c +1 -2
index 1861ae9..e530de2 100644
@@ -351,8 +351,7 @@ static void node_lost_contact(struct tipc_node *n_ptr)
 		}
 
 		tipc_bclink_remove_node(n_ptr->addr);
-		tipc_bclink_acknowledge(n_ptr,
-					mod(n_ptr->bclink.acked + 10000));
+		tipc_bclink_acknowledge(n_ptr, INVALID_LINK_SEQ);
 		if (n_ptr->addr < tipc_own_addr)
 			tipc_own_tag--;
 
Signature · 1 line
1.7.4.4
#23 lore raw

PATCH 23/23 tipc: Allow use of buf_seqno() helper routine by unicast links

In reply to Paul Gortmaker

From: Allan Stephens <[email protected]>

Migrates the buf_seqno() helper routine from broadcast link level to unicast link level so that it can be used both types of TIPC links. This is a cosmetic change only, and does not affect the operation of TIPC.

---
 net/tipc/bcast.c |    5 -----
 net/tipc/link.c  |   39 +++++++++++++++++++--------------------
 net/tipc/link.h  |    5 +++++
 3 files changed, 24 insertions(+), 25 deletions(-)
net/tipc/bcast.c +0 -5
index 15eb744..048b7a3 100644
@@ -115,11 +115,6 @@ static void tipc_nmap_diff(struct tipc_node_map *nm_a,
 			   struct tipc_node_map *nm_b,
 			   struct tipc_node_map *nm_diff);
 
-static u32 buf_seqno(struct sk_buff *buf)
-{
-	return msg_seqno(buf_msg(buf));
-}
-
 static u32 bcbuf_acks(struct sk_buff *buf)
 {
 	return (u32)(unsigned long)TIPC_SKB_CB(buf)->handle;
net/tipc/link.c +19 -20
index 4eff342..853b286 100644
@@ -130,7 +130,7 @@ static void link_init_max_pkt(struct link *l_ptr)
 static u32 link_next_sent(struct link *l_ptr)
 {
 	if (l_ptr->next_out)
-		return msg_seqno(buf_msg(l_ptr->next_out));
+		return buf_seqno(l_ptr->next_out);
 	return mod(l_ptr->next_out_no);
 }
 
@@ -1354,7 +1354,7 @@ u32 tipc_link_push_packet(struct link *l_ptr)
 	if (r_q_size && buf) {
 		u32 last = lesser(mod(r_q_head + r_q_size),
 				  link_last_sent(l_ptr));
-		u32 first = msg_seqno(buf_msg(buf));
+		u32 first = buf_seqno(buf);
 
 		while (buf && less(first, r_q_head)) {
 			first = mod(first + 1);
@@ -1403,7 +1403,7 @@ u32 tipc_link_push_packet(struct link *l_ptr)
 	if (buf) {
 		struct tipc_msg *msg = buf_msg(buf);
 		u32 next = msg_seqno(msg);
-		u32 first = msg_seqno(buf_msg(l_ptr->first_out));
+		u32 first = buf_seqno(l_ptr->first_out);
 
 		if (mod(next - first) < l_ptr->queue_limit[0]) {
 			msg_set_ack(msg, mod(l_ptr->next_in_no - 1));
@@ -1558,7 +1558,7 @@ void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf,
 		} else {
 			tipc_bearer_schedule(l_ptr->b_ptr, l_ptr);
 			l_ptr->stats.bearer_congs++;
-			l_ptr->retransm_queue_head = msg_seqno(buf_msg(buf));
+			l_ptr->retransm_queue_head = buf_seqno(buf);
 			l_ptr->retransm_queue_size = retransmits;
 			return;
 		}
@@ -1579,7 +1579,7 @@ static struct sk_buff *link_insert_deferred_queue(struct link *l_ptr,
 	if (l_ptr->oldest_deferred_in == NULL)
 		return buf;
 
-	seq_no = msg_seqno(buf_msg(l_ptr->oldest_deferred_in));
+	seq_no = buf_seqno(l_ptr->oldest_deferred_in);
 	if (seq_no == mod(l_ptr->next_in_no)) {
 		l_ptr->newest_deferred_in->next = buf;
 		buf = l_ptr->oldest_deferred_in;
@@ -1738,7 +1738,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *b_ptr)
 
 		crs = l_ptr->first_out;
 		while ((crs != l_ptr->next_out) &&
-		       less_eq(msg_seqno(buf_msg(crs)), ackd)) {
+		       less_eq(buf_seqno(crs), ackd)) {
 			struct sk_buff *next = crs->next;
 
 			buf_discard(crs);
@@ -1861,7 +1861,7 @@ u32 tipc_link_defer_pkt(struct sk_buff **head,
 {
 	struct sk_buff *prev = NULL;
 	struct sk_buff *crs = *head;
-	u32 seq_no = msg_seqno(buf_msg(buf));
+	u32 seq_no = buf_seqno(buf);
 
 	buf->next = NULL;
 
@@ -1872,7 +1872,7 @@ u32 tipc_link_defer_pkt(struct sk_buff **head,
 	}
 
 	/* Last ? */
-	if (less(msg_seqno(buf_msg(*tail)), seq_no)) {
+	if (less(buf_seqno(*tail), seq_no)) {
 		(*tail)->next = buf;
 		*tail = buf;
 		return 1;
@@ -1909,7 +1909,7 @@ u32 tipc_link_defer_pkt(struct sk_buff **head,
 static void link_handle_out_of_seq_msg(struct link *l_ptr,
 				       struct sk_buff *buf)
 {
-	u32 seq_no = msg_seqno(buf_msg(buf));
+	u32 seq_no = buf_seqno(buf);
 
 	if (likely(msg_user(buf_msg(buf)) == LINK_PROTOCOL)) {
 		link_recv_proto_msg(l_ptr, buf);
@@ -1971,10 +1971,10 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg,
 		if (!tipc_link_is_up(l_ptr))
 			return;
 		if (l_ptr->next_out)
-			next_sent = msg_seqno(buf_msg(l_ptr->next_out));
+			next_sent = buf_seqno(l_ptr->next_out);
 		msg_set_next_sent(msg, next_sent);
 		if (l_ptr->oldest_deferred_in) {
-			u32 rec = msg_seqno(buf_msg(l_ptr->oldest_deferred_in));
+			u32 rec = buf_seqno(l_ptr->oldest_deferred_in);
 			gap = mod(rec - mod(l_ptr->next_in_no));
 		}
 		msg_set_seq_gap(msg, gap);
@@ -2589,7 +2589,7 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
 
 	/* Is there an incomplete message waiting for this fragment? */
 
-	while (pbuf && ((msg_seqno(buf_msg(pbuf)) != long_msg_seq_no) ||
+	while (pbuf && ((buf_seqno(pbuf) != long_msg_seq_no) ||
 			(msg_orignode(fragm) != msg_orignode(buf_msg(pbuf))))) {
 		prev = pbuf;
 		pbuf = pbuf->next;
@@ -3112,13 +3112,12 @@ static void link_print(struct link *l_ptr, const char *str)
 	tipc_printf(buf, "NXI(%u):", mod(l_ptr->next_in_no));
 	tipc_printf(buf, "SQUE");
 	if (l_ptr->first_out) {
-		tipc_printf(buf, "[%u..", msg_seqno(buf_msg(l_ptr->first_out)));
+		tipc_printf(buf, "[%u..", buf_seqno(l_ptr->first_out));
 		if (l_ptr->next_out)
-			tipc_printf(buf, "%u..",
-				    msg_seqno(buf_msg(l_ptr->next_out)));
-		tipc_printf(buf, "%u]", msg_seqno(buf_msg(l_ptr->last_out)));
-		if ((mod(msg_seqno(buf_msg(l_ptr->last_out)) -
-			 msg_seqno(buf_msg(l_ptr->first_out)))
+			tipc_printf(buf, "%u..", buf_seqno(l_ptr->next_out));
+		tipc_printf(buf, "%u]", buf_seqno(l_ptr->last_out));
+		if ((mod(buf_seqno(l_ptr->last_out) -
+			 buf_seqno(l_ptr->first_out))
 		     != (l_ptr->out_queue_size - 1)) ||
 		    (l_ptr->last_out->next != NULL)) {
 			tipc_printf(buf, "\nSend queue inconsistency\n");
@@ -3130,8 +3129,8 @@ static void link_print(struct link *l_ptr, const char *str)
 		tipc_printf(buf, "[]");
 	tipc_printf(buf, "SQSIZ(%u)", l_ptr->out_queue_size);
 	if (l_ptr->oldest_deferred_in) {
-		u32 o = msg_seqno(buf_msg(l_ptr->oldest_deferred_in));
-		u32 n = msg_seqno(buf_msg(l_ptr->newest_deferred_in));
+		u32 o = buf_seqno(l_ptr->oldest_deferred_in);
+		u32 n = buf_seqno(l_ptr->newest_deferred_in);
 		tipc_printf(buf, ":RQUE[%u..%u]", o, n);
 		if (l_ptr->deferred_inqueue_sz != mod((n + 1) - o)) {
 			tipc_printf(buf, ":RQSIZ(%u)",
net/tipc/link.h +5 -0
index 7879239..d35b0f3 100644
@@ -254,6 +254,11 @@ void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *start, u32 retrans
  * Link sequence number manipulation routines (uses modulo 2**16 arithmetic)
  */
 
+static inline u32 buf_seqno(struct sk_buff *buf)
+{
+	return msg_seqno(buf_msg(buf));
+}
+
 static inline u32 mod(u32 x)
 {
 	return x & 0xffffu;
Signature · 1 line
1.7.4.4
maintainer
#24 lore raw
In reply to Paul Gortmaker

From: Paul Gortmaker <[email protected]>
Date: Tue, 27 Dec 2011 12:39:19 -0500

Quoted 7 lines

Here are some more updates for TIPC, based on the backlog of stuff that was unfortunately stacked away in sourceforge a while ago.

Given the timing, please feel free to defer these to the for-3.4 net-next if there isn't a convenient opportunity to process it before 3.2 is officially released. I can easily resend later.

Quoted 6 lines

Fortunately, the SF backlog will finally be 100% gone with the pending stuff that will be sent in the next year for the 3.4 net-next, so that will be nice to have that task closed out.

I just finished testing this over the wire between an x86-32 and an x86-64 box, with both taking turns being server and client.

Pulled, thanks Paul.

Two suggestions:

1) Please rename things like "struct media" to something more global namespace friendly like "struct tipc_media"

2) We really should get rid of the ad-hoc debug logging facility tipc uses. It's not like there aren't tons of generic, well maintained, feature-full logging facilities available. There is no reason for tipc to have it's own special, private, logginc facility.

If the generic facilities lack some feature, add it and submit it for inclusion to linux-kernel so everyone can use it, not just TIPC.

#25 lore raw
Quoted 17 lines · David Miller

From: Paul Gortmaker <[email protected]>
Date: Tue, 27 Dec 2011 12:39:19 -0500

Quoted 7 lines

Here are some more updates for TIPC, based on the backlog of stuff that was unfortunately stacked away in sourceforge a while ago.

Given the timing, please feel free to defer these to the for-3.4 net-next if there isn't a convenient opportunity to process it before 3.2 is officially released.  I can easily resend later.

Quoted 6 lines

Fortunately, the SF backlog will finally be 100% gone with the pending stuff that will be sent in the next year for the 3.4 net-next, so that will be nice to have that task closed out.

I just finished testing this over the wire between an x86-32 and an x86-64 box, with both taking turns being server and client.

Quoted 6 lines

Pulled, thanks Paul.

Two suggestions:

1) Please rename things like "struct media" to something more global namespace friendly like "struct tipc_media"

Yep, I can do that easily, and probably send that out this week, since a change like this won't invalidate any prev. testing etc.

Quoted 5 lines

2) We really should get rid of the ad-hoc debug logging facility tipc uses.  It's not like there aren't tons of generic, well maintained, feature-full logging facilities available.  There is no reason for tipc to have it's own special, private, logginc facility.

Sounds like the right thing to do; I will take a look at this to see how involved it is. I don't think there should be any problem getting it in with the remaining SF changes for 3.4 content in the new year.

Thanks,
Paul.

Quoted 8 lines

  If the generic facilities lack some feature, add it and submit it for inclusion to linux-kernel so everyone can use it, not just TIPC.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html