summaryrefslogtreecommitdiff
path: root/proto/rip/rip.c
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2022-06-08 15:31:28 +0200
committerMaria Matejka <mq@ucw.cz>2022-06-08 15:31:28 +0200
commit4364ee9b6f3764c971ab111bf7dc87477fd7272c (patch)
tree7659db681e5df6bee24eb580d02ab286d5855ee5 /proto/rip/rip.c
parentcae5979871ee7aa341334f8b1af6bafc60ee9692 (diff)
parent938742decc6e1d6d3a0375dd012b75172e747bbc (diff)
Merge commit '938742decc6e1d6d3a0375dd012b75172e747bbc' into haugesund
Diffstat (limited to 'proto/rip/rip.c')
-rw-r--r--proto/rip/rip.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/proto/rip/rip.c b/proto/rip/rip.c
index cc8b57eb..d6edac14 100644
--- a/proto/rip/rip.c
+++ b/proto/rip/rip.c
@@ -151,8 +151,6 @@ rip_announce_rte(struct rip_proto *p, struct rip_entry *en)
if (rt)
{
/* Update */
- rta a0 = {};
-
struct {
ea_list l;
eattr a[3];
@@ -164,7 +162,8 @@ rip_announce_rte(struct rip_proto *p, struct rip_entry *en)
EA_LITERAL_EMBEDDED(&ea_rip_metric, 0, rt->metric),
},
};
- a0.eattrs = &ea_block.l;
+
+ ea_list *ea = &ea_block.l;
u16 rt_tag = rt->tag;
struct iface *rt_from = NULL;
@@ -203,7 +202,7 @@ rip_announce_rte(struct rip_proto *p, struct rip_entry *en)
nhad->ad.length = ((void *) nh - (void *) nhad->ad.data);
- ea_set_attr(&a0.eattrs,
+ ea_set_attr(&ea,
EA_LITERAL_DIRECT_ADATA(&ea_gen_nexthop, 0,
&(nexthop_sort(nhad, tmp_linpool)->ad)));
}
@@ -217,22 +216,22 @@ rip_announce_rte(struct rip_proto *p, struct rip_entry *en)
.nh.iface = rt->from->ifa->iface,
};
- ea_set_attr_data(&a0.eattrs, &ea_gen_nexthop, 0,
+ ea_set_attr_data(&ea, &ea_gen_nexthop, 0,
&nhad.ad.data, sizeof nhad - sizeof nhad.ad);
- ea_set_attr_data(&a0.eattrs, &ea_gen_from, 0, &rt->from->nbr->addr, sizeof(ip_addr));
+ ea_set_attr_data(&ea, &ea_gen_from, 0, &rt->from->nbr->addr, sizeof(ip_addr));
}
- ea_set_attr_u32(&a0.eattrs, &ea_rip_tag, 0, rt_tag);
+ ea_set_attr_u32(&ea, &ea_rip_tag, 0, rt_tag);
struct rip_iface_adata riad = {
.ad = { .length = sizeof(struct rip_iface_adata) - sizeof(struct adata) },
.iface = rt_from,
};
- ea_set_attr(&a0.eattrs,
+ ea_set_attr(&ea,
EA_LITERAL_DIRECT_ADATA(&ea_rip_from, 0, &riad.ad));
rte e0 = {
- .attrs = &a0,
+ .attrs = ea,
.src = p->p.main_source,
};
@@ -344,9 +343,9 @@ rip_rt_notify(struct proto *P, struct channel *ch UNUSED, const net_addr *net, s
if (new)
{
/* Update */
- u32 rt_tag = ea_get_int(new->attrs->eattrs, &ea_rip_tag, 0);
- u32 rt_metric = ea_get_int(new->attrs->eattrs, &ea_rip_metric, 1);
- const eattr *rie = ea_find(new->attrs->eattrs, &ea_rip_from);
+ u32 rt_tag = ea_get_int(new->attrs, &ea_rip_tag, 0);
+ u32 rt_metric = ea_get_int(new->attrs, &ea_rip_metric, 1);
+ const eattr *rie = ea_find(new->attrs, &ea_rip_from);
struct iface *rt_from = rie ? ((struct rip_iface_adata *) rie->u.ptr)->iface : NULL;
if (rt_metric > p->infinity)
@@ -380,7 +379,7 @@ rip_rt_notify(struct proto *P, struct channel *ch UNUSED, const net_addr *net, s
en->tag = rt_tag;
en->from = (new->src->proto == P) ? rt_from : NULL;
- eattr *nhea = ea_find(new->attrs->eattrs, &ea_gen_nexthop);
+ eattr *nhea = ea_find(new->attrs, &ea_gen_nexthop);
if (nhea)
{
struct nexthop_adata *nhad = (struct nexthop_adata *) nhea->u.ptr;
@@ -1119,8 +1118,8 @@ rip_rte_better(struct rte *new, struct rte *old)
ASSERT_DIE(new->src == old->src);
struct rip_proto *p = (struct rip_proto *) new->src->proto;
- u32 new_metric = ea_get_int(new->attrs->eattrs, &ea_rip_metric, p->infinity);
- u32 old_metric = ea_get_int(old->attrs->eattrs, &ea_rip_metric, p->infinity);
+ u32 new_metric = ea_get_int(new->attrs, &ea_rip_metric, p->infinity);
+ u32 old_metric = ea_get_int(old->attrs, &ea_rip_metric, p->infinity);
return new_metric < old_metric;
}
@@ -1128,7 +1127,7 @@ rip_rte_better(struct rte *new, struct rte *old)
static u32
rip_rte_igp_metric(const rte *rt)
{
- return ea_get_int(rt->attrs->eattrs, &ea_rip_metric, IGP_METRIC_UNKNOWN);
+ return ea_get_int(rt->attrs, &ea_rip_metric, IGP_METRIC_UNKNOWN);
}
static void
@@ -1229,8 +1228,8 @@ static void
rip_get_route_info(rte *rte, byte *buf)
{
struct rip_proto *p = (struct rip_proto *) rte->src->proto;
- u32 rt_metric = ea_get_int(rte->attrs->eattrs, &ea_rip_metric, p->infinity);
- u32 rt_tag = ea_get_int(rte->attrs->eattrs, &ea_rip_tag, 0);
+ u32 rt_metric = ea_get_int(rte->attrs, &ea_rip_metric, p->infinity);
+ u32 rt_tag = ea_get_int(rte->attrs, &ea_rip_tag, 0);
buf += bsprintf(buf, " (%d/%d)", rt_get_preference(rte), rt_metric);