Date: Thu, 18 Apr 2013 12:03:07 +0000 From: Sreenivasa Honnur <shonnur@chelsio.com> To: "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org> Subject: IPv6 bind fails with 49 (#define EADDRNOTAVAIL 49 /* Can't assign requested address */) Message-ID: <F2BBBB6E0068844991318A316F34795C3491A8@nice.asicdesigners.com>
next in thread | raw e-mail | index | archive | help
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<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1=
500
options=3D6c07bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VL=
AN_HWCSUM,TSO4,TSO6,LRO,VLAN_HWTSO,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
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<PERFORMNUD,AUTO_LINKLOCAL>
media: Ethernet 10Gbase-SR <full-duplex>
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); =E8 it fails here s=
ince 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) =
=E8 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; ........
........
}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?F2BBBB6E0068844991318A316F34795C3491A8>
