Subject: Re: fix for if_detach()
To: Jason Thorpe <thorpej@wasabisystems.com>
From: Matthias Drochner <M.Drochner@fz-juelich.de>
List: tech-net
Date: 11/10/2003 17:26:24
This is a multipart MIME message.
--==_Exmh_25854662430330
Content-Type: text/plain; charset=us-ascii
thorpej@wasabisystems.com said:
> There are many Ethernet devices out there that support multiple MAC
> addresses.
Yep, I thought of ATM...
> I would prefer we not add any more assumptions
> about "one AF_LINK address" into the code
No problem - new patch appended.
> I'm not sure how many might exist right now
At a first glance, it is at least in if_{attach,free}_sadl, generally
everywhere if_sadl is referenced, and there are some places in the
routing code which assume that the physical address to announce is the
first one in if_addrlist. To change these is a lot of work already...
Maybe creating a pseudo-interface for each link addr is easier.
best regards
Matthias
--==_Exmh_25854662430330
Content-Type: text/plain ; name="ifdet.txt"; charset=us-ascii
Content-Description: ifdet.txt
Content-Disposition: attachment; filename="ifdet.txt"
Index: net/if.c
===================================================================
RCS file: /cvsroot/src/sys/net/if.c,v
retrieving revision 1.132
diff -u -p -r1.132 if.c
--- net/if.c 13 Oct 2003 08:02:56 -0000 1.132
+++ net/if.c 10 Nov 2003 16:02:59 -0000
@@ -543,7 +543,7 @@ if_detach(ifp)
struct ifnet *ifp;
{
struct socket so;
- struct ifaddr *ifa, *next;
+ struct ifaddr *ifa, **ifap;
#ifdef IFAREF_DEBUG
struct ifaddr *last_ifa = NULL;
#endif
@@ -580,8 +580,8 @@ if_detach(ifp)
* Rip all the addresses off the interface. This should make
* all of the routes go away.
*/
- for (ifa = TAILQ_FIRST(&ifp->if_addrlist); ifa; ifa = next) {
- next = TAILQ_NEXT(ifa, ifa_list);
+ ifap = &TAILQ_FIRST(&ifp->if_addrlist); /* XXX abstraction violation */
+ while ((ifa = *ifap)) {
family = ifa->ifa_addr->sa_family;
#ifdef IFAREF_DEBUG
printf("if_detach: ifaddr %p, family %d, refcnt %d\n",
@@ -590,8 +590,10 @@ if_detach(ifp)
panic("if_detach: loop detected");
last_ifa = ifa;
#endif
- if (family == AF_LINK)
+ if (family == AF_LINK) {
+ ifap = &TAILQ_NEXT(ifa, ifa_list);
continue;
+ }
dp = pffinddomain(family);
#ifdef DIAGNOSTIC
if (dp == NULL)
@@ -616,6 +618,7 @@ if_detach(ifp)
*/
printf("if_detach: WARNING: AF %d not purged\n",
family);
+ TAILQ_REMOVE(&ifp->if_addrlist, ifa, ifa_list);
}
}
--==_Exmh_25854662430330--