Thread (6 messages) flat view 6 messages, 4 authors, 2008-08-23

Re: [PATCH 1/4 2.6.28] cxgb3 - manage a private ip address for iSCSI

From: Steve Wise <hidden>
Date: 2008-08-22 20:06:44
Also in: linux-scsi, lkml

Andrew Morton wrote:
On Fri, 22 Aug 2008 14:17:18 -0500
Steve Wise [off-list ref] wrote:

  
quoted
Andrew Morton wrote:
    
quoted
quoted
+	unsigned long octet;
+	const char *parse = buf;
+	char *endp;
+	int i;
+
+	for (i = 1; i <= 4; i++) {
+		octet = simple_strtoul(parse, &endp, 10);
+		if (endp == buf || octet > 255 ||
+		    (i < 4 && *endp != '.') ||
+		    (i == 4 && *endp != '\0' && *endp != '\n'))
+			return -EINVAL;
+		a = (a << 8) | octet;
+		parse = endp+1;
+	}
+	pi->iscsi_ipaddr = htonl(a);
+	return endp-buf;
+}
    
        
This appears to be taking a dotted quad ipv4 address in ascii form,
turning it into a u32 while performing checking?

Surely we have a library function somewhere in networking which does
this?  If not, I'd suggest writing one. 

  
      
try in_aton() from include/linux/inet.h.

    
yeah.  But that function is a crock.  No error checking at all!
  
Oh you want error checking?

:)

Yea if this is a user/sysadmin supplied value, then we need a rubust 
inet_aton() in the kernel to validate it...
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help