diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 2bec4654bfd..2d4f3136986 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -274,10 +274,10 @@ static struct filterops bpfread_filtops = { * * 2. An userland application uses ioctl() call to bpf_d descriptor. * All such call are serialized with global lock. BPF filters can be - * changed, but pointer to old filter will be freed using epoch_call(). + * changed, but pointer to old filter will be freed using NET_EPOCH_CALL(). * Thus it should be safe for bpf_tap/bpf_mtap* code to do access to * filter pointers, even if change will happen during bpf_tap execution. - * Destroying of bpf_d descriptor also is doing using epoch_call(). + * Destroying of bpf_d descriptor also is doing using NET_EPOCH_CALL(). * * 3. An userland application can write packets into bpf_d descriptor. * There we need to be sure, that ifnet won't disappear during bpfwrite(). @@ -288,7 +288,7 @@ static struct filterops bpfread_filtops = { * * 5. The kernel invokes bpfdetach() on interface destroying. All lists * are modified with global lock held and actual free() is done using - * epoch_call(). + * NET_EPOCH_CALL(). */ static void @@ -314,7 +314,7 @@ bpfif_rele(struct bpf_if *bp) if (!refcount_release(&bp->bif_refcnt)) return; - epoch_call(net_epoch_preempt, &bp->epoch_ctx, bpfif_free); + NET_EPOCH_CALL(bpfif_free, &bp->epoch_ctx); } static void @@ -330,7 +330,7 @@ bpfd_rele(struct bpf_d *d) if (!refcount_release(&d->bd_refcnt)) return; - epoch_call(net_epoch_preempt, &d->epoch_ctx, bpfd_free); + NET_EPOCH_CALL(bpfd_free, &d->epoch_ctx); } static struct bpf_program_buffer* @@ -2036,8 +2036,7 @@ bpf_setf(struct bpf_d *d, struct bpf_program *fp, u_long cmd) BPFD_UNLOCK(d); if (fcode != NULL) - epoch_call(net_epoch_preempt, &fcode->epoch_ctx, - bpf_program_buffer_free); + NET_EPOCH_CALL(bpf_program_buffer_free, &fcode->epoch_ctx); if (track_event) EVENTHANDLER_INVOKE(bpf_track, diff --git a/sys/net/if.c b/sys/net/if.c index 8960416b1a8..5962185fde9 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -654,7 +654,7 @@ if_free(struct ifnet *ifp) IFNET_WUNLOCK(); if (refcount_release(&ifp->if_refcount)) - epoch_call(net_epoch_preempt, &ifp->if_epoch_ctx, if_destroy); + NET_EPOCH_CALL(if_destroy, &ifp->if_epoch_ctx); CURVNET_RESTORE(); } @@ -677,7 +677,7 @@ if_rele(struct ifnet *ifp) if (!refcount_release(&ifp->if_refcount)) return; - epoch_call(net_epoch_preempt, &ifp->if_epoch_ctx, if_destroy); + NET_EPOCH_CALL(if_destroy, &ifp->if_epoch_ctx); } void @@ -1826,7 +1826,7 @@ ifa_free(struct ifaddr *ifa) { if (refcount_release(&ifa->ifa_refcnt)) - epoch_call(net_epoch_preempt, &ifa->ifa_epoch_ctx, ifa_destroy); + NET_EPOCH_CALL(ifa_destroy, &ifa->ifa_epoch_ctx); } @@ -3410,7 +3410,7 @@ if_freemulti(struct ifmultiaddr *ifma) KASSERT(ifma->ifma_refcount == 0, ("if_freemulti_epoch: refcount %d", ifma->ifma_refcount)); - epoch_call(net_epoch_preempt, &ifma->ifma_epoch_ctx, if_destroymulti); + NET_EPOCH_CALL(if_destroymulti, &ifma->ifma_epoch_ctx); } diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c index ad87605efa0..91eb0d69b81 100644 --- a/sys/net/if_gre.c +++ b/sys/net/if_gre.c @@ -392,7 +392,7 @@ gre_delete_tunnel(struct gre_softc *sc) if ((gs = sc->gre_so) != NULL && CK_LIST_EMPTY(&gs->list)) { CK_LIST_REMOVE(gs, chain); soclose(gs->so); - epoch_call(net_epoch_preempt, &gs->epoch_ctx, gre_sofree); + NET_EPOCH_CALL(gre_sofree, &gs->epoch_ctx); sc->gre_so = NULL; } GRE2IFP(sc)->if_drv_flags &= ~IFF_DRV_RUNNING; diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c index 047908e1a50..174fd4479d8 100644 --- a/sys/net/if_lagg.c +++ b/sys/net/if_lagg.c @@ -910,7 +910,7 @@ lagg_port_destroy(struct lagg_port *lp, int rundelport) * free port and release it's ifnet reference after a grace period has * elapsed. */ - epoch_call(net_epoch_preempt, &lp->lp_epoch_ctx, lagg_port_destroy_cb); + NET_EPOCH_CALL(lagg_port_destroy_cb, &lp->lp_epoch_ctx); /* Update lagg capabilities */ lagg_capabilities(sc); lagg_linkstate(sc); diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index e7e32fb2a38..88844b0e848 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -584,7 +584,7 @@ vlan_setmulti(struct ifnet *ifp) while ((mc = CK_SLIST_FIRST(&sc->vlan_mc_listhead)) != NULL) { CK_SLIST_REMOVE_HEAD(&sc->vlan_mc_listhead, mc_entries); (void)if_delmulti(ifp_p, (struct sockaddr *)&mc->mc_addr); - epoch_call(net_epoch_preempt, &mc->mc_epoch_ctx, vlan_mc_free); + NET_EPOCH_CALL(vlan_mc_free, &mc->mc_epoch_ctx); } /* Now program new ones. */ @@ -1543,7 +1543,7 @@ vlan_unconfig_locked(struct ifnet *ifp, int departing) error); } CK_SLIST_REMOVE_HEAD(&ifv->vlan_mc_listhead, mc_entries); - epoch_call(net_epoch_preempt, &mc->mc_epoch_ctx, vlan_mc_free); + NET_EPOCH_CALL(vlan_mc_free, &mc->mc_epoch_ctx); } vlan_setflags(ifp, 0); /* clear special flags on parent */ diff --git a/sys/netinet/in.c b/sys/netinet/in.c index c83f0ae83fc..bf38e3c3350 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -1087,7 +1087,7 @@ in_lltable_destroy_lle(struct llentry *lle) { LLE_WUNLOCK(lle); - epoch_call(net_epoch_preempt, &lle->lle_epoch_ctx, in_lltable_destroy_lle_unlocked); + NET_EPOCH_CALL(in_lltable_destroy_lle_unlocked, &lle->lle_epoch_ctx); } static struct llentry * @@ -1348,7 +1348,7 @@ in_lltable_alloc(struct lltable *llt, u_int flags, const struct sockaddr *l3addr linkhdrsize = LLE_MAX_LINKHDR; if (lltable_calc_llheader(ifp, AF_INET, IF_LLADDR(ifp), linkhdr, &linkhdrsize, &lladdr_off) != 0) { - epoch_call(net_epoch_preempt, &lle->lle_epoch_ctx, in_lltable_destroy_lle_unlocked); + NET_EPOCH_CALL(in_lltable_destroy_lle_unlocked, &lle->lle_epoch_ctx); return (NULL); } lltable_set_entry_addr(ifp, lle, linkhdr, linkhdrsize, diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index f95569380ba..0835822501a 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -269,8 +269,7 @@ in_pcblbgroup_free(struct inpcblbgroup *grp) { CK_LIST_REMOVE(grp, il_list); - epoch_call(net_epoch_preempt, &grp->il_epoch_ctx, - in_pcblbgroup_free_deferred); + NET_EPOCH_CALL(in_pcblbgroup_free_deferred, &grp->il_epoch_ctx); } static struct inpcblbgroup * @@ -1663,7 +1662,7 @@ in_pcbfree(struct inpcb *inp) /* mark as destruction in progress */ inp->inp_flags2 |= INP_FREED; INP_WUNLOCK(inp); - epoch_call(net_epoch_preempt, &inp->inp_epoch_ctx, in_pcbfree_deferred); + NET_EPOCH_CALL(in_pcbfree_deferred, &inp->inp_epoch_ctx); } /* @@ -1704,7 +1703,7 @@ in_pcbdrop(struct inpcb *inp) CK_LIST_REMOVE(inp, inp_portlist); if (CK_LIST_FIRST(&phd->phd_pcblist) == NULL) { CK_LIST_REMOVE(phd, phd_hash); - epoch_call(net_epoch_preempt, &phd->phd_epoch_ctx, inpcbport_free); + NET_EPOCH_CALL(inpcbport_free, &phd->phd_epoch_ctx); } INP_HASH_WUNLOCK(inp->inp_pcbinfo); inp->inp_flags &= ~INP_INHASHLIST; @@ -2674,7 +2673,7 @@ in_pcbremlists(struct inpcb *inp) CK_LIST_REMOVE(inp, inp_portlist); if (CK_LIST_FIRST(&phd->phd_pcblist) == NULL) { CK_LIST_REMOVE(phd, phd_hash); - epoch_call(net_epoch_preempt, &phd->phd_epoch_ctx, inpcbport_free); + NET_EPOCH_CALL(inpcbport_free, &phd->phd_epoch_ctx); } INP_HASH_WUNLOCK(pcbinfo); inp->inp_flags &= ~INP_INHASHLIST; diff --git a/sys/netinet/ip_gre.c b/sys/netinet/ip_gre.c index d0db758bfec..0afd490944a 100644 --- a/sys/netinet/ip_gre.c +++ b/sys/netinet/ip_gre.c @@ -235,7 +235,7 @@ in_gre_udp_input(struct mbuf *m, int off, struct inpcb *inp, * If socket was closed before we have entered NET_EPOCH section, * INP_FREED flag should be set. Otherwise it should be safe to * make access to ctx data, because gre_so will be freed by - * gre_sofree() via epoch_call(). + * gre_sofree() via NET_EPOCH_CALL(). */ if (__predict_false(inp->inp_flags2 & INP_FREED)) { NET_EPOCH_EXIT(et); @@ -284,8 +284,7 @@ in_gre_setup_socket(struct gre_softc *sc) if (CK_LIST_EMPTY(&gs->list)) { CK_LIST_REMOVE(gs, chain); soclose(gs->so); - epoch_call(net_epoch_preempt, &gs->epoch_ctx, - gre_sofree); + NET_EPOCH_CALL(gre_sofree, &gs->epoch_ctx); } gs = sc->gre_so = NULL; } diff --git a/sys/netinet/tcp_ratelimit.c b/sys/netinet/tcp_ratelimit.c index 39698d55aab..30502e81bd1 100644 --- a/sys/netinet/tcp_ratelimit.c +++ b/sys/netinet/tcp_ratelimit.c @@ -286,7 +286,7 @@ rs_defer_destroy(struct tcp_rate_set *rs) /* Set flag to only defer once. */ rs->rs_flags |= RS_FUNERAL_SCHD; - epoch_call(net_epoch_preempt, &rs->rs_epoch_ctx, rs_destroy); + NET_EPOCH_CALL(rs_destroy, &rs->rs_epoch_ctx); } #ifdef INET diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index 54787ce3ec3..3eac100aa9b 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -2061,7 +2061,7 @@ in6_lltable_destroy_lle(struct llentry *lle) { LLE_WUNLOCK(lle); - epoch_call(net_epoch_preempt, &lle->lle_epoch_ctx, in6_lltable_destroy_lle_unlocked); + NET_EPOCH_CALL(in6_lltable_destroy_lle_unlocked, &lle->lle_epoch_ctx); } static struct llentry * @@ -2282,7 +2282,7 @@ in6_lltable_alloc(struct lltable *llt, u_int flags, linkhdrsize = LLE_MAX_LINKHDR; if (lltable_calc_llheader(ifp, AF_INET6, IF_LLADDR(ifp), linkhdr, &linkhdrsize, &lladdr_off) != 0) { - epoch_call(net_epoch_preempt, &lle->lle_epoch_ctx, in6_lltable_destroy_lle_unlocked); + NET_EPOCH_CALL(in6_lltable_destroy_lle_unlocked, &lle->lle_epoch_ctx); return (NULL); } lltable_set_entry_addr(ifp, lle, linkhdr, linkhdrsize, diff --git a/sys/netinet6/ip6_gre.c b/sys/netinet6/ip6_gre.c index 37f2046592d..410d1bcf952 100644 --- a/sys/netinet6/ip6_gre.c +++ b/sys/netinet6/ip6_gre.c @@ -228,7 +228,7 @@ in6_gre_udp_input(struct mbuf *m, int off, struct inpcb *inp, * If socket was closed before we have entered NET_EPOCH section, * INP_FREED flag should be set. Otherwise it should be safe to * make access to ctx data, because gre_so will be freed by - * gre_sofree() via epoch_call(). + * gre_sofree() via NET_EPOCH_CALL(). */ if (__predict_false(inp->inp_flags2 & INP_FREED)) { NET_EPOCH_EXIT(et); @@ -280,8 +280,7 @@ in6_gre_setup_socket(struct gre_softc *sc) if (CK_LIST_EMPTY(&gs->list)) { CK_LIST_REMOVE(gs, chain); soclose(gs->so); - epoch_call(net_epoch_preempt, &gs->epoch_ctx, - gre_sofree); + NET_EPOCH_CALL(gre_sofree, &gs->epoch_ctx); } gs = sc->gre_so = NULL; } diff --git a/sys/netpfil/ipfw/nat64/nat64lsn.c b/sys/netpfil/ipfw/nat64/nat64lsn.c index b1356b3b969..ed50239176d 100644 --- a/sys/netpfil/ipfw/nat64/nat64lsn.c +++ b/sys/netpfil/ipfw/nat64/nat64lsn.c @@ -75,7 +75,7 @@ MALLOC_DEFINE(M_NAT64LSN, "NAT64LSN", "NAT64LSN"); #define NAT64LSN_EPOCH_ENTER(et) NET_EPOCH_ENTER(et) #define NAT64LSN_EPOCH_EXIT(et) NET_EPOCH_EXIT(et) #define NAT64LSN_EPOCH_ASSERT() NET_EPOCH_ASSERT() -#define NAT64LSN_EPOCH_CALL(c, f) epoch_call(net_epoch_preempt, (c), (f)) +#define NAT64LSN_EPOCH_CALL(c, f) NET_EPOCH_CALL((f), (c)) static uma_zone_t nat64lsn_host_zone; static uma_zone_t nat64lsn_pgchunk_zone; diff --git a/sys/sys/epoch.h b/sys/sys/epoch.h index 67b08dfa691..6b6fb8f9e17 100644 --- a/sys/sys/epoch.h +++ b/sys/sys/epoch.h @@ -101,6 +101,7 @@ extern epoch_t net_epoch_preempt; #define NET_EPOCH_ENTER(et) epoch_enter_preempt(net_epoch_preempt, &(et)) #define NET_EPOCH_EXIT(et) epoch_exit_preempt(net_epoch_preempt, &(et)) #define NET_EPOCH_WAIT() epoch_wait_preempt(net_epoch_preempt) +#define NET_EPOCH_CALL(f, c) epoch_call(net_epoch_preempt, (c), (f)) #define NET_EPOCH_ASSERT() MPASS(in_epoch(net_epoch_preempt)) #endif /* _KERNEL */