diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2013-06-20 09:38:25 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2013-06-20 09:38:25 +0000 |
commit | 4d94fbeacc12993e6879d0f1f124aeee3eaddb70 (patch) | |
tree | 7ca757a1bc57371d23a3e31ae538df65e1543c26 /sys | |
parent | 3d13812ef33bfbd4535cddc50d4e511bf0da2ea9 (diff) |
Allocate the various hook head descriptors as part of the ifnet
structure rather than doing various M_WAITOK allocations during
the *attach() functions, we always rely on them anyway.
ok mikeb@, uebayasi@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/pci/if_art.c | 4 | ||||
-rw-r--r-- | sys/net/bridgestp.c | 11 | ||||
-rw-r--r-- | sys/net/if.c | 23 | ||||
-rw-r--r-- | sys/net/if.h | 9 | ||||
-rw-r--r-- | sys/net/if_pfsync.c | 10 | ||||
-rw-r--r-- | sys/net/if_pppx.c | 4 | ||||
-rw-r--r-- | sys/net/if_spppsubr.c | 8 | ||||
-rw-r--r-- | sys/net/if_trunk.c | 10 | ||||
-rw-r--r-- | sys/net/if_vlan.c | 10 | ||||
-rw-r--r-- | sys/net/pf_if.c | 6 | ||||
-rw-r--r-- | sys/netinet/in.c | 8 | ||||
-rw-r--r-- | sys/netinet/ip_carp.c | 10 | ||||
-rw-r--r-- | sys/netinet6/in6.c | 8 |
13 files changed, 54 insertions, 67 deletions
diff --git a/sys/dev/pci/if_art.c b/sys/dev/pci/if_art.c index 9a50ad6e725..ef6d1825ef8 100644 --- a/sys/dev/pci/if_art.c +++ b/sys/dev/pci/if_art.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_art.c,v 1.18 2010/06/29 07:12:31 matthew Exp $ */ +/* $OpenBSD: if_art.c,v 1.19 2013/06/20 09:38:24 mpi Exp $ */ /* * Copyright (c) 2004,2005 Internet Business Solutions AG, Zurich, Switzerland @@ -174,7 +174,7 @@ art_softc_attach(struct device *parent, struct device *self, void *aux) /* Set linkstate hook to track link state changes done by sppp. */ sc->art_linkstatehook = hook_establish( - sc->art_channel->cc_ifp->if_linkstatehooks, 0, art_linkstate, sc); + &sc->art_channel->cc_ifp->if_linkstatehooks, 0, art_linkstate, sc); /* Schedule the timeout one second from now. */ timeout_add_sec(&sc->art_onesec, 1); diff --git a/sys/net/bridgestp.c b/sys/net/bridgestp.c index 5ae8ca1d635..dfd695ec494 100644 --- a/sys/net/bridgestp.c +++ b/sys/net/bridgestp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bridgestp.c,v 1.42 2012/10/05 17:17:04 camield Exp $ */ +/* $OpenBSD: bridgestp.c,v 1.43 2013/06/20 09:38:24 mpi Exp $ */ /* * Copyright (c) 2000 Jason L. Wright (jason@thought.net) @@ -2017,9 +2017,8 @@ bstp_add(struct bstp_state *bs, struct ifnet *ifp) bstp_update_roles(bs, bp); /* Register callback for physical link state changes */ - if (ifp->if_linkstatehooks != NULL) - bp->bp_lhcookie = hook_establish(ifp->if_linkstatehooks, 1, - bstp_ifstate, ifp); + bp->bp_lhcookie = hook_establish(&ifp->if_linkstatehooks, 1, + bstp_ifstate, ifp); return (bp); } @@ -2033,8 +2032,8 @@ bstp_delete(struct bstp_port *bp) if (!bp->bp_active) panic("not a bstp member"); - if (ifp != NULL && ifp->if_linkstatehooks != NULL) - hook_disestablish(ifp->if_linkstatehooks, bp->bp_lhcookie); + if (ifp != NULL) + hook_disestablish(&ifp->if_linkstatehooks, bp->bp_lhcookie); LIST_REMOVE(bp, bp_next); bp->bp_bs = NULL; diff --git a/sys/net/if.c b/sys/net/if.c index f16d797d663..81bfb32a42f 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.259 2013/06/18 22:42:56 uebayasi Exp $ */ +/* $OpenBSD: if.c,v 1.260 2013/06/20 09:38:24 mpi Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -432,17 +432,10 @@ if_attach(struct ifnet *ifp) void if_attach_common(struct ifnet *ifp) { - TAILQ_INIT(&ifp->if_addrlist); - ifp->if_addrhooks = malloc(sizeof(*ifp->if_addrhooks), - M_TEMP, M_WAITOK); - TAILQ_INIT(ifp->if_addrhooks); - ifp->if_linkstatehooks = malloc(sizeof(*ifp->if_linkstatehooks), - M_TEMP, M_WAITOK); - TAILQ_INIT(ifp->if_linkstatehooks); - ifp->if_detachhooks = malloc(sizeof(*ifp->if_detachhooks), - M_TEMP, M_WAITOK); - TAILQ_INIT(ifp->if_detachhooks); + TAILQ_INIT(&ifp->if_addrhooks); + TAILQ_INIT(&ifp->if_linkstatehooks); + TAILQ_INIT(&ifp->if_detachhooks); } void @@ -503,7 +496,7 @@ if_detach(struct ifnet *ifp) ifp->if_watchdog = if_detached_watchdog; /* Call detach hooks, ie. to remove vlan interfaces */ - dohooks(ifp->if_detachhooks, HOOK_REMOVE | HOOK_FREE); + dohooks(&ifp->if_detachhooks, HOOK_REMOVE | HOOK_FREE); #if NTRUNK > 0 if (ifp->if_type == IFT_IEEE8023ADLAG) @@ -608,10 +601,6 @@ do { \ ifafree(ifp->if_lladdr); ifp->if_lladdr = NULL; - free(ifp->if_addrhooks, M_TEMP); - free(ifp->if_linkstatehooks, M_TEMP); - free(ifp->if_detachhooks, M_TEMP); - for (dp = domains; dp; dp = dp->dom_next) { if (dp->dom_ifdetach && ifp->if_afdata[dp->dom_family]) (*dp->dom_ifdetach)(ifp, @@ -1118,7 +1107,7 @@ if_link_state_change(struct ifnet *ifp) #ifndef SMALL_KERNEL rt_if_track(ifp); #endif - dohooks(ifp->if_linkstatehooks, 0); + dohooks(&ifp->if_linkstatehooks, 0); } /* diff --git a/sys/net/if.h b/sys/net/if.h index 20a42f6fba7..e12b7d9107d 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if.h,v 1.142 2013/04/02 08:54:37 mpi Exp $ */ +/* $OpenBSD: if.h,v 1.143 2013/06/20 09:38:24 mpi Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -59,6 +59,7 @@ __END_DECLS #if __BSD_VISIBLE +#include <sys/systm.h> #include <sys/queue.h> #include <sys/tree.h> @@ -264,9 +265,9 @@ struct ifnet { /* and the entries */ TAILQ_ENTRY(ifnet) if_txlist; /* list of ifnets ready to tx */ TAILQ_HEAD(, ifaddr) if_addrlist; /* linked list of addresses per if */ TAILQ_HEAD(, ifg_list) if_groups; /* linked list of groups per if */ - struct hook_desc_head *if_addrhooks; /* address change callbacks */ - struct hook_desc_head *if_linkstatehooks; /* link change callbacks */ - struct hook_desc_head *if_detachhooks; /* detach callbacks */ + struct hook_desc_head if_addrhooks; /* address change callbacks */ + struct hook_desc_head if_linkstatehooks; /* link change callbacks */ + struct hook_desc_head if_detachhooks; /* detach 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/net/if_pfsync.c b/sys/net/if_pfsync.c index 6bd50af40ec..78856e9dd57 100644 --- a/sys/net/if_pfsync.c +++ b/sys/net/if_pfsync.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pfsync.c,v 1.198 2013/05/10 11:36:24 mikeb Exp $ */ +/* $OpenBSD: if_pfsync.c,v 1.199 2013/06/20 09:38:24 mpi Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff @@ -367,7 +367,7 @@ pfsync_clone_destroy(struct ifnet *ifp) #endif if (sc->sc_sync_if) hook_disestablish( - sc->sc_sync_if->if_linkstatehooks, + &sc->sc_sync_if->if_linkstatehooks, sc->sc_lhcookie); if_detach(ifp); @@ -1350,7 +1350,7 @@ pfsyncioctl(struct ifnet *ifp, u_long cmd, caddr_t data) if (pfsyncr.pfsyncr_syncdev[0] == 0) { if (sc->sc_sync_if) hook_disestablish( - sc->sc_sync_if->if_linkstatehooks, + &sc->sc_sync_if->if_linkstatehooks, sc->sc_lhcookie); sc->sc_sync_if = NULL; if (imo->imo_num_memberships > 0) { @@ -1375,7 +1375,7 @@ pfsyncioctl(struct ifnet *ifp, u_long cmd, caddr_t data) if (sc->sc_sync_if) hook_disestablish( - sc->sc_sync_if->if_linkstatehooks, + &sc->sc_sync_if->if_linkstatehooks, sc->sc_lhcookie); sc->sc_sync_if = sifp; @@ -1421,7 +1421,7 @@ pfsyncioctl(struct ifnet *ifp, u_long cmd, caddr_t data) ip->ip_dst.s_addr = sc->sc_sync_peer.s_addr; sc->sc_lhcookie = - hook_establish(sc->sc_sync_if->if_linkstatehooks, 1, + hook_establish(&sc->sc_sync_if->if_linkstatehooks, 1, pfsync_syncdev_state, sc); pfsync_request_full_update(sc); diff --git a/sys/net/if_pppx.c b/sys/net/if_pppx.c index 9de8e901efc..ad58abc3a33 100644 --- a/sys/net/if_pppx.c +++ b/sys/net/if_pppx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pppx.c,v 1.20 2013/06/18 09:15:13 mpi Exp $ */ +/* $OpenBSD: if_pppx.c,v 1.21 2013/06/20 09:38:24 mpi Exp $ */ /* * Copyright (c) 2010 Claudio Jeker <claudio@openbsd.org> @@ -920,7 +920,7 @@ pppx_add_session(struct pppx_dev *pxd, struct pipex_session_req *req) ifp->if_xname, error); ifafree(&ia->ia_ifa); } else { - dohooks(ifp->if_addrhooks, 0); + dohooks(&ifp->if_addrhooks, 0); } splx(s); diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c index a435b58daaa..a2fb9a05060 100644 --- a/sys/net/if_spppsubr.c +++ b/sys/net/if_spppsubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_spppsubr.c,v 1.102 2013/05/31 19:16:52 mpi Exp $ */ +/* $OpenBSD: if_spppsubr.c,v 1.103 2013/06/20 09:38:24 mpi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. * Keepalive protocol implemented in both Cisco and PPP modes. @@ -4751,7 +4751,7 @@ sppp_set_ip_addrs(void *arg1, void *arg2) } } if (!(error = in_ifinit(ifp, ifatoia(ifa), &new_sin, 0))) - dohooks(ifp->if_addrhooks, 0); + dohooks(&ifp->if_addrhooks, 0); if (debug && error) { log(LOG_DEBUG, SPP_FMT "sppp_set_ip_addrs: in_ifinit " " failed, error=%d\n", SPP_ARGS(ifp), error); @@ -4812,7 +4812,7 @@ sppp_clear_ip_addrs(void *arg1, void *arg2) /* replace peer addr in place */ dest->sin_addr.s_addr = sp->ipcp.saved_hisaddr; if (!(error = in_ifinit(ifp, ifatoia(ifa), &new_sin, 0))) - dohooks(ifp->if_addrhooks, 0); + dohooks(&ifp->if_addrhooks, 0); if (debug && error) { log(LOG_DEBUG, SPP_FMT "sppp_clear_ip_addrs: in_ifinit " " failed, error=%d\n", SPP_ARGS(ifp), error); @@ -4912,7 +4912,7 @@ sppp_set_ip6_addr(struct sppp *sp, const struct in6_addr *src) if (ifa && sin6) { struct sockaddr_in6 new_sin6 = *sin6; bcopy(src, &new_sin6.sin6_addr, sizeof(new_sin6.sin6_addr)); - dohooks(ifp->if_addrhooks, 0); + dohooks(&ifp->if_addrhooks, 0); } } #endif diff --git a/sys/net/if_trunk.c b/sys/net/if_trunk.c index a3565678207..6162da4ab78 100644 --- a/sys/net/if_trunk.c +++ b/sys/net/if_trunk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_trunk.c,v 1.82 2013/05/11 11:18:27 sthen Exp $ */ +/* $OpenBSD: if_trunk.c,v 1.83 2013/06/20 09:38:24 mpi Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Reyk Floeter <reyk@openbsd.org> @@ -381,9 +381,8 @@ trunk_port_create(struct trunk_softc *tr, struct ifnet *ifp) trunk_ether_cmdmulti(tp, SIOCADDMULTI); /* Register callback for physical link state changes */ - if (ifp->if_linkstatehooks != NULL) - tp->lh_cookie = hook_establish(ifp->if_linkstatehooks, 1, - trunk_port_state, tp); + tp->lh_cookie = hook_establish(&ifp->if_linkstatehooks, 1, + trunk_port_state, tp); if (tr->tr_port_create != NULL) error = (*tr->tr_port_create)(tp); @@ -433,8 +432,7 @@ trunk_port_destroy(struct trunk_port *tp) ifp->if_ioctl = tp->tp_ioctl; ifp->if_tp = NULL; - if (ifp->if_linkstatehooks != NULL) - hook_disestablish(ifp->if_linkstatehooks, tp->lh_cookie); + hook_disestablish(&ifp->if_linkstatehooks, tp->lh_cookie); /* Finally, remove the port from the trunk */ SLIST_REMOVE(&tr->tr_ports, tp, trunk_port, tp_entries); diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index a69e502a65d..e47e372f0f2 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vlan.c,v 1.95 2013/04/02 08:54:37 mpi Exp $ */ +/* $OpenBSD: if_vlan.c,v 1.96 2013/06/20 09:38:24 mpi Exp $ */ /* * Copyright 1998 Massachusetts Institute of Technology @@ -448,11 +448,11 @@ vlan_config(struct ifvlan *ifv, struct ifnet *p, u_int16_t tag) LIST_INSERT_HEAD(&tagh[TAG_HASH(tag)], ifv, ifv_list); /* Register callback for physical link state changes */ - ifv->lh_cookie = hook_establish(p->if_linkstatehooks, 1, + ifv->lh_cookie = hook_establish(&p->if_linkstatehooks, 1, vlan_vlandev_state, ifv); /* Register callback if parent wants to unregister */ - ifv->dh_cookie = hook_establish(p->if_detachhooks, 1, + ifv->dh_cookie = hook_establish(&p->if_detachhooks, 1, vlan_ifdetach, ifv); vlan_vlandev_state(ifv); @@ -484,10 +484,10 @@ vlan_unconfig(struct ifnet *ifp, struct ifnet *newp) s = splnet(); LIST_REMOVE(ifv, ifv_list); if (ifv->lh_cookie != NULL) - hook_disestablish(p->if_linkstatehooks, ifv->lh_cookie); + hook_disestablish(&p->if_linkstatehooks, ifv->lh_cookie); /* The cookie is NULL if disestablished externally */ if (ifv->dh_cookie != NULL) - hook_disestablish(p->if_detachhooks, ifv->dh_cookie); + hook_disestablish(&p->if_detachhooks, ifv->dh_cookie); /* Reset link state */ if (newp != NULL) { ifp->if_link_state = LINK_STATE_INVALID; diff --git a/sys/net/pf_if.c b/sys/net/pf_if.c index 672b9de9468..0d79f0bf3b6 100644 --- a/sys/net/pf_if.c +++ b/sys/net/pf_if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf_if.c,v 1.64 2012/12/28 17:52:06 gsoares Exp $ */ +/* $OpenBSD: pf_if.c,v 1.65 2013/06/20 09:38:24 mpi Exp $ */ /* * Copyright 2005 Henning Brauer <henning@openbsd.org> @@ -219,7 +219,7 @@ pfi_attach_ifnet(struct ifnet *ifp) kif->pfik_ifp = ifp; ifp->if_pf_kif = (caddr_t)kif; - if ((kif->pfik_ah_cookie = hook_establish(ifp->if_addrhooks, 1, + if ((kif->pfik_ah_cookie = hook_establish(&ifp->if_addrhooks, 1, pfi_kifaddr_update, kif)) == NULL) panic("pfi_attach_ifnet: cannot allocate '%s' address hook", ifp->if_xname); @@ -240,7 +240,7 @@ pfi_detach_ifnet(struct ifnet *ifp) s = splsoftnet(); pfi_update++; - hook_disestablish(ifp->if_addrhooks, kif->pfik_ah_cookie); + hook_disestablish(&ifp->if_addrhooks, kif->pfik_ah_cookie); pfi_kif_update(kif); kif->pfik_ifp = NULL; diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 136dd5dcb1b..7c5e050d841 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in.c,v 1.78 2013/06/17 11:58:16 mpi Exp $ */ +/* $OpenBSD: in.c,v 1.79 2013/06/20 09:38:24 mpi Exp $ */ /* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */ /* @@ -343,7 +343,7 @@ in_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp) in_ifscrub(ifp, ia); error = in_ifinit(ifp, ia, satosin(&ifr->ifr_addr), newifaddr); if (!error) - dohooks(ifp->if_addrhooks, 0); + dohooks(&ifp->if_addrhooks, 0); else if (newifaddr) { splx(s); goto cleanup; @@ -393,7 +393,7 @@ in_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp) error = in_ifinit(ifp, ia, &ifra->ifra_addr, newifaddr); } if (!error) - dohooks(ifp->if_addrhooks, 0); + dohooks(&ifp->if_addrhooks, 0); else if (newifaddr) { splx(s); goto cleanup; @@ -425,7 +425,7 @@ cleanup: ia->ia_ifp = NULL; ifafree((&ia->ia_ifa)); if (!error) - dohooks(ifp->if_addrhooks, 0); + dohooks(&ifp->if_addrhooks, 0); splx(s); return (error); } diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index ac8688976bc..78f077eb9ff 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_carp.c,v 1.207 2013/06/18 09:23:33 mpi Exp $ */ +/* $OpenBSD: ip_carp.c,v 1.208 2013/06/20 09:38:24 mpi Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff. All rights reserved. @@ -904,7 +904,7 @@ carp_clone_create(ifc, unit) #endif /* Hook carp_addr_updated to cope with address and route changes. */ - sc->ah_cookie = hook_establish(sc->sc_if.if_addrhooks, 0, + sc->ah_cookie = hook_establish(&sc->sc_if.if_addrhooks, 0, carp_addr_updated, sc); carp_set_state_all(sc, INIT); @@ -991,10 +991,10 @@ carpdetach(struct carp_softc *sc) s = splnet(); if (sc->ah_cookie != NULL) - hook_disestablish(sc->sc_if.if_addrhooks, sc->ah_cookie); + hook_disestablish(&sc->sc_if.if_addrhooks, sc->ah_cookie); if (sc->sc_carpdev != NULL) { if (sc->lh_cookie != NULL) - hook_disestablish(sc->sc_carpdev->if_linkstatehooks, + hook_disestablish(&sc->sc_carpdev->if_linkstatehooks, sc->lh_cookie); cif = (struct carp_if *)sc->sc_carpdev->if_carp; TAILQ_REMOVE(&cif->vhif_vrs, sc, sc_list); @@ -1887,7 +1887,7 @@ carp_set_ifp(struct carp_softc *sc, struct ifnet *ifp) sc->sc_if.if_flags |= IFF_UP; carp_set_enaddr(sc); s = splnet(); - sc->lh_cookie = hook_establish(ifp->if_linkstatehooks, 1, + sc->lh_cookie = hook_establish(&ifp->if_linkstatehooks, 1, carp_carpdev_state, ifp); carp_carpdev_state(ifp); splx(s); diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index 0f4856a2a17..5f8efed9124 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6.c,v 1.114 2013/06/16 21:27:15 bluhm Exp $ */ +/* $OpenBSD: in6.c,v 1.115 2013/06/20 09:38:24 mpi Exp $ */ /* $KAME: in6.c,v 1.372 2004/06/14 08:14:21 itojun Exp $ */ /* @@ -670,7 +670,7 @@ in6_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp, pr0.ndpr_plen = in6_mask2len(&ifra->ifra_prefixmask.sin6_addr, NULL); if (pr0.ndpr_plen == 128) { - dohooks(ifp->if_addrhooks, 0); + dohooks(&ifp->if_addrhooks, 0); break; /* we don't need to install a host route. */ } pr0.ndpr_prefix = ifra->ifra_addr; @@ -720,13 +720,13 @@ in6_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp, */ pfxlist_onlink_check(); - dohooks(ifp->if_addrhooks, 0); + dohooks(&ifp->if_addrhooks, 0); break; } case SIOCDIFADDR_IN6: in6_purgeaddr(&ia->ia_ifa); - dohooks(ifp->if_addrhooks, 0); + dohooks(&ifp->if_addrhooks, 0); break; default: |