Yeah, I've been looking at the kernel source, and I'm trying to figure
out how on earth getpeername can return 0 for the len.  I copied this out
of net/socket.c.  Shouldn't len=*usockaddr_len; be in there somewhere?
Or, how does Linux manage to work at all...

asmlinkage int sys_getpeername(int fd, struct sockaddr *usockaddr, int *usockaddr_len)
{
        struct socket *sock;
        char address[MAX_SOCK_ADDR];
        int len, err;

        lock_kernel();
        if ((sock = sockfd_lookup(fd, &err))!=NULL)
        {
                err = sock->ops->getname(sock, (struct sockaddr *)address, &len, 1);
                if (!err)
                        err=move_addr_to_user(address,len, usockaddr, usockaddr_len);
                sockfd_put(sock);
        }
        unlock_kernel();
        return err;
}


Tomi Manninen OH2BNS wrote:
> 
> On Mon, 6 Sep 1999, Jan Wasserbauer wrote:
> 
> > Hi everyone on the list ..
> >
> > Part of checklogin() function:
> > ...
> >   tv.tv_sec = 0;
> >   tv.tv_usec = 0;
> >
> >   if (select (maxsock + 1, &rfds, NULL, NULL, &tv) <= 0)
> >     return;
> >
> >   for (i = 0; i < listen_sock_num; i++)
> >   {
> >       if (!FD_ISSET (listen_sock[i], &rfds))
> >              continue;
> >
> >       addrlen = sizeof (struct full_sockaddr_ax25);
> >       ret = accept (listen_sock[i], (struct sockaddr *) &newconn, &addrlen);
> > ...
> >
> > This does work OK with any kernel below 2.2.12.
> >
> > With 2.2.12 accept() does not correctly fill sockaddr struct
> > when tv.tv_sec=tv.tv_usec=0 (some binary mess instead of callsigns)
> > It works when tv is nonzero.
> >
> > Reffering to select() man page tv=0 should cause select
> > to check descriptors and exit immediately (and not just
> > break accept() :) )
> > To me it seems like kernel bug ..
> 
> This sounds very similar to the problem _some_ people have had with
> LinuxNode on 2.2.x kernels. The most visible symptom of the bug is that an
> incoming AX.25 connection to the node fails immediately and a message
> about unsupported address family is logged in the syslogs.
> 
> Also seems that in these cases ax25d logs the connection as coming from
> port (null).
> 
> At least in node the problem seems to be that a
> getpeername(s, &addr, &len) system call returns with len==0 and bogus data
> in the addr struct. The ax25d problem could be similarly failing
> getsockname() but I haven't been able to verify that (see below).
> 
> It's noteworthy that this has happened to different people with different
> 2.2.x kernels, with different ax25d and node versions, different
> distributions with different libc... For one guy this all suddenly went
> away as he upgraded to RH6 but I've had reports on that platform too...
> 
> It's also noteworthy that I haven't been able to duplicate this error EVER
> on ANY kernel version, including 2.2.12. This makes debugging very
> difficult... :(
> 
> > My system - Slackware 4.0 (gcc2.7.2.3, libc5.4.46)
> >
> > If this is known bug I hope this at least saves some time
> > to people wondering why their software doesn't work with 2.2.12.
> 
> --
> --- Tomi Manninen / [EMAIL PROTECTED] / OH2BNS @ OH2RBI.FIN.EU ---

-- 
http://junglevision.com

Reply via email to