diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2010-01-13 02:13:13 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2010-01-13 02:13:13 +0000 |
commit | dc2b77c5c209a007b4fbb3168795820a9b050aec (patch) | |
tree | 4f7fae1065dadd3c92ed1c4cbc84f912753db8d9 /sys/net | |
parent | 1f237c71d551d40b259d29c58f0b1cbff338af57 (diff) |
instead of fiddling with the per-interface address lists directly in
many places create a proper API (ifa_add / ifa_del) and use it.
ok theo ryan dlg
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if.c | 26 | ||||
-rw-r--r-- | sys/net/if.h | 4 |
2 files changed, 24 insertions, 6 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index af12ed94496..b06a360ea8b 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.204 2010/01/12 04:05:47 deraadt Exp $ */ +/* $OpenBSD: if.c,v 1.205 2010/01/13 02:13:12 henning Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -319,7 +319,6 @@ if_alloc_sadl(struct ifnet *ifp) ifnet_addrs[ifp->if_index] = ifa; ifa->ifa_ifp = ifp; ifa->ifa_rtrequest = link_rtrequest; - TAILQ_INSERT_HEAD(&ifp->if_addrlist, ifa, ifa_list); ifa->ifa_addr = (struct sockaddr *)sdl; ifp->if_sadl = sdl; sdl = (struct sockaddr_dl *)(socksize + (caddr_t)sdl); @@ -327,6 +326,7 @@ if_alloc_sadl(struct ifnet *ifp) sdl->sdl_len = masklen; while (namelen != 0) sdl->sdl_data[--namelen] = 0xff; + ifa_add(ifp, ifa); } /* @@ -347,7 +347,7 @@ if_free_sadl(struct ifnet *ifp) s = splnet(); rtinit(ifa, RTM_DELETE, 0); #if 0 - TAILQ_REMOVE(&ifp->if_addrlist, ifa, ifa_list); + ifa_del(ifp, ifa); ifnet_addrs[ifp->if_index] = NULL; #endif ifp->if_sadl = NULL; @@ -592,7 +592,7 @@ do { \ * Deallocate private resources. */ while ((ifa = TAILQ_FIRST(&ifp->if_addrlist)) != NULL) { - TAILQ_REMOVE(&ifp->if_addrlist, ifa, ifa_list); + ifa_del(ifp, ifa); #ifdef INET if (ifa->ifa_addr->sa_family == AF_INET) TAILQ_REMOVE(&in_ifaddr, (struct in_ifaddr *)ifa, @@ -1474,7 +1474,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) TAILQ_REMOVE(&in_ifaddr, (struct in_ifaddr *)ifa, ia_list); - TAILQ_REMOVE(&ifp->if_addrlist, ifa, ifa_list); + ifa_del(ifp, ifa); ifa->ifa_ifp = NULL; IFAFREE(ifa); } @@ -2148,3 +2148,19 @@ sysctl_ifq(int *name, u_int namelen, void *oldp, size_t *oldlenp, } /* NOTREACHED */ } + +void +ifa_add(struct ifnet *ifp, struct ifaddr *ifa) +{ + if (ifa->ifa_addr->sa_family == AF_LINK) + TAILQ_INSERT_HEAD(&ifp->if_addrlist, ifa, ifa_list); + else + TAILQ_INSERT_TAIL(&ifp->if_addrlist, ifa, ifa_list); +} + +void +ifa_del(struct ifnet *ifp, struct ifaddr *ifa) +{ + TAILQ_REMOVE(&ifp->if_addrlist, ifa, ifa_list); +} + diff --git a/sys/net/if.h b/sys/net/if.h index 73c4fdf46c0..9b4fa10d4ed 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if.h,v 1.111 2010/01/12 00:39:18 deraadt Exp $ */ +/* $OpenBSD: if.h,v 1.112 2010/01/13 02:13:12 henning Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -826,5 +826,7 @@ void loopattach(int); int looutput(struct ifnet *, struct mbuf *, struct sockaddr *, struct rtentry *); void lortrequest(int, struct rtentry *, struct rt_addrinfo *); +void ifa_add(struct ifnet *, struct ifaddr *); +void ifa_del(struct ifnet *, struct ifaddr *); #endif /* _KERNEL */ #endif /* _NET_IF_H_ */ |