Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Feb 1999 02:02:48 -0500 (EST)
From:      Bill Paul <wpaul@skynet.ctr.columbia.edu>
To:        wollman@khavrinen.lcs.mit.edu (Garrett Wollman)
Cc:        current@FreeBSD.ORG
Subject:   Re: SIOCADDMULTI doesn't work, proposed fix
Message-ID:  <199902010702.CAA02576@skynet.ctr.columbia.edu>
In-Reply-To: <199902010458.XAA14745@khavrinen.lcs.mit.edu> from "Garrett Wollman" at Jan 31, 99 11:58:31 pm

next in thread | previous in thread | raw e-mail | index | archive | help
Of all the gin joints in all the towns in all the world, Garrett Wollman 
had to walk into mine and say:

> <<On Sun, 31 Jan 1999 17:55:22 -0500 (EST), Bill Paul <wpaul@skynet.ctr.columbia.edu> said:
> 
> > a struct sockaddr_dl will be used. However, the user is supposed to
> > pass the address using a struct ifreq, and struct ifreq uses struct
> > sockaddr, not struct sockaddr_dl.
> 
> This is called ``poor man's inheritance''.
> 
> I believe it is an error for any code to use AF_UNSPEC for any purpose
> other than masks (where it makes sense since the address family is
> normally not included in the mask).  A `sockaddr_dl', while by default
> longer than a `sockaddr', in this case will fit withing the structure
> allotted.
> 
> In the future, I fully expect that `sockaddr' will be of maximal
> length (we need this for IPv6).

There's still one small problem: the code as it stands now can return
success and still not update the multicast filter. If you pass a structure
with AF_LINK as the family but with the length set to 0, if_addmulti()
falsely detects that the entry already matches an existing one and
returns success (it the equal() macro equates to a bcmp(), which tries
to compare 0 bytes worth of data and returns success). In my opinion,
this is a bug: either the equal() macro should return false, or the
zero length field should be detected by a sanity check and the function
should return EINVAL.
 
> > The patches included with this post change /sys/net/if.c and
> > /sys/net/if_ethersubr.c so that adding a mutlicast address with 
> > SIOCADDMULTI using a struct sockaddr and AF_UNSPEC works again. I would 
> > like Those Who Know More Than I (tm) to review these changes and offer 
> > criticisms and comments.
> 
> There are two things which should be done here.
> 
> First, the kernel AppleTalk code should be fixed to join the necessary
> multicast groups when an interface is first configured for AppleTalk.
> (By preference the AARP implementation should be entirely in the
> kernel as well, but that's more of a challenge.)  Second, the generic
> ether_resolvemulti function should be enhanced to know about AppleTalk
> multicast addresses.

The Columbia Appletalk code is not the same as netatalk: it's implemented
entirely in user space and uses BPF as well as manually joining multicast
groups. The existing Columbia Appletalk port, which works on 2.2.x, uses
SIOCADDMULTI with a family of AF_UNSPEC. I rifled through a bunch of
man pages in 3.0-RELEASE trying to find the Right Way To Do This (tm)
but came up empty. If the right way to do this is to cast the struct 
sockaddr to a struct sockaddr_dl and use AF_LINK, then this should be
documented somewhere. (If it is documented and I missed it, feel free
to slap me around and point me in the right direction.)

-Bill

-- 
=============================================================================
-Bill Paul            (212) 854-6020 | System Manager, Master of Unix-Fu
Work:         wpaul@ctr.columbia.edu | Center for Telecommunications Research
Home:  wpaul@skynet.ctr.columbia.edu | Columbia University, New York City
=============================================================================
 "It is not I who am crazy; it is I who am mad!" - Ren Hoek, "Space Madness"
=============================================================================

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199902010702.CAA02576>