netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Per Liden <per.liden@ericsson.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Allan Stephens <allan.stephens@windriver.com>
Subject: [PATCH 27/32] [TIPC] Disallow config operations that aren't supported in certain modes.
Date: Thu, 22 Jun 2006 15:59:40 +0200	[thread overview]
Message-ID: <11509847872189-git-send-email-per.liden@ericsson.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0606221233570.15853@ulinpc219.uab.ericsson.se>

From: Allan Stephens <allan.stephens@windriver.com>

This change provides user-friendly feedback when TIPC is unable to perform
certain configuration operations that don't work properly in certain modes.
(In particular, any reconfiguration request that would temporarily take TIPC
from network mode to standalone mode, or from standalone mode to not running
mode, is disallowed.)

Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Per Liden <per.liden@ericsson.com>
---
 net/tipc/config.c |   83 ++++++++++++++++++++++++-----------------------------
 1 files changed, 38 insertions(+), 45 deletions(-)

diff --git a/net/tipc/config.c b/net/tipc/config.c
index 48b5de2..41c8447 100644
--- a/net/tipc/config.c
+++ b/net/tipc/config.c
@@ -291,13 +291,22 @@ static struct sk_buff *cfg_set_own_addr(
 	if (!tipc_addr_node_valid(addr))
 		return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
 						   " (node address)");
-	if (tipc_own_addr)
+	if (tipc_mode == TIPC_NET_MODE)
 		return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
 						   " (cannot change node address once assigned)");
+	tipc_own_addr = addr;
+
+	/* 
+	 * 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.
+	 */
 
 	spin_unlock_bh(&config_lock);
-	tipc_core_stop_net();
-	tipc_own_addr = addr;
 	tipc_core_start_net();
 	spin_lock_bh(&config_lock);
 	return tipc_cfg_reply_none();
@@ -350,50 +359,21 @@ static struct sk_buff *cfg_set_max_subsc
 
 static struct sk_buff *cfg_set_max_ports(void)
 {
-	int orig_mode;
 	u32 value;
 
 	if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
 		return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
 	value = *(u32 *)TLV_DATA(req_tlv_area);
 	value = ntohl(value);
+	if (value == tipc_max_ports)
+		return tipc_cfg_reply_none();
 	if (value != delimit(value, 127, 65535))
 		return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
 						   " (max ports must be 127-65535)");
-
-	if (value == tipc_max_ports)
-		return tipc_cfg_reply_none();
-
-	if (atomic_read(&tipc_user_count) > 2)
+	if (tipc_mode != TIPC_NOT_RUNNING)
 		return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
-						   " (cannot change max ports while TIPC users exist)");
-
-	spin_unlock_bh(&config_lock);
-	orig_mode = tipc_get_mode();
-	if (orig_mode == TIPC_NET_MODE)
-		tipc_core_stop_net();
-	tipc_core_stop();
+			" (cannot change max ports while TIPC is active)");
 	tipc_max_ports = value;
-	tipc_core_start();
-	if (orig_mode == TIPC_NET_MODE)
-		tipc_core_start_net();
-	spin_lock_bh(&config_lock);
-	return tipc_cfg_reply_none();
-}
-
-static struct sk_buff *set_net_max(int value, int *parameter)
-{
-	int orig_mode;
-
-	if (value != *parameter) {
-		orig_mode = tipc_get_mode();
-		if (orig_mode == TIPC_NET_MODE)
-			tipc_core_stop_net();
-		*parameter = value;
-		if (orig_mode == TIPC_NET_MODE)
-			tipc_core_start_net();
-	}
-
 	return tipc_cfg_reply_none();
 }
 
@@ -405,10 +385,16 @@ static struct sk_buff *cfg_set_max_zones
 		return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
 	value = *(u32 *)TLV_DATA(req_tlv_area);
 	value = ntohl(value);
+	if (value == tipc_max_zones)
+		return tipc_cfg_reply_none();
 	if (value != delimit(value, 1, 255))
 		return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
 						   " (max zones must be 1-255)");
-	return set_net_max(value, &tipc_max_zones);
+	if (tipc_mode == TIPC_NET_MODE)
+		return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
+			" (cannot change max zones once TIPC has joined a network)");
+	tipc_max_zones = value;
+	return tipc_cfg_reply_none();
 }
 
 static struct sk_buff *cfg_set_max_clusters(void)
@@ -419,8 +405,8 @@ static struct sk_buff *cfg_set_max_clust
 		return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
 	value = *(u32 *)TLV_DATA(req_tlv_area);
 	value = ntohl(value);
-	if (value != 1)
-		return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
+	if (value != delimit(value, 1, 1))
+		return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
 						   " (max clusters fixed at 1)");
 	return tipc_cfg_reply_none();
 }
@@ -433,10 +419,16 @@ static struct sk_buff *cfg_set_max_nodes
 		return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
 	value = *(u32 *)TLV_DATA(req_tlv_area);
 	value = ntohl(value);
+	if (value == tipc_max_nodes)
+		return tipc_cfg_reply_none();
 	if (value != delimit(value, 8, 2047))
 		return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
 						   " (max nodes must be 8-2047)");
-	return set_net_max(value, &tipc_max_nodes);
+	if (tipc_mode == TIPC_NET_MODE)
+		return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
+			" (cannot change max nodes once TIPC has joined a network)");
+	tipc_max_nodes = value;
+	return tipc_cfg_reply_none();
 }
 
 static struct sk_buff *cfg_set_max_slaves(void)
@@ -461,15 +453,16 @@ static struct sk_buff *cfg_set_netid(voi
 		return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
 	value = *(u32 *)TLV_DATA(req_tlv_area);
 	value = ntohl(value);
+	if (value == tipc_net_id)
+		return tipc_cfg_reply_none();
 	if (value != delimit(value, 1, 9999))
 		return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
 						   " (network id must be 1-9999)");
-
-	if (tipc_own_addr)
+	if (tipc_mode == TIPC_NET_MODE)
 		return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
-						   " (cannot change network id once part of network)");
-	
-	return set_net_max(value, &tipc_net_id);
+			" (cannot change network id once TIPC has joined a network)");
+	tipc_net_id = value;
+	return tipc_cfg_reply_none();
 }
 
 struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area,
-- 
1.4.0


  parent reply	other threads:[~2006-06-22 13:59 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-22 11:14 [PATCH 0/32] TIPC updates Per Liden
2006-06-22 13:59 ` [PATCH 1/32] [TIPC] Improved tolerance to promiscuous mode interface Per Liden
2006-06-22 13:59 ` [PATCH 2/32] [TIPC] Prevent name table corruption if no room for new publication Per Liden
2006-06-22 13:59 ` [PATCH 3/32] [TIPC] Use correct upper bound when validating network zone number Per Liden
2006-06-22 13:59 ` [PATCH 4/32] [TIPC] Corrected potential misuse of tipc_media_addr structure Per Liden
2006-06-22 13:59 ` [PATCH 5/32] [TIPC] Allow ports to receive multicast messages through native API Per Liden
2006-06-22 13:59 ` [PATCH 6/32] [TIPC] Links now validate destination node specified by incoming messages Per Liden
2006-06-22 13:59 ` [PATCH 7/32] [TIPC] Multicast link failure now resets all links to "nacking" node Per Liden
2006-06-22 18:51   ` James Morris
2006-06-22 13:59 ` [PATCH 8/32] [TIPC] Allow compilation when CONFIG_TIPC_DEBUG is not set Per Liden
2006-06-22 13:59 ` [PATCH 9/32] [TIPC] Fix for NULL pointer dereference Per Liden
2006-06-22 13:59 ` [PATCH 10/32] [TIPC] Fixed privilege checking typo in dest_name_check() Per Liden
2006-06-22 13:59 ` [PATCH 11/32] [TIPC] Fix misleading comment in buf_discard() routine Per Liden
2006-06-22 13:59 ` [PATCH 12/32] [TIPC] Added support for MODULE_VERSION capability Per Liden
2006-06-22 13:59 ` [PATCH 13/32] [TIPC] Validate entire interface name when locating bearer to enable Per Liden
2006-06-22 13:59 ` [PATCH 14/32] [TIPC] Non-operation-affecting corrections to comments & function definitions Per Liden
2006-06-22 13:59 ` [PATCH 15/32] [TIPC] Fixed connect() to detect a dest address that is missing or too short Per Liden
2006-06-22 13:59 ` [PATCH 16/32] [TIPC] Implied connect now saves dest name for retrieval as ancillary data Per Liden
2006-06-22 13:59 ` [PATCH 17/32] [TIPC] Can now return destination name of form {0,x,y} via " Per Liden
2006-06-22 13:59 ` [PATCH 18/32] [TIPC] Connected send now checks socket state when retrying congested send Per Liden
2006-06-22 13:59 ` [PATCH 19/32] [TIPC] Stream socket send indicates partial success if data partially sent Per Liden
2006-06-22 13:59 ` [PATCH 20/32] [TIPC] Improved performance of error checking during socket creation Per Liden
2006-06-22 13:59 ` [PATCH 21/32] [TIPC] recvmsg() now returns TIPC ancillary data using correct level (SOL_TIPC) Per Liden
2006-06-22 13:59 ` [PATCH 22/32] [TIPC] Simplify code for returning partial success of stream send request Per Liden
2006-06-22 13:59 ` [PATCH 23/32] [TIPC] Optimized argument validation done by connect() Per Liden
2006-06-22 13:59 ` [PATCH 24/32] [TIPC] Withdrawing all names from nameless port now returns success, not error Per Liden
2006-06-22 13:59 ` [PATCH 25/32] [TIPC] Added missing warning for out-of-memory condition Per Liden
2006-06-22 13:59 ` [PATCH 26/32] [TIPC] Fixed memory leak in tipc_link_send() when destination is unreachable Per Liden
2006-06-22 13:59 ` Per Liden [this message]
2006-06-22 13:59 ` [PATCH 28/32] [TIPC] First phase of assert() cleanup Per Liden
2006-06-22 13:59 ` [PATCH 29/32] [TIPC] Enhanced & cleaned up system messages; fixed 2 obscure memory leaks Per Liden
2006-06-22 13:59 ` [PATCH 30/32] [TIPC] Fixed link switchover bugs Per Liden
2006-06-22 13:59 ` [PATCH 31/32] [TIPC] Get rid of dynamically allocated arrays in broadcast code Per Liden
2006-06-22 13:59 ` [PATCH 32/32] [TIPC] Fix incorrect correction to discovery timer frequency computation Per Liden
2006-06-26  6:54 ` [PATCH 0/32] TIPC updates David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11509847872189-git-send-email-per.liden@ericsson.com \
    --to=per.liden@ericsson.com \
    --cc=allan.stephens@windriver.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).