summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorMichele Marchetto <michele@cvs.openbsd.org>2009-01-08 12:47:46 +0000
committerMichele Marchetto <michele@cvs.openbsd.org>2009-01-08 12:47:46 +0000
commit9f7c3133fa3ada0c6c2f725ce1bcc2006c244120 (patch)
treebe7127edb0b27b212fbe39fb44aff27ff2868d97 /sys/net
parentf4ea0dc4cd832d8220a0e28e73e5b23280105bda (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/net')
-rw-r--r--sys/net/route.c17
-rw-r--r--sys/net/route.h6
-rw-r--r--sys/net/rtsock.c36
3 files changed, 55 insertions, 4 deletions
diff --git a/sys/net/route.c b/sys/net/route.c
index 3baafe32598..74c274cb772 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.100 2008/12/12 22:07:33 claudio Exp $ */
+/* $OpenBSD: route.c,v 1.101 2009/01/08 12:47:45 michele Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
@@ -121,6 +121,10 @@
#include <netinet/in.h>
#include <netinet/in_var.h>
+#ifdef MPLS
+#include <netmpls/mpls.h>
+#endif
+
#ifdef IPSEC
#include <netinet/ip_ipsp.h>
#include <net/if_enc.h>
@@ -723,6 +727,9 @@ rtrequest1(int req, struct rt_addrinfo *info, u_int8_t prio,
struct ifaddr *ifa;
struct sockaddr *ndst;
struct sockaddr_rtlabel *sa_rl;
+#ifdef MPLS
+ struct sockaddr_mpls *sa_mpls;
+#endif
#define senderr(x) { error = x ; goto bad; }
if ((rnh = rt_gettable(info->rti_info[RTAX_DST]->sa_family, tableid)) ==
@@ -859,6 +866,14 @@ makeroute:
rt->rt_labelid = rtlabel_name2id(sa_rl->sr_label);
}
+#ifdef MPLS
+ if (info->rti_info[RTAX_SRC] != NULL) {
+ sa_mpls = (struct sockaddr_mpls *)
+ info->rti_info[RTAX_SRC];
+ rt->rt_mpls = sa_mpls->smpls_label;
+ }
+#endif
+
ifa->ifa_refcnt++;
rt->rt_ifa = ifa;
rt->rt_ifp = ifa->ifa_ifp;
diff --git a/sys/net/route.h b/sys/net/route.h
index e6385e93100..3ce2f803fba 100644
--- a/sys/net/route.h
+++ b/sys/net/route.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.h,v 1.55 2008/12/12 22:07:33 claudio Exp $ */
+/* $OpenBSD: route.h,v 1.56 2009/01/08 12:47:45 michele Exp $ */
/* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */
/*
@@ -121,6 +121,10 @@ struct rtentry {
LIST_HEAD(, rttimer) rt_timer; /* queue of timeouts for misc funcs */
u_int16_t rt_labelid; /* route label ID */
u_int8_t rt_priority; /* routing priority to use */
+#ifdef MPLS
+ /* XXX: temporay hack, will be removed soon */
+ u_int32_t rt_mpls; /* MPLS outbound label */
+#endif
};
#define rt_use rt_rmx.rmx_pksent
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 60752027e7a..7d830e5e40c 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtsock.c,v 1.80 2009/01/03 15:31:03 claudio Exp $ */
+/* $OpenBSD: rtsock.c,v 1.81 2009/01/08 12:47:45 michele Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
@@ -183,6 +183,10 @@ route_output(struct mbuf *m, ...)
struct socket *so;
struct rawcb *rp = NULL;
struct sockaddr_rtlabel sa_rt;
+#ifdef MPLS
+ struct sockaddr_mpls sa_mpls;
+ struct sockaddr_mpls *psa_mpls;
+#endif
const char *label;
va_list ap;
u_int tableid;
@@ -421,7 +425,16 @@ report:
info.rti_info[RTAX_LABEL] =
(struct sockaddr *)&sa_rt;
}
-
+#ifdef MPLS
+ if (rt->rt_mpls) {
+ bzero(&sa_mpls, sizeof(sa_mpls));
+ sa_mpls.smpls_family = AF_MPLS;
+ sa_mpls.smpls_len = sizeof(sa_mpls);
+ sa_mpls.smpls_label = rt->rt_mpls;
+ info.rti_info[RTAX_SRC] =
+ (struct sockaddr *)&sa_mpls;
+ }
+#endif
ifpaddr = 0;
ifaaddr = 0;
if (rtm->rtm_addrs & (RTA_IFP | RTA_IFA) &&
@@ -509,6 +522,13 @@ report:
rt->rt_labelid =
rtlabel_name2id(rtlabel);
}
+#ifdef MPLS
+ if (info.rti_info[RTAX_SRC] != NULL) {
+ psa_mpls = (struct sockaddr_mpls *)
+ info.rti_info[RTAX_SRC];
+ rt->rt_mpls = psa_mpls->smpls_label;
+ }
+#endif
if_group_routechange(dst, netmask);
/* FALLTHROUGH */
case RTM_LOCK:
@@ -922,6 +942,9 @@ sysctl_dumpentry(struct radix_node *rn, void *v)
struct rtentry *rt = (struct rtentry *)rn;
int error = 0, size;
struct rt_addrinfo info;
+#ifdef MPLS
+ struct sockaddr_mpls sa_mpls;
+#endif
struct sockaddr_rtlabel sa_rt;
const char *label;
@@ -949,6 +972,15 @@ sysctl_dumpentry(struct radix_node *rn, void *v)
(struct sockaddr *)&sa_rt;
}
}
+#ifdef MPLS
+ if (rt->rt_mpls) {
+ bzero(&sa_mpls, sizeof(sa_mpls));
+ sa_mpls.smpls_family = AF_MPLS;
+ sa_mpls.smpls_len = sizeof(sa_mpls);
+ sa_mpls.smpls_label = rt->rt_mpls;
+ info.rti_info[RTAX_SRC] = (struct sockaddr *)&sa_mpls;
+ }
+#endif
size = rt_msg2(RTM_GET, RTM_VERSION, &info, NULL, w);
if (w->w_where && w->w_tmem && w->w_needed <= 0) {