diff options
author | Michele Marchetto <michele@cvs.openbsd.org> | 2009-04-18 10:45:48 +0000 |
---|---|---|
committer | Michele Marchetto <michele@cvs.openbsd.org> | 2009-04-18 10:45:48 +0000 |
commit | f930516e0d859884907275f3dfafbbbfd032c813 (patch) | |
tree | 5b3be628f5cdce793a33d0ebc553204b338366f5 | |
parent | 7528b6b31feb32538c41ad2f531028e756b82895 (diff) |
Make "route(8) change" aware of MPLS.
It is now possible to change routes' MPLS parameters via route change.
ok laurent@, ok and input claudio@
-rw-r--r-- | sys/net/rtsock.c | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 5999cbb1774..d0a9e3cf5cc 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.84 2009/02/03 16:42:54 michele Exp $ */ +/* $OpenBSD: rtsock.c,v 1.85 2009/04/18 10:45:47 michele Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -323,7 +323,7 @@ route_output(struct mbuf *m, ...) struct rawcb *rp = NULL; struct sockaddr_rtlabel sa_rt; #ifdef MPLS - struct sockaddr_mpls sa_mpls; + struct sockaddr_mpls sa_mpls, *psa_mpls; #endif const char *label; va_list ap; @@ -666,7 +666,45 @@ report: rt->rt_labelid = rtlabel_name2id(rtlabel); } +#ifdef MPLS + if (info.rti_info[RTAX_SRC] != NULL) { + struct rt_mpls *rt_mpls; + + psa_mpls = (struct sockaddr_mpls *) + info.rti_info[RTAX_SRC]; + + if (rt->rt_llinfo == NULL) { + rt->rt_llinfo = (caddr_t) + malloc(sizeof(struct rt_mpls), + M_TEMP, M_NOWAIT|M_ZERO); + } + if (rt->rt_llinfo == NULL) { + error = ENOMEM; + goto flush; + } + + rt_mpls = (struct rt_mpls *)rt->rt_llinfo; + if (psa_mpls != NULL) { + rt_mpls->mpls_label = + psa_mpls->smpls_label; + } + + rt_mpls->mpls_operation = info.rti_mpls; + + /* XXX: set experimental bits */ + + rt->rt_flags |= RTF_MPLS; + } else { + if (rt->rt_llinfo != NULL && + rt->rt_flags & RTF_MPLS) { + free(rt->rt_llinfo, M_TEMP); + rt->rt_llinfo = NULL; + + rt->rt_flags &= (~RTF_MPLS); + } + } +#endif if_group_routechange(dst, netmask); /* FALLTHROUGH */ case RTM_LOCK: |