diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2017-05-30 07:50:38 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2017-05-30 07:50:38 +0000 |
commit | f821aa1c0a176765b922adda04e7978033816e93 (patch) | |
tree | f61129b0cc445f31adf461d1eabbc0438b2fe8aa /sys/net | |
parent | def6d835df8ef7186f4a9e02f0911bbfe939e469 (diff) |
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@
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if.c | 21 | ||||
-rw-r--r-- | sys/net/if_ethersubr.c | 10 | ||||
-rw-r--r-- | sys/net/if_mpe.c | 6 | ||||
-rw-r--r-- | sys/net/if_ppp.c | 8 | ||||
-rw-r--r-- | sys/net/if_pppx.c | 10 | ||||
-rw-r--r-- | sys/net/if_spppsubr.c | 27 | ||||
-rw-r--r-- | sys/net/if_tun.c | 18 | ||||
-rw-r--r-- | sys/net/pipex.c | 19 |
8 files changed, 40 insertions, 79 deletions
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 <pyr@spootnik.org> @@ -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 <claudio@openbsd.org> @@ -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 <netinet/in.h> #include <netinet/in_var.h> #include <netinet/ip.h> -#include <netinet/tcp.h> -#include <netinet/if_ether.h> #ifdef INET6 #include <netinet6/in6_ifattach.h> @@ -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 |