11# Patch by Daniel Gröber <dxld at darkboxed.org>
22# Source: https://bird.network.cz/pipermail/bird-users/2023-February/016705.html
33
4- diff --git a/proto/babel/babel.c b/proto/babel/babel.c
5- index 04613788..c030784a 100644
64--- a/proto/babel/babel.c
75+++ b/proto/babel/babel.c
86@@ -28,10 +28,12 @@
@@ -22,7 +20,7 @@ index 04613788..c030784a 100644
2220 *
2321 * Supported standards:
2422 * RFC 8966 - The Babel Routing Protocol
25- @@ -59,8 +61,8 @@ static inline int gt_mod64k(uint a, uint b)
23+ @@ -59,8 +61,8 @@ static inline int gt_mod64k(uint a, uint
2624 { return ge_mod64k(a, b) && a != b; }
2725
2826 static void babel_expire_requests(struct babel_proto *p, struct babel_entry *e);
@@ -44,7 +42,7 @@ index 04613788..c030784a 100644
4442 }
4543
4644 static void
47- @@ -192,9 +192,6 @@ babel_flush_route(struct babel_proto *p UNUSED, struct babel_route *r)
45+ @@ -192,9 +192,6 @@ babel_flush_route(struct babel_proto *p
4846 rem_node(NODE r);
4947 rem_node(&r->neigh_route);
5048
@@ -54,15 +52,15 @@ index 04613788..c030784a 100644
5452 sl_free(r);
5553 }
5654
57- @@ -210,6 +207,7 @@ babel_expire_route(struct babel_proto *p, struct babel_route *r)
55+ @@ -210,6 +207,7 @@ babel_expire_route(struct babel_proto *p
5856 {
5957 r->metric = r->advert_metric = BABEL_INFINITY;
6058 r->expires = current_time() + cf->hold_time;
6159+ babel_announce_rte(p, r->e, r);
6260 }
6361 else
6462 {
65- @@ -239,8 +237,6 @@ babel_expire_routes_(struct babel_proto *p, struct fib *rtable)
63+ @@ -239,8 +237,6 @@ babel_expire_routes_(struct babel_proto
6664 loop:
6765 FIB_ITERATE_START(rtable, &fit, struct babel_entry, e)
6866 {
@@ -106,7 +104,7 @@ index 04613788..c030784a 100644
106104 goto loop;
107105 }
108106
109- @@ -457,6 +442,8 @@ babel_get_neighbor(struct babel_iface *ifa, ip_addr addr)
107+ @@ -457,6 +442,8 @@ babel_get_neighbor(struct babel_iface *i
110108
111109 nbr = mb_allocz(ifa->pool, sizeof(struct babel_neighbor));
112110 nbr->ifa = ifa;
@@ -115,7 +113,7 @@ index 04613788..c030784a 100644
115113 nbr->addr = addr;
116114 nbr->rxcost = BABEL_INFINITY;
117115 nbr->txcost = BABEL_INFINITY;
118- @@ -484,6 +471,9 @@ babel_flush_neighbor(struct babel_proto *p, struct babel_neighbor *nbr)
116+ @@ -484,6 +471,9 @@ babel_flush_neighbor(struct babel_proto
119117 }
120118
121119 nbr->ifa = NULL;
@@ -125,7 +123,7 @@ index 04613788..c030784a 100644
125123 rem_node(NODE nbr);
126124 mb_free(nbr);
127125 }
128- @@ -663,11 +653,47 @@ done:
126+ @@ -663,12 +653,48 @@ done:
129127 WALK_LIST2(r, n, nbr->routes, neigh_route)
130128 {
131129 r->metric = babel_compute_metric(nbr, r->advert_metric);
@@ -135,7 +133,7 @@ index 04613788..c030784a 100644
135133 }
136134 }
137135
138- + /**
136+ /**
139137+ * This function handles announcing the special unreachable route we insert for
140138+ * a prefix whenever we have no more feasible routes available as per RFC8966
141139+ * section 3.5.4 as well as retracting it when such routes are available
@@ -171,9 +169,10 @@ index 04613788..c030784a 100644
171169+ rte_update2(c, e->n.addr, rte, p->p.main_source);
172170+}
173171+
174- /**
172+ + /**
175173 * babel_announce_rte - announce selected route to the core
176174 * @p: Babel protocol instance
175+ * @e: Babel route entry to announce
177176@@ -678,12 +704,11 @@ done:
178177 * the entry is valid and ours, the unreachable route is announced instead.
179178 */
@@ -189,7 +188,7 @@ index 04613788..c030784a 100644
189188 {
190189 rta a0 = {
191190 .source = RTS_BABEL,
192- @@ -727,122 +752,24 @@ babel_announce_rte(struct babel_proto *p, struct babel_entry *e)
191+ @@ -727,122 +752,24 @@ babel_announce_rte(struct babel_proto *p
193192 a0.nh.flags = RNF_ONLINK;
194193
195194 rta *a = rta_lookup(&a0);
@@ -324,7 +323,7 @@ index 04613788..c030784a 100644
324323 }
325324
326325 /*
327- @@ -1405,7 +1332,12 @@ babel_handle_update(union babel_msg *m, struct babel_iface *ifa)
326+ @@ -1405,7 +1332,12 @@ babel_handle_update(union babel_msg *m,
328327 /*
329328 * RFC 8966 3.8.2.2 - dealing with unfeasible updates. Generate a one-off
330329 * (not retransmitted) unicast seqno request to the originator of this update.
@@ -338,7 +337,7 @@ index 04613788..c030784a 100644
338337 */
339338 if (!feasible && s && (metric != BABEL_INFINITY) &&
340339 (!best || (r == best) || (metric < best->metric)))
341- @@ -1439,7 +1371,7 @@ babel_handle_update(union babel_msg *m, struct babel_iface *ifa)
340+ @@ -1439,7 +1371,7 @@ babel_handle_update(union babel_msg *m,
342341 e->updated = current_time();
343342 }
344343
@@ -365,7 +364,7 @@ index 04613788..c030784a 100644
365364 babel_dump_route(r);
366365 }
367366 }
368- @@ -2303,7 +2235,7 @@ babel_show_entries_(struct babel_proto *p, struct fib *rtable)
367+ @@ -2303,7 +2235,7 @@ babel_show_entries_(struct babel_proto *
369368
370369 FIB_WALK(rtable, struct babel_entry, e)
371370 {
@@ -374,7 +373,7 @@ index 04613788..c030784a 100644
374373 uint rts = 0, srcs = 0;
375374 node *n;
376375
377- @@ -2316,7 +2248,7 @@ babel_show_entries_(struct babel_proto *p, struct fib *rtable)
376+ @@ -2316,7 +2248,7 @@ babel_show_entries_(struct babel_proto *
378377 if (e->valid)
379378 cli_msg(-1025, "%-*N %-23lR %6u %5u %7u %7u", width,
380379 e->n.addr, e->router_id, e->metric, e->seqno, rts, srcs);
@@ -383,7 +382,7 @@ index 04613788..c030784a 100644
383382 cli_msg(-1025, "%-*N %-23lR %6u %5u %7u %7u", width,
384383 e->n.addr, r->router_id, r->metric, r->seqno, rts, srcs);
385384 else
386- @@ -2353,10 +2285,10 @@ babel_show_routes_(struct babel_proto *p, struct fib *rtable)
385+ @@ -2353,10 +2285,10 @@ babel_show_routes_(struct babel_proto *p
387386
388387 FIB_WALK(rtable, struct babel_entry, e)
389388 {
@@ -396,7 +395,7 @@ index 04613788..c030784a 100644
396395 btime time = r->expires ? r->expires - current_time() : 0;
397396 cli_msg(-1025, "%-*N %-25I %-10s %5u %c %5u %7t", width,
398397 e->n.addr, r->next_hop, r->neigh->ifa->ifname,
399- @@ -2428,8 +2360,9 @@ babel_preexport(struct channel *C, struct rte *new)
398+ @@ -2428,8 +2360,9 @@ babel_preexport(struct channel *C, struc
400399 }
401400
402401 /*
@@ -408,7 +407,7 @@ index 04613788..c030784a 100644
408407 */
409408 static void
410409 babel_rt_notify(struct proto *P, struct channel *c UNUSED, struct network *net,
411- @@ -2437,15 +2370,19 @@ babel_rt_notify(struct proto *P, struct channel *c UNUSED, struct network *net,
410+ @@ -2437,15 +2370,19 @@ babel_rt_notify(struct proto *P, struct
412411 {
413412 struct babel_proto *p = (void *) P;
414413 struct babel_entry *e;
@@ -429,7 +428,7 @@ index 04613788..c030784a 100644
429428 {
430429 rt_seqno = ea_find(new->attrs->eattrs, EA_BABEL_SEQNO)->u.data;
431430 eattr *e = ea_find(new->attrs->eattrs, EA_BABEL_ROUTER_ID);
432- @@ -2454,6 +2391,8 @@ babel_rt_notify(struct proto *P, struct channel *c UNUSED, struct network *net,
431+ @@ -2454,6 +2391,8 @@ babel_rt_notify(struct proto *P, struct
433432 }
434433 else
435434 {
@@ -438,7 +437,7 @@ index 04613788..c030784a 100644
438437 rt_seqno = p->update_seqno;
439438 rt_router_id = p->router_id;
440439 }
441- @@ -2467,6 +2406,27 @@ babel_rt_notify(struct proto *P, struct channel *c UNUSED, struct network *net,
440+ @@ -2467,6 +2406,27 @@ babel_rt_notify(struct proto *P, struct
442441
443442 e = babel_get_entry(p, net->n.addr);
444443
@@ -466,7 +465,7 @@ index 04613788..c030784a 100644
466465 /* Activate triggered updates */
467466 if ((e->valid != BABEL_ENTRY_VALID) ||
468467 (e->router_id != rt_router_id))
469- @@ -2488,8 +2448,26 @@ babel_rt_notify(struct proto *P, struct channel *c UNUSED, struct network *net,
468+ @@ -2488,8 +2448,26 @@ babel_rt_notify(struct proto *P, struct
470469 if (!e || e->valid != BABEL_ENTRY_VALID)
471470 return;
472471
@@ -501,8 +500,6 @@ index 04613788..c030784a 100644
501500
502501 p->log_pkt_tbf = (struct tbf){ .rate = 1, .burst = 5 };
503502
504- diff --git a/proto/babel/babel.h b/proto/babel/babel.h
505- index edde4cab..3868d7c4 100644
506503--- a/proto/babel/babel.h
507504+++ b/proto/babel/babel.h
508505@@ -25,6 +25,7 @@
@@ -529,4 +526,3 @@ index edde4cab..3868d7c4 100644
529526
530527 ip_addr addr;
531528 u16 rxcost; /* Sent in last IHU */
532- --
0 commit comments