Comments on recent patches.

Denis Vlasenko vda.linux at googlemail.com
Sat Sep 2 18:02:53 UTC 2006


On Saturday 02 September 2006 19:17, Rob Landley wrote:
> Couple of comments on 16029:
> 
> +       if (sourceaddr.sin_addr.s_addr) {
> +               if (bind(pingsock, (struct sockaddr*)&sourceaddr, 
> sizeof(sourceaddr)) == -1)
> +                       bb_error_msg_and_die("could not bind to address");
> +       }
> +
> 
> I believe you can replace most of the above with xbind() (It's a fairly recent 
> addition to libbb/xfuncs.c.)

Done.

> I thought the library already does parse_nipquad(), doesn't gethostbyaddr() 
> cover it?  Also, gethostbyname() should automatically parse ##.##.##.## 
> notation without bouncing off a DNS server, and the code already uses that.  
> (I believe it calls gethostbyaddr() internally, but I haven't looked at the 
> library implementation.)

Just looked at manpages. "May return pointers to static data". Ugly.

"POSIX 1003.1-2001 marks gethostbyaddr() and gethostbyname() obsolescent.
See getaddrinfo(3), getnameinfo(3), gai_strerror(3)." Hmm.

Looking at "man getaddrinfo", parts about AI_NUMERICHOST... maybe
we should use this one? Looks less ugly.

"The getaddrinfo(3) function is not limited to creating IPv4 socket
address structures..."

BTW, other incarnations of parse_nipquad that we already have are buggy
(will accept N>255 and/or garbage after last component).

> Going in the other direction, another repetition of "%u.%u.%u.%u" was in the 
> CIFS patch to mount I just merged.  The comment on that was it doesn't 
> support ipv6.  I really haven't looked into ipv6, other than an idle 
> curiosity about whether it's possible to merge ping and ping6.  (I honestly 
> don't know.  I live in the united states, which claimed most of the ipv4 
> addresses back when it invented the thing, and thus has yet to actually need 
> ipv6 for anything.  Thus poking at ipv6 is way down on my todo list...)

ipv6 folks should have thought how to make ip4 -> ip6 transition
seamless, but didn't.
--
vda



More information about the busybox mailing list