From 83c2fc18fa56a10c3be90a1c98b0a7fa68d2a5d5 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Fri, 21 Jul 2017 16:44:29 +0800 Subject: [PATCH] vlan: It should only run in netisr_cpus netisrs --- sys/net/vlan/if_vlan.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/sys/net/vlan/if_vlan.c b/sys/net/vlan/if_vlan.c index 207b13d79f..9bd70c0104 100644 --- a/sys/net/vlan/if_vlan.c +++ b/sys/net/vlan/if_vlan.c @@ -450,10 +450,10 @@ vlan_clone_create(struct if_clone *ifc, int unit, caddr_t param __unused) int vlan_size, i; vlan_size = sizeof(struct ifvlan) - + ((ncpus - 1) * sizeof(struct vlan_entry)); + + ((netisr_ncpus - 1) * sizeof(struct vlan_entry)); ifv = kmalloc(vlan_size, M_VLAN, M_WAITOK | M_ZERO); SLIST_INIT(&ifv->vlan_mc_listhead); - for (i = 0; i < ncpus; ++i) + for (i = 0; i < netisr_ncpus; ++i) ifv->ifv_entries[i].ifv = ifv; crit_enter(); /* XXX not MP safe */ @@ -580,11 +580,16 @@ vlan_input(struct mbuf *m) struct ifnet *rcvif; struct vlan_trunk *vlantrunks; struct vlan_entry *entry; + int cpuid = mycpuid; + + ASSERT_NETISR_NCPUS(curthread, cpuid); rcvif = m->m_pkthdr.rcvif; KKASSERT(m->m_flags & M_VLANTAG); vlantrunks = rcvif->if_vlantrunks; + /* Make sure 'vlantrunks' is really used. */ + cpu_ccfence(); if (vlantrunks == NULL) { IFNET_STAT_INC(rcvif, noproto, 1); m_freem(m); @@ -592,7 +597,7 @@ vlan_input(struct mbuf *m) } crit_enter(); /* XXX Necessary? */ - LIST_FOREACH(entry, &vlantrunks[mycpuid].vlan_list, ifv_link) { + LIST_FOREACH(entry, &vlantrunks[cpuid].vlan_list, ifv_link) { if (entry->ifv->ifv_tag == EVL_VLANOFTAG(m->m_pkthdr.ether_vlantag)) { ifv = entry->ifv; @@ -643,7 +648,7 @@ vlan_link_dispatch(netmsg_t msg) LIST_INSERT_HEAD(&trunk->vlan_list, entry, ifv_link); crit_exit(); - netisr_forwardmsg_all(&vmsg->base, cpu + 1); + netisr_forwardmsg(&vmsg->base, cpu + 1); } static void @@ -658,9 +663,9 @@ vlan_link(struct ifvlan *ifv, struct ifnet *ifp_p) struct vlan_trunk *vlantrunks; int i; - vlantrunks = kmalloc(sizeof(*vlantrunks) * ncpus, M_VLAN, + vlantrunks = kmalloc(sizeof(*vlantrunks) * netisr_ncpus, M_VLAN, M_WAITOK | M_ZERO); - for (i = 0; i < ncpus; ++i) + for (i = 0; i < netisr_ncpus; ++i) LIST_INIT(&vlantrunks[i].vlan_list); ifp_p->if_vlantrunks = vlantrunks; @@ -801,7 +806,7 @@ vlan_unlink_dispatch(netmsg_t msg) LIST_REMOVE(entry, ifv_link); crit_exit(); - netisr_forwardmsg_all(&vmsg->base, cpu + 1); + netisr_forwardmsg(&vmsg->base, cpu + 1); } static void -- 2.11.4.GIT