netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lutz Jaenicke <ljaenicke@innominate.com>
To: Jan Engelhardt <jengelh@medozas.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH] Provide family and protocol to make getaddrinfo happy
Date: Wed, 25 May 2011 15:26:29 +0200	[thread overview]
Message-ID: <20110525132629.GA17366@lutz.bln.innominate.local> (raw)
In-Reply-To: <alpine.LNX.2.01.1105251423280.22697@frira.zrqbmnf.qr>

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@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2011-05-25 13:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-25 12:16 Proposed fix for getaddrinfo() issue Lutz Jaenicke
2011-05-25 12:16 ` [PATCH] Provide family and protocol to make getaddrinfo happy Lutz Jaenicke
2011-05-25 12:31   ` Jan Engelhardt
2011-05-25 13:26     ` Lutz Jaenicke [this message]
2011-05-25 13:41       ` Jan Engelhardt
2011-05-25 14:06         ` Lutz Jaenicke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110525132629.GA17366@lutz.bln.innominate.local \
    --to=ljaenicke@innominate.com \
    --cc=jengelh@medozas.de \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).