]> git.ipfire.org Git - thirdparty/bird.git/blame - proto/static/static.c
Filter: macro for recursive interpretation of instructions
[thirdparty/bird.git] / proto / static / static.c
CommitLineData
a1bf6440
MM
1/*
2 * BIRD -- Static Route Generator
3 *
d272fe22 4 * (c) 1998--2000 Martin Mares <mj@ucw.cz>
a1bf6440
MM
5 *
6 * Can be freely distributed and used under the terms of the GNU GPL.
7 */
8
3b31c538
MM
9/**
10 * DOC: Static
11 *
7126cadf
OZ
12 * The Static protocol is implemented in a straightforward way. It keeps a list
13 * of static routes. Routes of dest RTD_UNICAST have associated sticky node in
14 * the neighbor cache to be notified about gaining or losing the neighbor and
15 * about interface-related events (e.g. link down). They may also have a BFD
16 * request if associated with a BFD session. When a route is notified,
17 * static_decide() is used to see whether the route activeness is changed. In
18 * such case, the route is marked as dirty and scheduled to be announced or
19 * withdrawn, which is done asynchronously from event hook. Routes of other
20 * types (e.g. black holes) are announced all the time.
3b31c538 21 *
7126cadf
OZ
22 * Multipath routes are a bit tricky. To represent additional next hops, dummy
23 * static_route nodes are used, which are chained using @mp_next field and link
24 * to the master node by @mp_head field. Each next hop has a separate neighbor
25 * entry and an activeness state, but the master node is used for most purposes.
26 * Note that most functions DO NOT accept dummy nodes as arguments.
9852f810 27 *
3b31c538
MM
28 * The only other thing worth mentioning is that when asked for reconfiguration,
29 * Static not only compares the two configurations, but it also calculates
7126cadf
OZ
30 * difference between the lists of static routes and it just inserts the newly
31 * added routes, removes the obsolete ones and reannounces changed ones.
3b31c538
MM
32 */
33
6b9fa320 34#undef LOCAL_DEBUG
a1bf6440 35
7126cadf
OZ
36#include <stdlib.h>
37
a1bf6440
MM
38#include "nest/bird.h"
39#include "nest/iface.h"
40#include "nest/protocol.h"
41#include "nest/route.h"
feed8226 42#include "nest/cli.h"
a1bf6440 43#include "conf/conf.h"
1321e12a 44#include "filter/filter.h"
feed8226 45#include "lib/string.h"
9852f810 46#include "lib/alloca.h"
a1bf6440
MM
47
48#include "static.h"
49
1321e12a
OZ
50static linpool *static_lp;
51
f6bd2066 52static void
7126cadf 53static_announce_rte(struct static_proto *p, struct static_route *r)
f6bd2066 54{
7126cadf
OZ
55 rta *a = allocz(RTA_MAX_SIZE);
56 a->src = p->p.main_source;
57 a->source = RTS_STATIC;
58 a->scope = SCOPE_UNIVERSE;
59 a->dest = r->dest;
f2010f9c 60
4e276a89 61 if (r->dest == RTD_UNICAST)
7126cadf
OZ
62 {
63 struct static_route *r2;
64 struct nexthop *nhs = NULL;
65
66 for (r2 = r; r2; r2 = r2->mp_next)
9852f810 67 {
7126cadf
OZ
68 if (!r2->active)
69 continue;
4e276a89 70
7126cadf
OZ
71 struct nexthop *nh = allocz(NEXTHOP_MAX_SIZE);
72 nh->gw = r2->via;
73 nh->iface = r2->neigh->iface;
a1f5e514 74 nh->flags = r2->onlink ? RNF_ONLINK : 0;
7126cadf 75 nh->weight = r2->weight;
3c744164
JMM
76 if (r2->mls)
77 {
78 nh->labels = r2->mls->len;
79 memcpy(nh->label, r2->mls->stack, r2->mls->len * sizeof(u32));
80 }
9852f810 81
7126cadf
OZ
82 nexthop_insert(&nhs, nh);
83 }
f2010f9c 84
7126cadf
OZ
85 if (!nhs)
86 goto withdraw;
62e64905 87
7126cadf
OZ
88 nexthop_link(a, nhs);
89 }
62e64905 90
4116db18 91 if (r->dest == RTDX_RECURSIVE)
ffb38dfb
OZ
92 {
93 rtable *tab = ipa_is_ip4(r->via) ? p->igp_table_ip4 : p->igp_table_ip6;
94 rta_set_recursive_next_hop(p->p.main_channel->table, a, tab, r->via, IPA_NONE, r->mls);
95 }
4116db18 96
7126cadf
OZ
97 /* Already announced */
98 if (r->state == SRS_CLEAN)
99 return;
1321e12a 100
7126cadf
OZ
101 /* We skip rta_lookup() here */
102 rte *e = rte_get_temp(a);
f6bd2066 103 e->pflags = 0;
1321e12a
OZ
104
105 if (r->cmds)
106 f_eval_rte(r->cmds, &e, static_lp);
107
7126cadf
OZ
108 rte_update(&p->p, r->net, e);
109 r->state = SRS_CLEAN;
1321e12a
OZ
110
111 if (r->cmds)
112 lp_flush(static_lp);
7126cadf
OZ
113
114 return;
115
116withdraw:
117 if (r->state == SRS_DOWN)
118 return;
119
120 rte_update(&p->p, r->net, NULL);
121 r->state = SRS_DOWN;
122}
123
124static void
125static_mark_rte(struct static_proto *p, struct static_route *r)
126{
127 if (r->state == SRS_DIRTY)
128 return;
129
130 r->state = SRS_DIRTY;
131 BUFFER_PUSH(p->marked) = r;
132
133 if (!ev_active(p->event))
134 ev_schedule(p->event);
135}
136
137static void
138static_announce_marked(void *P)
139{
140 struct static_proto *p = P;
141
142 BUFFER_WALK(p->marked, r)
143 static_announce_rte(P, r);
144
145 BUFFER_FLUSH(p->marked);
f6bd2066
MM
146}
147
538264cf
OZ
148static void
149static_bfd_notify(struct bfd_request *req);
150
151static void
7126cadf 152static_update_bfd(struct static_proto *p, struct static_route *r)
538264cf 153{
7126cadf
OZ
154 /* The @r is a RTD_UNICAST next hop, may be a dummy node */
155
538264cf
OZ
156 struct neighbor *nb = r->neigh;
157 int bfd_up = (nb->scope > 0) && r->use_bfd;
158
159 if (bfd_up && !r->bfd_req)
160 {
161 // ip_addr local = ipa_nonzero(r->local) ? r->local : nb->ifa->ip;
7126cadf 162 r->bfd_req = bfd_request_session(p->p.pool, r->via, nb->ifa->ip, nb->iface,
538264cf
OZ
163 static_bfd_notify, r);
164 }
165
166 if (!bfd_up && r->bfd_req)
167 {
168 rfree(r->bfd_req);
169 r->bfd_req = NULL;
170 }
171}
172
9852f810 173static int
7126cadf 174static_decide(struct static_proto *p, struct static_route *r)
9852f810 175{
7126cadf 176 /* The @r is a RTD_UNICAST next hop, may be a dummy node */
9852f810 177
7126cadf
OZ
178 struct static_config *cf = (void *) p->p.cf;
179 uint old_active = r->active;
f2010f9c 180
69a8259c 181 if (r->neigh->scope < 0)
7126cadf 182 goto fail;
9852f810 183
69a8259c 184 if (cf->check_link && !(r->neigh->iface->flags & IF_LINK_UP))
7126cadf 185 goto fail;
9852f810 186
7126cadf
OZ
187 if (r->bfd_req && (r->bfd_req->state != BFD_STATE_UP))
188 goto fail;
538264cf 189
7126cadf
OZ
190 r->active = 1;
191 return !old_active;
9852f810 192
7126cadf
OZ
193fail:
194 r->active = 0;
195 return old_active;
196}
9852f810 197
295ae16d 198static void
7126cadf 199static_add_rte(struct static_proto *p, struct static_route *r)
295ae16d 200{
7126cadf
OZ
201 if (r->dest == RTD_UNICAST)
202 {
203 struct static_route *r2;
204 struct neighbor *n;
f2010f9c 205
7126cadf 206 for (r2 = r; r2; r2 = r2->mp_next)
295ae16d 207 {
7126cadf 208 n = ipa_nonzero(r2->via) ?
a1f5e514
OZ
209 neigh_find2(&p->p, &r2->via, r2->iface,
210 NEF_STICKY | (r2->onlink ? NEF_ONLINK : 0)) :
7126cadf
OZ
211 neigh_find_iface(&p->p, r2->iface);
212
213 if (!n)
9852f810 214 {
7126cadf
OZ
215 log(L_WARN "Invalid next hop %I of static route %N", r2->via, r2->net);
216 continue;
9852f810
OZ
217 }
218
7126cadf
OZ
219 r2->neigh = n;
220 r2->chain = n->data;
221 n->data = r2;
222
223 static_update_bfd(p, r2);
224 static_decide(p, r2);
295ae16d 225 }
7126cadf
OZ
226 }
227
228 static_announce_rte(p, r);
295ae16d
MM
229}
230
538264cf 231static void
7126cadf 232static_reset_rte(struct static_proto *p UNUSED, struct static_route *r)
538264cf
OZ
233{
234 struct static_route *r2;
4116db18 235
7126cadf
OZ
236 for (r2 = r; r2; r2 = r2->mp_next)
237 {
238 r2->neigh = NULL;
239 r2->chain = NULL;
d360f129 240
7126cadf
OZ
241 r2->state = 0;
242 r2->active = 0;
f2010f9c 243
7126cadf
OZ
244 rfree(r2->bfd_req);
245 r2->bfd_req = NULL;
246 }
247}
f2010f9c 248
7126cadf
OZ
249static void
250static_remove_rte(struct static_proto *p, struct static_route *r)
251{
252 if (r->state)
253 rte_update(&p->p, r->net, NULL);
f2010f9c 254
7126cadf 255 static_reset_rte(p, r);
a1bf6440
MM
256}
257
7126cadf
OZ
258
259static inline int
260static_same_dest(struct static_route *x, struct static_route *y)
e4bfafa1 261{
7126cadf
OZ
262 if (x->dest != y->dest)
263 return 0;
e4bfafa1 264
7126cadf 265 switch (x->dest)
538264cf 266 {
7126cadf
OZ
267 case RTD_UNICAST:
268 for (; x && y; x = x->mp_next, y = y->mp_next)
269 {
270 if (!ipa_equal(x->via, y->via) ||
271 (x->iface != y->iface) ||
a1f5e514 272 (x->onlink != y->onlink) ||
7126cadf 273 (x->weight != y->weight) ||
a1f5e514 274 (x->use_bfd != y->use_bfd) ||
3c744164
JMM
275 (!x->mls != !y->mls) ||
276 ((x->mls) && (y->mls) && (x->mls->len != y->mls->len)))
7126cadf
OZ
277 return 0;
278
3c744164
JMM
279 if (!x->mls)
280 continue;
281
282 for (uint i = 0; i < x->mls->len; i++)
283 if (x->mls->stack[i] != y->mls->stack[i])
7126cadf
OZ
284 return 0;
285 }
286 return !x && !y;
53434e44 287
7126cadf 288 case RTDX_RECURSIVE:
3c744164
JMM
289 if (!ipa_equal(x->via, y->via) ||
290 (!x->mls != !y->mls) ||
291 ((x->mls) && (y->mls) && (x->mls->len != y->mls->len)))
292 return 0;
293
294 if (!x->mls)
295 return 1;
296
297 for (uint i = 0; i < x->mls->len; i++)
298 if (x->mls->stack[i] != y->mls->stack[i])
299 return 0;
300
301 return 1;
f4a60a9b 302
7126cadf
OZ
303 default:
304 return 1;
305 }
e4bfafa1
MM
306}
307
7126cadf
OZ
308static inline int
309static_same_rte(struct static_route *or, struct static_route *nr)
4116db18 310{
7126cadf
OZ
311 /* Note that i_same() requires arguments in (new, old) order */
312 return static_same_dest(or, nr) && i_same(nr->cmds, or->cmds);
4116db18
OZ
313}
314
538264cf 315static void
7126cadf 316static_reconfigure_rte(struct static_proto *p, struct static_route *or, struct static_route *nr)
538264cf 317{
7126cadf
OZ
318 if ((or->state == SRS_CLEAN) && !static_same_rte(or, nr))
319 nr->state = SRS_DIRTY;
320 else
321 nr->state = or->state;
538264cf 322
7126cadf
OZ
323 static_add_rte(p, nr);
324 static_reset_rte(p, or);
538264cf 325}
4116db18 326
7126cadf 327
a1bf6440
MM
328static void
329static_neigh_notify(struct neighbor *n)
330{
7126cadf 331 struct static_proto *p = (void *) n->proto;
980297d2
MM
332 struct static_route *r;
333
d93a43a5 334 DBG("Static: neighbor notify for %I: iface %p\n", n->addr, n->iface);
7126cadf 335 for (r = n->data; r; r = r->chain)
538264cf
OZ
336 {
337 static_update_bfd(p, r);
7126cadf
OZ
338
339 if (static_decide(p, r))
340 static_mark_rte(p, r->mp_head);
538264cf
OZ
341 }
342}
9852f810 343
538264cf
OZ
344static void
345static_bfd_notify(struct bfd_request *req)
346{
347 struct static_route *r = req->data;
7126cadf 348 struct static_proto *p = (void *) r->neigh->proto;
9852f810 349
538264cf
OZ
350 // if (req->down) TRACE(D_EVENTS, "BFD session down for nbr %I on %s", XXXX);
351
7126cadf
OZ
352 if (static_decide(p, r))
353 static_mark_rte(p, r->mp_head);
a1bf6440
MM
354}
355
7126cadf 356static int
3e236955 357static_rte_mergable(rte *pri UNUSED, rte *sec UNUSED)
8d9eef17
OZ
358{
359 return 1;
360}
361
a1bf6440 362
f4a60a9b
OZ
363static void
364static_postconfig(struct proto_config *CF)
365{
366 struct static_config *cf = (void *) CF;
367 struct static_route *r;
368
369 if (EMPTY_LIST(CF->channels))
370 cf_error("Channel not specified");
371
ffb38dfb
OZ
372 struct channel_config *cc = proto_cf_main_channel(CF);
373
374 if (!cf->igp_table_ip4)
375 cf->igp_table_ip4 = (cc->table->addr_type == NET_IP4) ?
376 cc->table : cf->c.global->def_tables[NET_IP4];
377
378 if (!cf->igp_table_ip6)
379 cf->igp_table_ip6 = (cc->table->addr_type == NET_IP6) ?
380 cc->table : cf->c.global->def_tables[NET_IP6];
381
7126cadf 382 WALK_LIST(r, cf->routes)
f2010f9c
JMM
383 if (r->net && (r->net->type != CF->net_type))
384 cf_error("Route %N incompatible with channel type", r->net);
f4a60a9b
OZ
385}
386
e9e3dc26 387static struct proto *
f4a60a9b 388static_init(struct proto_config *CF)
a1bf6440 389{
f4a60a9b 390 struct proto *P = proto_new(CF);
ffb38dfb
OZ
391 struct static_proto *p = (void *) P;
392 struct static_config *cf = (void *) CF;
a1bf6440 393
f4a60a9b 394 P->main_channel = proto_add_channel(P, proto_cf_main_channel(CF));
094d2bdb 395
f4a60a9b 396 P->neigh_notify = static_neigh_notify;
f4a60a9b
OZ
397 P->rte_mergable = static_rte_mergable;
398
ffb38dfb
OZ
399 if (cf->igp_table_ip4)
400 p->igp_table_ip4 = cf->igp_table_ip4->table;
401
402 if (cf->igp_table_ip6)
403 p->igp_table_ip6 = cf->igp_table_ip6->table;
404
f4a60a9b 405 return P;
a1bf6440
MM
406}
407
7126cadf
OZ
408static int
409static_start(struct proto *P)
c1cefd7b 410{
7126cadf
OZ
411 struct static_proto *p = (void *) P;
412 struct static_config *cf = (void *) P->cf;
413 struct static_route *r;
9852f810 414
7126cadf 415 if (!static_lp)
05d47bd5 416 static_lp = lp_new(&root_pool, LP_GOOD_SIZE(1024));
9852f810 417
ffb38dfb
OZ
418 if (p->igp_table_ip4)
419 rt_lock_table(p->igp_table_ip4);
420
421 if (p->igp_table_ip6)
422 rt_lock_table(p->igp_table_ip6);
4116db18 423
7126cadf
OZ
424 p->event = ev_new(p->p.pool);
425 p->event->hook = static_announce_marked;
426 p->event->data = p;
295ae16d 427
7126cadf 428 BUFFER_INIT(p->marked, p->p.pool, 4);
1321e12a 429
7126cadf
OZ
430 /* We have to go UP before routes could be installed */
431 proto_notify_state(P, PS_UP);
1321e12a 432
7126cadf
OZ
433 WALK_LIST(r, cf->routes)
434 static_add_rte(p, r);
295ae16d 435
7126cadf
OZ
436 return PS_UP;
437}
f2010f9c 438
7126cadf
OZ
439static int
440static_shutdown(struct proto *P)
441{
442 struct static_proto *p = (void *) P;
443 struct static_config *cf = (void *) P->cf;
444 struct static_route *r;
c1cefd7b 445
7126cadf
OZ
446 /* Just reset the flag, the routes will be flushed by the nest */
447 WALK_LIST(r, cf->routes)
448 static_reset_rte(p, r);
d40c2659 449
7126cadf
OZ
450 return PS_DOWN;
451}
f2010f9c 452
7126cadf
OZ
453static void
454static_cleanup(struct proto *P)
455{
ffb38dfb
OZ
456 struct static_proto *p = (void *) P;
457
458 if (p->igp_table_ip4)
459 rt_unlock_table(p->igp_table_ip4);
d40c2659 460
ffb38dfb
OZ
461 if (p->igp_table_ip6)
462 rt_unlock_table(p->igp_table_ip6);
7126cadf 463}
d40c2659 464
7126cadf
OZ
465static void
466static_dump_rte(struct static_route *r)
467{
468 debug("%-1N: ", r->net);
469 if (r->dest == RTD_UNICAST)
470 if (r->iface && ipa_zero(r->via))
471 debug("dev %s\n", r->iface->name);
472 else
473 debug("via %I%J\n", r->via, r->iface);
474 else
475 debug("rtd %d\n", r->dest);
476}
d40c2659 477
7126cadf
OZ
478static void
479static_dump(struct proto *P)
480{
481 struct static_config *c = (void *) P->cf;
482 struct static_route *r;
f2010f9c 483
7126cadf
OZ
484 debug("Static routes:\n");
485 WALK_LIST(r, c->routes)
486 static_dump_rte(r);
295ae16d
MM
487}
488
ffb38dfb 489#define IGP_TABLE(cf, sym) ((cf)->igp_table_##sym ? (cf)->igp_table_##sym ->table : NULL )
4116db18 490
7126cadf
OZ
491static inline int
492static_cmp_rte(const void *X, const void *Y)
493{
494 struct static_route *x = *(void **)X, *y = *(void **)Y;
495 return net_compare(x->net, y->net);
496}
497
d272fe22 498static int
7126cadf 499static_reconfigure(struct proto *P, struct proto_config *CF)
d272fe22 500{
7126cadf
OZ
501 struct static_proto *p = (void *) P;
502 struct static_config *o = (void *) P->cf;
f4a60a9b 503 struct static_config *n = (void *) CF;
7126cadf 504 struct static_route *r, *r2, *or, *nr;
295ae16d 505
ffb38dfb
OZ
506 /* Check change in IGP tables */
507 if ((IGP_TABLE(o, ip4) != IGP_TABLE(n, ip4)) ||
508 (IGP_TABLE(o, ip6) != IGP_TABLE(n, ip6)))
4116db18
OZ
509 return 0;
510
7126cadf 511 if (!proto_configure_channel(P, &P->main_channel, proto_cf_main_channel(CF)))
f4a60a9b
OZ
512 return 0;
513
7126cadf
OZ
514 p->p.cf = CF;
515
516 /* Reset route lists in neighbor entries */
517 WALK_LIST(r, o->routes)
518 for (r2 = r; r2; r2 = r2->mp_next)
519 if (r2->neigh)
520 r2->neigh->data = NULL;
521
522 /* Reconfigure initial matching sequence */
523 for (or = HEAD(o->routes), nr = HEAD(n->routes);
524 NODE_VALID(or) && NODE_VALID(nr) && net_equal(or->net, nr->net);
525 or = NODE_NEXT(or), nr = NODE_NEXT(nr))
526 static_reconfigure_rte(p, or, nr);
527
528 if (!NODE_VALID(or) && !NODE_VALID(nr))
529 return 1;
530
531 /* Reconfigure remaining routes, sort them to find matching pairs */
532 struct static_route *or2, *nr2, **orbuf, **nrbuf;
533 uint ornum = 0, nrnum = 0, orpos = 0, nrpos = 0, i;
534
535 for (or2 = or; NODE_VALID(or2); or2 = NODE_NEXT(or2))
536 ornum++;
537
538 for (nr2 = nr; NODE_VALID(nr2); nr2 = NODE_NEXT(nr2))
539 nrnum++;
540
541 orbuf = xmalloc(ornum * sizeof(void *));
542 nrbuf = xmalloc(nrnum * sizeof(void *));
f2010f9c 543
7126cadf
OZ
544 for (i = 0, or2 = or; i < ornum; i++, or2 = NODE_NEXT(or2))
545 orbuf[i] = or2;
546
547 for (i = 0, nr2 = nr; i < nrnum; i++, nr2 = NODE_NEXT(nr2))
548 nrbuf[i] = nr2;
549
550 qsort(orbuf, ornum, sizeof(struct static_route *), static_cmp_rte);
551 qsort(nrbuf, nrnum, sizeof(struct static_route *), static_cmp_rte);
552
553 while ((orpos < ornum) && (nrpos < nrnum))
f2010f9c 554 {
7126cadf
OZ
555 int x = net_compare(orbuf[orpos]->net, nrbuf[nrpos]->net);
556 if (x < 0)
557 static_remove_rte(p, orbuf[orpos++]);
558 else if (x > 0)
559 static_add_rte(p, nrbuf[nrpos++]);
560 else
561 static_reconfigure_rte(p, orbuf[orpos++], nrbuf[nrpos++]);
f2010f9c 562 }
295ae16d 563
7126cadf
OZ
564 while (orpos < ornum)
565 static_remove_rte(p, orbuf[orpos++]);
538264cf 566
7126cadf
OZ
567 while (nrpos < nrnum)
568 static_add_rte(p, nrbuf[nrpos++]);
d272fe22 569
7126cadf
OZ
570 xfree(orbuf);
571 xfree(nrbuf);
a7f23f58 572
7126cadf 573 return 1;
a7f23f58
OZ
574}
575
576static void
577static_copy_config(struct proto_config *dest, struct proto_config *src)
578{
579 struct static_config *d = (struct static_config *) dest;
580 struct static_config *s = (struct static_config *) src;
581
7126cadf 582 struct static_route *srt, *snh;
a7f23f58 583
7126cadf
OZ
584 /* Copy route list */
585 init_list(&d->routes);
586 WALK_LIST(srt, s->routes)
587 {
588 struct static_route *drt = NULL, *dnh = NULL, **dnp = &drt;
feed8226 589
7126cadf 590 for (snh = srt; snh; snh = snh->mp_next)
feed8226 591 {
7126cadf
OZ
592 dnh = cfg_alloc(sizeof(struct static_route));
593 memcpy(dnh, snh, sizeof(struct static_route));
594
595 if (!drt)
596 add_tail(&d->routes, &(dnh->n));
597
598 *dnp = dnh;
599 dnp = &(dnh->mp_next);
600
601 if (snh->mp_head)
602 dnh->mp_head = drt;
feed8226 603 }
7126cadf 604 }
4e276a89 605}
9852f810 606
4e276a89
JMM
607static void
608static_show_rt(struct static_route *r)
609{
7126cadf
OZ
610 switch (r->dest)
611 {
612 case RTD_UNICAST:
4e276a89 613 {
4e276a89 614 struct static_route *r2;
7126cadf
OZ
615
616 cli_msg(-1009, "%N", r->net);
4e276a89 617 for (r2 = r; r2; r2 = r2->mp_next)
f2010f9c 618 {
7126cadf 619 if (r2->iface && ipa_zero(r2->via))
a1f5e514
OZ
620 cli_msg(-1009, "\tdev %s%s", r2->iface->name,
621 r2->active ? "" : " (dormant)");
7126cadf 622 else
a1f5e514
OZ
623 cli_msg(-1009, "\tvia %I%J%s%s%s", r2->via, r2->iface,
624 r2->onlink ? " onlink" : "",
625 r2->bfd_req ? " (bfd)" : "",
626 r2->active ? "" : " (dormant)");
f2010f9c 627 }
7126cadf
OZ
628 break;
629 }
630
631 case RTD_NONE:
632 case RTD_BLACKHOLE:
633 case RTD_UNREACHABLE:
634 case RTD_PROHIBIT:
635 cli_msg(-1009, "%N\t%s", r->net, rta_dest_names[r->dest]);
636 break;
637
638 case RTDX_RECURSIVE:
639 cli_msg(-1009, "%N\trecursive %I", r->net, r->via);
640 break;
4e276a89 641 }
feed8226
MM
642}
643
644void
645static_show(struct proto *P)
646{
647 struct static_config *c = (void *) P->cf;
648 struct static_route *r;
649
7126cadf 650 WALK_LIST(r, c->routes)
f2010f9c 651 static_show_rt(r);
feed8226
MM
652 cli_msg(0, "");
653}
7126cadf
OZ
654
655
656struct protocol proto_static = {
657 .name = "Static",
658 .template = "static%d",
659 .preference = DEF_PREF_STATIC,
660 .channel_mask = NB_ANY,
661 .proto_size = sizeof(struct static_proto),
662 .config_size = sizeof(struct static_config),
663 .postconfig = static_postconfig,
664 .init = static_init,
665 .dump = static_dump,
666 .start = static_start,
667 .shutdown = static_shutdown,
668 .cleanup = static_cleanup,
669 .reconfigure = static_reconfigure,
670 .copy_config = static_copy_config
671};