From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: Re: [Bug 42012] New: regression on 2.6.39.3 with socket/bind; still there in 3.0.4 Date: Tue, 30 Aug 2011 21:44:19 +0200 Message-ID: <1314733459.2556.10.camel@edumazet-laptop> References: <20110830084742.26c72c20@nehalam.ftrdhcpuser.net> <1314720708.2935.29.camel@edumazet-HP-Compaq-6005-Pro-SFF-PC> <20110830.140733.146208373221522199.davem@davemloft.net> <1314731803.2556.4.camel@edumazet-laptop> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: shemminger@linux-foundation.org, netdev@vger.kernel.org To: David Miller Return-path: Received: from mail-ww0-f44.google.com ([74.125.82.44]:64037 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756233Ab1H3ToX (ORCPT ); Tue, 30 Aug 2011 15:44:23 -0400 Received: by wwf5 with SMTP id 5so7198762wwf.1 for ; Tue, 30 Aug 2011 12:44:22 -0700 (PDT) In-Reply-To: <1314731803.2556.4.camel@edumazet-laptop> Sender: netdev-owner@vger.kernel.org List-ID: Le mardi 30 ao=C3=BBt 2011 =C3=A0 21:16 +0200, Eric Dumazet a =C3=A9cri= t : > Le mardi 30 ao=C3=BBt 2011 =C3=A0 14:07 -0400, David Miller a =C3=A9c= rit : > > From: Eric Dumazet > > Date: Tue, 30 Aug 2011 18:11:48 +0200 > >=20 > > > Yep, we should relax the check and accept AF_UNSPEC. > >=20 > > I guess we'll have to do this, but I just can't bring myself to acc= ept > > that we can just do zero validation of what the user is passing us, > > see an AF_UNSPEC, and say "yeah it's fine to assume there's an ipv4 > > address in there." >=20 > I couldnt accept it either ;) >=20 > By the way, if we accept it, strace() will probably still print binar= y > blob instead of the IP address (not necessarily ANY address ?) >=20 > connect ( AF_UNSPEC ) has special semantic, but AFAIK, bind (AF_UNSPE= C) > only brings some mixed results : FreeBSD was accepting it in old > versions it seems. I guess I should try current FreeBSD versions. >=20 Status on FreeBSD 8.1-RELEASE bind(AF_UNSPEC) is accepted (converted to AF_INET), only with a 0.0.0.0 address. =46ollowing code works : struct sockaddr_in addr; fd =3D socket(PF_INET, SOCK_STREAM, 0); memset(&addr, 0, sizeof(addr)) bind(fd, (struct sockaddr *)&addr, sizeof(addr)); -> 0 If tried on ipv6 sockets, it doesnt work : bind() returns -1, errno=3D4= 7 struct sockaddr_in6 addr; fd =3D socket(PF_INET6, SOCK_STREAM, 0); memset(&addr, 0, sizeof(addr)) bind(fd, (struct sockaddr *)&addr, sizeof(addr)); -> -1 errno=3D47