tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: struct sockaddr_storage issues



>> That last is almost certainly spurious.  Your address family is
>> probably AF_INET; at least on my systems, sizeof(struct sockaddr)
>> equals sizeof(struct sockaddr_in).  You really should be using the
>> correct size for the address family you're using.
> Perhaps read connect(2) impl in kernel, and it might check that the
> length arg is sizeof(struct sockaddr_in) after getting the AF and
> error out if not.  That could be all there is to it.

I had a look at 9.2's source, but it's different enough from what I'm
familiar with that it would take study to understand, and I don't have
the spare time right now.  But, in 5.2, tcp_usrreq's IPv4 PRU_CONNECT
code calls in_pcbconnect, which begins with

        if (inp->inp_af != AF_INET)
                return (EINVAL);

        if (nam->m_len != sizeof (*sin))
                return (EINVAL);
        if (sin->sin_family != AF_INET)
                return (EAFNOSUPPORT);

the middle test of which looks like the probable basis for the
failure-to-connect in question.

The original post does not specify what NetBSD version is at issue, but
I suspect the test in question is the above or something analogous.

/~\ The ASCII				  Mouse
\ / Ribbon Campaign
 X  Against HTML		mouse%rodents-montreal.org@localhost
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index