summary refs log tree commit diff
path: root/drivers/net/bonding
diff options
context:
space:
mode:
authorTonghao Zhang <xiangxia.m.yue@gmail.com>2019-02-11 10:49:48 -0800
committerDavid S. Miller <davem@davemloft.net>2019-02-14 11:35:50 -0500
commit415d39427317d1532d7f097471cc8aca5f229b69 (patch)
treeb0bea840cacafc205a1976799b70b0345ad282d0 /drivers/net/bonding
parent79e088239c3bfaf0b6f185770ae262041e42072f (diff)
downloadlinux-415d39427317d1532d7f097471cc8aca5f229b69.tar.gz
bonding: check slave set command firstly
This patch is a little improvement. If user use the
command shown as below, we should print the info [1]
instead of [2]. The eth0 exists actually, and it may
confuse user.

$ echo "eth0" > /sys/class/net/bond4/bonding/slaves

[1] "bond4: no command found in slaves file - use +ifname or -ifname"
[2] "write error: No such device"

Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding')
-rw-r--r--drivers/net/bonding/bond_options.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index 4d5d01cb8141..da1fc17295d9 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -1375,6 +1375,7 @@ static int bond_option_slaves_set(struct bonding *bond,
 	sscanf(newval->string, "%16s", command); /* IFNAMSIZ*/
 	ifname = command + 1;
 	if ((strlen(command) <= 1) ||
+	    (command[0] != '+' && command[0] != '-') ||
 	    !dev_valid_name(ifname))
 		goto err_no_cmd;
 
@@ -1398,6 +1399,7 @@ static int bond_option_slaves_set(struct bonding *bond,
 		break;
 
 	default:
+		/* should not run here. */
 		goto err_no_cmd;
 	}