summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/net/if.c58
-rw-r--r--sys/net/if_ethersubr.c4
-rw-r--r--sys/net/if_loop.c48
-rw-r--r--sys/net/if_var.h4
-rw-r--r--sys/netinet/ip_mroute.c4
-rw-r--r--sys/netinet/ip_output.c4
-rw-r--r--sys/netinet6/ip6_mroute.c4
-rw-r--r--sys/netinet6/ip6_output.c4
-rw-r--r--sys/netinet6/mld6.c4
9 files changed, 74 insertions, 60 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 0b13189a026..d1b00acc173 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.373 2015/09/11 16:58:00 mpi Exp $ */
+/* $OpenBSD: if.c,v 1.374 2015/09/12 13:34:12 mpi Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -562,6 +562,62 @@ if_input(struct ifnet *ifp, struct mbuf_list *ml)
task_add(softnettq, &if_input_task);
}
+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
+ * addresses.
+ *
+ * if_input_local() is also called for SIMPLEX interfaces to
+ * duplicate packets for local use. But don't dup them to bpf.
+ */
+ if (ifp->if_flags & IFF_LOOPBACK) {
+ caddr_t if_bpf = ifp->if_bpf;
+
+ if (if_bpf)
+ bpf_mtap_af(if_bpf, af, m, BPF_DIRECTION_OUT);
+ }
+#endif
+ m->m_pkthdr.ph_ifidx = ifp->if_index;
+
+ ifp->if_opackets++;
+ ifp->if_obytes += m->m_pkthdr.len;
+
+ switch (af) {
+ case AF_INET:
+ ifq = &ipintrq;
+ break;
+#ifdef INET6
+ case AF_INET6:
+ ifq = &ip6intrq;
+ break;
+#endif /* INET6 */
+#ifdef MPLS
+ case AF_MPLS:
+ ifp->if_ipackets++;
+ ifp->if_ibytes += m->m_pkthdr.len;
+ mpls_input(ifp, m);
+ return (0);
+#endif /* MPLS */
+ default:
+ printf("%s: can't handle af%d\n", ifp->if_xname, af);
+ m_freem(m);
+ return (EAFNOSUPPORT);
+ }
+
+ if (niq_enqueue(ifq, m) != 0)
+ return (ENOBUFS);
+
+ ifp->if_ipackets++;
+ ifp->if_ibytes += m->m_pkthdr.len;
+
+ return (0);
+}
+
struct ifih {
struct srpl_entry ifih_next;
int (*ifih_input)(struct ifnet *, struct mbuf *,
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index d824a7cf706..fc592a3207c 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ethersubr.c,v 1.223 2015/09/10 16:41:30 mikeb Exp $ */
+/* $OpenBSD: if_ethersubr.c,v 1.224 2015/09/12 13:34:12 mpi Exp $ */
/* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */
/*
@@ -262,7 +262,7 @@ ether_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
/* XXX Should we feed-back an unencrypted IPsec packet ? */
if (mcopy)
- (void) looutput(ifp, mcopy, dst, rt);
+ if_input_local(ifp, mcopy, dst->sa_family);
M_PREPEND(m, sizeof(struct ether_header), M_DONTWAIT);
if (m == NULL)
diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c
index 7b2bae1005f..8caaf6a255a 100644
--- a/sys/net/if_loop.c
+++ b/sys/net/if_loop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_loop.c,v 1.70 2015/07/29 00:04:03 rzalamena Exp $ */
+/* $OpenBSD: if_loop.c,v 1.71 2015/09/12 13:34:12 mpi Exp $ */
/* $NetBSD: if_loop.c,v 1.15 1996/05/07 02:40:33 thorpej Exp $ */
/*
@@ -203,20 +203,8 @@ int
looutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
struct rtentry *rt)
{
- struct niqueue *ifq = NULL;
-
if ((m->m_flags & M_PKTHDR) == 0)
panic("looutput: no header mbuf");
-#if NBPFILTER > 0
- /*
- * only send packets to bpf if they are real loopback packets;
- * looutput() is also called for SIMPLEX interfaces to duplicate
- * packets for local use. But don't dup them to bpf.
- */
- if (ifp->if_bpf && (ifp->if_flags & IFF_LOOPBACK))
- bpf_mtap_af(ifp->if_bpf, dst->sa_family, m, BPF_DIRECTION_OUT);
-#endif
- m->m_pkthdr.ph_ifidx = ifp->if_index;
if (rt && rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)) {
m_freem(m);
@@ -224,39 +212,7 @@ looutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH);
}
- ifp->if_opackets++;
- ifp->if_obytes += m->m_pkthdr.len;
- switch (dst->sa_family) {
-
- case AF_INET:
- ifq = &ipintrq;
- break;
-#ifdef INET6
- case AF_INET6:
- ifq = &ip6intrq;
- break;
-#endif /* INET6 */
-#ifdef MPLS
- case AF_MPLS:
- ifp->if_ipackets++;
- ifp->if_ibytes += m->m_pkthdr.len;
- mpls_input(ifp, m);
- return (0);
-#endif /* MPLS */
- default:
- printf("%s: can't handle af%d\n", ifp->if_xname,
- dst->sa_family);
- m_freem(m);
- return (EAFNOSUPPORT);
- }
-
- if (niq_enqueue(ifq, m) != 0)
- return (ENOBUFS);
-
- ifp->if_ipackets++;
- ifp->if_ibytes += m->m_pkthdr.len;
-
- return (0);
+ return (if_input_local(ifp, m, dst->sa_family));
}
/* ARGSUSED */
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index 3b37ff2c714..3b4d545b42e 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_var.h,v 1.39 2015/09/10 18:11:05 dlg Exp $ */
+/* $OpenBSD: if_var.h,v 1.40 2015/09/12 13:34:12 mpi Exp $ */
/* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */
/*
@@ -405,6 +405,7 @@ extern struct ifnet *lo0ifp;
void if_start(struct ifnet *);
int if_enqueue(struct ifnet *, struct mbuf *);
void if_input(struct ifnet *, struct mbuf_list *);
+int if_input_local(struct ifnet *, struct mbuf *, sa_family_t);
void ether_ifattach(struct ifnet *);
void ether_ifdetach(struct ifnet *);
@@ -436,6 +437,7 @@ void loopattach(int);
int looutput(struct ifnet *,
struct mbuf *, struct sockaddr *, struct rtentry *);
void lortrequest(int, struct rtentry *);
+
void ifa_add(struct ifnet *, struct ifaddr *);
void ifa_del(struct ifnet *, struct ifaddr *);
void ifa_update_broadaddr(struct ifnet *, struct ifaddr *,
diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c
index 20c3fbedd8b..ab76452a2eb 100644
--- a/sys/netinet/ip_mroute.c
+++ b/sys/netinet/ip_mroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_mroute.c,v 1.81 2015/09/01 21:24:04 bluhm Exp $ */
+/* $OpenBSD: ip_mroute.c,v 1.82 2015/09/12 13:34:12 mpi Exp $ */
/* $NetBSD: ip_mroute.c,v 1.85 2004/04/26 01:31:57 matt Exp $ */
/*
@@ -2201,7 +2201,7 @@ pim_input(struct mbuf *m, ...)
reg_vif_num);
}
/* NB: vifp was collected above; can it change on us? */
- looutput(vifp, m, sintosa(&dst), NULL);
+ if_input_local(vifp, m, dst->sin_family);
/* prepare the register head to send to the mrouting daemon */
m = mcp;
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index 1fd63d8b22b..d33392c4d8e 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_output.c,v 1.294 2015/09/12 11:40:04 claudio Exp $ */
+/* $OpenBSD: ip_output.c,v 1.295 2015/09/12 13:34:12 mpi Exp $ */
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
/*
@@ -1679,7 +1679,7 @@ ip_mloopback(struct ifnet *ifp, struct mbuf *m, struct sockaddr_in *dst)
ip = mtod(copym, struct ip *);
ip->ip_sum = 0;
ip->ip_sum = in_cksum(copym, ip->ip_hl << 2);
- (void) looutput(ifp, copym, sintosa(dst), NULL);
+ if_input_local(ifp, copym, dst->sin_family);
}
}
diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c
index 6d5856f930c..c0a30cdbc75 100644
--- a/sys/netinet6/ip6_mroute.c
+++ b/sys/netinet6/ip6_mroute.c
@@ -1899,8 +1899,8 @@ pim6_input(struct mbuf **mp, int *offp, int proto)
}
#endif
- looutput(mif6table[reg_mif_num].m6_ifp, m,
- sin6tosa(&dst), NULL);
+ if_input_local(mif6table[reg_mif_num].m6_ifp, m,
+ dst->sin6_family);
/* prepare the register head to send to the mrouting daemon */
m = mcp;
diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c
index 80c27a46edd..af8ba3d0e10 100644
--- a/sys/netinet6/ip6_output.c
+++ b/sys/netinet6/ip6_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_output.c,v 1.185 2015/09/11 20:16:03 claudio Exp $ */
+/* $OpenBSD: ip6_output.c,v 1.186 2015/09/12 13:34:12 mpi Exp $ */
/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */
/*
@@ -3070,7 +3070,7 @@ ip6_mloopback(struct ifnet *ifp, struct mbuf *m, struct sockaddr_in6 *dst)
if (IN6_IS_SCOPE_EMBED(&ip6->ip6_dst))
ip6->ip6_dst.s6_addr16[1] = 0;
- (void)looutput(ifp, copym, sin6tosa(dst), NULL);
+ if_input_local(ifp, copym, dst->sin6_family);
}
/*
diff --git a/sys/netinet6/mld6.c b/sys/netinet6/mld6.c
index 0bca05f3e9d..d9aa23a6cb1 100644
--- a/sys/netinet6/mld6.c
+++ b/sys/netinet6/mld6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mld6.c,v 1.45 2015/09/11 08:17:06 claudio Exp $ */
+/* $OpenBSD: mld6.c,v 1.46 2015/09/12 13:34:12 mpi Exp $ */
/* $KAME: mld6.c,v 1.26 2001/02/16 14:50:35 itojun Exp $ */
/*
@@ -287,7 +287,7 @@ mld6_input(struct mbuf *m, int off)
* router, so discard reports sourced by me.
* Note that it is impossible to check IFF_LOOPBACK flag of
* ifp for this purpose, since ip6_mloopback pass the physical
- * interface to looutput.
+ * interface to if_input_local().
*/
if (m->m_flags & M_LOOP) /* XXX: grotty flag, but efficient */
break;