diff options
author | Michele Marchetto <michele@cvs.openbsd.org> | 2009-01-08 12:47:46 +0000 |
---|---|---|
committer | Michele Marchetto <michele@cvs.openbsd.org> | 2009-01-08 12:47:46 +0000 |
commit | 9f7c3133fa3ada0c6c2f725ce1bcc2006c244120 (patch) | |
tree | be7127edb0b27b212fbe39fb44aff27ff2868d97 /sys/netmpls | |
parent | f4ea0dc4cd832d8220a0e28e73e5b23280105bda (diff) |
Fix sockaddr_mpls structure.
Now it contains just the label as it must be.
This introduces a ugly hack in rtentry that will be removed
as soon as possible.
OK claudio@
Diffstat (limited to 'sys/netmpls')
-rw-r--r-- | sys/netmpls/mpls.h | 9 | ||||
-rw-r--r-- | sys/netmpls/mpls_input.c | 34 | ||||
-rw-r--r-- | sys/netmpls/mpls_output.c | 25 | ||||
-rw-r--r-- | sys/netmpls/mpls_proto.c | 4 | ||||
-rw-r--r-- | sys/netmpls/mpls_shim.c | 4 |
5 files changed, 43 insertions, 33 deletions
diff --git a/sys/netmpls/mpls.h b/sys/netmpls/mpls.h index 1553a538945..f89151248bb 100644 --- a/sys/netmpls/mpls.h +++ b/sys/netmpls/mpls.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mpls.h,v 1.15 2008/12/15 16:13:55 michele Exp $ */ +/* $OpenBSD: mpls.h,v 1.16 2009/01/08 12:47:45 michele Exp $ */ /* * Copyright (C) 1999, 2000 and 2001 AYAME Project, WIDE Project. @@ -50,6 +50,8 @@ struct shim_hdr { u_int32_t shim_label; /* 20 bit label, 4 bit exp & BoS, 8 bit TTL */ }; +#define MPLS_HDRLEN sizeof(struct shim_hdr) + /* * By byte-swapping the constants, we avoid ever having to byte-swap IP * addresses inside the kernel. Unfortunately, user-level programs rely @@ -87,8 +89,9 @@ struct shim_hdr { struct sockaddr_mpls { u_int8_t smpls_len; /* length */ u_int8_t smpls_family; /* AF_MPLS */ - u_int32_t smpls_out_label; /* outgoing MPLS label */ - u_int32_t smpls_in_label; /* MPLS label 20 bits*/ + u_int16_t smpls_pad0; + u_int32_t smpls_label; /* MPLS label */ + u_int32_t smpls_pad1[2]; }; #define MPLS_OP_POP RTF_PROTO1 diff --git a/sys/netmpls/mpls_input.c b/sys/netmpls/mpls_input.c index 5df12744427..9382aa6f9cb 100644 --- a/sys/netmpls/mpls_input.c +++ b/sys/netmpls/mpls_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpls_input.c,v 1.16 2008/12/15 16:13:55 michele Exp $ */ +/* $OpenBSD: mpls_input.c,v 1.17 2009/01/08 12:47:45 michele Exp $ */ /* * Copyright (c) 2008 Claudio Jeker <claudio@openbsd.org> @@ -70,7 +70,8 @@ mpls_input(struct mbuf *m) { struct ifnet *ifp = m->m_pkthdr.rcvif; struct sockaddr_mpls *smpls; - struct sockaddr_mpls sa_mpls; + struct sockaddr_mpls *newsmpls; + struct sockaddr_mpls sa_mpls, sa_outmpls; struct shim_hdr *shim; struct rtentry *rt = NULL; u_int8_t ttl; @@ -91,6 +92,11 @@ mpls_input(struct mbuf *m) if ((m = m_pullup(m, sizeof(*shim))) == NULL) return; + bzero(&sa_outmpls, sizeof(sa_outmpls)); + newsmpls = &sa_outmpls; + newsmpls->smpls_family = AF_MPLS; + newsmpls->smpls_len = sizeof(*smpls); + shim = mtod(m, struct shim_hdr *); #ifdef MPLS_DEBUG @@ -118,22 +124,22 @@ mpls_input(struct mbuf *m) smpls = &sa_mpls; smpls->smpls_family = AF_MPLS; smpls->smpls_len = sizeof(*smpls); - smpls->smpls_in_label = shim->shim_label & MPLS_LABEL_MASK; + smpls->smpls_label = shim->shim_label & MPLS_LABEL_MASK; #ifdef MPLS_DEBUG printf("smpls af %d len %d in_label %d in_ifindex %d\n", smpls->smpls_family, smpls->smpls_len, - MPLS_LABEL_GET(smpls->smpls_in_label), + MPLS_LABEL_GET(smpls->smpls_label), ifp->if_index); #endif - if (ntohl(smpls->smpls_in_label) < MPLS_LABEL_RESERVED_MAX) { + if (ntohl(smpls->smpls_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)) { + switch (ntohl(smpls->smpls_label)) { case MPLS_LABEL_IPV4NULL: if (hasbos) { @@ -165,13 +171,7 @@ mpls_input(struct mbuf *m) rt->rt_use++; smpls = satosmpls(rt_key(rt)); - -#ifdef MPLS_DEBUG - printf("route af %d len %d in_label %d in_ifindex %d\n", - smpls->smpls_family, smpls->smpls_len, - MPLS_LABEL_GET(smpls->smpls_in_label), - ifp->if_index); -#endif + newsmpls->smpls_label = rt->rt_mpls; switch (rt->rt_flags & (MPLS_OP_PUSH | MPLS_OP_POP | MPLS_OP_SWAP)){ @@ -192,10 +192,10 @@ mpls_input(struct mbuf *m) } break; case MPLS_OP_PUSH: - m = mpls_shim_push(m, smpls); + m = mpls_shim_push(m, newsmpls); break; case MPLS_OP_SWAP: - m = mpls_shim_swap(m, smpls); + m = mpls_shim_swap(m, newsmpls); break; default: m_freem(m); @@ -222,8 +222,8 @@ mpls_input(struct mbuf *m) #ifdef MPLS_DEBUG printf("MPLS: sending on %s outlabel %x dst af %d in %d out %d\n", ifp->if_xname, ntohl(shim->shim_label), smpls->smpls_family, - MPLS_LABEL_GET(smpls->smpls_in_label), - MPLS_LABEL_GET(smpls->smpls_out_label)); + MPLS_LABEL_GET(smpls->smpls_label), + MPLS_LABEL_GET(newsmpls->smpls_label)); #endif (*ifp->if_output)(ifp, m, smplstosa(smpls), rt); diff --git a/sys/netmpls/mpls_output.c b/sys/netmpls/mpls_output.c index 03591baa0e6..c8f16019444 100644 --- a/sys/netmpls/mpls_output.c +++ b/sys/netmpls/mpls_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpls_output.c,v 1.3 2008/12/15 16:13:55 michele Exp $ */ +/* $OpenBSD: mpls_output.c,v 1.4 2009/01/08 12:47:45 michele Exp $ */ /* * Copyright (c) 2008 Claudio Jeker <claudio@openbsd.org> @@ -38,7 +38,8 @@ mpls_output(struct mbuf *m) { struct ifnet *ifp = m->m_pkthdr.rcvif; struct sockaddr_mpls *smpls; - struct sockaddr_mpls sa_mpls; + struct sockaddr_mpls *newsmpls; + struct sockaddr_mpls sa_mpls, sa_outmpls; struct shim_hdr *shim; struct rtentry *rt = NULL; u_int32_t ttl; @@ -56,6 +57,11 @@ mpls_output(struct mbuf *m) if ((m = m_pullup(m, sizeof(*shim))) == NULL) return; + bzero(&sa_outmpls, sizeof(sa_outmpls)); + newsmpls = &sa_outmpls; + newsmpls->smpls_family = AF_MPLS; + newsmpls->smpls_len = sizeof(*smpls); + shim = mtod(m, struct shim_hdr *); /* extract TTL */ @@ -66,12 +72,12 @@ mpls_output(struct mbuf *m) smpls = &sa_mpls; smpls->smpls_family = AF_MPLS; smpls->smpls_len = sizeof(*smpls); - smpls->smpls_in_label = shim->shim_label & MPLS_LABEL_MASK; + smpls->smpls_label = shim->shim_label & MPLS_LABEL_MASK; #ifdef MPLS_DEBUG printf("smpls af %d len %d in_label %d in_ifindex %d\n", smpls->smpls_family, smpls->smpls_len, - MPLS_LABEL_GET(smpls->smpls_in_label), + MPLS_LABEL_GET(smpls->smpls_label), ifp->if_index); #endif @@ -88,11 +94,12 @@ mpls_output(struct mbuf *m) rt->rt_use++; smpls = satosmpls(rt_key(rt)); + newsmpls->smpls_label = rt->rt_mpls; #ifdef MPLS_DEBUG printf("route af %d len %d in_label %d in_ifindex %d\n", smpls->smpls_family, smpls->smpls_len, - MPLS_LABEL_GET(smpls->smpls_in_label), + MPLS_LABEL_GET(smpls->smpls_label), ifp->if_index); #endif @@ -109,10 +116,10 @@ mpls_output(struct mbuf *m) m = mpls_shim_pop(m); break; case MPLS_OP_PUSH: - m = mpls_shim_push(m, smpls); + m = mpls_shim_push(m, newsmpls); break; case MPLS_OP_SWAP: - m = mpls_shim_swap(m, smpls); + m = mpls_shim_swap(m, newsmpls); break; default: m_freem(m); @@ -139,8 +146,8 @@ mpls_output(struct mbuf *m) #ifdef MPLS_DEBUG printf("MPLS: sending on %s outlabel %x dst af %d in %d out %d\n", ifp->if_xname, ntohl(shim->shim_label), smpls->smpls_family, - MPLS_LABEL_GET(smpls->smpls_in_label), - MPLS_LABEL_GET(smpls->smpls_out_label)); + MPLS_LABEL_GET(smpls->smpls_label), + MPLS_LABEL_GET(smpls->smpls_label)); #endif (*ifp->if_output)(ifp, m, smplstosa(smpls), rt); diff --git a/sys/netmpls/mpls_proto.c b/sys/netmpls/mpls_proto.c index d2e987ca0df..a2ddb5979c2 100644 --- a/sys/netmpls/mpls_proto.c +++ b/sys/netmpls/mpls_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpls_proto.c,v 1.3 2008/12/15 16:13:55 michele Exp $ */ +/* $OpenBSD: mpls_proto.c,v 1.4 2009/01/08 12:47:45 michele Exp $ */ /* * Copyright (C) 1999, 2000 and 2001 AYAME Project, WIDE Project. @@ -71,6 +71,6 @@ struct domain mplsdomain = { mplssw, &mplssw[sizeof(mplssw)/sizeof(mplssw[0])], 0, rn_inithead, - offsetof(struct sockaddr_mpls, smpls_in_label) << 3, + offsetof(struct sockaddr_mpls, smpls_label) << 3, sizeof(struct sockaddr_mpls) }; diff --git a/sys/netmpls/mpls_shim.c b/sys/netmpls/mpls_shim.c index 4152dd07da2..32c27713236 100644 --- a/sys/netmpls/mpls_shim.c +++ b/sys/netmpls/mpls_shim.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpls_shim.c,v 1.4 2008/12/15 16:13:55 michele Exp $ */ +/* $OpenBSD: mpls_shim.c,v 1.5 2009/01/08 12:47:45 michele Exp $ */ /* * Copyright (C) 1999, 2000 and 2001 AYAME Project, WIDE Project. @@ -70,7 +70,7 @@ mpls_shim_swap(struct mbuf *m, struct sockaddr_mpls *smplsp) /* swap label */ shim->shim_label &= ~MPLS_LABEL_MASK; - shim->shim_label |= smplsp->smpls_out_label & MPLS_LABEL_MASK; + shim->shim_label |= smplsp->smpls_label & MPLS_LABEL_MASK; /* swap exp : XXX exp override */ { |