From owner-freebsd-hackers@FreeBSD.ORG Thu Apr 18 11:37:30 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id BC7D59B7 for ; Thu, 18 Apr 2013 11:37:30 +0000 (UTC) (envelope-from shonnur@chelsio.com) Received: from stargate.chelsio.com (stargate.chelsio.com [67.207.112.58]) by mx1.freebsd.org (Postfix) with ESMTP id A295D3E7 for ; Thu, 18 Apr 2013 11:37:30 +0000 (UTC) Received: from maui.asicdesigners.com (maui.asicdesigners.com [10.192.180.15]) by stargate.chelsio.com (8.13.1/8.13.1) with SMTP id r3IBbUAA026060 for ; Thu, 18 Apr 2013 04:37:30 -0700 Received: from corona.asicdesigners.com ([10.192.160.6]) by maui.asicdesigners.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 18 Apr 2013 04:37:29 -0700 Received: from NICE.asicdesigners.com (10.192.160.7) by corona.asicdesigners.com (10.192.160.6) with Microsoft SMTP Server (TLS) id 8.3.83.0; Thu, 18 Apr 2013 04:37:29 -0700 Received: from NICE.asicdesigners.com ([fe80::51b2:ba95:9d72:babc]) by nice.asicdesigners.com ([fe80::51b2:ba95:9d72:babc%15]) with mapi id 14.02.0247.003; Thu, 18 Apr 2013 04:37:29 -0700 From: Sreenivasa Honnur To: "freebsd-hackers@freebsd.org" Subject: PV6 bind fails with 49 (#define EADDRNOTAVAIL 49 /* Can't assign requested address */) Thread-Topic: PV6 bind fails with 49 (#define EADDRNOTAVAIL 49 /* Can't assign requested address */) Thread-Index: Ac48KRnQ60GQkgjzQL+SWp8/cIeQxg== Date: Thu, 18 Apr 2013 11:37:28 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.193.190.128] MIME-Version: 1.0 X-OriginalArrivalTime: 18 Apr 2013 11:37:29.0889 (UTC) FILETIME=[1BD98910:01CE3C29] X-Mailman-Approved-At: Thu, 18 Apr 2013 11:56:34 +0000 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.14 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Apr 2013 11:37:30 -0000 I have a ipv6 interface(ping6 to a remove ipv6 works) when I try to bind to= this address through a socket program "sobind" fails with "49" as return v= alue. If I give "saddr6.sin6_addr =3D in6addr_any;" sobind works. Any idea what could be going wrong here? roundhay# ifconfig cxgbe1 cxgbe1: flags=3D8843 metric 0 mtu 1= 500 options=3D6c07bb ether 00:07:43:11:89:88 inet6 2010::102 prefixlen 64 inet6 fe80::207:43ff:fe11:8988%cxgbe1 prefixlen 64 scopeid 0xd nd6 options=3D21 media: Ethernet 10Gbase-SR status: active roundhay# ping6 2010::101 PING6(56=3D40+8+8 bytes) 2010::102 --> 2010::101 16 bytes from 2010::101, icmp_seq=3D0 hlim=3D64 time=3D0.950 ms 16 bytes from 2010::101, icmp_seq=3D1 hlim=3D64 time=3D0.158 ms ^C --- 2010::101 ping6 statistics --- 2 packets transmitted, 2 packets received, 0.0% packet loss round-trip min/avg/max/std-dev =3D 0.158/0.554/0.950/0.396 ms Code: =3D=3D=3D=3D=3D { rv =3D socreate(AF_INET6, &sock, SOCK_STREAM, IPPROTO_TCP, td->td_ucred, td); if (rv !=3D 0) { os_log_error("sock create ipv6 %s failed %d.\n", tbuf, rv); return NULL; } family =3D saddr6.sin6_family =3D AF_INET6; inet_pton(AF_INET6, "2010::102", &saddr6.sin6_addr); saddr6.sin6_port =3D htons(ep->port); saddr6.sin6_len =3D sizeof(struct sockaddr_in6); rv =3D sobind(sock, (struct sockaddr *)&saddr6, td); } Here is the code snippet from where EADDRNOTAVAIL is returned. File : netinet6/in6_pcb.c in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam, struct ucred *cred) { ........ ........ } else if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { struct ifaddr *ifa; sin6->sin6_port =3D 0; /* yech... */ if ((ifa =3D ifa_ifwithaddr((struct sockaddr *)sin6= )) =3D=3D NULL && (inp->inp_flags & INP_BINDANY) =3D=3D 0) { return (EADDRNOTAVAIL); =3D=3D> it fails he= re since ifa_ifwithaddr() returns NULL } ........ ........ } File: net/if.c struct ifaddr * ifa_ifwithaddr(struct sockaddr *addr) { return (ifa_ifwithaddr_internal(addr, 1)); } ifa_ifwithaddr_internal(struct sockaddr *addr, int getref) { ........ ........ TAILQ_FOREACH(ifp, &V_ifnet, if_link) { IF_ADDR_RLOCK(ifp); printf("ifp->xname:%s ifp->dname:%s\n",ifp->if_xname, ifp->= if_dname); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { if (ifa->ifa_addr->sa_family !=3D addr->sa_family) = =3D=3D> ifa->ifa_addr->sa_family=3D18 & addr->sa_family=3D28. Even though = the interface is in IPV6 mode its sa_family is not set properly, continue; } Ifa =3D NULL; ........ ........ }