On Wed, May 25, 2011 at 02:31:05PM +0200, Jan Engelhardt wrote: > On Wednesday 2011-05-25 14:16, Lutz Jaenicke wrote: > > >getaddrinfo() will fail for numeric port numbers if neither > >the socket type (stream/datagram) nor the protocol is > >provided. > >Since matches on ports only make sense if the protocol is known > >we "just" have to derive the protocol number from the information > >already collected. > > Not quite; ports are also possible with -m ipvs and -m conntrack, which > do not require -p tcp/udp. > > > If someone speicifies a numeric port to getaddrinfo, I just want the > thing encoded in struct sockaddr_XX.sXX_port - it does not need to know > the particular L4 proto, or the service's text-based name to do that - > which is most likely why glibc allows it. Manual pages may not be the ultimate reference about the reasoning on why something is implemented which way. Nevertheless let's see: Given node and service, which identify an Internet host and a service, getaddrinfo() returns one or more addrinfo structures, each of which contains an Internet address that can be specified in a call to bind(2) or connect(2). Taking this information "as is" actually means that using getaddrinfo() the way it is done is at least stretching the functionality... As I wrote in my introduction for the patch (which has not yet made it to the mailing list), other C libraries behave like uClibc: * http://gitorious.org/0xdroid/bionic/blobs/9ab75d4cc803e91b7f1b656ffbe2ad32c52a86f9/libc/netbsd/net/getaddrinfo.c -> look for "ANDROID-SPECIFIC CHANGE TO MATCH GLIBC" :-) * http://www.freebsd.org/cgi/query-pr.cgi?pr=51827 * Especially I like http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/lib/libc/net/getaddrinfo.c?rev=1.72;content-type=text%2Fplain which in the text says /* * check for special cases. (1) numeric servname is disallowed if * socktype/protocol are left unspecified. (2) servname is disallowed * for raw and other inet{,6} sockets. */ (and I took this as a reference until now) but later in get_portmatch(): case SOCK_DGRAM: case SOCK_STREAM: case ANY: allownumeric = 1; > I would like to have an opinion on that from µclibc preferably.. Seems uClibc is outdated wrt adjusting the behavior with other C libraries... Best regards, Lutz -- Dr.-Ing. Lutz Jänicke CTO Innominate Security Technologies AG /protecting industrial networks/ tel: +49.30.921028-200 fax: +49.30.921028-020 Rudower Chaussee 13 D-12489 Berlin, Germany www.innominate.com Register Court: AG Charlottenburg, HR B 81603 Management Board: Dirk Seewald Chairman of the Supervisory Board: Volker Bibelhausen -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html