r7570 - trunk/ipset

kadlec at blackhole.kfki.hu kadlec at blackhole.kfki.hu
Wed Oct 22 00:04:47 CEST 2008


Author: kadlec at blackhole.kfki.hu
Date: 2008-10-22 00:04:47 +0200 (Wed, 22 Oct 2008)
New Revision: 7570

Modified:
   trunk/ipset/ChangeLog
   trunk/ipset/ipset.c
   trunk/ipset/ipset.h
   trunk/ipset/ipset_ipporthash.c
   trunk/ipset/ipset_ipportiphash.c
   trunk/ipset/ipset_ipportnethash.c
   trunk/ipset/ipset_iptree.c
   trunk/ipset/ipset_iptreemap.c
   trunk/ipset/ipset_macipmap.c
Log:
  - macipmap type reported misleading deprecated separator
    tokens and printed the old one at listing set elements.
    Token printing was errorneous too.
    (Bugs reported by Krzysztof Oledzki)
  - Warn only once about deprecated separator tokens in
    restore mode.


Modified: trunk/ipset/ChangeLog
===================================================================
--- trunk/ipset/ChangeLog	2008-10-21 12:09:05 UTC (rev 7569)
+++ trunk/ipset/ChangeLog	2008-10-21 22:04:47 UTC (rev 7570)
@@ -1,3 +1,9 @@
+2.4.1
+  - macipmap type reported misleading deprecated separator
+    tokens and printed the old one at listing set elements
+    (bug reported by Krzysztof Oledzki)
+  - Warn only once about deprecated separator tokens in
+    restore mode.
 
 2.4
   - Added KBUILD_OUTPUT support (Sven Wegener)

Modified: trunk/ipset/ipset.c
===================================================================
--- trunk/ipset/ipset.c	2008-10-21 12:09:05 UTC (rev 7569)
+++ trunk/ipset/ipset.c	2008-10-21 22:04:47 UTC (rev 7570)
@@ -47,6 +47,7 @@
 size_t restore_offset = 0;
 socklen_t restore_size;
 unsigned restore_line = 0;
+unsigned warn_once = 0;
 
 #define TEMPFILE_PATTERN	"/ipsetXXXXXX"
 

Modified: trunk/ipset/ipset.h
===================================================================
--- trunk/ipset/ipset.h	2008-10-21 12:09:05 UTC (rev 7569)
+++ trunk/ipset/ipset.h	2008-10-21 22:04:47 UTC (rev 7570)
@@ -185,6 +185,8 @@
 extern struct set *set_find_byname(const char *name);
 extern struct set *set_find_byid(ip_set_id_t id);
 
+extern unsigned warn_once;
+
 #define BITSPERBYTE	(8*sizeof(char))
 #define ID2BYTE(id)	((id)/BITSPERBYTE)
 #define ID2MASK(id)	(1 << ((id)%BITSPERBYTE))

Modified: trunk/ipset/ipset_ipporthash.c
===================================================================
--- trunk/ipset/ipset_ipporthash.c	2008-10-21 12:09:05 UTC (rev 7569)
+++ trunk/ipset/ipset_ipporthash.c	2008-10-21 22:04:47 UTC (rev 7570)
@@ -198,10 +198,9 @@
 
 	DP("ipporthash: %p %p", optarg, data);
 
-	if ((ptr = strchr(tmp, ':')) || (ptr = strchr(tmp, '%')))
-		fprintf(stderr, "Warning: please replace old separator character '%s.1' with ','.\n"
-			        "Next release won't support it.\n",
-		        ptr);
+	if (((ptr = strchr(tmp, ':')) || (ptr = strchr(tmp, '%'))) && ++warn_once == 1)
+		fprintf(stderr, "Warning: please use ',' separator token between ip,port.\n"
+			        "Next release won't support old separator tokens.\n");
 
 	ptr = strsep(&tmp, ":%,");
 	parse_ip(ptr, &mydata->ip);

Modified: trunk/ipset/ipset_ipportiphash.c
===================================================================
--- trunk/ipset/ipset_ipportiphash.c	2008-10-21 12:09:05 UTC (rev 7569)
+++ trunk/ipset/ipset_ipportiphash.c	2008-10-21 22:04:47 UTC (rev 7570)
@@ -198,10 +198,9 @@
 
 	DP("ipportiphash: %p %p", optarg, data);
 
-	if ((ptr = strchr(tmp, ':')) || (ptr = strchr(tmp, '%')))
-		fprintf(stderr, "Warning: please replace old separator character '%s.1' with ','.\n"
-			        "Next release won't support it.\n",
-		        ptr);
+	if (((ptr = strchr(tmp, ':')) || (ptr = strchr(tmp, '%'))) && ++warn_once == 1)
+		fprintf(stderr, "Warning: please use ',' separator token between ip,port,ip.\n"
+			        "Next release won't support old separator tokens.\n");
 
 	ptr = strsep(&tmp, ":%,");
 	parse_ip(ptr, &mydata->ip);

Modified: trunk/ipset/ipset_ipportnethash.c
===================================================================
--- trunk/ipset/ipset_ipportnethash.c	2008-10-21 12:09:05 UTC (rev 7569)
+++ trunk/ipset/ipset_ipportnethash.c	2008-10-21 22:04:47 UTC (rev 7570)
@@ -199,10 +199,9 @@
 
 	DP("ipportnethash: %p %p", optarg, data);
 
-	if ((ptr = strchr(tmp, ':')) || (ptr = strchr(tmp, '%')))
-		fprintf(stderr, "Warning: please replace old separator character '%s.1' with ','.\n"
-			        "Next release won't support it.\n",
-		        ptr);
+	if (((ptr = strchr(tmp, ':')) || (ptr = strchr(tmp, '%'))) && ++warn_once == 1)
+		fprintf(stderr, "Warning: please use ',' separator token between ip,port,net.\n"
+			        "Next release won't support old separator tokens.\n");
 
 	ptr = strsep(&tmp, ":%,");
 	parse_ip(ptr, &mydata->ip);

Modified: trunk/ipset/ipset_iptree.c
===================================================================
--- trunk/ipset/ipset_iptree.c	2008-10-21 12:09:05 UTC (rev 7569)
+++ trunk/ipset/ipset_iptree.c	2008-10-21 22:04:47 UTC (rev 7570)
@@ -83,10 +83,9 @@
 
 	DP("iptree: %p %p", optarg, data);
 
-	if ((ptr = strchr(tmp, ':')) || (ptr = strchr(tmp, '%')))
-		fprintf(stderr, "Warning: please replace old separator character '%s.1' with ','.\n"
-			        "Next release won't support it.\n",
-		        ptr);
+	if (((ptr = strchr(tmp, ':')) || (ptr = strchr(tmp, '%'))) && ++warn_once == 1)
+		fprintf(stderr, "Warning: please use ',' separator token between ip,timeout.\n"
+			        "Next release won't support old separator tokens.\n");
 
 	ptr = strsep(&tmp, ":%,");
 	parse_ip(ptr, &mydata->ip);

Modified: trunk/ipset/ipset_iptreemap.c
===================================================================
--- trunk/ipset/ipset_iptreemap.c	2008-10-21 12:09:05 UTC (rev 7569)
+++ trunk/ipset/ipset_iptreemap.c	2008-10-21 22:04:47 UTC (rev 7570)
@@ -76,10 +76,9 @@
 		parse_ipandmask(tmp, &mydata->ip, &mask);
 		mydata->end = mydata->ip | ~mask;
 	} else {
-		if ((ptr = strchr(tmp, ':')) != NULL)
-			fprintf(stderr, "Warning: please replace old separator character '%s.1' with ','.\n"
-			        "Next release won't support it.\n",
-			        ptr);
+		if ((ptr = strchr(tmp, ':')) != NULL && ++warn_once == 1)
+			fprintf(stderr, "Warning: please use '-' separator token between IP range.\n"
+			        "Next release won't support old separator token.\n");
 		ptr = strsep(&tmp, "-:");
 		parse_ip(ptr, &mydata->ip);
 

Modified: trunk/ipset/ipset_macipmap.c
===================================================================
--- trunk/ipset/ipset_macipmap.c	2008-10-21 12:09:05 UTC (rev 7569)
+++ trunk/ipset/ipset_macipmap.c	2008-10-21 22:04:47 UTC (rev 7570)
@@ -183,13 +183,15 @@
 	char *ptr, *tmp = saved;
 
 	DP("macipmap: %p %p", optarg, data);
-	
-	if ((ptr = strchr(tmp, ':')) || (ptr = strchr(tmp, '%')))
-		fprintf(stderr, "Warning: please replace old separator character '%s.1' with ','.\n"
-			        "Next release won't support it.\n",
-		        ptr);
 
-	ptr = strsep(&tmp, ":%,");
+	ptr = strsep(&tmp, ",");
+	if (!tmp) {
+		tmp = saved;
+		ptr = strsep(&tmp, ":%");	
+		if (tmp && ++warn_once == 1)
+			fprintf(stderr, "Warning: please use ',' separator token between ip,mac.\n"
+				        "Next release won't support old separator tokens.\n");
+	}
 	parse_ip(ptr, &mydata->ip);
 
 	if (tmp)
@@ -250,7 +252,7 @@
 	while (addr <= mysetdata->last_ip) {
 		if (test_bit(IPSET_MACIP_ISSET,
 			     (void *)&table[addr - mysetdata->first_ip].flags)) {
-			printf("%s:", ip_tostring(addr, options));
+			printf("%s,", ip_tostring(addr, options));
 			print_mac(table[addr - mysetdata->first_ip].
 				  ethernet);
 			printf("\n");




More information about the netfilter-cvslog mailing list