diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2013-10-09 09:33:44 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2013-10-09 09:33:44 +0000 |
commit | 09031ac62e58cfacdc7e5781a0626dcd9a0b906e (patch) | |
tree | fe67c1e7504b1c96c7a57cfc91278d421b2f83ef /sys/netinet/in.c | |
parent | be759b8c35882bf5d34e4710d483a191c245250b (diff) |
Introduce in_ifdetach() a function to remove all the IPv4 addresses
of an interface, named after its IPv6 equivalent.
Make use of it instead of removing addresses by hand when detaching
or destroying an interface. As a bonus, multicast records linked
to the just divorced^Wdetached interface are no longer leaked.
No objection from the gang, ok mikeb@
Diffstat (limited to 'sys/netinet/in.c')
-rw-r--r-- | sys/netinet/in.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/sys/netinet/in.c b/sys/netinet/in.c index b5723f8f5c1..386ea9732be 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in.c,v 1.85 2013/09/26 08:53:17 mpi Exp $ */ +/* $OpenBSD: in.c,v 1.86 2013/10/09 09:33:43 mpi Exp $ */ /* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */ /* @@ -1017,3 +1017,16 @@ in_delmulti(struct in_multi *inm) } #endif + +void +in_ifdetach(struct ifnet *ifp) +{ + struct ifaddr *ifa, *next; + + /* nuke any of IPv4 addresses we have */ + TAILQ_FOREACH_SAFE(ifa, &ifp->if_addrlist, ifa_list, next) { + if (ifa->ifa_addr->sa_family != AF_INET) + continue; + in_purgeaddr(ifa); + } +} |