Commit Diff


commit - 731e161842282fb84808712dcea8d05a9a7918fb
commit + 15a2fabe4d49f7c280b90dcce141c15804dbc37f
blob - cd9996fc9a6116045ebadf27b4639ef38ebbb30f
blob + ab83616edf04a266cb51b2ab7adb8f168bdef2e7
--- if.c
+++ if.c
@@ -2378,18 +2378,21 @@ intparent(char *ifname, int ifs, int argc, char **argv
 	cmd = (set ? SIOCSIFPARENT : SIOCDIFPARENT);
 	ret = ioctl(ifs, cmd, &ifp);
 	if (ret == -1) {
+		int cmd_errno = errno;
 		if (errno == EBUSY) {
 			int flags = get_ifflags(ifname, ifs);
 			if (flags & IFF_UP) {
 				/* Put interface down, retry, and put it up. */
 				set_ifflags(ifname, ifs, flags & ~IFF_UP);
 				ret = ioctl(ifs, cmd, &ifp);
+				if (ret == -1)
+					cmd_errno = errno;
 				set_ifflags(ifname, ifs, flags);
 			}
 		}
 		if (ret == -1)
 			printf("%% intparent: SIOC%sIFPARENT: %s\n",
-			    set ? "S" : "D", strerror(errno));
+			    set ? "S" : "D", strerror(cmd_errno));
 	}
 
 	return 0;