Index: bus/usb/usb_ethersubr.c =================================================================== RCS file: /data/repos/df_cvs/src/sys/bus/usb/usb_ethersubr.c,v retrieving revision 1.19 diff -u -p -r1.19 usb_ethersubr.c --- bus/usb/usb_ethersubr.c 28 Jun 2007 06:32:31 -0000 1.19 +++ bus/usb/usb_ethersubr.c 21 Sep 2008 07:07:27 -0000 @@ -91,7 +91,7 @@ usb_register_netisr(void) { if (netisr_inited == 0) { netisr_inited = 1; - netisr_register(NETISR_USB, cpu0_portfn, usbintr); + netisr_register(NETISR_USB, cpu0_portfn, usbintr, 0); } } Index: net/bpf.c =================================================================== RCS file: /data/repos/df_cvs/src/sys/net/bpf.c,v retrieving revision 1.49 diff -u -p -r1.49 bpf.c --- net/bpf.c 17 Sep 2008 13:38:28 -0000 1.49 +++ net/bpf.c 21 Sep 2008 07:07:27 -0000 @@ -552,7 +552,7 @@ bpfwrite(struct dev_write_args *ap) if (d->bd_hdrcmplt) dst.sa_family = pseudo_AF_HDRCMPLT; - netmsg_init(&bmsg.nm_netmsg, &curthread->td_msgport, 0, + netmsg_init(&bmsg.nm_netmsg, &curthread->td_msgport, MSGF_MPSAFE, bpf_output_dispatch); bmsg.nm_mbuf = m; bmsg.nm_ifp = ifp; Index: net/netisr.c =================================================================== RCS file: /data/repos/df_cvs/src/sys/net/netisr.c,v retrieving revision 1.45 diff -u -p -r1.45 netisr.c --- net/netisr.c 20 Sep 2008 04:31:02 -0000 1.45 +++ net/netisr.c 21 Sep 2008 07:07:27 -0000 @@ -56,6 +56,18 @@ #include #include +#define NETISR_GET_MPLOCK(ni) \ +do { \ + if (((ni)->ni_flags & NETISR_FLAG_MPSAFE) == 0) \ + get_mplock(); \ +} while (0) + +#define NETISR_REL_MPLOCK(ni) \ +do { \ + if (((ni)->ni_flags & NETISR_FLAG_MPSAFE) == 0) \ + rel_mplock(); \ +} while (0) + static void netmsg_sync_func(struct netmsg *msg); struct netmsg_port_registration { @@ -139,18 +151,28 @@ netmsg_sync_putport(lwkt_port_t port, lw static void netisr_init(void) { - int i; + void (*func)(void *); + int i, flag; TAILQ_INIT(&netreglist); + if (netisr_mpsafe_thread == 1) { + func = netmsg_service_loop_mpsafe; + flag = 0; + } else if (netisr_mpsafe_thread == 2) { + func = netmsg_service_loop; + flag = TDF_MPSAFE; + } else { + func = netmsg_service_loop; + flag = 0; + } + /* * Create default per-cpu threads for generic protocol handling. */ for (i = 0; i < ncpus; ++i) { - lwkt_create(netisr_mpsafe_thread ? - netmsg_service_loop_mpsafe : netmsg_service_loop, - NULL, NULL, &netisr_cpu[i], - TDF_NETWORK, i, "netisr_cpu %d", i); + lwkt_create(func, NULL, NULL, &netisr_cpu[i], + TDF_NETWORK | flag, i, "netisr_cpu %d", i); netmsg_service_port_init(&netisr_cpu[i].td_msgport); } @@ -254,8 +276,38 @@ netmsg_service_loop(void *arg) void netmsg_service_loop_mpsafe(void *arg) { + struct netmsg *msg; + int mplocked; + rel_mplock(); - netmsg_service_loop(arg); + mplocked = 0; + + while ((msg = lwkt_waitport(&curthread->td_msgport, 0))) { + do { + /* + * Conditionally hold BGL + */ + if (msg->nm_lmsg.ms_flags & MSGF_MPSAFE) { + if (mplocked) { + rel_mplock(); + mplocked = 0; + } + } else if (!mplocked) { + get_mplock(); + mplocked = 1; + } + + msg->nm_dispatch(msg); + } while ((msg = lwkt_getport(&curthread->td_msgport)) != NULL); + + /* + * Always release BGL before being blocked + */ + if (mplocked) { + rel_mplock(); + mplocked = 0; + } + } } /* @@ -304,13 +356,15 @@ netisr_queue(int num, struct mbuf *m) } void -netisr_register(int num, lwkt_portfn_t mportfn, netisr_fn_t handler) +netisr_register(int num, lwkt_portfn_t mportfn, netisr_fn_t handler, + uint32_t flags) { KASSERT((num > 0 && num <= (sizeof(netisrs)/sizeof(netisrs[0]))), ("netisr_register: bad isr %d", num)); netmsg_init(&netisrs[num].ni_netmsg, &netisr_adone_rport, 0, NULL); netisrs[num].ni_mport = mportfn; netisrs[num].ni_handler = handler; + netisrs[num].ni_flags = flags; } int @@ -446,5 +500,7 @@ netisr_run(int num, struct mbuf *m) pmsg->nm_packet = m; pmsg->nm_netmsg.nm_lmsg.u.ms_result = num; + NETISR_GET_MPLOCK(ni); ni->ni_handler(&pmsg->nm_netmsg); + NETISR_REL_MPLOCK(ni); } Index: net/netisr.h =================================================================== RCS file: /data/repos/df_cvs/src/sys/net/netisr.h,v retrieving revision 1.35 diff -u -p -r1.35 netisr.h --- net/netisr.h 17 Sep 2008 07:24:18 -0000 1.35 +++ net/netisr.h 21 Sep 2008 07:07:27 -0000 @@ -203,8 +203,11 @@ struct netisr { lwkt_portfn_t ni_mport; netisr_fn_t ni_handler; struct netmsg ni_netmsg; /* for sched_netisr() (no-data) */ + uint32_t ni_flags; /* NETISR_FLAG_ */ }; +#define NETISR_FLAG_MPSAFE 0x1 + #endif #ifdef _KERNEL @@ -219,7 +222,7 @@ lwkt_port_t netisr_find_port(int, struct void netisr_dispatch(int, struct mbuf *); void netisr_run(int, struct mbuf *); int netisr_queue(int, struct mbuf *); -void netisr_register(int, lwkt_portfn_t, netisr_fn_t); +void netisr_register(int, lwkt_portfn_t, netisr_fn_t, uint32_t); int netisr_unregister(int); void netmsg_service_port_init(lwkt_port_t); void netmsg_service_loop(void *arg); Index: net/netmsg.h =================================================================== RCS file: /data/repos/df_cvs/src/sys/net/netmsg.h,v retrieving revision 1.8 diff -u -p -r1.8 netmsg.h --- net/netmsg.h 17 Sep 2008 11:22:13 -0000 1.8 +++ net/netmsg.h 21 Sep 2008 07:07:27 -0000 @@ -52,6 +52,8 @@ typedef struct netmsg { netisr_fn_t nm_dispatch; } *netmsg_t; +#define MSGF_MPSAFE MSGF_USER0 + #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES) /* Index: net/ppp/if_ppp.c =================================================================== RCS file: /data/repos/df_cvs/src/sys/net/ppp/if_ppp.c,v retrieving revision 1.39 diff -u -p -r1.39 if_ppp.c --- net/ppp/if_ppp.c 27 Jul 2008 10:06:57 -0000 1.39 +++ net/ppp/if_ppp.c 21 Sep 2008 07:07:27 -0000 @@ -256,7 +256,7 @@ pppattach(void *dummy) if_attach(&sc->sc_if, NULL); bpfattach(&sc->sc_if, DLT_PPP, PPP_HDRLEN); } - netisr_register(NETISR_PPP, cpu0_portfn, pppintr); + netisr_register(NETISR_PPP, cpu0_portfn, pppintr, 0); /* * XXX layering violation - if_ppp can work over any lower level * transport that cares to attach to it. Index: netbt/bt_proto.c =================================================================== RCS file: /data/repos/df_cvs/src/sys/netbt/bt_proto.c,v retrieving revision 1.4 diff -u -p -r1.4 bt_proto.c --- netbt/bt_proto.c 20 Apr 2008 13:44:25 -0000 1.4 +++ netbt/bt_proto.c 21 Sep 2008 07:07:28 -0000 @@ -234,7 +234,7 @@ SYSCTL_INT(_net_bluetooth_sco, OID_AUTO, static void netisr_netbt_setup(void *dummy __unused) { - netisr_register(NETISR_BLUETOOTH, cpu0_portfn, btintr); + netisr_register(NETISR_BLUETOOTH, cpu0_portfn, btintr, 0); } SYSINIT(netbt_setup, SI_BOOT2_KLD, SI_ORDER_ANY, netisr_netbt_setup, NULL); Index: netgraph/netgraph/ng_base.c =================================================================== RCS file: /data/repos/df_cvs/src/sys/netgraph/netgraph/ng_base.c,v retrieving revision 1.26 diff -u -p -r1.26 ng_base.c --- netgraph/netgraph/ng_base.c 5 Jan 2008 14:02:39 -0000 1.26 +++ netgraph/netgraph/ng_base.c 21 Sep 2008 07:07:28 -0000 @@ -1839,7 +1839,7 @@ ngb_mod_event(module_t mod, int event, v crit_exit(); break; } - netisr_register(NETISR_NETGRAPH, cpu0_portfn, ngintr); + netisr_register(NETISR_NETGRAPH, cpu0_portfn, ngintr, 0); error = 0; crit_exit(); break; Index: netgraph7/ng_base.c =================================================================== RCS file: /data/repos/df_cvs/src/sys/netgraph7/ng_base.c,v retrieving revision 1.2 diff -u -p -r1.2 ng_base.c --- netgraph7/ng_base.c 26 Jun 2008 23:05:35 -0000 1.2 +++ netgraph7/ng_base.c 21 Sep 2008 07:07:28 -0000 @@ -3068,8 +3068,7 @@ ngb_mod_event(module_t mod, int event, v ng_qdzone = uma_zcreate("NetGraph data items", sizeof(struct ng_item), NULL, NULL, NULL, NULL, UMA_ALIGN_CACHE, 0); uma_zone_set_max(ng_qdzone, maxdata); - netisr_register(NETISR_NETGRAPH, (netisr_t *)ngintr, NULL, - NETISR_MPSAFE); + netisr_register(NETISR_NETGRAPH, (netisr_t *)ngintr, NULL, 0); break; case MOD_UNLOAD: /* You can't unload it because an interface may be using it. */ Index: netinet/if_ether.c =================================================================== RCS file: /data/repos/df_cvs/src/sys/netinet/if_ether.c,v retrieving revision 1.49 diff -u -p -r1.49 if_ether.c --- netinet/if_ether.c 9 Jun 2008 11:24:24 -0000 1.49 +++ netinet/if_ether.c 21 Sep 2008 07:07:28 -0000 @@ -987,7 +987,7 @@ arp_init(void) for (cpu = 0; cpu < ncpus2; cpu++) LIST_INIT(&llinfo_arp_list[cpu]); - netisr_register(NETISR_ARP, cpu0_portfn, arpintr); + netisr_register(NETISR_ARP, cpu0_portfn, arpintr, 0); } SYSINIT(arp, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY, arp_init, 0); Index: netinet/ip_demux.c =================================================================== RCS file: /data/repos/df_cvs/src/sys/netinet/ip_demux.c,v retrieving revision 1.40 diff -u -p -r1.40 ip_demux.c --- netinet/ip_demux.c 20 Sep 2008 04:31:02 -0000 1.40 +++ netinet/ip_demux.c 21 Sep 2008 07:07:28 -0000 @@ -67,6 +67,9 @@ static struct thread udp_thread[MAXCPU]; static int udp_mpsafe_thread = 0; TUNABLE_INT("net.inet.udp.mpsafe_thread", &udp_mpsafe_thread); +static int tcp_mpsafe_thread = 0; +TUNABLE_INT("net.inet.tcp.mpsafe_thread", &tcp_mpsafe_thread); + static __inline int INP_MPORT_HASH(in_addr_t faddr, in_addr_t laddr, in_port_t fport, in_port_t lport) @@ -373,12 +376,23 @@ tcp_cport(int cpu) void tcp_thread_init(void) { - int cpu; + void (*func)(void *); + int cpu, flag; + + if (tcp_mpsafe_thread == 1) { + func = tcpmsg_service_loop_mpsafe; + flag = 0; + } else if (tcp_mpsafe_thread == 2) { + func = tcpmsg_service_loop; + flag = TDF_MPSAFE; + } else { + func = tcpmsg_service_loop; + flag = 0; + } for (cpu = 0; cpu < ncpus2; cpu++) { - lwkt_create(tcpmsg_service_loop, NULL, NULL, - &tcp_thread[cpu], TDF_NETWORK, cpu, - "tcp_thread %d", cpu); + lwkt_create(func, NULL, NULL, &tcp_thread[cpu], + TDF_NETWORK | flag, cpu, "tcp_thread %d", cpu); netmsg_service_port_init(&tcp_thread[cpu].td_msgport); } } @@ -386,13 +400,23 @@ tcp_thread_init(void) void udp_thread_init(void) { - int cpu; + void (*func)(void *); + int cpu, flag; + + if (udp_mpsafe_thread == 1) { + func = netmsg_service_loop_mpsafe; + flag = 0; + } else if (udp_mpsafe_thread == 2) { + func = netmsg_service_loop; + flag = TDF_MPSAFE; + } else { + func = netmsg_service_loop; + flag = 0; + } for (cpu = 0; cpu < ncpus2; cpu++) { - lwkt_create(udp_mpsafe_thread ? - netmsg_service_loop_mpsafe : netmsg_service_loop, - NULL, NULL, &udp_thread[cpu], TDF_NETWORK, cpu, - "udp_thread %d", cpu); + lwkt_create(func, NULL, NULL, &udp_thread[cpu], + TDF_NETWORK | flag, cpu, "udp_thread %d", cpu); netmsg_service_port_init(&udp_thread[cpu].td_msgport); } } Index: netinet/ip_input.c =================================================================== RCS file: /data/repos/df_cvs/src/sys/netinet/ip_input.c,v retrieving revision 1.107 diff -u -p -r1.107 ip_input.c --- netinet/ip_input.c 18 Sep 2008 11:19:42 -0000 1.107 +++ netinet/ip_input.c 21 Sep 2008 07:07:28 -0000 @@ -203,6 +203,9 @@ SYSCTL_INT(_net_inet_ip, OID_AUTO, check static int ipprintfs = 0; #endif +extern int udp_mpsafe_proto; +extern int tcp_mpsafe_proto; + extern struct domain inetdomain; extern struct protosw inetsw[]; u_char ip_protox[IPPROTO_MAX]; @@ -325,10 +328,25 @@ ip_init(void) for (i = 0; i < IPPROTO_MAX; i++) ip_protox[i] = pr - inetsw; for (pr = inetdomain.dom_protosw; - pr < inetdomain.dom_protoswNPROTOSW; pr++) - if (pr->pr_domain->dom_family == PF_INET && - pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW) - ip_protox[pr->pr_protocol] = pr - inetsw; + pr < inetdomain.dom_protoswNPROTOSW; pr++) { + if (pr->pr_domain->dom_family == PF_INET && pr->pr_protocol) { + if (pr->pr_protocol != IPPROTO_RAW) + ip_protox[pr->pr_protocol] = pr - inetsw; + + /* XXX */ + switch (pr->pr_protocol) { + case IPPROTO_TCP: + if (tcp_mpsafe_proto) + pr->pr_flags |= PR_MPSAFE; + break; + + case IPPROTO_UDP: + if (udp_mpsafe_proto) + pr->pr_flags |= PR_MPSAFE; + break; + } + } + } inet_pfil_hook.ph_type = PFIL_TYPE_AF; inet_pfil_hook.ph_af = AF_INET; @@ -357,7 +375,7 @@ ip_init(void) bzero(&ipstat, sizeof(struct ip_stats)); #endif - netisr_register(NETISR_IP, ip_mport_in, ip_input_handler); + netisr_register(NETISR_IP, ip_mport_in, ip_input_handler, 0); } /* @@ -371,10 +389,14 @@ struct route ipforward_rt[MAXCPU]; static void transport_processing_oncpu(struct mbuf *m, int hlen, struct ip *ip) { + const struct protosw *pr = &inetsw[ip_protox[ip->ip_p]]; + /* * Switch out to protocol's input routine. */ - (*inetsw[ip_protox[ip->ip_p]].pr_input)(m, hlen, ip->ip_p); + PR_GET_MPLOCK(pr); + pr->pr_input(m, hlen, ip->ip_p); + PR_REL_MPLOCK(pr); } static void @@ -898,7 +920,7 @@ DPRINTF(("ip_input: no SP, packet discar return; pmsg = &m->m_hdr.mh_netmsg; - netmsg_init(&pmsg->nm_netmsg, &netisr_apanic_rport, 0, + netmsg_init(&pmsg->nm_netmsg, &netisr_apanic_rport, MSGF_MPSAFE, transport_processing_handler); pmsg->nm_packet = m; pmsg->nm_netmsg.nm_lmsg.u.ms_result = hlen; Index: netinet/tcp_subr.c =================================================================== RCS file: /data/repos/df_cvs/src/sys/netinet/tcp_subr.c,v retrieving revision 1.60 diff -u -p -r1.60 tcp_subr.c --- netinet/tcp_subr.c 15 Aug 2008 21:37:16 -0000 1.60 +++ netinet/tcp_subr.c 21 Sep 2008 07:07:28 -0000 @@ -157,6 +157,9 @@ KTR_INFO(KTR_TCP, tcp, delayed, 2, "tcp struct inpcbinfo tcbinfo[MAXCPU]; struct tcpcbackqhead tcpcbackq[MAXCPU]; +int tcp_mpsafe_proto = 0; +TUNABLE_INT("net.inet.tcp.mpsafe_proto", &tcp_mpsafe_proto); + int tcp_mssdflt = TCP_MSS; SYSCTL_INT(_net_inet_tcp, TCPCTL_MSSDFLT, mssdflt, CTLFLAG_RW, &tcp_mssdflt, 0, "Default TCP Maximum Segment Size"); @@ -229,7 +232,7 @@ SYSCTL_INT(_net_inet_tcp, OID_AUTO, infl static MALLOC_DEFINE(M_TCPTEMP, "tcptemp", "TCP Templates for Keepalives"); static struct malloc_pipe tcptemp_mpipe; -static void tcp_willblock(void); +static int tcp_willblock(int); static void tcp_cleartaocache (void); static void tcp_notify (struct inpcb *, int); @@ -384,23 +387,76 @@ tcpmsg_service_loop(void *dummy) msg->nm_dispatch(msg); } while ((msg = lwkt_getport(&curthread->td_msgport)) != NULL); logtcp(delayed); - tcp_willblock(); + tcp_willblock(1); logtcp(wait); } } -static void -tcp_willblock(void) +/* + * MPSAFE version of netmsg_service_loop() + */ +void +tcpmsg_service_loop_mpsafe(void *dummy) +{ + struct netmsg *msg; + int mplocked; + + rel_mplock(); + mplocked = 0; + + while ((msg = lwkt_waitport(&curthread->td_msgport, 0))) { + do { + /* + * Conditionally hold BGL + */ + if (msg->nm_lmsg.ms_flags & MSGF_MPSAFE) { + if (mplocked) { + rel_mplock(); + mplocked = 0; + } + } else if (!mplocked) { + get_mplock(); + mplocked = 1; + } + + logtcp(rxmsg); + msg->nm_dispatch(msg); + } while ((msg = lwkt_getport(&curthread->td_msgport)) != NULL); + logtcp(delayed); + mplocked = tcp_willblock(mplocked); + logtcp(wait); + + /* + * Always release BGL before being blocked + */ + if (mplocked) { + rel_mplock(); + mplocked = 0; + } + } +} + +static int +tcp_willblock(int mplocked) { struct tcpcb *tp; int cpu = mycpu->gd_cpuid; + if (!mplocked && !tcp_mpsafe_proto) { + if (TAILQ_EMPTY(&tcpcbackq[cpu])) + return mplocked; + + get_mplock(); + mplocked = 1; + } + while ((tp = TAILQ_FIRST(&tcpcbackq[cpu])) != NULL) { KKASSERT(tp->t_flags & TF_ONOUTPUTQ); tp->t_flags &= ~TF_ONOUTPUTQ; TAILQ_REMOVE(&tcpcbackq[cpu], tp, t_outputq); tcp_output(tp); } + return mplocked; } Index: netinet/tcp_var.h =================================================================== RCS file: /data/repos/df_cvs/src/sys/netinet/tcp_var.h,v retrieving revision 1.41 diff -u -p -r1.41 tcp_var.h --- netinet/tcp_var.h 15 Aug 2008 21:37:16 -0000 1.41 +++ netinet/tcp_var.h 21 Sep 2008 07:07:28 -0000 @@ -573,6 +573,7 @@ void tcp_canceltimers (struct tcpcb *); struct tcpcb * tcp_close (struct tcpcb *); void tcpmsg_service_loop (void *); +void tcpmsg_service_loop_mpsafe (void *); void tcp_ctlinput (int, struct sockaddr *, void *); int tcp_ctloutput (struct socket *, struct sockopt *); struct lwkt_port * Index: netinet/udp_usrreq.c =================================================================== RCS file: /data/repos/df_cvs/src/sys/netinet/udp_usrreq.c,v retrieving revision 1.45 diff -u -p -r1.45 udp_usrreq.c --- netinet/udp_usrreq.c 12 Sep 2008 11:37:41 -0000 1.45 +++ netinet/udp_usrreq.c 21 Sep 2008 07:07:28 -0000 @@ -118,6 +118,9 @@ #include #endif +int udp_mpsafe_proto = 0; +TUNABLE_INT("net.inet.udp.mpsafe_proto", &udp_mpsafe_proto); + /* * UDP protocol implementation. * Per RFC 768, August, 1980. Index: netinet6/ip6_input.c =================================================================== RCS file: /data/repos/df_cvs/src/sys/netinet6/ip6_input.c,v retrieving revision 1.36 diff -u -p -r1.36 ip6_input.c --- netinet6/ip6_input.c 4 Sep 2008 09:08:22 -0000 1.36 +++ netinet6/ip6_input.c 21 Sep 2008 07:07:28 -0000 @@ -197,7 +197,7 @@ ip6_init(void) "error %d\n", __func__, i); } - netisr_register(NETISR_IPV6, cpu0_portfn, ip6_input); + netisr_register(NETISR_IPV6, cpu0_portfn, ip6_input, 0); scope6_init(); nd6_init(); frag6_init(); Index: netproto/atalk/ddp_usrreq.c =================================================================== RCS file: /data/repos/df_cvs/src/sys/netproto/atalk/ddp_usrreq.c,v retrieving revision 1.12 diff -u -p -r1.12 ddp_usrreq.c --- netproto/atalk/ddp_usrreq.c 5 Jan 2008 14:02:40 -0000 1.12 +++ netproto/atalk/ddp_usrreq.c 21 Sep 2008 07:07:28 -0000 @@ -540,9 +540,9 @@ at_setsockaddr(struct socket *so, struct void ddp_init(void) { - netisr_register(NETISR_ATALK1, cpu0_portfn, at1intr); - netisr_register(NETISR_ATALK2, cpu0_portfn, at2intr); - netisr_register(NETISR_AARP, cpu0_portfn, aarpintr); + netisr_register(NETISR_ATALK1, cpu0_portfn, at1intr, 0); + netisr_register(NETISR_ATALK2, cpu0_portfn, at2intr, 0); + netisr_register(NETISR_AARP, cpu0_portfn, aarpintr, 0); } #if 0 Index: netproto/atm/atm_subr.c =================================================================== RCS file: /data/repos/df_cvs/src/sys/netproto/atm/atm_subr.c,v retrieving revision 1.21 diff -u -p -r1.21 atm_subr.c --- netproto/atm/atm_subr.c 23 May 2007 08:57:07 -0000 1.21 +++ netproto/atm/atm_subr.c 21 Sep 2008 07:07:28 -0000 @@ -112,7 +112,7 @@ atm_initialize(void) atm_init = 1; atm_intrq.ifq_maxlen = ATM_INTRQ_MAX; - netisr_register(NETISR_ATM, cpu0_portfn, atm_intr); + netisr_register(NETISR_ATM, cpu0_portfn, atm_intr, 0); /* * Initialize subsystems Index: netproto/ipx/ipx_input.c =================================================================== RCS file: /data/repos/df_cvs/src/sys/netproto/ipx/ipx_input.c,v retrieving revision 1.18 diff -u -p -r1.18 ipx_input.c --- netproto/ipx/ipx_input.c 7 Mar 2008 11:34:21 -0000 1.18 +++ netproto/ipx/ipx_input.c 21 Sep 2008 07:07:28 -0000 @@ -117,7 +117,7 @@ ipx_init(void) ipx_hostmask.sipx_addr.x_net = ipx_broadnet; ipx_hostmask.sipx_addr.x_host = ipx_broadhost; - netisr_register(NETISR_IPX, cpu0_portfn, ipxintr); + netisr_register(NETISR_IPX, cpu0_portfn, ipxintr, 0); } /* Index: netproto/mpls/mpls_input.c =================================================================== RCS file: /data/repos/df_cvs/src/sys/netproto/mpls/mpls_input.c,v retrieving revision 1.2 diff -u -p -r1.2 mpls_input.c --- netproto/mpls/mpls_input.c 5 Aug 2008 15:11:32 -0000 1.2 +++ netproto/mpls/mpls_input.c 21 Sep 2008 07:07:28 -0000 @@ -76,7 +76,7 @@ mpls_init(void) bzero(&mplsstat, sizeof(struct mpls_stats)); #endif - netisr_register(NETISR_MPLS, mpls_mport, mpls_input_handler); + netisr_register(NETISR_MPLS, mpls_mport, mpls_input_handler, 0); } static void Index: netproto/natm/natm.c =================================================================== RCS file: /data/repos/df_cvs/src/sys/netproto/natm/natm.c,v retrieving revision 1.29 diff -u -p -r1.29 natm.c --- netproto/natm/natm.c 14 May 2008 11:59:24 -0000 1.29 +++ netproto/natm/natm.c 21 Sep 2008 07:07:28 -0000 @@ -748,7 +748,7 @@ static void natmintr(struct netmsg *); static void netisr_natm_setup(void *dummy __unused) { - netisr_register(NETISR_NATM, cpu0_portfn, natmintr); + netisr_register(NETISR_NATM, cpu0_portfn, natmintr, 0); } SYSINIT(natm_setup, SI_BOOT2_KLD, SI_ORDER_ANY, netisr_natm_setup, NULL); #endif @@ -758,7 +758,7 @@ natm_init(void) { LIST_INIT(&natm_pcbs); - netisr_register(NETISR_NATM, cpu0_portfn, natmintr); + netisr_register(NETISR_NATM, cpu0_portfn, natmintr, 0); } /* Index: netproto/ns/ns_input.c =================================================================== RCS file: /data/repos/df_cvs/src/sys/netproto/ns/ns_input.c,v retrieving revision 1.21 diff -u -p -r1.21 ns_input.c --- netproto/ns/ns_input.c 7 Mar 2008 11:34:21 -0000 1.21 +++ netproto/ns/ns_input.c 21 Sep 2008 07:07:28 -0000 @@ -96,7 +96,7 @@ ns_init(void) ns_hostmask.sns_len = 12; ns_hostmask.sns_addr.x_net = ns_broadnet; ns_hostmask.sns_addr.x_host = ns_broadhost; - netisr_register(NETISR_NS, cpu0_portfn, nsintr); + netisr_register(NETISR_NS, cpu0_portfn, nsintr, 0); } /* Index: sys/protosw.h =================================================================== RCS file: /data/repos/df_cvs/src/sys/sys/protosw.h,v retrieving revision 1.22 diff -u -p -r1.22 protosw.h --- sys/protosw.h 17 Jun 2008 20:50:11 -0000 1.22 +++ sys/protosw.h 21 Sep 2008 07:07:29 -0000 @@ -127,6 +127,7 @@ struct protosw { #define PR_IMPLOPCL 0x20 /* implied open/close */ #define PR_LASTHDR 0x40 /* enforce ipsec policy; last header */ #define PR_ADDR_OPT 0x80 /* allow addresses during delivery */ +#define PR_MPSAFE 0x0100 /* protocal is MPSAFE */ /* * The arguments to usrreq are: @@ -391,6 +392,18 @@ void kpfctlinput2 (int, struct sockaddr struct protosw *pffindproto (int family, int protocol, int type); struct protosw *pffindtype (int family, int type); +#define PR_GET_MPLOCK(_pr) \ +do { \ + if (((_pr)->pr_flags & PR_MPSAFE) == 0) \ + get_mplock(); \ +} while (0) + +#define PR_REL_MPLOCK(_pr) \ +do { \ + if (((_pr)->pr_flags & PR_MPSAFE) == 0) \ + rel_mplock(); \ +} while (0) + #endif /* _KERNEL */ #endif /* _SYS_PROTOSW_H_ */