1998-12-07 02:21:23 +08:00
|
|
|
/*
|
|
|
|
* BIRD -- Static Route Generator
|
|
|
|
*
|
2000-01-17 19:52:50 +08:00
|
|
|
* (c) 1998--2000 Martin Mares <mj@ucw.cz>
|
1998-12-07 02:21:23 +08:00
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
|
|
|
|
2000-06-05 00:15:37 +08:00
|
|
|
/**
|
|
|
|
* DOC: Static
|
|
|
|
*
|
2017-03-08 01:42:41 +08:00
|
|
|
* The Static protocol is implemented in a straightforward way. It keeps a list
|
|
|
|
* of static routes. Routes of dest RTD_UNICAST have associated sticky node in
|
|
|
|
* the neighbor cache to be notified about gaining or losing the neighbor and
|
|
|
|
* about interface-related events (e.g. link down). They may also have a BFD
|
|
|
|
* request if associated with a BFD session. When a route is notified,
|
|
|
|
* static_decide() is used to see whether the route activeness is changed. In
|
|
|
|
* such case, the route is marked as dirty and scheduled to be announced or
|
|
|
|
* withdrawn, which is done asynchronously from event hook. Routes of other
|
|
|
|
* types (e.g. black holes) are announced all the time.
|
2000-06-05 00:15:37 +08:00
|
|
|
*
|
2017-03-08 01:42:41 +08:00
|
|
|
* Multipath routes are a bit tricky. To represent additional next hops, dummy
|
|
|
|
* static_route nodes are used, which are chained using @mp_next field and link
|
|
|
|
* to the master node by @mp_head field. Each next hop has a separate neighbor
|
|
|
|
* entry and an activeness state, but the master node is used for most purposes.
|
|
|
|
* Note that most functions DO NOT accept dummy nodes as arguments.
|
2010-12-08 06:34:36 +08:00
|
|
|
*
|
2000-06-05 00:15:37 +08:00
|
|
|
* The only other thing worth mentioning is that when asked for reconfiguration,
|
|
|
|
* Static not only compares the two configurations, but it also calculates
|
2017-03-08 01:42:41 +08:00
|
|
|
* difference between the lists of static routes and it just inserts the newly
|
|
|
|
* added routes, removes the obsolete ones and reannounces changed ones.
|
2000-06-05 00:15:37 +08:00
|
|
|
*/
|
|
|
|
|
2000-03-13 05:01:38 +08:00
|
|
|
#undef LOCAL_DEBUG
|
1998-12-07 02:21:23 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
1998-12-07 02:21:23 +08:00
|
|
|
#include "nest/bird.h"
|
|
|
|
#include "nest/iface.h"
|
|
|
|
#include "nest/protocol.h"
|
|
|
|
#include "nest/route.h"
|
1999-12-03 19:41:23 +08:00
|
|
|
#include "nest/cli.h"
|
1998-12-07 02:21:23 +08:00
|
|
|
#include "conf/conf.h"
|
2015-07-20 17:12:02 +08:00
|
|
|
#include "filter/filter.h"
|
1999-12-03 19:41:23 +08:00
|
|
|
#include "lib/string.h"
|
2010-12-08 06:34:36 +08:00
|
|
|
#include "lib/alloca.h"
|
1998-12-07 02:21:23 +08:00
|
|
|
|
|
|
|
#include "static.h"
|
|
|
|
|
2015-07-20 17:12:02 +08:00
|
|
|
static linpool *static_lp;
|
|
|
|
|
2020-11-19 23:38:39 +08:00
|
|
|
static inline struct rte_src * static_get_source(struct static_proto *p, uint i)
|
|
|
|
{ return i ? rt_get_source(&p->p, i) : p->p.main_source; }
|
|
|
|
|
1998-12-07 07:13:31 +08:00
|
|
|
static void
|
2017-03-08 01:42:41 +08:00
|
|
|
static_announce_rte(struct static_proto *p, struct static_route *r)
|
1998-12-07 07:13:31 +08:00
|
|
|
{
|
2017-03-08 01:42:41 +08:00
|
|
|
rta *a = allocz(RTA_MAX_SIZE);
|
2020-11-19 23:38:39 +08:00
|
|
|
a->src = static_get_source(p, r->index);
|
2017-03-08 01:42:41 +08:00
|
|
|
a->source = RTS_STATIC;
|
|
|
|
a->scope = SCOPE_UNIVERSE;
|
|
|
|
a->dest = r->dest;
|
2020-02-10 15:41:05 +08:00
|
|
|
a->pref = p->p.main_channel->preference;
|
2016-06-13 21:49:53 +08:00
|
|
|
|
2016-05-06 21:48:35 +08:00
|
|
|
if (r->dest == RTD_UNICAST)
|
2017-03-08 01:42:41 +08:00
|
|
|
{
|
|
|
|
struct static_route *r2;
|
|
|
|
struct nexthop *nhs = NULL;
|
|
|
|
|
|
|
|
for (r2 = r; r2; r2 = r2->mp_next)
|
2010-12-08 06:34:36 +08:00
|
|
|
{
|
2017-03-08 01:42:41 +08:00
|
|
|
if (!r2->active)
|
|
|
|
continue;
|
2016-05-06 21:48:35 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
struct nexthop *nh = allocz(NEXTHOP_MAX_SIZE);
|
|
|
|
nh->gw = r2->via;
|
|
|
|
nh->iface = r2->neigh->iface;
|
2017-07-05 05:36:21 +08:00
|
|
|
nh->flags = r2->onlink ? RNF_ONLINK : 0;
|
2017-03-08 01:42:41 +08:00
|
|
|
nh->weight = r2->weight;
|
2017-03-17 22:48:09 +08:00
|
|
|
if (r2->mls)
|
|
|
|
{
|
|
|
|
nh->labels = r2->mls->len;
|
|
|
|
memcpy(nh->label, r2->mls->stack, r2->mls->len * sizeof(u32));
|
|
|
|
}
|
2010-12-08 06:34:36 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
nexthop_insert(&nhs, nh);
|
|
|
|
}
|
2016-06-13 21:49:53 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
if (!nhs)
|
|
|
|
goto withdraw;
|
2017-02-20 09:26:45 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
nexthop_link(a, nhs);
|
|
|
|
}
|
2017-02-20 09:26:45 +08:00
|
|
|
|
2011-09-24 08:21:52 +08:00
|
|
|
if (r->dest == RTDX_RECURSIVE)
|
2017-03-30 19:29:34 +08:00
|
|
|
{
|
|
|
|
rtable *tab = ipa_is_ip4(r->via) ? p->igp_table_ip4 : p->igp_table_ip6;
|
|
|
|
rta_set_recursive_next_hop(p->p.main_channel->table, a, tab, r->via, IPA_NONE, r->mls);
|
|
|
|
}
|
2011-09-24 08:21:52 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
/* Already announced */
|
|
|
|
if (r->state == SRS_CLEAN)
|
|
|
|
return;
|
2015-07-20 17:12:02 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
/* We skip rta_lookup() here */
|
|
|
|
rte *e = rte_get_temp(a);
|
1998-12-07 07:13:31 +08:00
|
|
|
e->pflags = 0;
|
2015-07-20 17:12:02 +08:00
|
|
|
|
|
|
|
if (r->cmds)
|
2020-12-29 04:19:27 +08:00
|
|
|
{
|
|
|
|
/* Create a temporary table node */
|
|
|
|
e->net = alloca(sizeof(net) + r->net->length);
|
|
|
|
memset(e->net, 0, sizeof(net) + r->net->length);
|
|
|
|
net_copy(e->net->n.addr, r->net);
|
|
|
|
|
|
|
|
/* Evaluate the filter */
|
2015-07-20 17:12:02 +08:00
|
|
|
f_eval_rte(r->cmds, &e, static_lp);
|
|
|
|
|
2020-12-29 04:19:27 +08:00
|
|
|
/* Remove the temporary node */
|
|
|
|
e->net = NULL;
|
|
|
|
}
|
|
|
|
|
2020-11-19 23:38:39 +08:00
|
|
|
rte_update2(p->p.main_channel, r->net, e, a->src);
|
2017-03-08 01:42:41 +08:00
|
|
|
r->state = SRS_CLEAN;
|
2015-07-20 17:12:02 +08:00
|
|
|
|
|
|
|
if (r->cmds)
|
|
|
|
lp_flush(static_lp);
|
2017-03-08 01:42:41 +08:00
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
withdraw:
|
|
|
|
if (r->state == SRS_DOWN)
|
|
|
|
return;
|
|
|
|
|
2020-11-19 23:38:39 +08:00
|
|
|
rte_update2(p->p.main_channel, r->net, NULL, a->src);
|
2017-03-08 01:42:41 +08:00
|
|
|
r->state = SRS_DOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
static_mark_rte(struct static_proto *p, struct static_route *r)
|
|
|
|
{
|
|
|
|
if (r->state == SRS_DIRTY)
|
|
|
|
return;
|
|
|
|
|
|
|
|
r->state = SRS_DIRTY;
|
|
|
|
BUFFER_PUSH(p->marked) = r;
|
|
|
|
|
|
|
|
if (!ev_active(p->event))
|
|
|
|
ev_schedule(p->event);
|
|
|
|
}
|
|
|
|
|
2021-03-10 22:07:19 +08:00
|
|
|
static void
|
|
|
|
static_mark_all(struct static_proto *p)
|
|
|
|
{
|
|
|
|
struct static_config *cf = (void *) p->p.cf;
|
|
|
|
struct static_route *r;
|
|
|
|
|
|
|
|
/* We want to reload all routes, mark them as dirty */
|
|
|
|
|
|
|
|
WALK_LIST(r, cf->routes)
|
|
|
|
if (r->state == SRS_CLEAN)
|
|
|
|
r->state = SRS_DIRTY;
|
|
|
|
|
|
|
|
p->marked_all = 1;
|
|
|
|
BUFFER_FLUSH(p->marked);
|
|
|
|
|
|
|
|
if (!ev_active(p->event))
|
|
|
|
ev_schedule(p->event);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
static void
|
|
|
|
static_announce_marked(void *P)
|
|
|
|
{
|
|
|
|
struct static_proto *p = P;
|
2021-03-10 22:07:19 +08:00
|
|
|
struct static_config *cf = (void *) p->p.cf;
|
|
|
|
struct static_route *r;
|
2017-03-08 01:42:41 +08:00
|
|
|
|
2021-03-10 22:07:19 +08:00
|
|
|
if (p->marked_all)
|
|
|
|
{
|
|
|
|
WALK_LIST(r, cf->routes)
|
|
|
|
if (r->state == SRS_DIRTY)
|
|
|
|
static_announce_rte(p, r);
|
2017-03-08 01:42:41 +08:00
|
|
|
|
2021-03-10 22:07:19 +08:00
|
|
|
p->marked_all = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BUFFER_WALK(p->marked, r)
|
|
|
|
static_announce_rte(p, r);
|
|
|
|
|
|
|
|
BUFFER_FLUSH(p->marked);
|
|
|
|
}
|
1998-12-07 07:13:31 +08:00
|
|
|
}
|
|
|
|
|
2015-07-25 00:02:07 +08:00
|
|
|
static void
|
|
|
|
static_bfd_notify(struct bfd_request *req);
|
|
|
|
|
|
|
|
static void
|
2017-03-08 01:42:41 +08:00
|
|
|
static_update_bfd(struct static_proto *p, struct static_route *r)
|
2015-07-25 00:02:07 +08:00
|
|
|
{
|
2017-03-08 01:42:41 +08:00
|
|
|
/* The @r is a RTD_UNICAST next hop, may be a dummy node */
|
|
|
|
|
2015-07-25 00:02:07 +08:00
|
|
|
struct neighbor *nb = r->neigh;
|
|
|
|
int bfd_up = (nb->scope > 0) && r->use_bfd;
|
|
|
|
|
|
|
|
if (bfd_up && !r->bfd_req)
|
|
|
|
{
|
|
|
|
// ip_addr local = ipa_nonzero(r->local) ? r->local : nb->ifa->ip;
|
2019-07-17 22:20:35 +08:00
|
|
|
r->bfd_req = bfd_request_session(p->p.pool, r->via, nb->ifa->ip,
|
|
|
|
nb->iface, p->p.vrf,
|
2020-11-08 22:33:22 +08:00
|
|
|
static_bfd_notify, r, NULL);
|
2015-07-25 00:02:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!bfd_up && r->bfd_req)
|
|
|
|
{
|
|
|
|
rfree(r->bfd_req);
|
|
|
|
r->bfd_req = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-08 06:34:36 +08:00
|
|
|
static int
|
2017-03-08 01:42:41 +08:00
|
|
|
static_decide(struct static_proto *p, struct static_route *r)
|
2010-12-08 06:34:36 +08:00
|
|
|
{
|
2017-03-08 01:42:41 +08:00
|
|
|
/* The @r is a RTD_UNICAST next hop, may be a dummy node */
|
2010-12-08 06:34:36 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
struct static_config *cf = (void *) p->p.cf;
|
|
|
|
uint old_active = r->active;
|
2016-06-13 21:49:53 +08:00
|
|
|
|
2012-01-01 19:02:20 +08:00
|
|
|
if (r->neigh->scope < 0)
|
2017-03-08 01:42:41 +08:00
|
|
|
goto fail;
|
2010-12-08 06:34:36 +08:00
|
|
|
|
2012-01-01 19:02:20 +08:00
|
|
|
if (cf->check_link && !(r->neigh->iface->flags & IF_LINK_UP))
|
2017-03-08 01:42:41 +08:00
|
|
|
goto fail;
|
2010-12-08 06:34:36 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
if (r->bfd_req && (r->bfd_req->state != BFD_STATE_UP))
|
|
|
|
goto fail;
|
2015-07-25 00:02:07 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
r->active = 1;
|
|
|
|
return !old_active;
|
2010-12-08 06:34:36 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
fail:
|
|
|
|
r->active = 0;
|
|
|
|
return old_active;
|
|
|
|
}
|
2010-12-08 06:34:36 +08:00
|
|
|
|
2000-01-17 20:38:50 +08:00
|
|
|
static void
|
2017-03-08 01:42:41 +08:00
|
|
|
static_add_rte(struct static_proto *p, struct static_route *r)
|
2000-01-17 20:38:50 +08:00
|
|
|
{
|
2017-03-08 01:42:41 +08:00
|
|
|
if (r->dest == RTD_UNICAST)
|
|
|
|
{
|
|
|
|
struct static_route *r2;
|
|
|
|
struct neighbor *n;
|
2016-06-13 21:49:53 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
for (r2 = r; r2; r2 = r2->mp_next)
|
2000-01-17 20:38:50 +08:00
|
|
|
{
|
2018-06-27 22:51:53 +08:00
|
|
|
n = neigh_find(&p->p, r2->via, r2->iface, NEF_STICKY |
|
|
|
|
(r2->onlink ? NEF_ONLINK : 0) |
|
|
|
|
(ipa_zero(r2->via) ? NEF_IFACE : 0));
|
2017-03-08 01:42:41 +08:00
|
|
|
|
|
|
|
if (!n)
|
2010-12-08 06:34:36 +08:00
|
|
|
{
|
2017-03-08 01:42:41 +08:00
|
|
|
log(L_WARN "Invalid next hop %I of static route %N", r2->via, r2->net);
|
|
|
|
continue;
|
2010-12-08 06:34:36 +08:00
|
|
|
}
|
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
r2->neigh = n;
|
|
|
|
r2->chain = n->data;
|
|
|
|
n->data = r2;
|
|
|
|
|
|
|
|
static_update_bfd(p, r2);
|
|
|
|
static_decide(p, r2);
|
2000-01-17 20:38:50 +08:00
|
|
|
}
|
2017-03-08 01:42:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static_announce_rte(p, r);
|
2000-01-17 20:38:50 +08:00
|
|
|
}
|
|
|
|
|
2015-07-25 00:02:07 +08:00
|
|
|
static void
|
2017-03-08 01:42:41 +08:00
|
|
|
static_reset_rte(struct static_proto *p UNUSED, struct static_route *r)
|
2015-07-25 00:02:07 +08:00
|
|
|
{
|
|
|
|
struct static_route *r2;
|
2011-09-24 08:21:52 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
for (r2 = r; r2; r2 = r2->mp_next)
|
|
|
|
{
|
|
|
|
r2->neigh = NULL;
|
|
|
|
r2->chain = NULL;
|
2012-04-15 21:13:12 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
r2->state = 0;
|
|
|
|
r2->active = 0;
|
2016-06-13 21:49:53 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
rfree(r2->bfd_req);
|
|
|
|
r2->bfd_req = NULL;
|
|
|
|
}
|
|
|
|
}
|
2016-06-13 21:49:53 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
static void
|
|
|
|
static_remove_rte(struct static_proto *p, struct static_route *r)
|
|
|
|
{
|
|
|
|
if (r->state)
|
2020-11-19 23:38:39 +08:00
|
|
|
rte_update2(p->p.main_channel, r->net, NULL, static_get_source(p, r->index));
|
2016-06-13 21:49:53 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
static_reset_rte(p, r);
|
1998-12-07 02:21:23 +08:00
|
|
|
}
|
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
|
|
|
|
static inline int
|
|
|
|
static_same_dest(struct static_route *x, struct static_route *y)
|
2000-05-13 19:01:41 +08:00
|
|
|
{
|
2017-03-08 01:42:41 +08:00
|
|
|
if (x->dest != y->dest)
|
|
|
|
return 0;
|
2000-05-13 19:01:41 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
switch (x->dest)
|
2015-07-25 00:02:07 +08:00
|
|
|
{
|
2017-03-08 01:42:41 +08:00
|
|
|
case RTD_UNICAST:
|
|
|
|
for (; x && y; x = x->mp_next, y = y->mp_next)
|
|
|
|
{
|
|
|
|
if (!ipa_equal(x->via, y->via) ||
|
|
|
|
(x->iface != y->iface) ||
|
2017-07-05 05:36:21 +08:00
|
|
|
(x->onlink != y->onlink) ||
|
2017-03-08 01:42:41 +08:00
|
|
|
(x->weight != y->weight) ||
|
2017-07-05 05:36:21 +08:00
|
|
|
(x->use_bfd != y->use_bfd) ||
|
2017-03-17 22:48:09 +08:00
|
|
|
(!x->mls != !y->mls) ||
|
|
|
|
((x->mls) && (y->mls) && (x->mls->len != y->mls->len)))
|
2017-03-08 01:42:41 +08:00
|
|
|
return 0;
|
|
|
|
|
2017-03-17 22:48:09 +08:00
|
|
|
if (!x->mls)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (uint i = 0; i < x->mls->len; i++)
|
|
|
|
if (x->mls->stack[i] != y->mls->stack[i])
|
2017-03-08 01:42:41 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return !x && !y;
|
2010-02-27 23:00:07 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
case RTDX_RECURSIVE:
|
2017-03-17 22:48:09 +08:00
|
|
|
if (!ipa_equal(x->via, y->via) ||
|
|
|
|
(!x->mls != !y->mls) ||
|
|
|
|
((x->mls) && (y->mls) && (x->mls->len != y->mls->len)))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!x->mls)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
for (uint i = 0; i < x->mls->len; i++)
|
|
|
|
if (x->mls->stack[i] != y->mls->stack[i])
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
2016-01-26 18:48:58 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
default:
|
|
|
|
return 1;
|
|
|
|
}
|
2000-05-13 19:01:41 +08:00
|
|
|
}
|
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
static inline int
|
|
|
|
static_same_rte(struct static_route *or, struct static_route *nr)
|
2011-09-24 08:21:52 +08:00
|
|
|
{
|
2017-03-08 01:42:41 +08:00
|
|
|
/* Note that i_same() requires arguments in (new, old) order */
|
2018-12-27 21:26:11 +08:00
|
|
|
return static_same_dest(or, nr) && f_same(nr->cmds, or->cmds);
|
2011-09-24 08:21:52 +08:00
|
|
|
}
|
|
|
|
|
2015-07-25 00:02:07 +08:00
|
|
|
static void
|
2017-03-08 01:42:41 +08:00
|
|
|
static_reconfigure_rte(struct static_proto *p, struct static_route *or, struct static_route *nr)
|
2015-07-25 00:02:07 +08:00
|
|
|
{
|
2017-03-08 01:42:41 +08:00
|
|
|
if ((or->state == SRS_CLEAN) && !static_same_rte(or, nr))
|
|
|
|
nr->state = SRS_DIRTY;
|
|
|
|
else
|
|
|
|
nr->state = or->state;
|
2015-07-25 00:02:07 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
static_add_rte(p, nr);
|
|
|
|
static_reset_rte(p, or);
|
2015-07-25 00:02:07 +08:00
|
|
|
}
|
2011-09-24 08:21:52 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
|
1998-12-07 02:21:23 +08:00
|
|
|
static void
|
|
|
|
static_neigh_notify(struct neighbor *n)
|
|
|
|
{
|
2017-03-08 01:42:41 +08:00
|
|
|
struct static_proto *p = (void *) n->proto;
|
1998-12-09 02:31:31 +08:00
|
|
|
struct static_route *r;
|
|
|
|
|
2011-04-01 18:21:18 +08:00
|
|
|
DBG("Static: neighbor notify for %I: iface %p\n", n->addr, n->iface);
|
2017-03-08 01:42:41 +08:00
|
|
|
for (r = n->data; r; r = r->chain)
|
2015-07-25 00:02:07 +08:00
|
|
|
{
|
|
|
|
static_update_bfd(p, r);
|
2017-03-08 01:42:41 +08:00
|
|
|
|
|
|
|
if (static_decide(p, r))
|
|
|
|
static_mark_rte(p, r->mp_head);
|
2015-07-25 00:02:07 +08:00
|
|
|
}
|
|
|
|
}
|
2010-12-08 06:34:36 +08:00
|
|
|
|
2015-07-25 00:02:07 +08:00
|
|
|
static void
|
|
|
|
static_bfd_notify(struct bfd_request *req)
|
|
|
|
{
|
|
|
|
struct static_route *r = req->data;
|
2017-03-08 01:42:41 +08:00
|
|
|
struct static_proto *p = (void *) r->neigh->proto;
|
2010-12-08 06:34:36 +08:00
|
|
|
|
2015-07-25 00:02:07 +08:00
|
|
|
// if (req->down) TRACE(D_EVENTS, "BFD session down for nbr %I on %s", XXXX);
|
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
if (static_decide(p, r))
|
|
|
|
static_mark_rte(p, r->mp_head);
|
1998-12-07 02:21:23 +08:00
|
|
|
}
|
|
|
|
|
2021-03-10 22:07:19 +08:00
|
|
|
static void
|
|
|
|
static_reload_routes(struct channel *C)
|
|
|
|
{
|
|
|
|
struct static_proto *p = (void *) C->proto;
|
|
|
|
|
|
|
|
TRACE(D_EVENTS, "Scheduling route reload");
|
|
|
|
|
|
|
|
static_mark_all(p);
|
|
|
|
}
|
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
static int
|
2020-11-19 23:38:39 +08:00
|
|
|
static_rte_better(rte *new, rte *old)
|
2015-06-08 08:20:43 +08:00
|
|
|
{
|
2020-11-19 23:38:39 +08:00
|
|
|
u32 n = ea_get_int(new->attrs->eattrs, EA_GEN_IGP_METRIC, IGP_METRIC_UNKNOWN);
|
|
|
|
u32 o = ea_get_int(old->attrs->eattrs, EA_GEN_IGP_METRIC, IGP_METRIC_UNKNOWN);
|
|
|
|
return n < o;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
static_rte_mergable(rte *pri, rte *sec)
|
|
|
|
{
|
|
|
|
u32 a = ea_get_int(pri->attrs->eattrs, EA_GEN_IGP_METRIC, IGP_METRIC_UNKNOWN);
|
|
|
|
u32 b = ea_get_int(sec->attrs->eattrs, EA_GEN_IGP_METRIC, IGP_METRIC_UNKNOWN);
|
|
|
|
return a == b;
|
2015-06-08 08:20:43 +08:00
|
|
|
}
|
|
|
|
|
2020-11-19 23:38:39 +08:00
|
|
|
static void static_index_routes(struct static_config *cf);
|
1998-12-07 02:21:23 +08:00
|
|
|
|
2016-01-26 18:48:58 +08:00
|
|
|
static void
|
|
|
|
static_postconfig(struct proto_config *CF)
|
|
|
|
{
|
|
|
|
struct static_config *cf = (void *) CF;
|
|
|
|
struct static_route *r;
|
|
|
|
|
2021-06-17 22:56:51 +08:00
|
|
|
if (! proto_cf_main_channel(CF))
|
2016-01-26 18:48:58 +08:00
|
|
|
cf_error("Channel not specified");
|
|
|
|
|
2017-03-30 19:29:34 +08:00
|
|
|
struct channel_config *cc = proto_cf_main_channel(CF);
|
|
|
|
|
|
|
|
if (!cf->igp_table_ip4)
|
|
|
|
cf->igp_table_ip4 = (cc->table->addr_type == NET_IP4) ?
|
|
|
|
cc->table : cf->c.global->def_tables[NET_IP4];
|
|
|
|
|
|
|
|
if (!cf->igp_table_ip6)
|
|
|
|
cf->igp_table_ip6 = (cc->table->addr_type == NET_IP6) ?
|
|
|
|
cc->table : cf->c.global->def_tables[NET_IP6];
|
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
WALK_LIST(r, cf->routes)
|
2016-06-13 21:49:53 +08:00
|
|
|
if (r->net && (r->net->type != CF->net_type))
|
|
|
|
cf_error("Route %N incompatible with channel type", r->net);
|
2020-11-19 23:38:39 +08:00
|
|
|
|
|
|
|
static_index_routes(cf);
|
2016-01-26 18:48:58 +08:00
|
|
|
}
|
|
|
|
|
1999-02-06 05:38:22 +08:00
|
|
|
static struct proto *
|
2016-01-26 18:48:58 +08:00
|
|
|
static_init(struct proto_config *CF)
|
1998-12-07 02:21:23 +08:00
|
|
|
{
|
2016-01-26 18:48:58 +08:00
|
|
|
struct proto *P = proto_new(CF);
|
2017-03-30 19:29:34 +08:00
|
|
|
struct static_proto *p = (void *) P;
|
|
|
|
struct static_config *cf = (void *) CF;
|
1998-12-07 02:21:23 +08:00
|
|
|
|
2016-01-26 18:48:58 +08:00
|
|
|
P->main_channel = proto_add_channel(P, proto_cf_main_channel(CF));
|
2012-08-14 22:25:22 +08:00
|
|
|
|
2016-01-26 18:48:58 +08:00
|
|
|
P->neigh_notify = static_neigh_notify;
|
2021-03-10 22:07:19 +08:00
|
|
|
P->reload_routes = static_reload_routes;
|
2020-11-19 23:38:39 +08:00
|
|
|
P->rte_better = static_rte_better;
|
2016-01-26 18:48:58 +08:00
|
|
|
P->rte_mergable = static_rte_mergable;
|
|
|
|
|
2017-03-30 19:29:34 +08:00
|
|
|
if (cf->igp_table_ip4)
|
|
|
|
p->igp_table_ip4 = cf->igp_table_ip4->table;
|
|
|
|
|
|
|
|
if (cf->igp_table_ip6)
|
|
|
|
p->igp_table_ip6 = cf->igp_table_ip6->table;
|
|
|
|
|
2016-01-26 18:48:58 +08:00
|
|
|
return P;
|
1998-12-07 02:21:23 +08:00
|
|
|
}
|
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
static int
|
|
|
|
static_start(struct proto *P)
|
2010-05-16 17:03:59 +08:00
|
|
|
{
|
2017-03-08 01:42:41 +08:00
|
|
|
struct static_proto *p = (void *) P;
|
|
|
|
struct static_config *cf = (void *) P->cf;
|
|
|
|
struct static_route *r;
|
2010-12-08 06:34:36 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
if (!static_lp)
|
2017-05-16 20:31:16 +08:00
|
|
|
static_lp = lp_new(&root_pool, LP_GOOD_SIZE(1024));
|
2010-12-08 06:34:36 +08:00
|
|
|
|
2017-03-30 19:29:34 +08:00
|
|
|
if (p->igp_table_ip4)
|
|
|
|
rt_lock_table(p->igp_table_ip4);
|
|
|
|
|
|
|
|
if (p->igp_table_ip6)
|
|
|
|
rt_lock_table(p->igp_table_ip6);
|
2011-09-24 08:21:52 +08:00
|
|
|
|
2018-10-01 21:55:23 +08:00
|
|
|
p->event = ev_new_init(p->p.pool, static_announce_marked, p);
|
2000-01-17 20:38:50 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
BUFFER_INIT(p->marked, p->p.pool, 4);
|
2015-07-20 17:12:02 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
/* We have to go UP before routes could be installed */
|
|
|
|
proto_notify_state(P, PS_UP);
|
2015-07-20 17:12:02 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
WALK_LIST(r, cf->routes)
|
|
|
|
static_add_rte(p, r);
|
2000-01-17 20:38:50 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
return PS_UP;
|
|
|
|
}
|
2016-06-13 21:49:53 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
static int
|
|
|
|
static_shutdown(struct proto *P)
|
|
|
|
{
|
|
|
|
struct static_proto *p = (void *) P;
|
|
|
|
struct static_config *cf = (void *) P->cf;
|
|
|
|
struct static_route *r;
|
2010-05-16 17:03:59 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
/* Just reset the flag, the routes will be flushed by the nest */
|
|
|
|
WALK_LIST(r, cf->routes)
|
|
|
|
static_reset_rte(p, r);
|
2014-02-26 20:25:39 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
return PS_DOWN;
|
|
|
|
}
|
2016-06-13 21:49:53 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
static void
|
|
|
|
static_cleanup(struct proto *P)
|
|
|
|
{
|
2017-03-30 19:29:34 +08:00
|
|
|
struct static_proto *p = (void *) P;
|
|
|
|
|
|
|
|
if (p->igp_table_ip4)
|
|
|
|
rt_unlock_table(p->igp_table_ip4);
|
2014-02-26 20:25:39 +08:00
|
|
|
|
2017-03-30 19:29:34 +08:00
|
|
|
if (p->igp_table_ip6)
|
|
|
|
rt_unlock_table(p->igp_table_ip6);
|
2017-03-08 01:42:41 +08:00
|
|
|
}
|
2014-02-26 20:25:39 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
static void
|
|
|
|
static_dump_rte(struct static_route *r)
|
|
|
|
{
|
2020-11-19 23:38:39 +08:00
|
|
|
debug("%-1N (%u): ", r->net, r->index);
|
2017-03-08 01:42:41 +08:00
|
|
|
if (r->dest == RTD_UNICAST)
|
|
|
|
if (r->iface && ipa_zero(r->via))
|
|
|
|
debug("dev %s\n", r->iface->name);
|
|
|
|
else
|
|
|
|
debug("via %I%J\n", r->via, r->iface);
|
|
|
|
else
|
|
|
|
debug("rtd %d\n", r->dest);
|
|
|
|
}
|
2014-02-26 20:25:39 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
static void
|
|
|
|
static_dump(struct proto *P)
|
|
|
|
{
|
|
|
|
struct static_config *c = (void *) P->cf;
|
|
|
|
struct static_route *r;
|
2016-06-13 21:49:53 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
debug("Static routes:\n");
|
|
|
|
WALK_LIST(r, c->routes)
|
|
|
|
static_dump_rte(r);
|
2000-01-17 20:38:50 +08:00
|
|
|
}
|
|
|
|
|
2017-03-30 19:29:34 +08:00
|
|
|
#define IGP_TABLE(cf, sym) ((cf)->igp_table_##sym ? (cf)->igp_table_##sym ->table : NULL )
|
2011-09-24 08:21:52 +08:00
|
|
|
|
2020-11-19 23:38:39 +08:00
|
|
|
static inline int srt_equal(const struct static_route *a, const struct static_route *b)
|
|
|
|
{ return net_equal(a->net, b->net) && (a->index == b->index); }
|
|
|
|
|
|
|
|
static inline int srt_compare(const struct static_route *a, const struct static_route *b)
|
|
|
|
{ return net_compare(a->net, b->net) ?: uint_cmp(a->index, b->index); }
|
|
|
|
|
|
|
|
static inline int srt_compare_qsort(const void *A, const void *B)
|
2017-03-08 01:42:41 +08:00
|
|
|
{
|
2020-11-19 23:38:39 +08:00
|
|
|
return srt_compare(*(const struct static_route * const *)A,
|
|
|
|
*(const struct static_route * const *)B);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
static_index_routes(struct static_config *cf)
|
|
|
|
{
|
|
|
|
struct static_route *rt, **buf;
|
|
|
|
uint num, i, v;
|
|
|
|
|
|
|
|
num = list_length(&cf->routes);
|
|
|
|
buf = xmalloc(num * sizeof(void *));
|
|
|
|
|
|
|
|
/* Initialize with sequential indexes to ensure stable sorting */
|
|
|
|
i = 0;
|
|
|
|
WALK_LIST(rt, cf->routes)
|
|
|
|
{
|
|
|
|
buf[i] = rt;
|
|
|
|
rt->index = i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
qsort(buf, num, sizeof(struct static_route *), srt_compare_qsort);
|
|
|
|
|
|
|
|
/* Compute proper indexes - sequential for routes with same network */
|
|
|
|
for (i = 0, v = 0, rt = NULL; i < num; i++, v++)
|
|
|
|
{
|
|
|
|
if (rt && !net_equal(buf[i]->net, rt->net))
|
|
|
|
v = 0;
|
|
|
|
|
|
|
|
rt = buf[i];
|
|
|
|
rt->index = v;
|
|
|
|
}
|
|
|
|
|
|
|
|
xfree(buf);
|
2017-03-08 01:42:41 +08:00
|
|
|
}
|
|
|
|
|
2000-01-17 19:52:50 +08:00
|
|
|
static int
|
2017-03-08 01:42:41 +08:00
|
|
|
static_reconfigure(struct proto *P, struct proto_config *CF)
|
2000-01-17 19:52:50 +08:00
|
|
|
{
|
2017-03-08 01:42:41 +08:00
|
|
|
struct static_proto *p = (void *) P;
|
|
|
|
struct static_config *o = (void *) P->cf;
|
2016-01-26 18:48:58 +08:00
|
|
|
struct static_config *n = (void *) CF;
|
2017-03-08 01:42:41 +08:00
|
|
|
struct static_route *r, *r2, *or, *nr;
|
2000-01-17 20:38:50 +08:00
|
|
|
|
2017-03-30 19:29:34 +08:00
|
|
|
/* Check change in IGP tables */
|
|
|
|
if ((IGP_TABLE(o, ip4) != IGP_TABLE(n, ip4)) ||
|
|
|
|
(IGP_TABLE(o, ip6) != IGP_TABLE(n, ip6)))
|
2011-09-24 08:21:52 +08:00
|
|
|
return 0;
|
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
if (!proto_configure_channel(P, &P->main_channel, proto_cf_main_channel(CF)))
|
2016-01-26 18:48:58 +08:00
|
|
|
return 0;
|
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
p->p.cf = CF;
|
|
|
|
|
|
|
|
/* Reset route lists in neighbor entries */
|
|
|
|
WALK_LIST(r, o->routes)
|
|
|
|
for (r2 = r; r2; r2 = r2->mp_next)
|
|
|
|
if (r2->neigh)
|
|
|
|
r2->neigh->data = NULL;
|
|
|
|
|
|
|
|
/* Reconfigure initial matching sequence */
|
|
|
|
for (or = HEAD(o->routes), nr = HEAD(n->routes);
|
2020-11-19 23:38:39 +08:00
|
|
|
NODE_VALID(or) && NODE_VALID(nr) && srt_equal(or, nr);
|
2017-03-08 01:42:41 +08:00
|
|
|
or = NODE_NEXT(or), nr = NODE_NEXT(nr))
|
|
|
|
static_reconfigure_rte(p, or, nr);
|
|
|
|
|
|
|
|
if (!NODE_VALID(or) && !NODE_VALID(nr))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
/* Reconfigure remaining routes, sort them to find matching pairs */
|
|
|
|
struct static_route *or2, *nr2, **orbuf, **nrbuf;
|
|
|
|
uint ornum = 0, nrnum = 0, orpos = 0, nrpos = 0, i;
|
|
|
|
|
|
|
|
for (or2 = or; NODE_VALID(or2); or2 = NODE_NEXT(or2))
|
|
|
|
ornum++;
|
|
|
|
|
|
|
|
for (nr2 = nr; NODE_VALID(nr2); nr2 = NODE_NEXT(nr2))
|
|
|
|
nrnum++;
|
|
|
|
|
|
|
|
orbuf = xmalloc(ornum * sizeof(void *));
|
|
|
|
nrbuf = xmalloc(nrnum * sizeof(void *));
|
2016-06-13 21:49:53 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
for (i = 0, or2 = or; i < ornum; i++, or2 = NODE_NEXT(or2))
|
|
|
|
orbuf[i] = or2;
|
|
|
|
|
|
|
|
for (i = 0, nr2 = nr; i < nrnum; i++, nr2 = NODE_NEXT(nr2))
|
|
|
|
nrbuf[i] = nr2;
|
|
|
|
|
2020-11-19 23:38:39 +08:00
|
|
|
qsort(orbuf, ornum, sizeof(struct static_route *), srt_compare_qsort);
|
|
|
|
qsort(nrbuf, nrnum, sizeof(struct static_route *), srt_compare_qsort);
|
2017-03-08 01:42:41 +08:00
|
|
|
|
|
|
|
while ((orpos < ornum) && (nrpos < nrnum))
|
2016-06-13 21:49:53 +08:00
|
|
|
{
|
2020-11-19 23:38:39 +08:00
|
|
|
int x = srt_compare(orbuf[orpos], nrbuf[nrpos]);
|
2017-03-08 01:42:41 +08:00
|
|
|
if (x < 0)
|
|
|
|
static_remove_rte(p, orbuf[orpos++]);
|
|
|
|
else if (x > 0)
|
|
|
|
static_add_rte(p, nrbuf[nrpos++]);
|
|
|
|
else
|
|
|
|
static_reconfigure_rte(p, orbuf[orpos++], nrbuf[nrpos++]);
|
2016-06-13 21:49:53 +08:00
|
|
|
}
|
2000-01-17 20:38:50 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
while (orpos < ornum)
|
|
|
|
static_remove_rte(p, orbuf[orpos++]);
|
2015-07-25 00:02:07 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
while (nrpos < nrnum)
|
|
|
|
static_add_rte(p, nrbuf[nrpos++]);
|
2000-01-17 19:52:50 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
xfree(orbuf);
|
|
|
|
xfree(nrbuf);
|
2011-11-07 07:31:23 +08:00
|
|
|
|
2021-03-10 22:07:19 +08:00
|
|
|
/* All dirty routes were announced anyways */
|
|
|
|
BUFFER_FLUSH(p->marked);
|
|
|
|
p->marked_all = 0;
|
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
return 1;
|
2011-11-07 07:31:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
static_copy_config(struct proto_config *dest, struct proto_config *src)
|
|
|
|
{
|
|
|
|
struct static_config *d = (struct static_config *) dest;
|
|
|
|
struct static_config *s = (struct static_config *) src;
|
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
struct static_route *srt, *snh;
|
2011-11-07 07:31:23 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
/* Copy route list */
|
|
|
|
init_list(&d->routes);
|
|
|
|
WALK_LIST(srt, s->routes)
|
|
|
|
{
|
|
|
|
struct static_route *drt = NULL, *dnh = NULL, **dnp = &drt;
|
1999-12-03 19:41:23 +08:00
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
for (snh = srt; snh; snh = snh->mp_next)
|
1999-12-03 19:41:23 +08:00
|
|
|
{
|
2017-03-08 01:42:41 +08:00
|
|
|
dnh = cfg_alloc(sizeof(struct static_route));
|
|
|
|
memcpy(dnh, snh, sizeof(struct static_route));
|
2020-11-24 10:42:23 +08:00
|
|
|
memset(&dnh->n, 0, sizeof(node));
|
2017-03-08 01:42:41 +08:00
|
|
|
|
|
|
|
if (!drt)
|
|
|
|
add_tail(&d->routes, &(dnh->n));
|
|
|
|
|
|
|
|
*dnp = dnh;
|
|
|
|
dnp = &(dnh->mp_next);
|
|
|
|
|
|
|
|
if (snh->mp_head)
|
|
|
|
dnh->mp_head = drt;
|
1999-12-03 19:41:23 +08:00
|
|
|
}
|
2017-03-08 01:42:41 +08:00
|
|
|
}
|
2016-05-06 21:48:35 +08:00
|
|
|
}
|
2010-12-08 06:34:36 +08:00
|
|
|
|
2020-11-19 23:38:39 +08:00
|
|
|
static void
|
|
|
|
static_get_route_info(rte *rte, byte *buf)
|
|
|
|
{
|
|
|
|
eattr *a = ea_find(rte->attrs->eattrs, EA_GEN_IGP_METRIC);
|
|
|
|
if (a)
|
2020-02-10 15:41:05 +08:00
|
|
|
buf += bsprintf(buf, " (%d/%u)", rte->attrs->pref, a->u.data);
|
2020-11-19 23:38:39 +08:00
|
|
|
else
|
2020-02-10 15:41:05 +08:00
|
|
|
buf += bsprintf(buf, " (%d)", rte->attrs->pref);
|
2020-11-19 23:38:39 +08:00
|
|
|
}
|
|
|
|
|
2016-05-06 21:48:35 +08:00
|
|
|
static void
|
|
|
|
static_show_rt(struct static_route *r)
|
|
|
|
{
|
2017-03-08 01:42:41 +08:00
|
|
|
switch (r->dest)
|
|
|
|
{
|
|
|
|
case RTD_UNICAST:
|
2016-05-06 21:48:35 +08:00
|
|
|
{
|
|
|
|
struct static_route *r2;
|
2017-03-08 01:42:41 +08:00
|
|
|
|
|
|
|
cli_msg(-1009, "%N", r->net);
|
2016-05-06 21:48:35 +08:00
|
|
|
for (r2 = r; r2; r2 = r2->mp_next)
|
2016-06-13 21:49:53 +08:00
|
|
|
{
|
2017-03-08 01:42:41 +08:00
|
|
|
if (r2->iface && ipa_zero(r2->via))
|
2017-07-05 05:36:21 +08:00
|
|
|
cli_msg(-1009, "\tdev %s%s", r2->iface->name,
|
|
|
|
r2->active ? "" : " (dormant)");
|
2017-03-08 01:42:41 +08:00
|
|
|
else
|
2017-07-05 05:36:21 +08:00
|
|
|
cli_msg(-1009, "\tvia %I%J%s%s%s", r2->via, r2->iface,
|
|
|
|
r2->onlink ? " onlink" : "",
|
|
|
|
r2->bfd_req ? " (bfd)" : "",
|
|
|
|
r2->active ? "" : " (dormant)");
|
2016-06-13 21:49:53 +08:00
|
|
|
}
|
2017-03-08 01:42:41 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case RTD_NONE:
|
|
|
|
case RTD_BLACKHOLE:
|
|
|
|
case RTD_UNREACHABLE:
|
|
|
|
case RTD_PROHIBIT:
|
|
|
|
cli_msg(-1009, "%N\t%s", r->net, rta_dest_names[r->dest]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RTDX_RECURSIVE:
|
|
|
|
cli_msg(-1009, "%N\trecursive %I", r->net, r->via);
|
|
|
|
break;
|
2016-05-06 21:48:35 +08:00
|
|
|
}
|
1999-12-03 19:41:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
static_show(struct proto *P)
|
|
|
|
{
|
|
|
|
struct static_config *c = (void *) P->cf;
|
|
|
|
struct static_route *r;
|
|
|
|
|
2017-03-08 01:42:41 +08:00
|
|
|
WALK_LIST(r, c->routes)
|
2016-06-13 21:49:53 +08:00
|
|
|
static_show_rt(r);
|
1999-12-03 19:41:23 +08:00
|
|
|
}
|
2017-03-08 01:42:41 +08:00
|
|
|
|
|
|
|
|
|
|
|
struct protocol proto_static = {
|
|
|
|
.name = "Static",
|
|
|
|
.template = "static%d",
|
2018-05-07 20:47:00 +08:00
|
|
|
.class = PROTOCOL_STATIC,
|
2017-03-08 01:42:41 +08:00
|
|
|
.preference = DEF_PREF_STATIC,
|
|
|
|
.channel_mask = NB_ANY,
|
|
|
|
.proto_size = sizeof(struct static_proto),
|
|
|
|
.config_size = sizeof(struct static_config),
|
|
|
|
.postconfig = static_postconfig,
|
|
|
|
.init = static_init,
|
|
|
|
.dump = static_dump,
|
|
|
|
.start = static_start,
|
|
|
|
.shutdown = static_shutdown,
|
|
|
|
.cleanup = static_cleanup,
|
|
|
|
.reconfigure = static_reconfigure,
|
2020-11-19 23:38:39 +08:00
|
|
|
.copy_config = static_copy_config,
|
|
|
|
.get_route_info = static_get_route_info,
|
2017-03-08 01:42:41 +08:00
|
|
|
};
|