-/* $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
int
umb_input(struct ifnet *ifp, struct mbuf *m, void *cookie)
{
- struct niqueue *inq;
uint8_t ipv;
if ((ifp->if_flags & IFF_UP) == 0) {
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++;
m_freem(m);
return 1;
}
- niq_enqueue(inq, m);
return 1;
}
-/* $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 $ */
/*
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
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);
return (EAFNOSUPPORT);
}
- if (niq_enqueue(ifq, m) != 0)
- return (ENOBUFS);
-
- ifp->if_ipackets++;
- ifp->if_ibytes += m->m_pkthdr.len;
-
return (0);
}
-/* $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 $ */
/*
decapsulate:
switch (etype) {
case ETHERTYPE_IP:
- inq = &ipintrq;
- break;
+ ipv4_input(ifp, m);
+ return (1);
case ETHERTYPE_ARP:
if (ifp->if_flags & IFF_NOARP)
* 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:
-/* $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>
bpf_mtap_af(ifp->if_bpf, AF_INET, m, BPF_DIRECTION_IN);
#endif
- niq_enqueue(&ipintrq, m);
+ ipv4_input(ifp, m);
}
#ifdef INET6
bpf_mtap_af(ifp->if_bpf, AF_INET6, m, BPF_DIRECTION_IN);
#endif
- niq_enqueue(&ip6intrq, m);
+ ipv6_input(ifp, m);
}
#endif /* INET6 */
-/* $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 $ */
/*
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:
-/* $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>
struct pppx_if *pxi;
uint32_t proto;
struct mbuf *top, **mp, *m;
- struct niqueue *ifq;
int tlen;
int error = 0;
size_t mlen;
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:
return (EAFNOSUPPORT);
}
- if (niq_enqueue(ifq, top) != 0)
- return (ENOBUFS);
-
return (error);
}
-/* $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.
*
#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>
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;
SPP_ARGS(ifp), m->m_pkthdr.len);
drop:
m_freem (m);
- dropped:
++ifp->if_ierrors;
++ifp->if_iqdrops;
return;
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
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
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;
}
/*
-/* $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 $ */
/*
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;
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:
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);
}
-/* $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.
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++;
}
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
-/* $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 $ */
/*
#ifdef _KERNEL
extern int inetctlerrmap[];
-extern struct niqueue ipintrq; /* ip packet input queue */
extern struct in_addr zeroin_addr;
struct mbuf;
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);
-/* $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 <michele@openbsd.org>
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;
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);
-/* $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 $ */
/*
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;
*/
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
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 */
}
pf_pkt_addr_changed(m);
#endif
- niq_enqueue(&ipintrq, m);
+ ipv4_input(&sc->sc_if, m);
return IPPROTO_DONE;
}
-/* $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 $ */
/*
mq_init(&ipsend_mq, 64, IPL_SOFTNET);
}
+void
+ipv4_input(struct ifnet *ifp, struct mbuf *m)
+{
+ niq_enqueue(&ipintrq, m);
+}
+
void
ipintr(void)
{
if ((m->m_flags & M_PKTHDR) == 0)
panic("ipintr no HDR");
#endif
- ipv4_input(m);
+ ip_input(m);
}
}
* 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;
-/* $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
struct mbuf *m = *mp;
struct sockaddr_in *sin;
struct ifnet *ifp;
- struct niqueue *ifq = NULL;
struct ip *ip;
#ifdef INET6
struct sockaddr_in6 *sin6;
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;
}
-/* $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 $ */
/*
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 *);
-/* $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 $ */
/*
#ifdef _KERNEL
extern u_char inet6ctlerrmap[];
-extern struct niqueue ip6intrq; /* IP6 packet input queue */
extern struct in6_addr zeroin6_addr;
struct mbuf;
__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 **);
-/* $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 <michele@openbsd.org>
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) {
*/
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);
-/* $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 $ */
/*
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.
*/
-/* $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 <claudio@openbsd.org>
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: