mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 01:31:55 +00:00
Merge commit '08571b20' into thread-merge-2.16
This commit is contained in:
commit
d73d861f0c
@ -124,7 +124,7 @@ CF_DECLS
|
||||
%type <settle> settle
|
||||
%type <a> ipa net_ip6_slash
|
||||
%type <net> net_ip4_ net_ip4 net_ip6_ net_ip6 net_ip_ net_ip net_or_ipa
|
||||
%type <net_ptr> net_ net_any net_vpn4_ net_vpn6_ net_vpn_ net_roa4_ net_roa6_ net_roa_ net_ip6_sadr_ net_mpls_
|
||||
%type <net_ptr> net_ net_any net_vpn4_ net_vpn6_ net_vpn_ net_roa4_ net_roa6_ net_roa_ net_ip6_sadr_ net_mpls_ net_aspa_
|
||||
%type <ad> label_stack_start label_stack
|
||||
|
||||
%type <t> text opttext
|
||||
@ -325,6 +325,12 @@ net_mpls_: MPLS NUM
|
||||
net_fill_mpls($$, $2);
|
||||
}
|
||||
|
||||
net_aspa_: ASPA NUM
|
||||
{
|
||||
$$ = cfg_alloc(sizeof(net_addr_aspa));
|
||||
net_fill_aspa($$, $2);
|
||||
}
|
||||
|
||||
net_ip_: net_ip4_ | net_ip6_ ;
|
||||
net_vpn_: net_vpn4_ | net_vpn6_ ;
|
||||
net_roa_: net_roa4_ | net_roa6_ ;
|
||||
@ -336,6 +342,7 @@ net_:
|
||||
| net_flow_
|
||||
| net_ip6_sadr_
|
||||
| net_mpls_
|
||||
| net_aspa_
|
||||
;
|
||||
|
||||
|
||||
|
@ -5966,6 +5966,13 @@ options (<cf/bfd/ and <cf/weight 1/), the second nexthop has just <cf/weight 2/.
|
||||
|
||||
<p>The ROA config is just <cf>route <m/prefix/ max <m/int/ as <m/int/</cf> with no nexthop.
|
||||
|
||||
<sect1>Autonomous System Provider Authorization
|
||||
|
||||
<p>The ASPA config is <cf>route aspa <m/int/ providers <m/int/ [, <m/int/ ...]</cf> with no nexthop.
|
||||
The first ASN is client and the following are a list of providers.
|
||||
For a transit, you can also write <cf>route aspa <m/int/ transit</cf> to get
|
||||
the no-provider ASPA.
|
||||
|
||||
<sect1>Flowspec
|
||||
<label id="flowspec-network-type">
|
||||
|
||||
|
18
lib/a-set.c
18
lib/a-set.c
@ -34,7 +34,7 @@
|
||||
* the buffer to indicate truncation.
|
||||
*/
|
||||
int
|
||||
int_set_format(const struct adata *set, int way, int from, byte *buf, uint size)
|
||||
int_set_format(const struct adata *set, enum isf_way way, int from, byte *buf, uint size)
|
||||
{
|
||||
u32 *z = (u32 *) set->data;
|
||||
byte *end = buf + size - 24;
|
||||
@ -56,10 +56,18 @@ int_set_format(const struct adata *set, int way, int from, byte *buf, uint size)
|
||||
if (i > from2)
|
||||
*buf++ = ' ';
|
||||
|
||||
if (way)
|
||||
buf += bsprintf(buf, "(%d,%d)", z[i] >> 16, z[i] & 0xffff);
|
||||
else
|
||||
buf += bsprintf(buf, "%R", z[i]);
|
||||
switch (way)
|
||||
{
|
||||
case ISF_COMMUNITY_LIST:
|
||||
buf += bsprintf(buf, "(%d,%d)", z[i] >> 16, z[i] & 0xffff);
|
||||
break;
|
||||
case ISF_ROUTER_ID:
|
||||
buf += bsprintf(buf, "%R", z[i]);
|
||||
break;
|
||||
case ISF_NUMBERS:
|
||||
buf += bsprintf(buf, "%u", z[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
*buf = 0;
|
||||
return 0;
|
||||
|
@ -92,11 +92,11 @@ t_set_int_union(void)
|
||||
const struct adata *set_union;
|
||||
set_union = int_set_union(tmp_linpool, set_sequence, set_sequence_same);
|
||||
bt_assert(int_set_get_size(set_union) == SET_SIZE);
|
||||
bt_assert(int_set_format(set_union, 0, 2, buf, T_BUFFER_SIZE) == 0);
|
||||
bt_assert(int_set_format(set_union, ISF_ROUTER_ID, 2, buf, T_BUFFER_SIZE) == 0);
|
||||
|
||||
set_union = int_set_union(tmp_linpool, set_sequence, set_sequence_higher);
|
||||
bt_assert_msg(int_set_get_size(set_union) == SET_SIZE*2, "int_set_get_size(set_union) %d, SET_SIZE*2 %d", int_set_get_size(set_union), SET_SIZE*2);
|
||||
bt_assert(int_set_format(set_union, 0, 2, buf, T_BUFFER_SIZE) == 0);
|
||||
bt_assert(int_set_format(set_union, ISF_ROUTER_ID, 2, buf, T_BUFFER_SIZE) == 0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -106,17 +106,21 @@ t_set_int_format(void)
|
||||
{
|
||||
generate_set_sequence(SET_TYPE_INT, SET_SIZE_FOR_FORMAT_OUTPUT);
|
||||
|
||||
bt_assert(int_set_format(set_sequence, 0, 0, buf, T_BUFFER_SIZE) == 0);
|
||||
bt_assert(int_set_format(set_sequence, ISF_ROUTER_ID, 0, buf, T_BUFFER_SIZE) == 0);
|
||||
bt_assert(strcmp(buf, "0.0.0.0 0.0.0.1 0.0.0.2 0.0.0.3 0.0.0.4 0.0.0.5 0.0.0.6 0.0.0.7 0.0.0.8 0.0.0.9") == 0);
|
||||
|
||||
bzero(buf, T_BUFFER_SIZE);
|
||||
bt_assert(int_set_format(set_sequence, 0, 2, buf, T_BUFFER_SIZE) == 0);
|
||||
bt_assert(int_set_format(set_sequence, ISF_ROUTER_ID, 2, buf, T_BUFFER_SIZE) == 0);
|
||||
bt_assert(strcmp(buf, "0.0.0.2 0.0.0.3 0.0.0.4 0.0.0.5 0.0.0.6 0.0.0.7 0.0.0.8 0.0.0.9") == 0);
|
||||
|
||||
bzero(buf, T_BUFFER_SIZE);
|
||||
bt_assert(int_set_format(set_sequence, 1, 0, buf, T_BUFFER_SIZE) == 0);
|
||||
bt_assert(int_set_format(set_sequence, ISF_COMMUNITY_LIST, 0, buf, T_BUFFER_SIZE) == 0);
|
||||
bt_assert(strcmp(buf, "(0,0) (0,1) (0,2) (0,3) (0,4) (0,5) (0,6) (0,7) (0,8) (0,9)") == 0);
|
||||
|
||||
bzero(buf, T_BUFFER_SIZE);
|
||||
bt_assert(int_set_format(set_sequence, ISF_NUMBERS, 0, buf, T_BUFFER_SIZE) == 0);
|
||||
bt_assert(strcmp(buf, "0 1 2 3 4 5 6 7 8 9") == 0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -238,8 +238,13 @@ static inline int lc_match(const u32 *l, int i, lcomm v)
|
||||
static inline u32 *lc_copy(u32 *dst, const u32 *src)
|
||||
{ memcpy(dst, src, LCOMM_LENGTH); return dst + 3; }
|
||||
|
||||
enum isf_way {
|
||||
ISF_NUMBERS,
|
||||
ISF_COMMUNITY_LIST,
|
||||
ISF_ROUTER_ID,
|
||||
};
|
||||
|
||||
int int_set_format(const struct adata *set, int way, int from, byte *buf, uint size);
|
||||
int int_set_format(const struct adata *set, enum isf_way way, int from, byte *buf, uint size);
|
||||
int ec_format(byte *buf, u64 ec);
|
||||
int ec_set_format(const struct adata *set, int from, byte *buf, uint size);
|
||||
int lc_format(byte *buf, lcomm lc);
|
||||
|
15
lib/net.c
15
lib/net.c
@ -16,6 +16,7 @@ const char * const net_label[] = {
|
||||
[NET_FLOW6] = "flow6",
|
||||
[NET_IP6_SADR]= "ipv6-sadr",
|
||||
[NET_MPLS] = "mpls",
|
||||
[NET_ASPA] = "aspa",
|
||||
};
|
||||
|
||||
const u16 net_addr_length[] = {
|
||||
@ -29,6 +30,7 @@ const u16 net_addr_length[] = {
|
||||
[NET_FLOW6] = 0,
|
||||
[NET_IP6_SADR]= sizeof(net_addr_ip6_sadr),
|
||||
[NET_MPLS] = sizeof(net_addr_mpls),
|
||||
[NET_ASPA] = sizeof(net_addr_aspa),
|
||||
};
|
||||
|
||||
const u8 net_max_prefix_length[] = {
|
||||
@ -42,6 +44,7 @@ const u8 net_max_prefix_length[] = {
|
||||
[NET_FLOW6] = IP6_MAX_PREFIX_LENGTH,
|
||||
[NET_IP6_SADR]= IP6_MAX_PREFIX_LENGTH,
|
||||
[NET_MPLS] = 0,
|
||||
[NET_ASPA] = 0,
|
||||
};
|
||||
|
||||
const u16 net_max_text_length[] = {
|
||||
@ -55,6 +58,7 @@ const u16 net_max_text_length[] = {
|
||||
[NET_FLOW6] = 0, /* "flow6 { ... }" */
|
||||
[NET_IP6_SADR]= 92, /* "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128 from ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128" */
|
||||
[NET_MPLS] = 7, /* "1048575" */
|
||||
[NET_ASPA] = 10, /* "4294967295" */
|
||||
};
|
||||
|
||||
/* There should be no implicit padding in net_addr structures */
|
||||
@ -69,6 +73,7 @@ STATIC_ASSERT(sizeof(net_addr_flow4) == 8);
|
||||
STATIC_ASSERT(sizeof(net_addr_flow6) == 20);
|
||||
STATIC_ASSERT(sizeof(net_addr_ip6_sadr) == 40);
|
||||
STATIC_ASSERT(sizeof(net_addr_mpls) == 8);
|
||||
STATIC_ASSERT(sizeof(net_addr_aspa) == 8);
|
||||
|
||||
|
||||
int
|
||||
@ -123,6 +128,8 @@ net_format(const net_addr *N, char *buf, int buflen)
|
||||
return bsnprintf(buf, buflen, "%I6/%d from %I6/%d", n->ip6_sadr.dst_prefix, n->ip6_sadr.dst_pxlen, n->ip6_sadr.src_prefix, n->ip6_sadr.src_pxlen);
|
||||
case NET_MPLS:
|
||||
return bsnprintf(buf, buflen, "%u", n->mpls.label);
|
||||
case NET_ASPA:
|
||||
return bsnprintf(buf, buflen, "%u", n->aspa.asn);
|
||||
}
|
||||
|
||||
bug("unknown network type");
|
||||
@ -147,6 +154,7 @@ net_pxmask(const net_addr *a)
|
||||
return ipa_from_ip6(ip6_mkmask(net6_pxlen(a)));
|
||||
|
||||
case NET_MPLS:
|
||||
case NET_ASPA:
|
||||
default:
|
||||
return IPA_NONE;
|
||||
}
|
||||
@ -180,6 +188,8 @@ net_compare(const net_addr *a, const net_addr *b)
|
||||
return net_compare_ip6_sadr((const net_addr_ip6_sadr *) a, (const net_addr_ip6_sadr *) b);
|
||||
case NET_MPLS:
|
||||
return net_compare_mpls((const net_addr_mpls *) a, (const net_addr_mpls *) b);
|
||||
case NET_ASPA:
|
||||
return net_compare_aspa((const net_addr_aspa *) a, (const net_addr_aspa *) b);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -201,6 +211,7 @@ net_hash(const net_addr *n)
|
||||
case NET_FLOW6: return NET_HASH(n, flow6);
|
||||
case NET_IP6_SADR: return NET_HASH(n, ip6_sadr);
|
||||
case NET_MPLS: return NET_HASH(n, mpls);
|
||||
case NET_ASPA: return NET_HASH(n, aspa);
|
||||
default: bug("invalid type");
|
||||
}
|
||||
}
|
||||
@ -223,6 +234,7 @@ net_validate(const net_addr *n)
|
||||
case NET_FLOW6: return NET_VALIDATE(n, flow6);
|
||||
case NET_IP6_SADR: return NET_VALIDATE(n, ip6_sadr);
|
||||
case NET_MPLS: return NET_VALIDATE(n, mpls);
|
||||
case NET_ASPA: return NET_VALIDATE(n, aspa);
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
@ -250,6 +262,7 @@ net_normalize(net_addr *N)
|
||||
return net_normalize_ip6_sadr(&n->ip6_sadr);
|
||||
|
||||
case NET_MPLS:
|
||||
case NET_ASPA:
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -277,6 +290,7 @@ net_classify(const net_addr *N)
|
||||
return ip6_zero(n->ip6_sadr.dst_prefix) ? (IADDR_HOST | SCOPE_UNIVERSE) : ip6_classify(&n->ip6_sadr.dst_prefix);
|
||||
|
||||
case NET_MPLS:
|
||||
case NET_ASPA:
|
||||
return IADDR_HOST | SCOPE_UNIVERSE;
|
||||
}
|
||||
|
||||
@ -310,6 +324,7 @@ ipa_in_netX(const ip_addr a, const net_addr *n)
|
||||
ip6_mkmask(net6_pxlen(n))));
|
||||
|
||||
case NET_MPLS:
|
||||
case NET_ASPA:
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
43
lib/net.h
43
lib/net.h
@ -23,7 +23,8 @@
|
||||
#define NET_FLOW6 8
|
||||
#define NET_IP6_SADR 9
|
||||
#define NET_MPLS 10
|
||||
#define NET_MAX 11
|
||||
#define NET_ASPA 11
|
||||
#define NET_MAX 12
|
||||
|
||||
#define NB_IP4 (1 << NET_IP4)
|
||||
#define NB_IP6 (1 << NET_IP6)
|
||||
@ -35,6 +36,7 @@
|
||||
#define NB_FLOW6 (1 << NET_FLOW6)
|
||||
#define NB_IP6_SADR (1 << NET_IP6_SADR)
|
||||
#define NB_MPLS (1 << NET_MPLS)
|
||||
#define NB_ASPA (1 << NET_ASPA)
|
||||
|
||||
#define NB_IP (NB_IP4 | NB_IP6)
|
||||
#define NB_VPN (NB_VPN4 | NB_VPN6)
|
||||
@ -124,6 +126,13 @@ typedef struct net_addr_mpls {
|
||||
u32 label;
|
||||
} net_addr_mpls;
|
||||
|
||||
typedef struct net_addr_aspa {
|
||||
u8 type;
|
||||
u8 pxlen;
|
||||
u16 length;
|
||||
u32 asn;
|
||||
} net_addr_aspa;
|
||||
|
||||
typedef struct net_addr_ip6_sadr {
|
||||
u8 type;
|
||||
u8 dst_pxlen;
|
||||
@ -145,6 +154,7 @@ typedef union net_addr_union {
|
||||
net_addr_flow6 flow6;
|
||||
net_addr_ip6_sadr ip6_sadr;
|
||||
net_addr_mpls mpls;
|
||||
net_addr_aspa aspa;
|
||||
} net_addr_union;
|
||||
|
||||
|
||||
@ -201,6 +211,12 @@ extern const u16 net_max_text_length[];
|
||||
#define NET_ADDR_IP6_SADR(dst_prefix,dst_pxlen,src_prefix,src_pxlen) \
|
||||
((net_addr_ip6_sadr) { NET_IP6_SADR, dst_pxlen, sizeof(net_addr_ip6_sadr), dst_prefix, src_pxlen, src_prefix })
|
||||
|
||||
#define NET_ADDR_ASPA(asn) \
|
||||
((net_addr_aspa) { NET_ASPA, 32, sizeof(net_addr_aspa), asn })
|
||||
|
||||
#define NET_ADDR_ASPA_EXISTS(asn) NET_ADDR_ASPA(asn, asn)
|
||||
#define NET_ADDR_ASPA_TRANSIT(asn) NET_ADDR_ASPA(asn, 0)
|
||||
|
||||
#define NET_ADDR_MPLS(label) \
|
||||
((net_addr_mpls) { NET_MPLS, 20, sizeof(net_addr_mpls), label })
|
||||
|
||||
@ -229,6 +245,9 @@ static inline void net_fill_ip6_sadr(net_addr *a, ip6_addr dst_prefix, uint dst_
|
||||
static inline void net_fill_mpls(net_addr *a, u32 label)
|
||||
{ *(net_addr_mpls *)a = NET_ADDR_MPLS(label); }
|
||||
|
||||
static inline void net_fill_aspa(net_addr *a, u32 asn)
|
||||
{ *(net_addr_aspa *)a = NET_ADDR_ASPA(asn); }
|
||||
|
||||
static inline void net_fill_ipa(net_addr *a, ip_addr prefix, uint pxlen)
|
||||
{
|
||||
if (ipa_is_ip4(prefix))
|
||||
@ -287,6 +306,9 @@ static inline int net_is_roa(const net_addr *a)
|
||||
static inline int net_is_flow(const net_addr *a)
|
||||
{ return (a->type == NET_FLOW4) || (a->type == NET_FLOW6); }
|
||||
|
||||
static inline int net_is_aspa(const net_addr *a)
|
||||
{ return (a->type == NET_ASPA); }
|
||||
|
||||
static inline int net_is_sadr(const net_addr *a)
|
||||
{ return (a->type == NET_IP6_SADR); }
|
||||
|
||||
@ -314,6 +336,7 @@ static inline ip_addr net_prefix(const net_addr *a)
|
||||
return ipa_from_ip6(net6_prefix(a));
|
||||
|
||||
case NET_MPLS:
|
||||
case NET_ASPA:
|
||||
default:
|
||||
return IPA_NONE;
|
||||
}
|
||||
@ -384,6 +407,9 @@ static inline int net_equal_ip6_sadr(const net_addr_ip6_sadr *a, const net_addr_
|
||||
static inline int net_equal_mpls(const net_addr_mpls *a, const net_addr_mpls *b)
|
||||
{ return !memcmp(a, b, sizeof(net_addr_mpls)); }
|
||||
|
||||
static inline int net_equal_aspa(const net_addr_aspa *a, const net_addr_aspa *b)
|
||||
{ return !memcmp(a, b, sizeof(net_addr_aspa)); }
|
||||
|
||||
|
||||
static inline int net_equal_prefix_roa4(const net_addr_roa4 *a, const net_addr_roa4 *b)
|
||||
{ return ip4_equal(a->prefix, b->prefix) && (a->pxlen == b->pxlen); }
|
||||
@ -425,6 +451,9 @@ static inline int net_zero_flow6(const net_addr_flow6 *a)
|
||||
static inline int net_zero_mpls(const net_addr_mpls *a)
|
||||
{ return !a->label; }
|
||||
|
||||
static inline int net_zero_aspa(const net_addr_aspa *a)
|
||||
{ return !a->asn; }
|
||||
|
||||
|
||||
static inline int net_compare_ip4(const net_addr_ip4 *a, const net_addr_ip4 *b)
|
||||
{ return ip4_compare(a->prefix, b->prefix) ?: uint_cmp(a->pxlen, b->pxlen); }
|
||||
@ -460,6 +489,9 @@ static inline int net_compare_ip6_sadr(const net_addr_ip6_sadr *a, const net_add
|
||||
static inline int net_compare_mpls(const net_addr_mpls *a, const net_addr_mpls *b)
|
||||
{ return uint_cmp(a->label, b->label); }
|
||||
|
||||
static inline int net_compare_aspa(const net_addr_aspa *a, const net_addr_aspa *b)
|
||||
{ return uint_cmp(a->asn, b->asn); }
|
||||
|
||||
int net_compare(const net_addr *a, const net_addr *b);
|
||||
|
||||
|
||||
@ -496,6 +528,9 @@ static inline void net_copy_ip6_sadr(net_addr_ip6_sadr *dst, const net_addr_ip6_
|
||||
static inline void net_copy_mpls(net_addr_mpls *dst, const net_addr_mpls *src)
|
||||
{ memcpy(dst, src, sizeof(net_addr_mpls)); }
|
||||
|
||||
static inline void net_copy_aspa(net_addr_aspa *dst, const net_addr_aspa *src)
|
||||
{ memcpy(dst, src, sizeof(net_addr_aspa)); }
|
||||
|
||||
|
||||
static inline u32 px4_hash(ip4_addr prefix, u32 pxlen)
|
||||
{ return ip4_hash(prefix) ^ (pxlen << 26); }
|
||||
@ -539,6 +574,9 @@ static inline u32 net_hash_ip6_sadr(const net_addr_ip6_sadr *n)
|
||||
static inline u32 net_hash_mpls(const net_addr_mpls *n)
|
||||
{ return u32_hash(n->label); }
|
||||
|
||||
static inline u32 net_hash_aspa(const net_addr_aspa *n)
|
||||
{ return u32_hash(n->asn); }
|
||||
|
||||
u32 net_hash(const net_addr *a);
|
||||
|
||||
|
||||
@ -588,6 +626,9 @@ static inline int net_validate_flow6(const net_addr_flow6 *n)
|
||||
static inline int net_validate_mpls(const net_addr_mpls *n)
|
||||
{ return n->label < (1 << 20); }
|
||||
|
||||
static inline int net_validate_aspa(const net_addr_aspa *n)
|
||||
{ return n->asn > 0; }
|
||||
|
||||
static inline int net_validate_ip6_sadr(const net_addr_ip6_sadr *n)
|
||||
{ return net_validate_px6(n->dst_prefix, n->dst_pxlen) && net_validate_px6(n->src_prefix, n->src_pxlen); }
|
||||
|
||||
|
@ -558,6 +558,10 @@ static inline int rte_dest(const rte *r)
|
||||
return nhea_dest(ea_find(r->attrs, &ea_gen_nexthop));
|
||||
}
|
||||
|
||||
/* ASPA Providers eattr */
|
||||
extern struct ea_class ea_gen_aspa_providers;
|
||||
|
||||
|
||||
void rta_init(void);
|
||||
|
||||
ea_list *ea_lookup_slow(ea_list *r, u32 squash_upto, enum ea_stored oid);
|
||||
|
@ -153,7 +153,7 @@ CF_DECLS
|
||||
|
||||
CF_KEYWORDS(ROUTER, ID, HOSTNAME, PROTOCOL, TEMPLATE, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT, PIPE)
|
||||
CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, VRF, DEFAULT, TABLE, TABLES, STATES, ROUTES, FILTERS)
|
||||
CF_KEYWORDS(IPV4, IPV6, VPN4, VPN6, ROA4, ROA6, FLOW4, FLOW6, SADR, MPLS)
|
||||
CF_KEYWORDS(IPV4, IPV6, VPN4, VPN6, ROA4, ROA6, FLOW4, FLOW6, SADR, MPLS, ASPA)
|
||||
CF_KEYWORDS(RECEIVE, LIMIT, ACTION, WARN, BLOCK, RESTART, DISABLE, KEEP, FILTERED, RPKI)
|
||||
CF_KEYWORDS(PASSWORD, KEY, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS, CHANNELS, INTERFACES)
|
||||
CF_KEYWORDS(ALGORITHM, KEYED, HMAC, MD5, SHA1, SHA256, SHA384, SHA512, BLAKE2S128, BLAKE2S256, BLAKE2B256, BLAKE2B512)
|
||||
@ -166,9 +166,10 @@ CF_KEYWORDS(MIN, IDLE, RX, TX, INTERVAL, MULTIPLIER, PASSIVE)
|
||||
CF_KEYWORDS(CHECK, LINK)
|
||||
CF_KEYWORDS(CORK, SORTED, TRIE, MIN, MAX, ROA, DIGEST, ROUTE, REFRESH, SETTLE, TIME, GC, THRESHOLD, PERIOD)
|
||||
CF_KEYWORDS(MPLS_LABEL, MPLS_POLICY, MPLS_CLASS)
|
||||
CF_KEYWORDS(ASPA_PROVIDERS)
|
||||
|
||||
/* For r_args_channel */
|
||||
CF_KEYWORDS(IPV4, IPV4_MC, IPV4_MPLS, IPV6, IPV6_MC, IPV6_MPLS, IPV6_SADR, VPN4, VPN4_MC, VPN4_MPLS, VPN6, VPN6_MC, VPN6_MPLS, ROA4, ROA6, FLOW4, FLOW6, MPLS, PRI, SEC)
|
||||
CF_KEYWORDS(IPV4, IPV4_MC, IPV4_MPLS, IPV6, IPV6_MC, IPV6_MPLS, IPV6_SADR, VPN4, VPN4_MC, VPN4_MPLS, VPN6, VPN6_MC, VPN6_MPLS, ROA4, ROA6, FLOW4, FLOW6, MPLS, PRI, SEC, ASPA)
|
||||
|
||||
CF_ENUM(T_ENUM_RTS, RTS_, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIRECT,
|
||||
RIP, OSPF, OSPF_IA, OSPF_EXT1, OSPF_EXT2, BGP, PIPE, BABEL, RPKI, L3VPN,
|
||||
@ -241,6 +242,7 @@ net_type_base:
|
||||
| ROA6 { $$ = NET_ROA6; }
|
||||
| FLOW4{ $$ = NET_FLOW4; }
|
||||
| FLOW6{ $$ = NET_FLOW6; }
|
||||
| ASPA { $$ = NET_ASPA; }
|
||||
;
|
||||
|
||||
net_type:
|
||||
@ -248,7 +250,7 @@ net_type:
|
||||
| MPLS { $$ = NET_MPLS; }
|
||||
;
|
||||
|
||||
CF_ENUM(T_ENUM_NETTYPE, NET_, IP4, IP6, VPN4, VPN6, ROA4, ROA6, FLOW4, FLOW6, IP6_SADR, MPLS)
|
||||
CF_ENUM(T_ENUM_NETTYPE, NET_, IP4, IP6, VPN4, VPN6, ROA4, ROA6, FLOW4, FLOW6, IP6_SADR, MPLS, ASPA)
|
||||
|
||||
|
||||
/* Creation of routing tables */
|
||||
@ -908,6 +910,7 @@ channel_sym:
|
||||
| FLOW4 { $$ = "flow4"; }
|
||||
| FLOW6 { $$ = "flow6"; }
|
||||
| MPLS { $$ = "mpls"; }
|
||||
| ASPA { $$ = "aspa"; }
|
||||
| PRI { $$ = "pri"; }
|
||||
| SEC { $$ = "sec"; }
|
||||
;
|
||||
|
@ -188,6 +188,18 @@ const char * flowspec_valid_names[FLOWSPEC__MAX] = {
|
||||
[FLOWSPEC_INVALID] = "invalid",
|
||||
};
|
||||
|
||||
static void
|
||||
ea_gen_aspa_providers_format(const eattr *a, byte *buf, uint size)
|
||||
{
|
||||
int_set_format(a->u.ad, ISF_NUMBERS, -1, buf, size - 5);
|
||||
}
|
||||
|
||||
struct ea_class ea_gen_aspa_providers = {
|
||||
.name = "aspa_providers",
|
||||
.type = T_CLIST,
|
||||
.format = ea_gen_aspa_providers_format,
|
||||
};
|
||||
|
||||
DOMAIN(attrs) attrs_domain;
|
||||
|
||||
pool *rta_pool;
|
||||
@ -1454,7 +1466,7 @@ ea_show(struct cli *c, const eattr *e)
|
||||
as_path_format(ad, pos, end - pos);
|
||||
break;
|
||||
case T_CLIST:
|
||||
ea_show_int_set(c, cls->name, ad, 1, buf);
|
||||
ea_show_int_set(c, cls->name, ad, ISF_COMMUNITY_LIST, buf);
|
||||
return;
|
||||
case T_ECLIST:
|
||||
ea_show_ec_set(c, cls->name, ad, buf);
|
||||
@ -1876,6 +1888,9 @@ rta_init(void)
|
||||
ea_register_init(&ea_gen_mpls_policy);
|
||||
ea_register_init(&ea_gen_mpls_class);
|
||||
ea_register_init(&ea_gen_mpls_label);
|
||||
|
||||
/* ASPA providers */
|
||||
ea_register_init(&ea_gen_aspa_providers);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -279,6 +279,7 @@ fib_find(struct fib *f, const net_addr *a)
|
||||
case NET_FLOW6: return FIB_FIND(f, a, flow6);
|
||||
case NET_IP6_SADR: return FIB_FIND(f, a, ip6_sadr);
|
||||
case NET_MPLS: return FIB_FIND(f, a, mpls);
|
||||
case NET_ASPA: return FIB_FIND(f, a, aspa);
|
||||
default: bug("invalid type");
|
||||
}
|
||||
}
|
||||
@ -300,6 +301,7 @@ fib_insert(struct fib *f, const net_addr *a, struct fib_node *e)
|
||||
case NET_FLOW6: FIB_INSERT(f, a, e, flow6); return;
|
||||
case NET_IP6_SADR: FIB_INSERT(f, a, e, ip6_sadr); return;
|
||||
case NET_MPLS: FIB_INSERT(f, a, e, mpls); return;
|
||||
case NET_ASPA: FIB_INSERT(f, a, e, aspa); return;
|
||||
default: bug("invalid type");
|
||||
}
|
||||
}
|
||||
|
@ -729,7 +729,7 @@ static void
|
||||
bgp_format_cluster_list(const eattr *a, byte *buf, uint size)
|
||||
{
|
||||
/* Truncates cluster lists larger than buflen, probably not a problem */
|
||||
int_set_format(a->u.ptr, 0, -1, buf, size);
|
||||
int_set_format(a->u.ptr, ISF_ROUTER_ID, -1, buf, size);
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,6 +15,7 @@ CF_DEFINES
|
||||
#define STATIC_CFG ((struct static_config *) this_proto)
|
||||
static struct static_route *this_srt, *this_snh;
|
||||
static struct f_inst *this_srt_cmds, *this_srt_last_cmd;
|
||||
static uint this_srt_aspa_max;
|
||||
|
||||
static struct static_route *
|
||||
static_nexthop_new(void)
|
||||
@ -47,6 +48,7 @@ CF_DECLS
|
||||
|
||||
CF_KEYWORDS(STATIC, ROUTE, VIA, DROP, REJECT, PROHIBIT, PREFERENCE, CHECK, LINK, DEV)
|
||||
CF_KEYWORDS(ONLINK, WEIGHT, RECURSIVE, IGP, TABLE, BLACKHOLE, UNREACHABLE, BFD, MPLS)
|
||||
CF_KEYWORDS(TRANSIT, PROVIDERS)
|
||||
|
||||
|
||||
CF_GRAMMAR
|
||||
@ -148,8 +150,35 @@ stat_route:
|
||||
| stat_route0 BLACKHOLE { this_srt->dest = RTD_BLACKHOLE; }
|
||||
| stat_route0 UNREACHABLE { this_srt->dest = RTD_UNREACHABLE; }
|
||||
| stat_route0 PROHIBIT { this_srt->dest = RTD_PROHIBIT; }
|
||||
| stat_route0 PROVIDER {
|
||||
if (this_srt->net->type != NET_ASPA) cf_error("Provider settings available only for ASPA");
|
||||
this_srt->aspa = cfg_alloc(sizeof (adata) + (this_srt_aspa_max = 8) * sizeof (u32));
|
||||
this_srt->aspa->length = 0;
|
||||
} stat_aspa_providers
|
||||
| stat_route0 TRANSIT {
|
||||
if (this_srt->net->type != NET_ASPA) cf_error("Transit settings available only for ASPA");
|
||||
/* Allocate an explicit zero */
|
||||
this_srt->aspa = cfg_alloc(sizeof (adata) + sizeof (u32));
|
||||
this_srt->aspa->length = sizeof(u32);
|
||||
((u32 *) this_srt->aspa->data)[0] = 0;
|
||||
}
|
||||
;
|
||||
|
||||
stat_aspa_provider: NUM {
|
||||
if (this_srt->aspa->length == this_srt_aspa_max * sizeof(u32))
|
||||
{
|
||||
adata *new = cfg_alloc(sizeof (adata) + (this_srt_aspa_max * 2) * sizeof (u32));
|
||||
memcpy(new, this_srt->aspa, this_srt->aspa->length + sizeof(adata));
|
||||
this_srt->aspa = new;
|
||||
this_srt_aspa_max *= 2;
|
||||
}
|
||||
|
||||
((u32 *) this_srt->aspa->data)[this_srt->aspa->length / sizeof(u32)] = $1;
|
||||
this_srt->aspa->length += sizeof(u32);
|
||||
}
|
||||
|
||||
stat_aspa_providers: stat_aspa_provider | stat_aspa_providers ',' stat_aspa_provider ;
|
||||
|
||||
stat_route_item:
|
||||
cmd {
|
||||
if (this_srt_last_cmd)
|
||||
|
@ -112,6 +112,26 @@ static_announce_rte(struct static_proto *p, struct static_route *r)
|
||||
else if (r->dest)
|
||||
ea_set_dest(&ea, 0, r->dest);
|
||||
|
||||
if (r->net->type == NET_ASPA)
|
||||
{
|
||||
if (r->dest != RTD_NONE)
|
||||
{
|
||||
log(L_WARN "%s: ASPA %u configured with nexthop, ignoring the nexthop",
|
||||
p->p.name, ((struct net_addr_aspa *) r->net)->asn);
|
||||
r->dest = RTD_NONE;
|
||||
}
|
||||
|
||||
if (!r->aspa)
|
||||
{
|
||||
log(L_WARN "%s: ASPA %u configured with no provider list, ignoring the whole rule",
|
||||
p->p.name, ((struct net_addr_aspa *) r->net)->asn);
|
||||
goto withdraw;
|
||||
}
|
||||
|
||||
ea_set_attr(&ea, EA_LITERAL_DIRECT_ADATA(
|
||||
&ea_gen_aspa_providers, 0, r->aspa));
|
||||
}
|
||||
|
||||
if (p->p.mpls_channel)
|
||||
{
|
||||
struct mpls_channel *mc = (void *) p->p.mpls_channel;
|
||||
|
@ -50,7 +50,10 @@ struct static_route {
|
||||
byte use_bfd; /* Configured to use BFD */
|
||||
uint mpls_label; /* Local MPLS label, -1 if unused */
|
||||
struct bfd_request *bfd_req; /* BFD request, if BFD is used */
|
||||
struct adata *mls; /* MPLS label stack; may be NULL */
|
||||
union {
|
||||
adata *mls; /* MPLS label stack; may be NULL */
|
||||
adata *aspa; /* ASPA provider list; may be NULL */
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user