changeset 12592:40d4395b2cd4

6954959 libipadm now allows 'ifconfig bge0 removeif <address>' to succeed.
author Vasumathi Sundaram <Vasumathi.Sundaram@oracle.COM>
date Wed, 09 Jun 2010 12:41:50 -0400
parents cdf3cc28b713
children 3c3a4d3d1dda
files usr/src/cmd/cmd-inet/usr.sbin/ifconfig/ifconfig.c
diffstat 1 files changed, 19 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/ifconfig.c	Wed Jun 09 09:43:56 2010 -0600
+++ b/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/ifconfig.c	Wed Jun 09 12:41:50 2010 -0400
@@ -1996,13 +1996,23 @@
 		if (sockaddrcmp(ainfop->ia_ifa.ifa_addr, &laddr))
 			break;
 
-	if (ainfop != NULL && ainfop->ia_aobjname[0] != '\0') {
-		istatus = ipadm_delete_addr(iph, ainfop->ia_aobjname,
-		    IPADM_OPT_ACTIVE);
-		if (istatus != IPADM_SUCCESS)
-			ipadmerr_exit(istatus, "could not delete address");
-		ipadm_free_addr_info(ainfo);
-		return (0);
+	if (ainfop != NULL) {
+		if (strchr(ainfop->ia_ifa.ifa_name, ':') == NULL) {
+			(void) fprintf(stderr,
+			    "ifconfig: removeif: cannot remove interface: %s\n",
+			    name);
+			exit(1);
+		}
+		if (ainfop->ia_aobjname[0] != '\0') {
+			istatus = ipadm_delete_addr(iph, ainfop->ia_aobjname,
+			    IPADM_OPT_ACTIVE);
+			if (istatus != IPADM_SUCCESS) {
+				ipadmerr_exit(istatus,
+				    "could not delete address");
+			}
+			ipadm_free_addr_info(ainfo);
+			return (0);
+		}
 	}
 	ipadm_free_addr_info(ainfo);
 
@@ -2017,7 +2027,7 @@
 		if (errno == EBUSY) {
 			/* This can only happen if ipif_id = 0 */
 			(void) fprintf(stderr,
-			    "ifconfig: removeif: can't remove interface: %s\n",
+			    "ifconfig: removeif: cannot remove interface: %s\n",
 			    name);
 			exit(1);
 		}
@@ -3016,7 +3026,7 @@
 	}
 
 	/*
-	 * Build the interface name to print (we can't directly use `name'
+	 * Build the interface name to print (we cannot directly use `name'
 	 * because one cannot "plumb" ":0" interfaces).
 	 */
 	(void) strlcpy(lifname, name, LIFNAMSIZ);