Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net RFC3032 conformance for Router Alert Label
details: https://anonhg.NetBSD.org/src/rev/bc2ebdec02e4
branches: trunk
changeset: 790848:bc2ebdec02e4
user: kefren <kefren%NetBSD.org@localhost>
date: Fri Oct 25 09:25:32 2013 +0000
description:
RFC3032 conformance for Router Alert Label
diffstat:
sys/net/if_mpls.c | 41 +++++++++++++++++++++++++++++++----------
1 files changed, 31 insertions(+), 10 deletions(-)
diffs (83 lines):
diff -r 262f465afc64 -r bc2ebdec02e4 sys/net/if_mpls.c
--- a/sys/net/if_mpls.c Fri Oct 25 08:51:55 2013 +0000
+++ b/sys/net/if_mpls.c Fri Oct 25 09:25:32 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_mpls.c,v 1.10 2013/07/23 11:11:55 kefren Exp $ */
+/* $NetBSD: if_mpls.c,v 1.11 2013/10/25 09:25:32 kefren Exp $ */
/*
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mpls.c,v 1.10 2013/07/23 11:11:55 kefren Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mpls.c,v 1.11 2013/10/25 09:25:32 kefren Exp $");
#include "opt_inet.h"
#include "opt_mpls.h"
@@ -66,6 +66,15 @@
#include "if_mpls.h"
+#define TRIM_LABEL do { \
+ m_adj(m, sizeof(union mpls_shim)); \
+ if (m->m_len < sizeof(union mpls_shim) && \
+ (m = m_pullup(m, sizeof(union mpls_shim))) == NULL) \
+ goto done; \
+ dst.smpls_addr.s_addr = ntohl(mtod(m, union mpls_shim *)->s_addr); \
+ } while (/* CONSTCOND */ 0)
+
+
void ifmplsattach(int);
static int mpls_clone_create(struct if_clone *, int);
@@ -308,6 +317,7 @@
struct rtentry *rt = NULL;
int error = ENOBUFS;
uint psize = sizeof(struct sockaddr_mpls);
+ bool push_back_alert = false;
if (m->m_len < sizeof(union mpls_shim) &&
(m = m_pullup(m, sizeof(union mpls_shim))) == NULL)
@@ -330,14 +340,15 @@
if (mpls_rfc4182 != 0)
while((dst.smpls_addr.shim.label == MPLS_LABEL_IPV4NULL ||
dst.smpls_addr.shim.label == MPLS_LABEL_IPV6NULL) &&
- __predict_false(dst.smpls_addr.shim.bos == 0)) {
- m_adj(m, sizeof(union mpls_shim));
- if (m->m_len < sizeof(union mpls_shim) &&
- (m = m_pullup(m, sizeof(union mpls_shim))) == NULL)
- goto done;
- dst.smpls_addr.s_addr =
- ntohl(mtod(m, union mpls_shim *)->s_addr);
- }
+ __predict_false(dst.smpls_addr.shim.bos == 0))
+ TRIM_LABEL;
+
+ /* RFC 3032 Section 2.1 Page 4 */
+ if (__predict_false(dst.smpls_addr.shim.label == MPLS_LABEL_RTALERT) &&
+ dst.smpls_addr.shim.bos == 0) {
+ TRIM_LABEL;
+ push_back_alert = true;
+ }
if (dst.smpls_addr.shim.label <= MPLS_LABEL_RESMAX) {
/* Don't swap reserved labels */
@@ -412,6 +423,16 @@
psize += sizeof(tshim);
}
+ if (__predict_false(push_back_alert == true)) {
+ /* re-add the router alert label */
+ memset(&tshim, 0, sizeof(tshim));
+ tshim.s_addr = MPLS_LABEL_RTALERT;
+ tshim.shim.bos = tshim.shim.exp = 0;
+ tshim.shim.ttl = mpls_defttl;
+ if ((m = mpls_prepend_shim(m, &tshim)) == NULL)
+ return ENOBUFS;
+ }
+
error = mpls_send_frame(m, rt->rt_ifp, rt);
done:
Home |
Main Index |
Thread Index |
Old Index