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/rip | |
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/rip')
-rw-r--r-- | proto/rip/rip.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/proto/rip/rip.c b/proto/rip/rip.c index d87a078c..8b09330c 100644 --- a/proto/rip/rip.c +++ b/proto/rip/rip.c @@ -158,10 +158,10 @@ rip_announce_rte(struct rip_proto *p, struct rip_entry *en) while (rt2 && !rip_valid_rte(rt2)) rt2 = rt2->next; + a0.dest = RTD_UNICAST; if (p->ecmp && rt2) { /* ECMP route */ - struct mpnh *nhs = NULL; int num = 0; for (rt = en->routes; rt && (num < p->ecmp); rt = rt->next) @@ -169,33 +169,34 @@ rip_announce_rte(struct rip_proto *p, struct rip_entry *en) if (!rip_valid_rte(rt)) continue; - struct mpnh *nh = alloca(sizeof(struct mpnh)); + struct nexthop *nh = (a0.nh.next ? &(a0.nh) : alloca(sizeof(struct nexthop))); + nh->gw = rt->next_hop; nh->iface = rt->from->nbr->iface; nh->weight = rt->from->ifa->cf->ecmp_weight; - mpnh_insert(&nhs, nh); + + if (a0.nh.next) + nexthop_insert(&(a0.nh), nh); + num++; if (rt->tag != rt_tag) rt_tag = 0; } - - a0.dest = RTD_MULTIPATH; - a0.nexthops = nhs; } else { /* Unipath route */ - a0.dest = RTD_ROUTER; - a0.gw = rt->next_hop; - a0.iface = rt->from->nbr->iface; + a0.nh.next = NULL; + a0.nh.gw = rt->next_hop; + a0.nh.iface = rt->from->nbr->iface; a0.from = rt->from->nbr->addr; } rta *a = rta_lookup(&a0); rte *e = rte_get_temp(a); - e->u.rip.from = a0.iface; + e->u.rip.from = a0.nh.iface; e->u.rip.metric = rt_metric; e->u.rip.tag = rt_tag; @@ -345,8 +346,8 @@ rip_rt_notify(struct proto *P, struct channel *ch UNUSED, struct network *net, s en->metric = rt_metric; en->tag = rt_tag; en->from = (new->attrs->src->proto == P) ? new->u.rip.from : NULL; - en->iface = new->attrs->iface; - en->next_hop = new->attrs->gw; + en->iface = new->attrs->nh.iface; + en->next_hop = new->attrs->nh.gw; } else { |