summaryrefslogtreecommitdiff
path: root/proto/babel/babel.c
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2022-05-30 17:36:36 +0200
committerMaria Matejka <mq@ucw.cz>2022-05-30 17:37:08 +0200
commit1493695c6ba2b169523f7c2097fac8e8343352fe (patch)
tree0a0e5296b7b53d79a99aa3ebf254c124e1373414 /proto/babel/babel.c
parent7b0c89a47fa1f63248ceaa1e9c1b3948dd29a68d (diff)
parentf15f2fcee7eeb5a100bd204a0e67018e25953420 (diff)
Merge commit 'f15f2fcee7eeb5a100bd204a0e67018e25953420' into haugesund
Diffstat (limited to 'proto/babel/babel.c')
-rw-r--r--proto/babel/babel.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/proto/babel/babel.c b/proto/babel/babel.c
index be75694f..f3456369 100644
--- a/proto/babel/babel.c
+++ b/proto/babel/babel.c
@@ -643,15 +643,34 @@ babel_announce_rte(struct babel_proto *p, struct babel_entry *e)
if (r)
{
+ struct nexthop_adata nhad = {
+ .nh = {
+ .gw = r->next_hop,
+ .iface = r->neigh->ifa->iface,
+ },
+ .ad = {
+ .length = sizeof nhad - sizeof nhad.ad,
+ },
+ };
+
+ /*
+ * If we cannot find a reachable neighbour, set the entry to be onlink. This
+ * makes it possible to, e.g., assign /32 addresses on a mesh interface and
+ * have routing work.
+ */
+ if (!neigh_find(&p->p, r->next_hop, r->neigh->ifa->iface, 0))
+ nhad.nh.flags = RNF_ONLINK;
+
struct {
ea_list l;
- eattr a[6];
+ eattr a[7];
} eattrs = {
.l.count = ARRAY_SIZE(eattrs.a),
.a = {
EA_LITERAL_EMBEDDED(&ea_gen_preference, 0, c->preference),
EA_LITERAL_STORE_ADATA(&ea_gen_from, 0, &r->neigh->addr, sizeof(r->neigh->addr)),
EA_LITERAL_EMBEDDED(&ea_gen_source, 0, RTS_BABEL),
+ EA_LITERAL_STORE_ADATA(&ea_gen_nexthop, 0, nhad.ad.data, nhad.ad.length),
EA_LITERAL_EMBEDDED(&ea_babel_metric, 0, r->metric),
EA_LITERAL_STORE_ADATA(&ea_babel_router_id, 0, &r->router_id, sizeof(r->router_id)),
EA_LITERAL_EMBEDDED(&ea_babel_seqno, 0, r->seqno),
@@ -660,19 +679,9 @@ babel_announce_rte(struct babel_proto *p, struct babel_entry *e)
rta a0 = {
.dest = RTD_UNICAST,
- .nh.gw = r->next_hop,
- .nh.iface = r->neigh->ifa->iface,
.eattrs = &eattrs.l,
};
- /*
- * If we cannot find a reachable neighbour, set the entry to be onlink. This
- * makes it possible to, e.g., assign /32 addresses on a mesh interface and
- * have routing work.
- */
- if (!neigh_find(&p->p, r->next_hop, r->neigh->ifa->iface, 0))
- a0.nh.flags = RNF_ONLINK;
-
rte e0 = {
.attrs = &a0,
.src = p->p.main_source,