From 3f9b99eed8cb819707ecac8b1cf3d4a747d087dc Mon Sep 17 00:00:00 2001 From: mpi Date: Tue, 30 May 2017 07:50:37 +0000 Subject: [PATCH] Introduce ipv{4,6}_input(), two wrappers around IP queues. This will help transitionning to an un-KERNEL_LOCK()ed IP forwarding path. Disucssed with bluhm@, ok claudio@ --- sys/dev/usb/if_umb.c | 12 +++++------- sys/net/if.c | 21 +++++++-------------- sys/net/if_ethersubr.c | 10 +++++----- sys/net/if_mpe.c | 6 +++--- sys/net/if_ppp.c | 8 +++----- sys/net/if_pppx.c | 10 +++------- sys/net/if_spppsubr.c | 27 ++++++++++----------------- sys/net/if_tun.c | 18 ++++++------------ sys/net/pipex.c | 19 +++---------------- sys/netinet/in.h | 5 +++-- sys/netinet/ip_divert.c | 6 ++++-- sys/netinet/ip_gre.c | 23 ++++++++++++++++------- sys/netinet/ip_input.c | 12 +++++++++--- sys/netinet/ip_ipip.c | 12 +++--------- sys/netinet/ip_var.h | 4 ++-- sys/netinet6/in6.h | 5 +++-- sys/netinet6/ip6_divert.c | 6 ++++-- sys/netinet6/ip6_input.c | 8 +++++++- sys/netmpls/mpls_input.c | 18 +++++++++++++++--- 19 files changed, 111 insertions(+), 119 deletions(-) diff --git a/sys/dev/usb/if_umb.c b/sys/dev/usb/if_umb.c index a7843ab0375..1fbf2ea9c15 100644 --- a/sys/dev/usb/if_umb.c +++ b/sys/dev/usb/if_umb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_umb.c,v 1.13 2017/05/18 14:48:27 bluhm Exp $ */ +/* $OpenBSD: if_umb.c,v 1.14 2017/05/30 07:50:37 mpi Exp $ */ /* * Copyright (c) 2016 genua mbH @@ -768,7 +768,6 @@ umb_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, int umb_input(struct ifnet *ifp, struct mbuf *m, void *cookie) { - struct niqueue *inq; uint8_t ipv; if ((ifp->if_flags & IFF_UP) == 0) { @@ -789,12 +788,12 @@ umb_input(struct ifnet *ifp, struct mbuf *m, void *cookie) ifp->if_ibytes += m->m_pkthdr.len; switch (ipv) { case 4: - inq = &ipintrq; - break; + ipv4_input(ifp, m); + return 1; #ifdef INET6 case 6: - inq = &ip6intrq; - break; + ipv6_input(ifp, m); + return 1; #endif /* INET6 */ default: ifp->if_ierrors++; @@ -803,7 +802,6 @@ umb_input(struct ifnet *ifp, struct mbuf *m, void *cookie) m_freem(m); return 1; } - niq_enqueue(inq, m); return 1; } diff --git a/sys/net/if.c b/sys/net/if.c index 29ec9034760..cdeb70a2d13 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.501 2017/05/30 06:42:13 mpi Exp $ */ +/* $OpenBSD: if.c,v 1.502 2017/05/30 07:50:37 mpi Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -734,8 +734,6 @@ if_input(struct ifnet *ifp, struct mbuf_list *ml) int if_input_local(struct ifnet *ifp, struct mbuf *m, sa_family_t af) { - struct niqueue *ifq = NULL; - #if NBPFILTER > 0 /* * Only send packets to bpf if they are destinated to local @@ -758,21 +756,22 @@ if_input_local(struct ifnet *ifp, struct mbuf *m, sa_family_t af) ifp->if_opackets++; ifp->if_obytes += m->m_pkthdr.len; + ifp->if_ipackets++; + ifp->if_ibytes += m->m_pkthdr.len; + switch (af) { case AF_INET: - ifq = &ipintrq; + ipv4_input(ifp, m); break; #ifdef INET6 case AF_INET6: - ifq = &ip6intrq; + ipv6_input(ifp, m); break; #endif /* INET6 */ #ifdef MPLS case AF_MPLS: - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; mpls_input(m); - return (0); + break; #endif /* MPLS */ default: printf("%s: can't handle af%d\n", ifp->if_xname, af); @@ -780,12 +779,6 @@ if_input_local(struct ifnet *ifp, struct mbuf *m, sa_family_t af) return (EAFNOSUPPORT); } - if (niq_enqueue(ifq, m) != 0) - return (ENOBUFS); - - ifp->if_ipackets++; - ifp->if_ibytes += m->m_pkthdr.len; - return (0); } diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index b1b49434b04..da6f90a1e9f 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ethersubr.c,v 1.244 2017/05/28 12:51:34 yasuoka Exp $ */ +/* $OpenBSD: if_ethersubr.c,v 1.245 2017/05/30 07:50:37 mpi Exp $ */ /* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */ /* @@ -374,8 +374,8 @@ ether_input(struct ifnet *ifp, struct mbuf *m, void *cookie) decapsulate: switch (etype) { case ETHERTYPE_IP: - inq = &ipintrq; - break; + ipv4_input(ifp, m); + return (1); case ETHERTYPE_ARP: if (ifp->if_flags & IFF_NOARP) @@ -394,8 +394,8 @@ decapsulate: * Schedule IPv6 software interrupt for incoming IPv6 packet. */ case ETHERTYPE_IPV6: - inq = &ip6intrq; - break; + ipv6_input(ifp, m); + return (1); #endif /* INET6 */ #if NPPPOE > 0 || defined(PIPEX) case ETHERTYPE_PPPOEDISC: diff --git a/sys/net/if_mpe.c b/sys/net/if_mpe.c index 5586a30f54a..e1c2db01829 100644 --- a/sys/net/if_mpe.c +++ b/sys/net/if_mpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_mpe.c,v 1.59 2017/05/04 15:00:24 bluhm Exp $ */ +/* $OpenBSD: if_mpe.c,v 1.60 2017/05/30 07:50:37 mpi Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard @@ -396,7 +396,7 @@ mpe_input(struct mbuf *m, struct ifnet *ifp, struct sockaddr_mpls *smpls, bpf_mtap_af(ifp->if_bpf, AF_INET, m, BPF_DIRECTION_IN); #endif - niq_enqueue(&ipintrq, m); + ipv4_input(ifp, m); } #ifdef INET6 @@ -428,6 +428,6 @@ mpe_input6(struct mbuf *m, struct ifnet *ifp, struct sockaddr_mpls *smpls, bpf_mtap_af(ifp->if_bpf, AF_INET6, m, BPF_DIRECTION_IN); #endif - niq_enqueue(&ip6intrq, m); + ipv6_input(ifp, m); } #endif /* INET6 */ diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c index 6911c1c97db..fb970b1302f 100644 --- a/sys/net/if_ppp.c +++ b/sys/net/if_ppp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ppp.c,v 1.107 2017/05/27 18:39:17 mpi Exp $ */ +/* $OpenBSD: if_ppp.c,v 1.108 2017/05/30 07:50:37 mpi Exp $ */ /* $NetBSD: if_ppp.c,v 1.39 1997/05/17 21:11:59 christos Exp $ */ /* @@ -1396,10 +1396,8 @@ ppp_inproc(struct ppp_softc *sc, struct mbuf *m) m->m_data += PPP_HDRLEN; m->m_len -= PPP_HDRLEN; - if (niq_enqueue(&ipintrq, m) != 0) - rv = 0; /* failure */ - else - rv = 1; /* ipintrq success */ + ipv4_input(ifp, m); + rv = 1; break; default: diff --git a/sys/net/if_pppx.c b/sys/net/if_pppx.c index 92f9b775e85..1bb9e45dc2f 100644 --- a/sys/net/if_pppx.c +++ b/sys/net/if_pppx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pppx.c,v 1.60 2017/05/28 18:43:51 yasuoka Exp $ */ +/* $OpenBSD: if_pppx.c,v 1.61 2017/05/30 07:50:37 mpi Exp $ */ /* * Copyright (c) 2010 Claudio Jeker @@ -318,7 +318,6 @@ pppxwrite(dev_t dev, struct uio *uio, int ioflag) struct pppx_if *pxi; uint32_t proto; struct mbuf *top, **mp, *m; - struct niqueue *ifq; int tlen; int error = 0; size_t mlen; @@ -396,11 +395,11 @@ pppxwrite(dev_t dev, struct uio *uio, int ioflag) switch (proto) { case AF_INET: - ifq = &ipintrq; + ipv4_input(&pxi->pxi_if, top); break; #ifdef INET6 case AF_INET6: - ifq = &ip6intrq; + ipv6_input(&pxi->pxi_if, top); break; #endif default: @@ -408,9 +407,6 @@ pppxwrite(dev_t dev, struct uio *uio, int ioflag) return (EAFNOSUPPORT); } - if (niq_enqueue(ifq, top) != 0) - return (ENOBUFS); - return (error); } diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c index bc9e30fbd41..c3ad8882d7c 100644 --- a/sys/net/if_spppsubr.c +++ b/sys/net/if_spppsubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_spppsubr.c,v 1.163 2017/04/14 15:11:31 bluhm Exp $ */ +/* $OpenBSD: if_spppsubr.c,v 1.164 2017/05/30 07:50:37 mpi Exp $ */ /* * Synchronous PPP link level subroutines. * @@ -58,8 +58,6 @@ #include #include #include -#include -#include #ifdef INET6 #include @@ -417,7 +415,6 @@ void sppp_input(struct ifnet *ifp, struct mbuf *m) { struct ppp_header ht; - struct niqueue *inq = NULL; struct sppp *sp = (struct sppp *)ifp; struct timeval tv; int debug = ifp->if_flags & IFF_DEBUG; @@ -438,7 +435,6 @@ sppp_input(struct ifnet *ifp, struct mbuf *m) SPP_ARGS(ifp), m->m_pkthdr.len); drop: m_freem (m); - dropped: ++ifp->if_ierrors; ++ifp->if_iqdrops; return; @@ -503,8 +499,11 @@ sppp_input(struct ifnet *ifp, struct mbuf *m) return; case PPP_IP: if (sp->state[IDX_IPCP] == STATE_OPENED) { - inq = &ipintrq; sp->pp_last_activity = tv.tv_sec; + if (ifp->if_flags & IFF_UP) { + ipv4_input(ifp, m); + return; + } } break; #ifdef INET6 @@ -515,8 +514,11 @@ sppp_input(struct ifnet *ifp, struct mbuf *m) return; case PPP_IPV6: if (sp->state[IDX_IPV6CP] == STATE_OPENED) { - inq = &ip6intrq; sp->pp_last_activity = tv.tv_sec; + if (ifp->if_flags & IFF_UP) { + ipv6_input(ifp, m); + return; + } } break; #endif @@ -533,16 +535,7 @@ sppp_input(struct ifnet *ifp, struct mbuf *m) goto drop; } - if (! (ifp->if_flags & IFF_UP) || ! inq) - goto drop; - - if (niq_enqueue(inq, m) != 0) { - /* Queue overflow. */ - if (debug) - log(LOG_DEBUG, SPP_FMT "protocol queue overflow\n", - SPP_ARGS(ifp)); - goto dropped; - } + goto drop; } /* diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index e60427f267c..48981038698 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tun.c,v 1.174 2017/05/27 06:44:14 mpi Exp $ */ +/* $OpenBSD: if_tun.c,v 1.175 2017/05/30 07:50:37 mpi Exp $ */ /* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */ /* @@ -835,7 +835,6 @@ int tun_dev_write(struct tun_softc *tp, struct uio *uio, int ioflag) { struct ifnet *ifp; - struct niqueue *ifq; u_int32_t *th; struct mbuf *top, **mp, *m; int error = 0, tlen; @@ -928,13 +927,16 @@ tun_dev_write(struct tun_softc *tp, struct uio *uio, int ioflag) top->m_pkthdr.ph_rtableid = ifp->if_rdomain; top->m_pkthdr.ph_ifidx = ifp->if_index; + ifp->if_ipackets++; + ifp->if_ibytes += top->m_pkthdr.len; + switch (ntohl(*th)) { case AF_INET: - ifq = &ipintrq; + ipv4_input(ifp, top); break; #ifdef INET6 case AF_INET6: - ifq = &ip6intrq; + ipv6_input(ifp, top); break; #endif default: @@ -942,14 +944,6 @@ tun_dev_write(struct tun_softc *tp, struct uio *uio, int ioflag) return (EAFNOSUPPORT); } - if (niq_enqueue(ifq, top) != 0) { - ifp->if_collisions++; - return (ENOBUFS); - } - - ifp->if_ipackets++; - ifp->if_ibytes += top->m_pkthdr.len; - return (error); } diff --git a/sys/net/pipex.c b/sys/net/pipex.c index 505165ceff2..00508517f7a 100644 --- a/sys/net/pipex.c +++ b/sys/net/pipex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pipex.c,v 1.100 2017/05/28 20:48:29 yasuoka Exp $ */ +/* $OpenBSD: pipex.c,v 1.101 2017/05/30 07:50:37 mpi Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. @@ -1096,20 +1096,15 @@ pipex_ip_input(struct mbuf *m0, struct pipex_session *session) bpf_mtap_af(ifp->if_bpf, AF_INET, m0, BPF_DIRECTION_IN); #endif - if (niq_enqueue(&ipintrq, m0) != 0) { - ifp->if_collisions++; - goto dropped; - } - ifp->if_ipackets++; ifp->if_ibytes += len; session->stat.ipackets++; session->stat.ibytes += len; + ipv4_input(ifp, m0); return; drop: m_freem(m0); -dropped: session->stat.ierrors++; } @@ -1147,19 +1142,11 @@ pipex_ip6_input(struct mbuf *m0, struct pipex_session *session) bpf_mtap_af(ifp->if_bpf, AF_INET6, m0, BPF_DIRECTION_IN); #endif - if (niq_enqueue(&ip6intrq, m0) != 0) { - ifp->if_collisions++; - goto dropped; - } - ifp->if_ipackets++; ifp->if_ibytes += len; session->stat.ipackets++; session->stat.ibytes += len; - - return; -dropped: - session->stat.ierrors++; + ipv6_input(ifp, m0); } #endif diff --git a/sys/netinet/in.h b/sys/netinet/in.h index aae85fc430a..8d59a6a3e8c 100644 --- a/sys/netinet/in.h +++ b/sys/netinet/in.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in.h,v 1.122 2017/05/04 15:00:24 bluhm Exp $ */ +/* $OpenBSD: in.h,v 1.123 2017/05/30 07:50:37 mpi Exp $ */ /* $NetBSD: in.h,v 1.20 1996/02/13 23:41:47 christos Exp $ */ /* @@ -800,7 +800,6 @@ __END_DECLS #ifdef _KERNEL extern int inetctlerrmap[]; -extern struct niqueue ipintrq; /* ip packet input queue */ extern struct in_addr zeroin_addr; struct mbuf; @@ -809,6 +808,8 @@ struct sockaddr_in; struct ifaddr; struct in_ifaddr; +void ipv4_input(struct ifnet *, struct mbuf *); + int in_broadcast(struct in_addr, u_int); int in_canforward(struct in_addr); int in_cksum(struct mbuf *, int); diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 1f95bd5d935..28ba9d7fc6a 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_divert.c,v 1.46 2017/04/05 13:35:18 deraadt Exp $ */ +/* $OpenBSD: ip_divert.c,v 1.47 2017/05/30 07:50:37 mpi Exp $ */ /* * Copyright (c) 2009 Michele Marchetto @@ -134,6 +134,7 @@ divert_output(struct inpcb *inp, struct mbuf *m, struct mbuf *nam, if (dir == PF_IN) { ipaddr.sin_addr = sin->sin_addr; + /* XXXSMP ifa_ifwithaddr() is not safe. */ ifa = ifa_ifwithaddr(sintosa(&ipaddr), m->m_pkthdr.ph_rtableid); if (ifa == NULL) { error = EADDRNOTAVAIL; @@ -150,7 +151,8 @@ divert_output(struct inpcb *inp, struct mbuf *m, struct mbuf *nam, ip->ip_sum = in_cksum(m, off); in_proto_cksum_out(m, NULL); - niq_enqueue(&ipintrq, m); + /* XXXSMP ``ifa'' is not reference counted. */ + ipv4_input(ifa->ifa_ifp, m); } else { error = ip_output(m, NULL, &inp->inp_route, IP_ALLOWBROADCAST | IP_RAWOUTPUT, NULL, NULL, 0); diff --git a/sys/netinet/ip_gre.c b/sys/netinet/ip_gre.c index 27573c63b07..49119644209 100644 --- a/sys/netinet/ip_gre.c +++ b/sys/netinet/ip_gre.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_gre.c,v 1.64 2017/05/04 17:58:46 bluhm Exp $ */ +/* $OpenBSD: ip_gre.c,v 1.65 2017/05/30 07:50:37 mpi Exp $ */ /* $NetBSD: ip_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */ /* @@ -93,7 +93,6 @@ int gre_input2(struct mbuf *m, int hlen, int proto) { struct greip *gip; - struct niqueue *ifq; struct gre_softc *sc; u_short flags; u_int af; @@ -160,13 +159,11 @@ gre_input2(struct mbuf *m, int hlen, int proto) */ if (gre_wccp == 2) hlen += 4; - case ETHERTYPE_IP: /* shouldn't need a schednetisr(), as */ - ifq = &ipintrq; /* we are in ip_input */ + case ETHERTYPE_IP: af = AF_INET; break; #ifdef INET6 case ETHERTYPE_IPV6: - ifq = &ip6intrq; af = AF_INET6; break; #endif @@ -205,7 +202,19 @@ gre_input2(struct mbuf *m, int hlen, int proto) pf_pkt_addr_changed(m); #endif - niq_enqueue(ifq, m); + switch (af) { + case AF_INET: + ipv4_input(&sc->sc_if, m); + break; +#ifdef INET6 + case AF_INET6: + ipv6_input(&sc->sc_if, m); + break; +#endif + default: + return (0); + } + return (1); /* packet is done, no further processing needed */ } @@ -334,7 +343,7 @@ gre_mobile_input(struct mbuf **mp, int *offp, int proto, int af) pf_pkt_addr_changed(m); #endif - niq_enqueue(&ipintrq, m); + ipv4_input(&sc->sc_if, m); return IPPROTO_DONE; } diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 7eeb83b07c9..65c9402684f 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_input.c,v 1.307 2017/05/29 14:36:22 mpi Exp $ */ +/* $OpenBSD: ip_input.c,v 1.308 2017/05/30 07:50:37 mpi Exp $ */ /* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */ /* @@ -207,6 +207,12 @@ ip_init(void) mq_init(&ipsend_mq, 64, IPL_SOFTNET); } +void +ipv4_input(struct ifnet *ifp, struct mbuf *m) +{ + niq_enqueue(&ipintrq, m); +} + void ipintr(void) { @@ -221,7 +227,7 @@ ipintr(void) if ((m->m_flags & M_PKTHDR) == 0) panic("ipintr no HDR"); #endif - ipv4_input(m); + ip_input(m); } } @@ -231,7 +237,7 @@ ipintr(void) * Checksum and byte swap header. Process options. Forward or deliver. */ void -ipv4_input(struct mbuf *m) +ip_input(struct mbuf *m) { struct ifnet *ifp; struct rtentry *rt = NULL; diff --git a/sys/netinet/ip_ipip.c b/sys/netinet/ip_ipip.c index fadb0594478..41fc0d0ddd6 100644 --- a/sys/netinet/ip_ipip.c +++ b/sys/netinet/ip_ipip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ipip.c,v 1.81 2017/05/28 13:59:05 bluhm Exp $ */ +/* $OpenBSD: ip_ipip.c,v 1.82 2017/05/30 07:50:37 mpi Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -122,7 +122,6 @@ ipip_input_gif(struct mbuf **mp, int *offp, int proto, int oaf, struct mbuf *m = *mp; struct sockaddr_in *sin; struct ifnet *ifp; - struct niqueue *ifq = NULL; struct ip *ip; #ifdef INET6 struct sockaddr_in6 *sin6; @@ -319,22 +318,17 @@ ipip_input_gif(struct mbuf **mp, int *offp, int proto, int oaf, switch (proto) { case IPPROTO_IPV4: - ifq = &ipintrq; + ipv4_input(ifp, m); break; #ifdef INET6 case IPPROTO_IPV6: - ifq = &ip6intrq; + ipv6_input(ifp, m); break; #endif default: panic("%s: should never reach here", __func__); } - if (niq_enqueue(ifq, m) != 0) { - ipipstat_inc(ipips_qfull); - DPRINTF(("%s: packet dropped because of full queue\n", - __func__)); - } return IPPROTO_DONE; } diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h index ff7d599289d..5bda4828dfe 100644 --- a/sys/netinet/ip_var.h +++ b/sys/netinet/ip_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_var.h,v 1.76 2017/05/28 09:25:51 bluhm Exp $ */ +/* $OpenBSD: ip_var.h,v 1.77 2017/05/30 07:50:37 mpi Exp $ */ /* $NetBSD: ip_var.h,v 1.16 1996/02/13 23:43:20 christos Exp $ */ /* @@ -248,7 +248,7 @@ int ip_sysctl(int *, u_int, void *, size_t *, void *, size_t); void ip_savecontrol(struct inpcb *, struct mbuf **, struct ip *, struct mbuf *); void ipintr(void); -void ipv4_input(struct mbuf *); +void ip_input(struct mbuf *); void ip_deliver(struct mbuf **, int *, int, int); void ip_forward(struct mbuf *, struct ifnet *, struct rtentry *, int); int rip_ctloutput(int, struct socket *, int, int, struct mbuf *); diff --git a/sys/netinet6/in6.h b/sys/netinet6/in6.h index 53ac30ddc48..b62cfccf2bd 100644 --- a/sys/netinet6/in6.h +++ b/sys/netinet6/in6.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in6.h,v 1.94 2017/05/04 15:00:24 bluhm Exp $ */ +/* $OpenBSD: in6.h,v 1.95 2017/05/30 07:50:37 mpi Exp $ */ /* $KAME: in6.h,v 1.83 2001/03/29 02:55:07 jinmei Exp $ */ /* @@ -405,7 +405,6 @@ typedef __socklen_t socklen_t; /* length type for network syscalls */ #ifdef _KERNEL extern u_char inet6ctlerrmap[]; -extern struct niqueue ip6intrq; /* IP6 packet input queue */ extern struct in6_addr zeroin6_addr; struct mbuf; @@ -713,6 +712,8 @@ ifatoia6(struct ifaddr *ifa) __BEGIN_DECLS struct cmsghdr; +void ipv6_input(struct ifnet *, struct mbuf *); + extern int inet6_opt_init(void *, socklen_t); extern int inet6_opt_append(void *, socklen_t, int, u_int8_t, socklen_t, u_int8_t, void **); diff --git a/sys/netinet6/ip6_divert.c b/sys/netinet6/ip6_divert.c index 386c4e8cff1..ea0b0000652 100644 --- a/sys/netinet6/ip6_divert.c +++ b/sys/netinet6/ip6_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_divert.c,v 1.46 2017/03/13 20:18:21 claudio Exp $ */ +/* $OpenBSD: ip6_divert.c,v 1.47 2017/05/30 07:50:37 mpi Exp $ */ /* * Copyright (c) 2009 Michele Marchetto @@ -139,6 +139,7 @@ divert6_output(struct inpcb *inp, struct mbuf *m, struct mbuf *nam, if (dir == PF_IN) { ip6addr.sin6_addr = sin6->sin6_addr; + /* XXXSMP ``ifa'' is not reference counted. */ ifa = ifa_ifwithaddr(sin6tosa(&ip6addr), m->m_pkthdr.ph_rtableid); if (ifa == NULL) { @@ -154,7 +155,8 @@ divert6_output(struct inpcb *inp, struct mbuf *m, struct mbuf *nam, */ in6_proto_cksum_out(m, NULL); - niq_enqueue(&ip6intrq, m); /* return error on q full? */ + /* XXXSMP ``ifa'' is not reference counted. */ + ipv6_input(ifa->ifa_ifp, m); } else { error = ip6_output(m, NULL, &inp->inp_route6, IP_ALLOWBROADCAST | IP_RAWOUTPUT, NULL, NULL); diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c index 183d7807e81..b0c7b162471 100644 --- a/sys/netinet6/ip6_input.c +++ b/sys/netinet6/ip6_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_input.c,v 1.191 2017/05/29 14:36:22 mpi Exp $ */ +/* $OpenBSD: ip6_input.c,v 1.192 2017/05/30 07:50:37 mpi Exp $ */ /* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */ /* @@ -160,6 +160,12 @@ ip6_init(void) ip6counters = counters_alloc(ip6s_ncounters); } +void +ipv6_input(struct ifnet *ifp, struct mbuf *m) +{ + niq_enqueue(&ip6intrq, m); +} + /* * IP6 input interrupt handling. Just pass the packet to ip6_input. */ diff --git a/sys/netmpls/mpls_input.c b/sys/netmpls/mpls_input.c index 8dabe8a2c1e..19b61377296 100644 --- a/sys/netmpls/mpls_input.c +++ b/sys/netmpls/mpls_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpls_input.c,v 1.59 2017/03/02 03:09:50 renato Exp $ */ +/* $OpenBSD: mpls_input.c,v 1.60 2017/05/30 07:50:37 mpi Exp $ */ /* * Copyright (c) 2008 Claudio Jeker @@ -121,14 +121,26 @@ mpls_input(struct mbuf *m) do_v4: if (mpls_ip_adjttl(m, ttl)) return; - niq_enqueue(&ipintrq, m); + ifp = if_get(m->m_pkthdr.ph_ifidx); + if (ifp == NULL) { + m_freem(m); + return; + } + ipv4_input(ifp, m); + if_put(ifp); return; #ifdef INET6 case MPLS_LABEL_IPV6NULL: do_v6: if (mpls_ip6_adjttl(m, ttl)) return; - niq_enqueue(&ip6intrq, m); + ifp = if_get(m->m_pkthdr.ph_ifidx); + if (ifp == NULL) { + m_freem(m); + return; + } + ipv6_input(ifp, m); + if_put(ifp); return; #endif /* INET6 */ case MPLS_LABEL_IMPLNULL: -- 2.20.1