svn commit: trunk/busybox/networking/libiproute

vda at busybox.net vda at busybox.net
Tue Mar 3 14:55:30 UTC 2009


Author: vda
Date: 2009-03-03 14:55:29 +0000 (Tue, 03 Mar 2009)
New Revision: 25508

Log:
ip: in "ip rule add from all table 1", "all" is taken as 0.0.0.0/32,
whereas "any" and "default" would be 0.0.0.0/0. They must be all 0.0.0.0/0.
Closes bug 57.



Modified:
   trunk/busybox/networking/libiproute/utils.c
   trunk/busybox/networking/libiproute/utils.h


Changeset:
Modified: trunk/busybox/networking/libiproute/utils.c
===================================================================
--- trunk/busybox/networking/libiproute/utils.c	2009-03-03 14:27:36 UTC (rev 25507)
+++ trunk/busybox/networking/libiproute/utils.c	2009-03-03 14:55:29 UTC (rev 25508)
@@ -43,7 +43,7 @@
 	return 0;
 }
 
-int get_u32(uint32_t * val, char *arg, int base)
+int get_u32(uint32_t *val, char *arg, int base)
 {
 	unsigned long res;
 	char *ptr;
@@ -57,7 +57,7 @@
 	return 0;
 }
 
-int get_u16(uint16_t * val, char *arg, int base)
+int get_u16(uint16_t *val, char *arg, int base)
 {
 	unsigned long res;
 	char *ptr;
@@ -71,7 +71,7 @@
 	return 0;
 }
 
-int get_u8(uint8_t * val, char *arg, int base)
+int get_u8(uint8_t *val, char *arg, int base)
 {
 	unsigned long res;
 	char *ptr;
@@ -85,7 +85,7 @@
 	return 0;
 }
 
-int get_s16(int16_t * val, char *arg, int base)
+int get_s16(int16_t *val, char *arg, int base)
 {
 	long res;
 	char *ptr;
@@ -99,7 +99,7 @@
 	return 0;
 }
 
-int get_s8(int8_t * val, char *arg, int base)
+int get_s8(int8_t *val, char *arg, int base)
 {
 	long res;
 	char *ptr;
@@ -113,12 +113,14 @@
 	return 0;
 }
 
-int get_addr_1(inet_prefix * addr, char *name, int family)
+int get_addr_1(inet_prefix *addr, char *name, int family)
 {
 	memset(addr, 0, sizeof(*addr));
 
-	if (strcmp(name, bb_str_default) == 0 ||
-		strcmp(name, "all") == 0 || strcmp(name, "any") == 0) {
+	if (strcmp(name, bb_str_default) == 0
+	 || strcmp(name, "all") == 0
+	 || strcmp(name, "any") == 0
+	) {
 		addr->family = family;
 		addr->bytelen = (family == AF_INET6 ? 16 : 4);
 		addr->bitlen = -1;
@@ -146,7 +148,7 @@
 	return 0;
 }
 
-int get_prefix_1(inet_prefix * dst, char *arg, int family)
+static int get_prefix_1(inet_prefix *dst, char *arg, int family)
 {
 	int err;
 	unsigned plen;
@@ -154,7 +156,10 @@
 
 	memset(dst, 0, sizeof(*dst));
 
-	if (strcmp(arg, bb_str_default) == 0 || strcmp(arg, "any") == 0) {
+	if (strcmp(arg, bb_str_default) == 0
+	 || strcmp(arg, "all") == 0
+	 || strcmp(arg, "any") == 0
+	) {
 		dst->family = family;
 		dst->bytelen = 0;
 		dst->bitlen = 0;
@@ -172,7 +177,7 @@
 
 			netmask_pfx.family = AF_UNSPEC;
 			if ((get_unsigned(&plen, slash + 1, 0) || plen > dst->bitlen)
-				&& (get_addr_1(&netmask_pfx, slash + 1, family)))
+			 && (get_addr_1(&netmask_pfx, slash + 1, family)))
 				err = -1;
 			else if (netmask_pfx.family == AF_INET) {
 				/* fill in prefix length of dotted quad */
@@ -184,8 +189,8 @@
 					for (plen = 0; mask; mask <<= 1)
 						++plen;
 					if (plen >= 0 && plen <= dst->bitlen) {
-							dst->bitlen = plen;
-							/* dst->flags |= PREFIXLEN_SPECIFIED; */
+						dst->bitlen = plen;
+						/* dst->flags |= PREFIXLEN_SPECIFIED; */
 					} else
 						err = -1;
 				} else
@@ -201,7 +206,7 @@
 	return err;
 }
 
-int get_addr(inet_prefix * dst, char *arg, int family)
+int get_addr(inet_prefix *dst, char *arg, int family)
 {
 	if (family == AF_PACKET) {
 		bb_error_msg_and_die("\"%s\" may be inet %s, but it is not allowed in this context", arg, "address");
@@ -212,7 +217,7 @@
 	return 0;
 }
 
-int get_prefix(inet_prefix * dst, char *arg, int family)
+int get_prefix(inet_prefix *dst, char *arg, int family)
 {
 	if (family == AF_PACKET) {
 		bb_error_msg_and_die("\"%s\" may be inet %s, but it is not allowed in this context", arg, "prefix");
@@ -253,7 +258,7 @@
 	bb_error_msg_and_die("either \"%s\" is duplicate, or \"%s\" is garbage", key, arg);
 }
 
-int inet_addr_match(inet_prefix * a, inet_prefix * b, int bits)
+int inet_addr_match(inet_prefix *a, inet_prefix *b, int bits)
 {
 	uint32_t *a1 = a->data;
 	uint32_t *a2 = b->data;
@@ -293,7 +298,6 @@
 	}
 }
 
-
 const char *format_host(int af, int len, void *addr, char *buf, int buflen)
 {
 #ifdef RESOLVE_HOSTNAMES

Modified: trunk/busybox/networking/libiproute/utils.h
===================================================================
--- trunk/busybox/networking/libiproute/utils.h	2009-03-03 14:27:36 UTC (rev 25507)
+++ trunk/busybox/networking/libiproute/utils.h	2009-03-03 14:55:29 UTC (rev 25508)
@@ -60,7 +60,7 @@
 
 extern uint32_t get_addr32(char *name);
 extern int get_addr_1(inet_prefix *dst, char *arg, int family);
-extern int get_prefix_1(inet_prefix *dst, char *arg, int family);
+/*extern int get_prefix_1(inet_prefix *dst, char *arg, int family);*/
 extern int get_addr(inet_prefix *dst, char *arg, int family);
 extern int get_prefix(inet_prefix *dst, char *arg, int family);
 



More information about the busybox-cvs mailing list