0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 09:41:54 +00:00

Removing the route scope attribute. Use custom attributes instead.

The route scope attribute was used for simple user route marking. As
there is a better tool for this (custom attributes), the old and limited
way can be dropped.
This commit is contained in:
Maria Matejka 2022-05-04 12:41:54 +02:00
parent 0c4e0e4a63
commit 702c04fbef
17 changed files with 3 additions and 38 deletions

View File

@ -1723,14 +1723,6 @@ Common route attributes are:
primary key of the routing table. Read-only. (See the <ref id="routes" primary key of the routing table. Read-only. (See the <ref id="routes"
name="chapter about routes">.) name="chapter about routes">.)
<tag><label id="rta-scope"><m/enum/ scope</tag>
The scope of the route. Possible values: <cf/SCOPE_HOST/ for routes
local to this host, <cf/SCOPE_LINK/ for those specific for a physical
link, <cf/SCOPE_SITE/ and <cf/SCOPE_ORGANIZATION/ for private routes and
<cf/SCOPE_UNIVERSE/ for globally visible routes. This attribute is not
interpreted by BIRD and can be used to mark routes in filters. The
default value for new routes is <cf/SCOPE_UNIVERSE/.
<tag><label id="rta-preference"><m/int/ preference</tag> <tag><label id="rta-preference"><m/int/ preference</tag>
Preference of the route. Preference of the route.

View File

@ -766,7 +766,6 @@ static_attr:
| NET { $$ = f_new_static_attr(T_NET, SA_NET, 1); } | NET { $$ = f_new_static_attr(T_NET, SA_NET, 1); }
| PROTO { $$ = f_new_static_attr(T_STRING, SA_PROTO, 1); } | PROTO { $$ = f_new_static_attr(T_STRING, SA_PROTO, 1); }
| SOURCE { $$ = f_new_static_attr(T_ENUM_RTS, SA_SOURCE, 1); } | SOURCE { $$ = f_new_static_attr(T_ENUM_RTS, SA_SOURCE, 1); }
| SCOPE { $$ = f_new_static_attr(T_ENUM_SCOPE, SA_SCOPE, 0); }
| DEST { $$ = f_new_static_attr(T_ENUM_RTD, SA_DEST, 0); } | DEST { $$ = f_new_static_attr(T_ENUM_RTD, SA_DEST, 0); }
| IFNAME { $$ = f_new_static_attr(T_STRING, SA_IFNAME, 0); } | IFNAME { $$ = f_new_static_attr(T_STRING, SA_IFNAME, 0); }
| IFINDEX { $$ = f_new_static_attr(T_INT, SA_IFINDEX, 1); } | IFINDEX { $$ = f_new_static_attr(T_INT, SA_IFINDEX, 1); }

View File

@ -26,7 +26,6 @@ enum f_sa_code {
SA_NET, SA_NET,
SA_PROTO, SA_PROTO,
SA_SOURCE, SA_SOURCE,
SA_SCOPE,
SA_DEST, SA_DEST,
SA_IFNAME, SA_IFNAME,
SA_IFINDEX, SA_IFINDEX,

View File

@ -537,7 +537,6 @@
case SA_NET: RESULT(sa.type, net, (*fs->rte)->net->n.addr); break; case SA_NET: RESULT(sa.type, net, (*fs->rte)->net->n.addr); break;
case SA_PROTO: RESULT(sa.type, s, (*fs->rte)->src->proto->name); break; case SA_PROTO: RESULT(sa.type, s, (*fs->rte)->src->proto->name); break;
case SA_SOURCE: RESULT(sa.type, i, rta->source); break; case SA_SOURCE: RESULT(sa.type, i, rta->source); break;
case SA_SCOPE: RESULT(sa.type, i, rta->scope); break;
case SA_DEST: RESULT(sa.type, i, rta->dest); break; case SA_DEST: RESULT(sa.type, i, rta->dest); break;
case SA_IFNAME: RESULT(sa.type, s, rta->nh.iface ? rta->nh.iface->name : ""); break; case SA_IFNAME: RESULT(sa.type, s, rta->nh.iface ? rta->nh.iface->name : ""); break;
case SA_IFINDEX: RESULT(sa.type, i, rta->nh.iface ? rta->nh.iface->index : 0); break; case SA_IFINDEX: RESULT(sa.type, i, rta->nh.iface ? rta->nh.iface->index : 0); break;
@ -579,10 +578,6 @@
} }
break; break;
case SA_SCOPE:
rta->scope = v1.val.i;
break;
case SA_DEST: case SA_DEST:
{ {
int i = v1.val.i; int i = v1.val.i;

View File

@ -38,12 +38,6 @@ protocol static {
print from; print from;
from = 1.2.3.4; from = 1.2.3.4;
print from; print from;
print scope;
scope = SCOPE_HOST;
print scope;
if !(scope ~ [ SCOPE_HOST, SCOPE_SITE ]) then {
print "Failed in test";
}
preference = 15; preference = 15;
print preference; print preference;

View File

@ -86,7 +86,6 @@ typedef struct rta {
struct hostentry *hostentry; /* Hostentry for recursive next-hops */ struct hostentry *hostentry; /* Hostentry for recursive next-hops */
u16 cached:1; /* Are attributes cached? */ u16 cached:1; /* Are attributes cached? */
u16 source:7; /* Route source (RTS_...) */ u16 source:7; /* Route source (RTS_...) */
u16 scope:4; /* Route scope (SCOPE_... -- see ip.h) */
u16 dest:4; /* Route destination type (RTD_...) */ u16 dest:4; /* Route destination type (RTD_...) */
struct nexthop nh; /* Next hop */ struct nexthop nh; /* Next hop */
} rta; } rta;

View File

@ -1235,7 +1235,6 @@ rta_hash(rta *a)
#define BMIX(f) mem_hash_mix_num(&h, a->f); #define BMIX(f) mem_hash_mix_num(&h, a->f);
MIX(hostentry); MIX(hostentry);
BMIX(source); BMIX(source);
BMIX(scope);
BMIX(dest); BMIX(dest);
#undef MIX #undef MIX
@ -1246,7 +1245,6 @@ static inline int
rta_same(rta *x, rta *y) rta_same(rta *x, rta *y)
{ {
return (x->source == y->source && return (x->source == y->source &&
x->scope == y->scope &&
x->dest == y->dest && x->dest == y->dest &&
x->hostentry == y->hostentry && x->hostentry == y->hostentry &&
nexthop_same(&(x->nh), &(y->nh)) && nexthop_same(&(x->nh), &(y->nh)) &&
@ -1396,8 +1394,8 @@ rta_dump(rta *a)
"RTS_OSPF_EXT2", "RTS_BGP", "RTS_PIPE", "RTS_BABEL" }; "RTS_OSPF_EXT2", "RTS_BGP", "RTS_PIPE", "RTS_BABEL" };
static char *rtd[] = { "", " DEV", " HOLE", " UNREACH", " PROHIBIT" }; static char *rtd[] = { "", " DEV", " HOLE", " UNREACH", " PROHIBIT" };
debug("uc=%d %s %s%s h=%04x", debug("uc=%d %s %s h=%04x",
a->uc, rts[a->source], ip_scope_text(a->scope), a->uc, rts[a->source],
rtd[a->dest], a->hash_key); rtd[a->dest], a->hash_key);
if (!a->cached) if (!a->cached)
debug(" !CACHED"); debug(" !CACHED");
@ -1443,7 +1441,7 @@ rta_dump_all(void)
void void
rta_show(struct cli *c, rta *a) rta_show(struct cli *c, rta *a)
{ {
cli_printf(c, -1008, "\tType: %s %s", rta_src_names[a->source], ip_scope_text(a->scope)); cli_printf(c, -1008, "\tType: %s", rta_src_names[a->source]);
for(ea_list *eal = a->eattrs; eal; eal=eal->next) for(ea_list *eal = a->eattrs; eal; eal=eal->next)
for(int i=0; i<eal->count; i++) for(int i=0; i<eal->count; i++)

View File

@ -84,7 +84,6 @@ dev_ifa_notify(struct proto *P, uint flags, struct ifa *ad)
rta a0 = { rta a0 = {
.source = RTS_DEVICE, .source = RTS_DEVICE,
.scope = SCOPE_UNIVERSE,
.dest = RTD_UNICAST, .dest = RTD_UNICAST,
.nh.iface = ad->iface, .nh.iface = ad->iface,
}; };

View File

@ -659,7 +659,6 @@ babel_announce_rte(struct babel_proto *p, struct babel_entry *e)
rta a0 = { rta a0 = {
.source = RTS_BABEL, .source = RTS_BABEL,
.scope = SCOPE_UNIVERSE,
.dest = RTD_UNICAST, .dest = RTD_UNICAST,
.nh.gw = r->next_hop, .nh.gw = r->next_hop,
.nh.iface = r->neigh->ifa->iface, .nh.iface = r->neigh->ifa->iface,
@ -685,7 +684,6 @@ babel_announce_rte(struct babel_proto *p, struct babel_entry *e)
/* Unreachable */ /* Unreachable */
rta a0 = { rta a0 = {
.source = RTS_BABEL, .source = RTS_BABEL,
.scope = SCOPE_UNIVERSE,
.dest = RTD_UNREACHABLE, .dest = RTD_UNREACHABLE,
}; };

View File

@ -2475,7 +2475,6 @@ bgp_decode_nlri(struct bgp_parse_state *s, u32 afi, byte *nlri, uint len, ea_lis
a = allocz(RTA_MAX_SIZE); a = allocz(RTA_MAX_SIZE);
a->source = RTS_BGP; a->source = RTS_BGP;
a->scope = SCOPE_UNIVERSE;
a->eattrs = ea; a->eattrs = ea;
ea_set_attr_data(&a->eattrs, &ea_gen_from, 0, &s->proto->remote_ip, sizeof(ip_addr)); ea_set_attr_data(&a->eattrs, &ea_gen_from, 0, &s->proto->remote_ip, sizeof(ip_addr));

View File

@ -2054,7 +2054,6 @@ again1:
{ {
rta a0 = { rta a0 = {
.source = nf->n.type, .source = nf->n.type,
.scope = SCOPE_UNIVERSE,
.dest = RTD_UNICAST, .dest = RTD_UNICAST,
.nh = *(nf->n.nhs), .nh = *(nf->n.nhs),
}; };

View File

@ -144,7 +144,6 @@ perf_loop(void *data)
if (!p->attrs_per_rte || !(i % p->attrs_per_rte)) { if (!p->attrs_per_rte || !(i % p->attrs_per_rte)) {
struct rta a0 = { struct rta a0 = {
.source = RTS_PERF, .source = RTS_PERF,
.scope = SCOPE_UNIVERSE,
.dest = RTD_UNICAST, .dest = RTD_UNICAST,
.nh.iface = p->ifa->iface, .nh.iface = p->ifa->iface,
.nh.gw = gw, .nh.gw = gw,

View File

@ -153,7 +153,6 @@ rip_announce_rte(struct rip_proto *p, struct rip_entry *en)
/* Update */ /* Update */
rta a0 = { rta a0 = {
.source = RTS_RIP, .source = RTS_RIP,
.scope = SCOPE_UNIVERSE,
.dest = RTD_UNICAST, .dest = RTD_UNICAST,
}; };

View File

@ -122,7 +122,6 @@ rpki_table_add_roa(struct rpki_cache *cache, struct channel *channel, const net_
rta a0 = { rta a0 = {
.source = RTS_RPKI, .source = RTS_RPKI,
.scope = SCOPE_UNIVERSE,
.dest = RTD_NONE, .dest = RTD_NONE,
}; };

View File

@ -56,7 +56,6 @@ static_announce_rte(struct static_proto *p, struct static_route *r)
rta *a = allocz(RTA_MAX_SIZE); rta *a = allocz(RTA_MAX_SIZE);
struct rte_src *src = static_get_source(p, r->index); struct rte_src *src = static_get_source(p, r->index);
a->source = RTS_STATIC; a->source = RTS_STATIC;
a->scope = SCOPE_UNIVERSE;
a->dest = r->dest; a->dest = r->dest;
ea_set_attr_u32(&a->eattrs, &ea_gen_preference, 0, p->p.main_channel->preference); ea_set_attr_u32(&a->eattrs, &ea_gen_preference, 0, p->p.main_channel->preference);

View File

@ -521,7 +521,6 @@ krt_read_route(struct ks_msg *msg, struct krt_proto *p, int scan)
rta a = { rta a = {
.src = p->p.main_source, .src = p->p.main_source,
.source = RTS_INHERIT, .source = RTS_INHERIT,
.scope = SCOPE_UNIVERSE,
}; };
/* reject/blackhole routes have also set RTF_GATEWAY, /* reject/blackhole routes have also set RTF_GATEWAY,

View File

@ -1855,7 +1855,6 @@ nl_parse_route(struct nl_parse_state *s, struct nlmsghdr *h)
rta *ra = lp_allocz(s->pool, RTA_MAX_SIZE); rta *ra = lp_allocz(s->pool, RTA_MAX_SIZE);
ra->source = RTS_INHERIT; ra->source = RTS_INHERIT;
ra->scope = SCOPE_UNIVERSE;
if (a[RTA_FLOW]) if (a[RTA_FLOW])
s->rta_flow = rta_get_u32(a[RTA_FLOW]); s->rta_flow = rta_get_u32(a[RTA_FLOW]);