LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File net-tools-1.60-ifconfig-SIOCSIFNETMASK.diff of Package net-tools (Project home:pwieczorkiewicz:branches:openSUSE:Leap:42.1:Update)

--- net-tools-1.60/ifconfig.c.orig	2008-11-06 16:25:50.000000000 +0100
+++ net-tools-1.60/ifconfig.c	2008-11-06 16:36:10.000000000 +0100
@@ -227,13 +227,13 @@
 
 int main(int argc, char **argv)
 {
-    struct sockaddr sa;
+    struct sockaddr sa, sa_netmask; 
     struct sockaddr_in sin;
     char host[128];
     struct aftype *ap;
     struct hwtype *hw;
     struct ifreq ifr;
-    int goterr = 0, didnetmask = 0;
+    int goterr = 0, didnetmask = 0, donetmask = 0;
     char **spp;
     int fd;
 #if HAVE_AFINET6
@@ -903,7 +903,7 @@
 	/* FIXME: sa is too small for INET6 addresses, inet6 should use that too, 
 	   broadcast is unexpected */
 	if (ap->getmask) {
-	    switch (ap->getmask(host, &sa, NULL)) {
+	    switch (ap->getmask(host, &sa_netmask, NULL)) { 
 	    case -1:
 		usage();
 		break;
@@ -911,8 +911,8 @@
 		if (didnetmask)
 		    usage();
 
-		goterr = set_netmask(skfd, &ifr, &sa);
-		didnetmask++;
+		/* delay setting the CIDR netmask till after setting the addr */
+		donetmask = 1;
 		break;
 	    }
 	}
@@ -960,6 +960,13 @@
 	    }
 	}
 
+	/* set CIDR netmask */
+	if (donetmask) {
+		donetmask = 0;
+		goterr = set_netmask(skfd, &ifr, &sa_netmask);
+		didnetmask++;
+	} 
+
        /*
         * Don't do the set_flag() if the address is an alias with a - at the
         * end, since it's deleted already! - Roman