0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2025-01-03 07:31:54 +00:00

Nest: Handle unresolvable routes as invalid

Handle unresolvable routes (recursive routes that cannot be resolved) as
invalid, i.e. deprioritize tham and do not allow them for propagation.
Such route now shows as 'unresolvable' instead of 'unreachable'.
This commit is contained in:
Ondrej Zajicek (work) 2019-05-10 14:51:33 +02:00
parent 3cd20658e2
commit e092341df3
4 changed files with 14 additions and 4 deletions

View File

@ -270,8 +270,10 @@ typedef struct rte {
#define REF_STALE 4 /* Route is stale in a refresh cycle */ #define REF_STALE 4 /* Route is stale in a refresh cycle */
#define REF_DISCARD 8 /* Route is scheduled for discard */ #define REF_DISCARD 8 /* Route is scheduled for discard */
static inline int rte_is_resolvable(rte *r);
/* Route is valid for propagation (may depend on other flags in the future), accepts NULL */ /* Route is valid for propagation (may depend on other flags in the future), accepts NULL */
static inline int rte_is_valid(rte *r) { return r && !(r->flags & REF_FILTERED); } static inline int rte_is_valid(rte *r) { return r && !(r->flags & REF_FILTERED) && rte_is_resolvable(r); }
/* Route just has REF_FILTERED flag */ /* Route just has REF_FILTERED flag */
static inline int rte_is_filtered(rte *r) { return !!(r->flags & REF_FILTERED); } static inline int rte_is_filtered(rte *r) { return !!(r->flags & REF_FILTERED); }
@ -451,7 +453,8 @@ typedef struct rta {
#define RTD_BLACKHOLE 2 /* Silently drop packets */ #define RTD_BLACKHOLE 2 /* Silently drop packets */
#define RTD_UNREACHABLE 3 /* Reject as unreachable */ #define RTD_UNREACHABLE 3 /* Reject as unreachable */
#define RTD_PROHIBIT 4 /* Administratively prohibited */ #define RTD_PROHIBIT 4 /* Administratively prohibited */
#define RTD_MAX 5 #define RTD_UNRESOLVABLE 5 /* Recursive route is unresolvable */
#define RTD_MAX 6
/* Flags for net->n.flags, used by kernel syncer */ /* Flags for net->n.flags, used by kernel syncer */
#define KRF_INSTALLED 0x80 /* This route should be installed in the kernel */ #define KRF_INSTALLED 0x80 /* This route should be installed in the kernel */
@ -472,6 +475,9 @@ static inline const char *rta_dest_name(uint n)
static inline int rte_is_reachable(rte *r) static inline int rte_is_reachable(rte *r)
{ return r->attrs->dest == RTD_UNICAST; } { return r->attrs->dest == RTD_UNICAST; }
static inline int rte_is_resolvable(rte *r)
{ return r->attrs->dest != RTD_UNRESOLVABLE; }
/* /*
* Extended Route Attributes * Extended Route Attributes

View File

@ -64,6 +64,7 @@ const char * rta_dest_names[RTD_MAX] = {
[RTD_BLACKHOLE] = "blackhole", [RTD_BLACKHOLE] = "blackhole",
[RTD_UNREACHABLE] = "unreachable", [RTD_UNREACHABLE] = "unreachable",
[RTD_PROHIBIT] = "prohibited", [RTD_PROHIBIT] = "prohibited",
[RTD_UNRESOLVABLE] = "unresolvable",
}; };
pool *rta_pool; pool *rta_pool;

View File

@ -34,7 +34,7 @@ rt_show_rte(struct cli *c, byte *ia, rte *e, struct rt_show_data *d, ea_list *tm
byte from[IPA_MAX_TEXT_LENGTH+8]; byte from[IPA_MAX_TEXT_LENGTH+8];
byte tm[TM_DATETIME_BUFFER_SIZE], info[256]; byte tm[TM_DATETIME_BUFFER_SIZE], info[256];
rta *a = e->attrs; rta *a = e->attrs;
int primary = (e->net->routes == e); int primary = (e->net->routes == e) && rte_is_valid(e);
int sync_error = (e->net->n.flags & KRF_SYNC_ERROR); int sync_error = (e->net->n.flags & KRF_SYNC_ERROR);
void (*get_route_info)(struct rte *, byte *buf, struct ea_list *attrs); void (*get_route_info)(struct rte *, byte *buf, struct ea_list *attrs);
struct nexthop *nh; struct nexthop *nh;
@ -139,6 +139,9 @@ rt_show_net(struct cli *c, net *n, struct rt_show_data *d)
} }
else if (d->export_mode) else if (d->export_mode)
{ {
if (!rte_is_valid(e))
goto skip;
struct proto *ep = ec->proto; struct proto *ep = ec->proto;
int ic = ep->import_control ? ep->import_control(ep, &e, &tmpa, c->show_pool) : 0; int ic = ep->import_control ? ep->import_control(ep, &e, &tmpa, c->show_pool) : 0;

View File

@ -2609,7 +2609,7 @@ rt_update_hostentry(rtable *tab, struct hostentry *he)
/* Reset the hostentry */ /* Reset the hostentry */
he->src = NULL; he->src = NULL;
he->dest = RTD_UNREACHABLE; he->dest = RTD_UNRESOLVABLE;
he->nexthop_linkable = 0; he->nexthop_linkable = 0;
he->igp_metric = 0; he->igp_metric = 0;