netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bonding: enhance the IP address check of arp_ip_target
@ 2006-07-12  4:25 Tetsuo Takata
  2006-07-12  4:53 ` Stephen Hemminger
  0 siblings, 1 reply; 4+ messages in thread
From: Tetsuo Takata @ 2006-07-12  4:25 UTC (permalink / raw)
  To: bonding-devel; +Cc: netdev, takatatt

Hi,


I found this in drivers/net/bonding/bond_main.c.
> /* not complete check, but should be good enough to
>     catch mistakes */

I made a patch which I believe is little bit better than this,
I hope...


best regards,

---
Signed-off-by: Tetsuo Takata <takatatt@intellilink.co.jp>

--- linux-2.6.17.3/drivers/net/bonding/bond_main.c	2006-07-01 02:37:38.000000000 +0900
+++ linux-2.6.17.3-bonding-ipcheck/drivers/net/bonding/bond_main.c	2006-07-12 09:51:12.000000000 +0900
@@ -4455,7 +4455,113 @@ static int bond_check_params(struct bond
 	     arp_ip_count++) {
 		/* not complete check, but should be good enough to
 		   catch mistakes */
-		if (!isdigit(arp_ip_target[arp_ip_count][0])) {
+		int i, notip = 0;
+		char *cp;
+
+		cp = arp_ip_target[arp_ip_count];
+
+		/* notip's number is the error code for debug purpose */
+		do {
+			if (cp == NULL) {
+				notip = 1;
+				break;
+			}
+
+			/* check digit */
+			for (i = 0; isdigit(*cp); i++) {
+				if ((i < 0) || (i >= 3)) {
+					notip = 2;
+					break;
+				}
+				cp++;
+			}
+			if (notip)
+				break;
+
+			if (i == 0) {
+				notip = 3;
+				break;
+			}
+
+			/* check delimiter */
+			if (*cp != '.') {
+				notip = 4;
+				break;
+			}
+			cp++;
+
+			/* check digit */
+			for (i = 0; isdigit(*cp); i++) {
+				if ((i < 0) || (i >= 3)) {
+					notip = 5;
+					break;
+				}
+				cp++;
+			}
+			if (notip)
+				break;
+
+			if (i == 0) {
+				notip = 6;
+				break;
+			}
+
+			/* check delimiter */
+			if (*cp != '.') {
+				notip = 7;
+				break;
+			}
+			cp++;
+
+			/* check digit */
+			for (i = 0; isdigit(*cp); i++) {
+				if ((i < 0) || (i >= 3)) {
+					notip = 8;
+					break;
+				}
+				cp++;
+			}
+			if (notip)
+				break;
+
+			if (i == 0) {
+				notip = 9;
+				break;
+			}
+
+			/* check delimiter */
+			if (*cp != '.') {
+				notip = 10;
+				break;
+			}
+			cp++;
+
+			/* check digit */
+			for (i = 0; isdigit(*cp); i++) {
+				if ((i < 0) || (i >= 3)) {
+					notip = 11;
+					break;
+				}
+				cp++;
+			}
+			if (notip)
+				break;
+
+			if (i == 0) {
+				notip = 12;
+				break;
+			}
+
+
+			/* check EOS */
+			if (*cp != '\0') {
+				notip = 13;
+				break;
+			}
+
+		} while(0);
+
+		if (notip) {
 			printk(KERN_WARNING DRV_NAME
 			       ": Warning: bad arp_ip_target module parameter "
 			       "(%s), ARP monitoring will not be performed\n",


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-07-12  9:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-12  4:25 [PATCH] bonding: enhance the IP address check of arp_ip_target Tetsuo Takata
2006-07-12  4:53 ` Stephen Hemminger
2006-07-12  5:19   ` Herbert Xu
2006-07-12  9:30     ` Tetsuo Takata

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).