RE: IPv6 - sobind fails with 49

From: Sreenivasa Honnur <shonnur_at_chelsio.com>
Date: Fri, 28 Jun 2013 04:05:13 +0000
I am writing a kernel socket program which binds to a IPv6 address, so bind always fails with 49. Below is the code snippet I am using, is something wrong here?



roundhay# uname -a

FreeBSD roundhay 9.1-RELEASE FreeBSD 9.1-RELEASE #2: Mon Apr  8 16:15:06 IST 2013     root_at_roundhay:/usr/obj/home/freebsd.org/sys/TOED<mailto:root_at_roundhay:/usr/obj/home/freebsd.org/sys/TOED>  amd64



Ifconfig/ping6 output:

======================

cxgbe1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500

        options=6c07bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_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

        inet6 fe80::1%cxgbe1 prefixlen 64 scopeid 0xd

        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

        media: Ethernet 10Gbase-SR <full-duplex>

        status: active

roundhay# ping6 2010::101

PING6(56=40+8+8 bytes) 2010::102 --> 2010::101

16 bytes from 2010::101, icmp_seq=0 hlim=64 time=0.915 ms

16 bytes from 2010::101, icmp_seq=1 hlim=64 time=0.168 ms

^C

--- 2010::101 ping6 statistics ---

2 packets transmitted, 2 packets received, 0.0% packet loss

round-trip min/avg/max/std-dev = 0.168/0.541/0.915/0.374 ms





Code:

            struct sockaddr_in6 saddr6;

            rv = socreate(AF_INET6, &sock, SOCK_STREAM, IPPROTO_TCP,

                                td->td_ucred, td);



                if (rv != 0) {

                        printf("sock create ipv6 %s failed %d.\n",

                                        tbuf, rv);

                        return NULL;

                }



                saddr6.sin6_family = AF_INET6;

                rv = inet_pton(AF_INET6, "2010::102", &saddr6.sin6_addr); ==> returns 1, which indicates it's a valid IPV6 address

                printf("inet_pton retunred:%d\n", rv);



                saddr6.sin6_port = htons(3260);

                saddr6.sin6_len = sizeof(saddr6);



                rv = sobind(sock, (struct sockaddr *)&saddr6, td); ==> fails with return value of 49
Received on Fri Jun 28 2013 - 02:05:15 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:39 UTC