mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-09-07 22:15:19 +00:00
ASPA: basic data structures and Static protocol support
This commit is contained in:
parent
b95dc8f29f
commit
08571b2059
@ -118,7 +118,7 @@ CF_DECLS
|
||||
%type <time> expr_us time
|
||||
%type <a> ipa
|
||||
%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 <mls> label_stack_start label_stack
|
||||
|
||||
%type <t> text opttext
|
||||
@ -299,6 +299,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_ ;
|
||||
@ -310,6 +316,7 @@ net_:
|
||||
| net_flow_
|
||||
| net_ip6_sadr_
|
||||
| net_mpls_
|
||||
| net_aspa_
|
||||
;
|
||||
|
||||
|
||||
|
@ -5972,6 +5972,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">
|
||||
|
||||
|
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;
|
||||
|
||||
|
||||
@ -183,6 +193,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 })
|
||||
|
||||
@ -211,6 +227,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))
|
||||
@ -269,6 +288,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); }
|
||||
|
||||
@ -296,6 +318,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;
|
||||
}
|
||||
@ -366,6 +389,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); }
|
||||
@ -407,6 +433,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); }
|
||||
@ -442,6 +471,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);
|
||||
|
||||
|
||||
@ -478,6 +510,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); }
|
||||
@ -521,6 +556,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);
|
||||
|
||||
|
||||
@ -570,6 +608,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); }
|
||||
|
||||
|
18
nest/a-set.c
18
nest/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, BUFFER_SIZE) == 0);
|
||||
bt_assert(int_set_format(set_union, ISF_ROUTER_ID, 2, buf, 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, BUFFER_SIZE) == 0);
|
||||
bt_assert(int_set_format(set_union, ISF_ROUTER_ID, 2, buf, 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, BUFFER_SIZE) == 0);
|
||||
bt_assert(int_set_format(set_sequence, ISF_ROUTER_ID, 0, buf, 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, BUFFER_SIZE);
|
||||
bt_assert(int_set_format(set_sequence, 0, 2, buf, BUFFER_SIZE) == 0);
|
||||
bt_assert(int_set_format(set_sequence, ISF_ROUTER_ID, 2, buf, 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, BUFFER_SIZE);
|
||||
bt_assert(int_set_format(set_sequence, 1, 0, buf, BUFFER_SIZE) == 0);
|
||||
bt_assert(int_set_format(set_sequence, ISF_COMMUNITY_LIST, 0, buf, 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, BUFFER_SIZE);
|
||||
bt_assert(int_set_format(set_sequence, ISF_NUMBERS, 0, buf, BUFFER_SIZE) == 0);
|
||||
bt_assert(strcmp(buf, "0 1 2 3 4 5 6 7 8 9") == 0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -206,8 +206,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);
|
||||
|
@ -115,7 +115,7 @@ CF_DECLS
|
||||
|
||||
CF_KEYWORDS(ROUTER, ID, HOSTNAME, PROTOCOL, TEMPLATE, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT)
|
||||
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)
|
||||
@ -128,9 +128,10 @@ CF_KEYWORDS(MIN, IDLE, RX, TX, INTERVAL, MULTIPLIER, PASSIVE)
|
||||
CF_KEYWORDS(CHECK, LINK)
|
||||
CF_KEYWORDS(SORTED, TRIE, MIN, MAX, 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,
|
||||
@ -202,6 +203,7 @@ net_type_base:
|
||||
| ROA6 { $$ = NET_ROA6; }
|
||||
| FLOW4{ $$ = NET_FLOW4; }
|
||||
| FLOW6{ $$ = NET_FLOW6; }
|
||||
| ASPA { $$ = NET_ASPA; }
|
||||
;
|
||||
|
||||
net_type:
|
||||
@ -209,7 +211,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 */
|
||||
@ -840,6 +842,7 @@ channel_sym:
|
||||
| FLOW4 { $$ = "flow4"; }
|
||||
| FLOW6 { $$ = "flow6"; }
|
||||
| MPLS { $$ = "mpls"; }
|
||||
| ASPA { $$ = "aspa"; }
|
||||
| PRI { $$ = "pri"; }
|
||||
| SEC { $$ = "sec"; }
|
||||
;
|
||||
@ -972,6 +975,8 @@ proto_patt2:
|
||||
|
||||
dynamic_attr: IGP_METRIC { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_GEN_IGP_METRIC); } ;
|
||||
|
||||
dynamic_attr: ASPA_PROVIDERS { $$ = f_new_dynamic_attr(EAF_TYPE_INT_SET, T_CLIST, EA_ASPA_PROVIDERS); } ;
|
||||
|
||||
dynamic_attr: MPLS_LABEL { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_MPLS_LABEL); } ;
|
||||
dynamic_attr: MPLS_POLICY { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_ENUM_MPLS_POLICY, EA_MPLS_POLICY); } ;
|
||||
dynamic_attr: MPLS_CLASS { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_MPLS_CLASS); } ;
|
||||
|
@ -536,6 +536,7 @@ const char *ea_custom_name(uint ea);
|
||||
#define EA_MPLS_LABEL EA_CODE(PROTOCOL_NONE, 1)
|
||||
#define EA_MPLS_POLICY EA_CODE(PROTOCOL_NONE, 2)
|
||||
#define EA_MPLS_CLASS EA_CODE(PROTOCOL_NONE, 3)
|
||||
#define EA_ASPA_PROVIDERS EA_CODE(PROTOCOL_NONE, 4)
|
||||
|
||||
#define EA_CODE_MASK 0xffff
|
||||
#define EA_CUSTOM_BIT 0x8000
|
||||
|
@ -823,8 +823,10 @@ ea_free(ea_list *o)
|
||||
}
|
||||
|
||||
static int
|
||||
get_generic_attr(const eattr *a, byte **buf, int buflen UNUSED)
|
||||
get_generic_attr(const eattr *a, byte **buf, int buflen)
|
||||
{
|
||||
byte *end = (*buf) + buflen;
|
||||
|
||||
switch (a->id)
|
||||
{
|
||||
case EA_GEN_IGP_METRIC:
|
||||
@ -843,6 +845,13 @@ get_generic_attr(const eattr *a, byte **buf, int buflen UNUSED)
|
||||
*buf += bsprintf(*buf, "mpls_class");
|
||||
return GA_NAME;
|
||||
|
||||
case EA_ASPA_PROVIDERS:
|
||||
*buf += bsprintf(*buf, "aspa_providers");
|
||||
*(*buf)++ = ':';
|
||||
*(*buf)++ = ' ';
|
||||
*buf += int_set_format(a->u.ptr, ISF_NUMBERS, -1, *buf, end - *buf);
|
||||
return GA_FULL;
|
||||
|
||||
default:
|
||||
return GA_UNKNOWN;
|
||||
}
|
||||
@ -1007,7 +1016,7 @@ ea_show(struct cli *c, const eattr *e)
|
||||
bsprintf(pos, "%08x", e->u.data);
|
||||
break;
|
||||
case EAF_TYPE_INT_SET:
|
||||
ea_show_int_set(c, ad, 1, pos, buf, end);
|
||||
ea_show_int_set(c, ad, ISF_COMMUNITY_LIST, pos, buf, end);
|
||||
return;
|
||||
case EAF_TYPE_EC_SET:
|
||||
ea_show_ec_set(c, ad, pos, buf, end);
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
@ -690,7 +690,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)
|
||||
|
@ -99,6 +99,32 @@ static_announce_rte(struct static_proto *p, struct static_route *r)
|
||||
rta_set_recursive_next_hop(p->p.main_channel->table, a, tab, r->via, IPA_NONE, r->mls);
|
||||
}
|
||||
|
||||
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_list *ea = alloca(sizeof(ea_list) + sizeof(eattr));
|
||||
*ea = (ea_list) { .flags = EALF_SORTED, .count = 1, .next = a->eattrs, };
|
||||
ea->attrs[0] = (eattr) {
|
||||
.id = EA_ASPA_PROVIDERS,
|
||||
.type = EAF_TYPE_INT_SET,
|
||||
.u.ptr = r->aspa,
|
||||
};
|
||||
a->eattrs = ea;
|
||||
}
|
||||
|
||||
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 */
|
||||
mpls_label_stack *mls; /* MPLS label stack; may be NULL */
|
||||
union {
|
||||
mpls_label_stack *mls; /* MPLS label stack; may be NULL */
|
||||
adata *aspa; /* ASPA provider list; may be NULL */
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user