diff options
Diffstat (limited to 'sys/netmpls/mpls_output.c')
-rw-r--r-- | sys/netmpls/mpls_output.c | 25 |
1 files changed, 16 insertions, 9 deletions
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); |