summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMichele Marchetto <michele@cvs.openbsd.org>2008-10-14 20:43:34 +0000
committerMichele Marchetto <michele@cvs.openbsd.org>2008-10-14 20:43:34 +0000
commit9c7f701201d27ef2d5880d01479515e3abbcc287 (patch)
tree0f62659741261c12b6be76bd8c4b37ce5772c752 /sys
parent842c943d0b9533fb5f723d2e8d941739ee0898a8 (diff)
Now mpls_input() handles ipv4 and ipv6 explicit null labels.
Added mpe_input6 to manage also ipv6 packets insted of just ipv4 ones. OK claudio@ laurent@
Diffstat (limited to 'sys')
-rw-r--r--sys/net/if_mpe.c30
-rw-r--r--sys/netmpls/mpls.h4
-rw-r--r--sys/netmpls/mpls_input.c29
3 files changed, 56 insertions, 7 deletions
diff --git a/sys/net/if_mpe.c b/sys/net/if_mpe.c
index 524a94fbaee..892f20cdb1f 100644
--- a/sys/net/if_mpe.c
+++ b/sys/net/if_mpe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_mpe.c,v 1.9 2008/05/08 09:52:36 pyr Exp $ */
+/* $OpenBSD: if_mpe.c,v 1.10 2008/10/14 20:43:33 michele Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@spootnik.org>
@@ -153,8 +153,8 @@ mpestart(struct ifnet *ifp)
return;
#if NBPFILTER > 0
- if (ifp->if_bpf)
- bpf_mtap_af(ifp->if_bpf, AF_INET, m, BPF_DIRECTION_OUT);
+ if (ifp->if_bpf)
+ bpf_mtap_af(ifp->if_bpf, AF_INET, m, BPF_DIRECTION_OUT);
#endif
ifm = ifp->if_softc;
shim.shim_label = ifm->sc_shim.shim_label;
@@ -284,7 +284,7 @@ mpe_input(struct mbuf *m, struct ifnet *ifp, struct sockaddr_mpls *smpls,
/* label -> AF lookup */
#if NBPFILTER > 0
- if (ifp->if_bpf)
+ if (ifp && ifp->if_bpf)
bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_OUT);
#endif
s = splnet();
@@ -295,3 +295,25 @@ mpe_input(struct mbuf *m, struct ifnet *ifp, struct sockaddr_mpls *smpls,
schednetisr(NETISR_IP);
splx(s);
}
+
+void
+mpe_input6(struct mbuf *m, struct ifnet *ifp, struct sockaddr_mpls *smpls,
+ u_int32_t ttl)
+{
+ int s;
+
+ /* fixup ttl */
+ /* label -> AF lookup */
+
+#if NBPFILTER > 0
+ if (ifp && ifp->if_bpf)
+ bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_OUT);
+#endif
+ s = splnet();
+ /*
+ * assume we only get fed ipv4 packets for now.
+ */
+ IF_ENQUEUE(&ip6intrq, m);
+ schednetisr(NETISR_IPV6);
+ splx(s);
+}
diff --git a/sys/netmpls/mpls.h b/sys/netmpls/mpls.h
index 8858864d74b..0ad5fe11457 100644
--- a/sys/netmpls/mpls.h
+++ b/sys/netmpls/mpls.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mpls.h,v 1.11 2008/05/23 16:03:03 thib Exp $ */
+/* $OpenBSD: mpls.h,v 1.12 2008/10/14 20:43:33 michele Exp $ */
/*
* Copyright (C) 1999, 2000 and 2001 AYAME Project, WIDE Project.
@@ -152,6 +152,8 @@ struct mpe_softc {
void mpe_input(struct mbuf *, struct ifnet *, struct sockaddr_mpls *,
u_int32_t);
+void mpe_input6(struct mbuf *, struct ifnet *, struct sockaddr_mpls *,
+ u_int32_t);
extern int mpls_raw_usrreq(struct socket *, int, struct mbuf *,
struct mbuf *, struct mbuf *, struct proc *);
diff --git a/sys/netmpls/mpls_input.c b/sys/netmpls/mpls_input.c
index e95c19db693..39ff4c621b6 100644
--- a/sys/netmpls/mpls_input.c
+++ b/sys/netmpls/mpls_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mpls_input.c,v 1.13 2008/05/23 16:06:29 thib Exp $ */
+/* $OpenBSD: mpls_input.c,v 1.14 2008/10/14 20:43:33 michele Exp $ */
/*
* Copyright (c) 2008 Claudio Jeker <claudio@openbsd.org>
@@ -128,7 +128,32 @@ mpls_input(struct mbuf *m)
smpls->smpls_in_ifindex);
#endif
- rt = rtalloc1(smplstosa(smpls),1, 0);
+ if (ntohl(smpls->smpls_in_label) < MPLS_LABEL_RESERVED_MAX) {
+
+ hasbos = MPLS_BOS_ISSET(shim->shim_label);
+ m = mpls_shim_pop(m);
+ shim = mtod(m, struct shim_hdr *);
+
+ switch (ntohl(smpls->smpls_in_label)) {
+
+ case MPLS_LABEL_IPV4NULL:
+ if (hasbos) {
+ mpe_input(m, NULL, smpls, ttl);
+ goto done;
+ } else
+ continue;
+
+ case MPLS_LABEL_IPV6NULL:
+ if (hasbos) {
+ mpe_input6(m, NULL, smpls, ttl);
+ goto done;
+ } else
+ continue;
+ }
+ /* Other cases are not handled for now */
+ }
+
+ rt = rtalloc1(smplstosa(smpls), 1, 0);
if (rt == NULL) {
/* no entry for this label */