diff options
-rw-r--r-- | sys/net/if.c | 7 | ||||
-rw-r--r-- | sys/net/if.h | 3 | ||||
-rw-r--r-- | sys/netinet/in.c | 7 |
3 files changed, 14 insertions, 3 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 66fd2ed60ae..680be3afd9b 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.51 2002/03/14 01:27:09 millert Exp $ */ +/* $OpenBSD: if.c,v 1.52 2002/04/24 00:51:51 dhartmei Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -259,6 +259,10 @@ if_attach(ifp) if (if_index == 0) TAILQ_INIT(&ifnet); TAILQ_INIT(&ifp->if_addrlist); + ifp->if_addrhooks = malloc(sizeof(*ifp->if_addrhooks), M_TEMP, M_NOWAIT); + if (ifp->if_addrhooks == NULL) + panic("if_attach: malloc"); + TAILQ_INIT(ifp->if_addrhooks); TAILQ_INSERT_TAIL(&ifnet, ifp, if_list); if_attachsetup(ifp); } @@ -393,6 +397,7 @@ if_detach(ifp) #endif free(ifa, M_IFADDR); } + free(ifp->if_addrhooks, M_TEMP); splx(s); } diff --git a/sys/net/if.h b/sys/net/if.h index 93bfabff279..55155fc9809 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if.h,v 1.34 2002/03/15 01:20:04 millert Exp $ */ +/* $OpenBSD: if.h,v 1.35 2002/04/24 00:51:51 dhartmei Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -148,6 +148,7 @@ struct ifnet { /* and the entries */ void *if_softc; /* lower-level data for this if */ TAILQ_ENTRY(ifnet) if_list; /* all struct ifnets are chained */ TAILQ_HEAD(, ifaddr) if_addrlist; /* linked list of addresses per if */ + struct hook_desc_head *if_addrhooks; /* address change callbacks */ char if_xname[IFNAMSIZ]; /* external name (name + unit) */ int if_pcount; /* number of promiscuous listeners */ caddr_t if_bpf; /* packet filter structure */ diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 54f07f5b797..8db742a7056 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in.c,v 1.25 2002/04/01 02:44:08 itojun Exp $ */ +/* $OpenBSD: in.c,v 1.26 2002/04/24 00:51:51 dhartmei Exp $ */ /* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */ /* @@ -367,6 +367,8 @@ in_control(so, cmd, data, ifp) case SIOCSIFADDR: error = in_ifinit(ifp, ia, satosin(&ifr->ifr_addr), 1); + if (!error) + dohooks(ifp->if_addrhooks); return error; case SIOCSIFNETMASK: @@ -405,6 +407,8 @@ in_control(so, cmd, data, ifp) if ((ifp->if_flags & IFF_BROADCAST) && (ifra->ifra_broadaddr.sin_family == AF_INET)) ia->ia_broadaddr = ifra->ifra_broadaddr; + if (!error) + dohooks(ifp->if_addrhooks); return (error); case SIOCDIFADDR: @@ -412,6 +416,7 @@ in_control(so, cmd, data, ifp) TAILQ_REMOVE(&ifp->if_addrlist, (struct ifaddr *)ia, ifa_list); TAILQ_REMOVE(&in_ifaddr, ia, ia_list); IFAFREE((&ia->ia_ifa)); + dohooks(ifp->if_addrhooks); break; #ifdef MROUTING |