summaryrefslogtreecommitdiff
path: root/nest
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2017-03-22 15:00:07 +0100
committerOndrej Zajicek (work) <santiago@crfreenet.org>2017-03-22 18:16:49 +0100
commit1e37e35c3ea88672c677ea7ac63fe0b9df609b0c (patch)
tree8400d1b28ae6d4d0146ad1573c7ebd3653152ace /nest
parentead7b8f498ddefc0b7373cbba78f9a7ba1dddaa9 (diff)
BGP: Support for MPLS labels and VPN SAFI
Basic support for SAFI 4 and 128 (MPLS labeled IP and VPN) for IPv4 and IPv6. Should work for route reflector, but does not properly handle originating routes with next hop self. Based on patches from Jan Matejka.
Diffstat (limited to 'nest')
-rw-r--r--nest/route.h10
-rw-r--r--nest/rt-table.c14
2 files changed, 13 insertions, 11 deletions
diff --git a/nest/route.h b/nest/route.h
index 546b04c4..d7d4df69 100644
--- a/nest/route.h
+++ b/nest/route.h
@@ -551,7 +551,15 @@ static inline rta * rta_cow(rta *r, linpool *lp) { return rta_is_cached(r) ? rta
void rta_dump(rta *);
void rta_dump_all(void);
void rta_show(struct cli *, rta *, ea_list *);
-void rta_set_recursive_next_hop(rtable *dep, rta *a, rtable *tab, ip_addr gw, ip_addr ll, mpls_label_stack *mls);
+
+struct hostentry * rt_get_hostentry(rtable *tab, ip_addr a, ip_addr ll, rtable *dep);
+void rta_apply_hostentry(rta *a, struct hostentry *he, mpls_label_stack *mls);
+
+static inline void
+rta_set_recursive_next_hop(rtable *dep, rta *a, rtable *tab, ip_addr gw, ip_addr ll, mpls_label_stack *mls)
+{
+ rta_apply_hostentry(a, rt_get_hostentry(tab, gw, ll, dep), mls);
+}
/*
* rta_set_recursive_next_hop() acquires hostentry from hostcache and fills
diff --git a/nest/rt-table.c b/nest/rt-table.c
index f8baf572..8be7520c 100644
--- a/nest/rt-table.c
+++ b/nest/rt-table.c
@@ -1766,7 +1766,7 @@ rta_next_hop_outdated(rta *a)
(!he->nexthop_linkable) || !nexthop_same(&(a->nh), &(he->src->nh));
}
-static inline void
+void
rta_apply_hostentry(rta *a, struct hostentry *he, mpls_label_stack *mls)
{
a->hostentry = he;
@@ -1794,7 +1794,7 @@ no_nexthop:
struct nexthop *nhp = NULL, *nhr = NULL;
int skip_nexthop = 0;
-
+
for (struct nexthop *nh = &(he->src->nh); nh; nh = nh->next)
{
if (skip_nexthop)
@@ -2475,7 +2475,7 @@ rt_update_hostcache(rtable *tab)
tab->hcu_scheduled = 0;
}
-static struct hostentry *
+struct hostentry *
rt_get_hostentry(rtable *tab, ip_addr a, ip_addr ll, rtable *dep)
{
struct hostentry *he;
@@ -2489,17 +2489,11 @@ rt_get_hostentry(rtable *tab, ip_addr a, ip_addr ll, rtable *dep)
if (ipa_equal(he->addr, a) && (he->tab == dep))
return he;
- he = hc_new_hostentry(hc, a, ll, dep, k);
+ he = hc_new_hostentry(hc, a, ipa_zero(ll) ? a : ll, dep, k);
rt_update_hostentry(tab, he);
return he;
}
-void
-rta_set_recursive_next_hop(rtable *dep, rta *a, rtable *tab, ip_addr gw, ip_addr ll, mpls_label_stack *mls)
-{
- rta_apply_hostentry(a, rt_get_hostentry(tab, gw, ipa_zero(ll) ? gw : ll, dep), mls);
-}
-
/*
* CLI commands