diff options
author | Jan Moskyto Matejka <mq@ucw.cz> | 2016-05-06 15:48:35 +0200 |
---|---|---|
committer | Jan Moskyto Matejka <mq@ucw.cz> | 2016-12-22 13:01:06 +0100 |
commit | 4e276a8920ed0496836f002f144943ab42f120f6 (patch) | |
tree | b2d24394f036cbd825330e0087a7f9f4ca167174 /proto/bgp | |
parent | b7605d5c953902b461e5c9e87aa3dfa60ddce5bc (diff) |
Merged multipath and single-path data structures.
Dropped struct mpnh and mpnh_*()
Now struct nexthop exists, nexthop_*(), and also included struct nexthop
into struct rta.
Also converted RTD_DEVICE and RTD_ROUTER to RTD_UNICAST. If it is needed
to distinguish between these two cases, RTD_DEVICE is equivalent to
IPA_ZERO(a->nh.gw), RTD_ROUTER is then IPA_NONZERO(a->nh.gw).
From now on, we also explicitely want C99 compatible compiler. We assume
that this 20-year norm should be known almost everywhere.
Diffstat (limited to 'proto/bgp')
-rw-r--r-- | proto/bgp/attrs.c | 2 | ||||
-rw-r--r-- | proto/bgp/packets.c | 13 |
2 files changed, 8 insertions, 7 deletions
diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c index 52b56efa..11666f30 100644 --- a/proto/bgp/attrs.c +++ b/proto/bgp/attrs.c @@ -1462,7 +1462,7 @@ static inline int rte_resolvable(rte *rt) { int rd = rt->attrs->dest; - return (rd == RTD_ROUTER) || (rd == RTD_DEVICE) || (rd == RTD_MULTIPATH); + return (rd == RTD_UNICAST); } int diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c index 66561ee4..0baa84c9 100644 --- a/proto/bgp/packets.c +++ b/proto/bgp/packets.c @@ -699,9 +699,10 @@ bgp_apply_next_hop(struct bgp_parse_state *s, rta *a, ip_addr gw, ip_addr ll) if (!nbr || (nbr->scope == SCOPE_HOST)) WITHDRAW(BAD_NEXT_HOP); - a->dest = RTD_ROUTER; - a->gw = nbr->addr; - a->iface = nbr->iface; + a->dest = RTD_UNICAST; + a->nh.gw = nbr->addr; + a->nh.iface = nbr->iface; + a->nh.next = NULL; a->hostentry = NULL; a->igp_metric = 0; } @@ -749,7 +750,7 @@ bgp_use_gateway(struct bgp_export_state *s) return 0; /* We need valid global gateway */ - if ((ra->dest != RTD_ROUTER) || ipa_zero(ra->gw) || ipa_is_link_local(ra->gw)) + if ((ra->dest != RTD_UNICAST) || (ra->nh.next) || ipa_zero(ra->nh.gw) || ipa_is_link_local(ra->nh.gw)) return 0; /* Use it when exported to internal peers */ @@ -757,7 +758,7 @@ bgp_use_gateway(struct bgp_export_state *s) return 1; /* Use it when forwarded to single-hop BGP peer on on the same iface */ - return p->neigh && (p->neigh->iface == ra->iface); + return p->neigh && (p->neigh->iface == ra->nh.iface); } static void @@ -767,7 +768,7 @@ bgp_update_next_hop_ip(struct bgp_export_state *s, eattr *a, ea_list **to) { if (bgp_use_gateway(s)) { - ip_addr nh[1] = { s->route->attrs->gw }; + ip_addr nh[1] = { s->route->attrs->nh.gw }; bgp_set_attr_data(to, s->pool, BA_NEXT_HOP, 0, nh, 16); } else |