rtnetlink: propagate error from dev_change_flags in do_setlink()

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: David S. Miller <davem@...>
Cc: netdev <netdev@...>, Patrick McHardy <kaber@...>
Date: Sunday, November 16, 2008 - 9:10 am

Unlike ifconfig, iproute doesn't report an error when setting
an interface up fails:

(example: put wireless network mac80211 interface into repeater mode
with iwconfig but do not set a peer MAC address, it should fail with
-ENOLINK)

without patch:
# ip link set wlan0 up ; echo $?
0
# 

with patch:
# ip link set wlan0 up ; echo $?
RTNETLINK answers: Link has been severed
2
# 

Propagate the return value from dev_change_flags() to fix this.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Tested-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
 net/core/rtnetlink.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- everything.orig/net/core/rtnetlink.c	2008-10-26 20:00:12.000000000 +0100
+++ everything/net/core/rtnetlink.c	2008-11-11 23:24:14.000000000 +0100
@@ -878,7 +878,9 @@ static int do_setlink(struct net_device 
 		if (ifm->ifi_change)
 			flags = (flags & ifm->ifi_change) |
 				(dev->flags & ~ifm->ifi_change);
-		dev_change_flags(dev, flags);
+		err = dev_change_flags(dev, flags);
+		if (err < 0)
+			goto errout;
 	}
 
 	if (tb[IFLA_TXQLEN])


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
rtnetlink: propagate error from dev_change_flags in do_setli..., Johannes Berg, (Sun Nov 16, 9:10 am)