From owner-freebsd-current Sun Jan 31 22:56:00 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id WAA02461 for freebsd-current-outgoing; Sun, 31 Jan 1999 22:56:00 -0800 (PST) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from skynet.ctr.columbia.edu (skynet.ctr.columbia.edu [128.59.64.70]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id WAA02452 for ; Sun, 31 Jan 1999 22:55:55 -0800 (PST) (envelope-from wpaul@skynet.ctr.columbia.edu) Received: (from wpaul@localhost) by skynet.ctr.columbia.edu (8.6.12/8.6.9) id CAA02576; Mon, 1 Feb 1999 02:02:50 -0500 From: Bill Paul Message-Id: <199902010702.CAA02576@skynet.ctr.columbia.edu> Subject: Re: SIOCADDMULTI doesn't work, proposed fix To: wollman@khavrinen.lcs.mit.edu (Garrett Wollman) Date: Mon, 1 Feb 1999 02:02:48 -0500 (EST) Cc: current@FreeBSD.ORG In-Reply-To: <199902010458.XAA14745@khavrinen.lcs.mit.edu> from "Garrett Wollman" at Jan 31, 99 11:58:31 pm X-Mailer: ELM [version 2.4 PL24] Content-Type: text Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Of all the gin joints in all the towns in all the world, Garrett Wollman had to walk into mine and say: > < 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