2023-02-08 13:17:09 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2017-11-10 13:56:24 +01:00
|
|
|
/*
|
|
|
|
* BGP RPKI
|
|
|
|
* Copyright (C) 2013 Michael Mester (m.mester@fu-berlin.de), for FU Berlin
|
|
|
|
* Copyright (C) 2014-2017 Andreas Reuter (andreas.reuter@fu-berlin.de), for FU
|
|
|
|
* Berlin
|
|
|
|
* Copyright (C) 2016-2017 Colin Sames (colin.sames@haw-hamburg.de), for HAW
|
|
|
|
* Hamburg
|
2018-04-12 14:13:07 +02:00
|
|
|
* Copyright (C) 2017-2018 Marcel Röthke (marcel.roethke@haw-hamburg.de),
|
|
|
|
* for HAW Hamburg
|
2017-11-10 13:56:24 +01:00
|
|
|
*/
|
|
|
|
|
2018-05-13 12:36:50 +02:00
|
|
|
/* If rtrlib compiled with ssh support, don`t fail build */
|
|
|
|
#define LIBSSH_LEGACY_0_4
|
|
|
|
|
2017-11-10 13:56:24 +01:00
|
|
|
#include <zebra.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "prefix.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "command.h"
|
|
|
|
#include "linklist.h"
|
|
|
|
#include "memory.h"
|
|
|
|
#include "thread.h"
|
|
|
|
#include "filter.h"
|
|
|
|
#include "bgpd/bgpd.h"
|
|
|
|
#include "bgpd/bgp_table.h"
|
|
|
|
#include "bgp_advertise.h"
|
|
|
|
#include "bgpd/bgp_debug.h"
|
|
|
|
#include "bgpd/bgp_attr.h"
|
|
|
|
#include "bgpd/bgp_aspath.h"
|
|
|
|
#include "bgpd/bgp_route.h"
|
2021-03-08 21:56:12 +01:00
|
|
|
#include "bgpd/bgp_rpki.h"
|
2021-04-01 10:03:58 +02:00
|
|
|
#include "northbound_cli.h"
|
2021-03-08 21:56:12 +01:00
|
|
|
|
2018-07-18 15:41:34 +02:00
|
|
|
#include "lib/network.h"
|
2018-03-29 11:15:18 +02:00
|
|
|
#include "lib/thread.h"
|
2017-11-10 13:56:24 +01:00
|
|
|
#include "rtrlib/rtrlib.h"
|
|
|
|
#include "hook.h"
|
|
|
|
#include "libfrr.h"
|
2021-04-21 11:19:39 +02:00
|
|
|
#include "lib/version.h"
|
2017-11-10 13:56:24 +01:00
|
|
|
|
2017-12-04 22:32:20 +01:00
|
|
|
#include "bgpd/bgp_rpki_clippy.c"
|
2017-11-10 13:56:24 +01:00
|
|
|
|
|
|
|
DEFINE_MTYPE_STATIC(BGPD, BGP_RPKI_CACHE, "BGP RPKI Cache server");
|
|
|
|
DEFINE_MTYPE_STATIC(BGPD, BGP_RPKI_CACHE_GROUP, "BGP RPKI Cache server group");
|
2022-04-05 10:02:07 +02:00
|
|
|
DEFINE_MTYPE_STATIC(BGPD, BGP_RPKI_RTRLIB, "BGP RPKI RTRLib");
|
2022-11-08 13:36:56 +01:00
|
|
|
DEFINE_MTYPE_STATIC(BGPD, BGP_RPKI_REVALIDATE, "BGP RPKI Revalidation");
|
2017-11-10 13:56:24 +01:00
|
|
|
|
|
|
|
#define POLLING_PERIOD_DEFAULT 3600
|
|
|
|
#define EXPIRE_INTERVAL_DEFAULT 7200
|
|
|
|
#define RETRY_INTERVAL_DEFAULT 600
|
2022-04-05 15:54:19 +02:00
|
|
|
#define BGP_RPKI_CACHE_SERVER_SYNC_RETRY_TIMEOUT 3
|
2017-11-10 13:56:24 +01:00
|
|
|
|
2022-05-03 14:13:23 +02:00
|
|
|
static struct thread *t_rpki_sync;
|
|
|
|
|
2017-11-10 13:56:24 +01:00
|
|
|
#define RPKI_DEBUG(...) \
|
|
|
|
if (rpki_debug) { \
|
|
|
|
zlog_debug("RPKI: " __VA_ARGS__); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RPKI_OUTPUT_STRING "Control rpki specific settings\n"
|
|
|
|
|
|
|
|
struct cache {
|
|
|
|
enum { TCP, SSH } type;
|
|
|
|
struct tr_socket *tr_socket;
|
|
|
|
union {
|
|
|
|
struct tr_tcp_config *tcp_config;
|
|
|
|
struct tr_ssh_config *ssh_config;
|
|
|
|
} tr_config;
|
|
|
|
struct rtr_socket *rtr_socket;
|
|
|
|
uint8_t preference;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum return_values { SUCCESS = 0, ERROR = -1 };
|
|
|
|
|
|
|
|
struct rpki_for_each_record_arg {
|
|
|
|
struct vty *vty;
|
|
|
|
unsigned int *prefix_amount;
|
2020-02-20 16:37:37 +01:00
|
|
|
as_t as;
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
json_object *json;
|
2022-11-25 17:51:33 +01:00
|
|
|
enum asnotation_mode asnotation;
|
2017-11-10 13:56:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static int start(void);
|
|
|
|
static void stop(void);
|
|
|
|
static int reset(bool force);
|
|
|
|
static struct rtr_mgr_group *get_connected_group(void);
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
static void print_prefix_table(struct vty *vty, json_object *json);
|
2017-11-10 13:56:24 +01:00
|
|
|
static void install_cli_commands(void);
|
|
|
|
static int config_write(struct vty *vty);
|
2018-09-09 00:03:19 +02:00
|
|
|
static int config_on_exit(struct vty *vty);
|
2017-11-10 13:56:24 +01:00
|
|
|
static void free_cache(struct cache *cache);
|
|
|
|
static struct rtr_mgr_group *get_groups(void);
|
|
|
|
#if defined(FOUND_SSH)
|
|
|
|
static int add_ssh_cache(const char *host, const unsigned int port,
|
|
|
|
const char *username, const char *client_privkey_path,
|
|
|
|
const char *server_pubkey_path,
|
2021-09-02 17:12:06 +02:00
|
|
|
const uint8_t preference, const char *bindaddr);
|
2017-11-10 13:56:24 +01:00
|
|
|
#endif
|
|
|
|
static struct rtr_socket *create_rtr_socket(struct tr_socket *tr_socket);
|
|
|
|
static struct cache *find_cache(const uint8_t preference);
|
2022-06-20 19:31:18 +02:00
|
|
|
static void rpki_delete_all_cache_nodes(void);
|
2017-11-10 13:56:24 +01:00
|
|
|
static int add_tcp_cache(const char *host, const char *port,
|
2021-09-02 17:12:06 +02:00
|
|
|
const uint8_t preference, const char *bindaddr);
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
static void print_record(const struct pfx_record *record, struct vty *vty,
|
2022-11-25 17:51:33 +01:00
|
|
|
json_object *json, enum asnotation_mode asnotation);
|
2022-05-03 14:13:23 +02:00
|
|
|
static bool is_synchronized(void);
|
2022-05-03 14:35:22 +02:00
|
|
|
static bool is_running(void);
|
|
|
|
static bool is_stopping(void);
|
2017-11-10 13:56:24 +01:00
|
|
|
static void route_match_free(void *rule);
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t route_match(void *rule,
|
|
|
|
const struct prefix *prefix,
|
2020-11-14 01:35:20 +01:00
|
|
|
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
void *object);
|
2017-11-10 13:56:24 +01:00
|
|
|
static void *route_match_compile(const char *arg);
|
2020-03-27 00:11:58 +01:00
|
|
|
static void revalidate_bgp_node(struct bgp_dest *dest, afi_t afi, safi_t safi);
|
2018-07-18 15:41:34 +02:00
|
|
|
static void revalidate_all_routes(void);
|
2017-11-10 13:56:24 +01:00
|
|
|
|
|
|
|
static struct rtr_mgr_config *rtr_config;
|
|
|
|
static struct list *cache_list;
|
2022-05-03 14:35:22 +02:00
|
|
|
static bool rtr_is_running;
|
|
|
|
static bool rtr_is_stopping;
|
2022-05-03 14:13:23 +02:00
|
|
|
static bool rtr_is_synced;
|
2018-07-18 15:41:34 +02:00
|
|
|
static _Atomic int rtr_update_overflow;
|
2022-05-03 14:35:22 +02:00
|
|
|
static bool rpki_debug;
|
2017-11-10 13:56:24 +01:00
|
|
|
static unsigned int polling_period;
|
|
|
|
static unsigned int expire_interval;
|
|
|
|
static unsigned int retry_interval;
|
2018-03-29 11:15:18 +02:00
|
|
|
static int rpki_sync_socket_rtr;
|
|
|
|
static int rpki_sync_socket_bgpd;
|
2017-11-10 13:56:24 +01:00
|
|
|
|
2018-09-08 21:46:23 +02:00
|
|
|
static struct cmd_node rpki_node = {
|
2018-09-09 00:15:50 +02:00
|
|
|
.name = "rpki",
|
2018-09-08 21:46:23 +02:00
|
|
|
.node = RPKI_NODE,
|
2018-09-08 23:15:09 +02:00
|
|
|
.parent_node = CONFIG_NODE,
|
2018-09-08 21:46:23 +02:00
|
|
|
.prompt = "%s(config-rpki)# ",
|
2018-09-08 22:31:43 +02:00
|
|
|
.config_write = config_write,
|
2018-09-09 00:03:19 +02:00
|
|
|
.node_exit = config_on_exit,
|
2018-09-08 21:46:23 +02:00
|
|
|
};
|
2019-11-20 17:20:58 +01:00
|
|
|
static const struct route_map_rule_cmd route_match_rpki_cmd = {
|
2017-11-10 13:56:24 +01:00
|
|
|
"rpki", route_match, route_match_compile, route_match_free};
|
|
|
|
|
|
|
|
static void *malloc_wrapper(size_t size)
|
|
|
|
{
|
2022-04-05 10:02:07 +02:00
|
|
|
return XMALLOC(MTYPE_BGP_RPKI_RTRLIB, size);
|
2017-11-10 13:56:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void *realloc_wrapper(void *ptr, size_t size)
|
|
|
|
{
|
2022-04-05 10:02:07 +02:00
|
|
|
return XREALLOC(MTYPE_BGP_RPKI_RTRLIB, ptr, size);
|
2017-11-10 13:56:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void free_wrapper(void *ptr)
|
|
|
|
{
|
2022-04-05 10:02:07 +02:00
|
|
|
XFREE(MTYPE_BGP_RPKI_RTRLIB, ptr);
|
2017-11-10 13:56:24 +01:00
|
|
|
}
|
|
|
|
|
2018-07-01 22:54:51 +02:00
|
|
|
static void init_tr_socket(struct cache *cache)
|
|
|
|
{
|
|
|
|
if (cache->type == TCP)
|
|
|
|
tr_tcp_init(cache->tr_config.tcp_config,
|
|
|
|
cache->tr_socket);
|
|
|
|
#if defined(FOUND_SSH)
|
|
|
|
else
|
|
|
|
tr_ssh_init(cache->tr_config.ssh_config,
|
|
|
|
cache->tr_socket);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void free_tr_socket(struct cache *cache)
|
|
|
|
{
|
|
|
|
if (cache->type == TCP)
|
|
|
|
tr_tcp_init(cache->tr_config.tcp_config,
|
|
|
|
cache->tr_socket);
|
|
|
|
#if defined(FOUND_SSH)
|
|
|
|
else
|
|
|
|
tr_ssh_init(cache->tr_config.ssh_config,
|
|
|
|
cache->tr_socket);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-11-10 13:56:24 +01:00
|
|
|
static int rpki_validate_prefix(struct peer *peer, struct attr *attr,
|
2018-08-09 00:08:22 +02:00
|
|
|
const struct prefix *prefix);
|
2017-11-10 13:56:24 +01:00
|
|
|
|
2018-03-29 11:15:18 +02:00
|
|
|
static void ipv6_addr_to_network_byte_order(const uint32_t *src, uint32_t *dest)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
dest[i] = htonl(src[i]);
|
|
|
|
}
|
|
|
|
|
2018-04-12 14:13:07 +02:00
|
|
|
static void ipv6_addr_to_host_byte_order(const uint32_t *src, uint32_t *dest)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
dest[i] = ntohl(src[i]);
|
|
|
|
}
|
|
|
|
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t route_match(void *rule,
|
|
|
|
const struct prefix *prefix,
|
|
|
|
void *object)
|
2017-11-10 13:56:24 +01:00
|
|
|
{
|
|
|
|
int *rpki_status = rule;
|
2018-10-03 00:34:03 +02:00
|
|
|
struct bgp_path_info *path;
|
2017-11-10 13:56:24 +01:00
|
|
|
|
2020-11-14 01:35:20 +01:00
|
|
|
path = object;
|
2017-11-10 13:56:24 +01:00
|
|
|
|
2020-11-14 01:35:20 +01:00
|
|
|
if (rpki_validate_prefix(path->peer, path->attr, prefix)
|
|
|
|
== *rpki_status) {
|
|
|
|
return RMAP_MATCH;
|
2017-11-10 13:56:24 +01:00
|
|
|
}
|
2020-11-14 01:35:20 +01:00
|
|
|
|
2017-11-10 13:56:24 +01:00
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *route_match_compile(const char *arg)
|
|
|
|
{
|
|
|
|
int *rpki_status;
|
|
|
|
|
2018-07-19 17:57:40 +02:00
|
|
|
rpki_status = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(int));
|
2017-11-10 13:56:24 +01:00
|
|
|
|
|
|
|
if (strcmp(arg, "valid") == 0)
|
|
|
|
*rpki_status = RPKI_VALID;
|
|
|
|
else if (strcmp(arg, "invalid") == 0)
|
|
|
|
*rpki_status = RPKI_INVALID;
|
|
|
|
else
|
|
|
|
*rpki_status = RPKI_NOTFOUND;
|
|
|
|
|
|
|
|
return rpki_status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void route_match_free(void *rule)
|
|
|
|
{
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct rtr_socket *create_rtr_socket(struct tr_socket *tr_socket)
|
|
|
|
{
|
|
|
|
struct rtr_socket *rtr_socket =
|
|
|
|
XMALLOC(MTYPE_BGP_RPKI_CACHE, sizeof(struct rtr_socket));
|
|
|
|
rtr_socket->tr_socket = tr_socket;
|
|
|
|
return rtr_socket;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct cache *find_cache(const uint8_t preference)
|
|
|
|
{
|
|
|
|
struct listnode *cache_node;
|
|
|
|
struct cache *cache;
|
|
|
|
|
|
|
|
for (ALL_LIST_ELEMENTS_RO(cache_list, cache_node, cache)) {
|
|
|
|
if (cache->preference == preference)
|
|
|
|
return cache;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2022-06-20 19:31:18 +02:00
|
|
|
static void rpki_delete_all_cache_nodes(void)
|
|
|
|
{
|
|
|
|
struct listnode *cache_node, *cache_next;
|
|
|
|
struct cache *cache;
|
|
|
|
|
|
|
|
for (ALL_LIST_ELEMENTS(cache_list, cache_node, cache_next, cache)) {
|
|
|
|
rtr_mgr_remove_group(rtr_config, cache->preference);
|
|
|
|
listnode_delete(cache_list, cache);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
static void print_record(const struct pfx_record *record, struct vty *vty,
|
2022-11-25 17:51:33 +01:00
|
|
|
json_object *json, enum asnotation_mode asnotation)
|
2017-11-10 13:56:24 +01:00
|
|
|
{
|
|
|
|
char ip[INET6_ADDRSTRLEN];
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
json_object *json_record = NULL;
|
2019-03-23 11:57:09 +01:00
|
|
|
|
|
|
|
lrtr_ip_addr_to_str(&record->prefix, ip, sizeof(ip));
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
|
|
|
|
if (!json) {
|
2022-11-25 17:51:33 +01:00
|
|
|
vty_out(vty, "%-40s %3u - %3u ", ip, record->min_len,
|
|
|
|
record->max_len);
|
|
|
|
vty_out(vty, ASN_FORMAT(asnotation), &record->asn);
|
|
|
|
vty_out(vty, "\n");
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
} else {
|
|
|
|
json_record = json_object_new_object();
|
|
|
|
json_object_string_add(json_record, "prefix", ip);
|
|
|
|
json_object_int_add(json_record, "prefixLenMin",
|
|
|
|
record->min_len);
|
|
|
|
json_object_int_add(json_record, "prefixLenMax",
|
|
|
|
record->max_len);
|
2022-11-25 17:51:33 +01:00
|
|
|
asn_asn2json(json_record, "asn", record->asn, asnotation);
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
json_object_array_add(json, json_record);
|
|
|
|
}
|
2019-03-23 11:57:09 +01:00
|
|
|
}
|
|
|
|
|
2020-02-20 16:37:37 +01:00
|
|
|
static void print_record_by_asn(const struct pfx_record *record, void *data)
|
|
|
|
{
|
|
|
|
struct rpki_for_each_record_arg *arg = data;
|
|
|
|
struct vty *vty = arg->vty;
|
|
|
|
|
|
|
|
if (record->asn == arg->as) {
|
|
|
|
(*arg->prefix_amount)++;
|
2022-11-25 17:51:33 +01:00
|
|
|
print_record(record, vty, arg->json, arg->asnotation);
|
2020-02-20 16:37:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-23 11:57:09 +01:00
|
|
|
static void print_record_cb(const struct pfx_record *record, void *data)
|
|
|
|
{
|
2017-11-10 13:56:24 +01:00
|
|
|
struct rpki_for_each_record_arg *arg = data;
|
|
|
|
struct vty *vty = arg->vty;
|
|
|
|
|
2017-11-14 09:38:51 +01:00
|
|
|
(*arg->prefix_amount)++;
|
2017-11-10 13:56:24 +01:00
|
|
|
|
2022-11-25 17:51:33 +01:00
|
|
|
print_record(record, vty, arg->json, arg->asnotation);
|
2017-11-10 13:56:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct rtr_mgr_group *get_groups(void)
|
|
|
|
{
|
|
|
|
struct listnode *cache_node;
|
|
|
|
struct rtr_mgr_group *rtr_mgr_groups;
|
|
|
|
struct cache *cache;
|
|
|
|
|
|
|
|
int group_count = listcount(cache_list);
|
|
|
|
|
|
|
|
if (group_count == 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
rtr_mgr_groups = XMALLOC(MTYPE_BGP_RPKI_CACHE_GROUP,
|
|
|
|
group_count * sizeof(struct rtr_mgr_group));
|
|
|
|
|
|
|
|
size_t i = 0;
|
|
|
|
|
|
|
|
for (ALL_LIST_ELEMENTS_RO(cache_list, cache_node, cache)) {
|
|
|
|
rtr_mgr_groups[i].sockets = &cache->rtr_socket;
|
|
|
|
rtr_mgr_groups[i].sockets_len = 1;
|
|
|
|
rtr_mgr_groups[i].preference = cache->preference;
|
|
|
|
|
2018-07-01 22:54:51 +02:00
|
|
|
init_tr_socket(cache);
|
2017-11-10 13:56:24 +01:00
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rtr_mgr_groups;
|
|
|
|
}
|
|
|
|
|
2022-05-03 14:13:23 +02:00
|
|
|
inline bool is_synchronized(void)
|
2017-11-10 13:56:24 +01:00
|
|
|
{
|
2022-05-03 14:13:23 +02:00
|
|
|
return rtr_is_synced;
|
2017-11-10 13:56:24 +01:00
|
|
|
}
|
|
|
|
|
2022-05-03 14:35:22 +02:00
|
|
|
inline bool is_running(void)
|
2017-11-10 13:56:24 +01:00
|
|
|
{
|
|
|
|
return rtr_is_running;
|
|
|
|
}
|
|
|
|
|
2022-05-03 14:35:22 +02:00
|
|
|
inline bool is_stopping(void)
|
2022-04-05 13:14:00 +02:00
|
|
|
{
|
|
|
|
return rtr_is_stopping;
|
|
|
|
}
|
|
|
|
|
2022-11-08 13:50:40 +01:00
|
|
|
static void pfx_record_to_prefix(struct pfx_record *record,
|
|
|
|
struct prefix *prefix)
|
2018-03-29 11:15:18 +02:00
|
|
|
{
|
|
|
|
prefix->prefixlen = record->min_len;
|
|
|
|
|
|
|
|
if (record->prefix.ver == LRTR_IPV4) {
|
|
|
|
prefix->family = AF_INET;
|
|
|
|
prefix->u.prefix4.s_addr = htonl(record->prefix.u.addr4.addr);
|
|
|
|
} else {
|
|
|
|
prefix->family = AF_INET6;
|
|
|
|
ipv6_addr_to_network_byte_order(record->prefix.u.addr6.addr,
|
|
|
|
prefix->u.prefix6.s6_addr32);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-08 14:10:49 +01:00
|
|
|
struct rpki_revalidate_prefix {
|
|
|
|
struct bgp *bgp;
|
|
|
|
struct prefix prefix;
|
|
|
|
afi_t afi;
|
|
|
|
safi_t safi;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void rpki_revalidate_prefix(struct thread *thread)
|
|
|
|
{
|
|
|
|
struct rpki_revalidate_prefix *rrp = THREAD_ARG(thread);
|
|
|
|
struct bgp_dest *match, *node;
|
|
|
|
|
|
|
|
match = bgp_table_subtree_lookup(rrp->bgp->rib[rrp->afi][rrp->safi],
|
|
|
|
&rrp->prefix);
|
bgpd: rpki was decrementing the node lock one time too many
The code was this:
1) match = bgp_table_subtree_lookup(rrp->bgp->rib[rrp->afi][rrp->safi],
&rrp->prefix);
2) node = match;
while (node) {
if (bgp_dest_has_bgp_path_info_data(node)) {
revalidate_bgp_node(node, rrp->afi, rrp->safi);
}
3) node = bgp_route_next_until(node, match);
}
if (match)
4) bgp_dest_unlock_node(match);
At 1) match was locked and became +1
At 2) match and node are now equal
At 3) On first iteration, match is decremented( as that node points
at it ) and the next item is locked, if it is found, and returned which becomes node
If 3 is run again because node is non-null then, current node is decremented
and the next node found is incremented and returned which becomes node again.
So if we get to 4) match is unlocked again which is now a double unlock
which, frankly, is not good. In all code paths that I can see the
test for `if (match) ...` is not needed so let's just remove it.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-11-08 20:38:02 +01:00
|
|
|
|
2022-11-08 14:10:49 +01:00
|
|
|
node = match;
|
|
|
|
|
|
|
|
while (node) {
|
|
|
|
if (bgp_dest_has_bgp_path_info_data(node)) {
|
|
|
|
revalidate_bgp_node(node, rrp->afi, rrp->safi);
|
|
|
|
}
|
|
|
|
|
|
|
|
node = bgp_route_next_until(node, match);
|
|
|
|
}
|
|
|
|
|
|
|
|
XFREE(MTYPE_BGP_RPKI_REVALIDATE, rrp);
|
|
|
|
}
|
|
|
|
|
2022-02-23 01:04:25 +01:00
|
|
|
static void bgpd_sync_callback(struct thread *thread)
|
2018-03-29 11:15:18 +02:00
|
|
|
{
|
|
|
|
struct bgp *bgp;
|
|
|
|
struct listnode *node;
|
2022-11-08 13:50:40 +01:00
|
|
|
struct prefix prefix;
|
2018-03-29 11:15:18 +02:00
|
|
|
struct pfx_record rec;
|
|
|
|
|
2022-05-03 14:09:52 +02:00
|
|
|
thread_add_read(bm->master, bgpd_sync_callback, NULL,
|
|
|
|
rpki_sync_socket_bgpd, NULL);
|
2018-07-18 15:41:34 +02:00
|
|
|
|
|
|
|
if (atomic_load_explicit(&rtr_update_overflow, memory_order_seq_cst)) {
|
2022-05-03 14:09:52 +02:00
|
|
|
while (read(rpki_sync_socket_bgpd, &rec,
|
|
|
|
sizeof(struct pfx_record)) != -1)
|
2018-07-18 15:41:34 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
atomic_store_explicit(&rtr_update_overflow, 0,
|
|
|
|
memory_order_seq_cst);
|
|
|
|
revalidate_all_routes();
|
2022-02-23 01:04:25 +01:00
|
|
|
return;
|
2018-07-18 15:41:34 +02:00
|
|
|
}
|
|
|
|
|
2022-05-03 14:09:52 +02:00
|
|
|
int retval =
|
|
|
|
read(rpki_sync_socket_bgpd, &rec, sizeof(struct pfx_record));
|
2022-02-02 12:30:52 +01:00
|
|
|
if (retval != sizeof(struct pfx_record)) {
|
2022-05-03 14:09:52 +02:00
|
|
|
RPKI_DEBUG("Could not read from rpki_sync_socket_bgpd");
|
2022-02-23 01:04:25 +01:00
|
|
|
return;
|
2022-01-27 10:14:11 +01:00
|
|
|
}
|
2022-11-08 13:50:40 +01:00
|
|
|
pfx_record_to_prefix(&rec, &prefix);
|
2018-03-29 11:15:18 +02:00
|
|
|
|
|
|
|
afi_t afi = (rec.prefix.ver == LRTR_IPV4) ? AFI_IP : AFI_IP6;
|
|
|
|
|
|
|
|
for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) {
|
2021-08-15 16:15:38 +02:00
|
|
|
safi_t safi;
|
2018-03-29 11:15:18 +02:00
|
|
|
|
2021-08-15 16:15:38 +02:00
|
|
|
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) {
|
2022-09-06 11:38:30 +02:00
|
|
|
struct bgp_table *table = bgp->rib[afi][safi];
|
2022-11-08 14:10:49 +01:00
|
|
|
struct rpki_revalidate_prefix *rrp;
|
2022-09-06 11:38:30 +02:00
|
|
|
|
|
|
|
if (!table)
|
2021-08-15 16:15:38 +02:00
|
|
|
continue;
|
2018-07-19 17:58:05 +02:00
|
|
|
|
2022-11-08 14:10:49 +01:00
|
|
|
rrp = XCALLOC(MTYPE_BGP_RPKI_REVALIDATE, sizeof(*rrp));
|
|
|
|
rrp->bgp = bgp;
|
|
|
|
rrp->prefix = prefix;
|
|
|
|
rrp->afi = afi;
|
|
|
|
rrp->safi = safi;
|
|
|
|
thread_add_event(bm->master, rpki_revalidate_prefix,
|
|
|
|
rrp, 0, &bgp->t_revalidate[afi][safi]);
|
2018-03-29 11:15:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-27 00:11:58 +01:00
|
|
|
static void revalidate_bgp_node(struct bgp_dest *bgp_dest, afi_t afi,
|
2018-03-29 11:15:18 +02:00
|
|
|
safi_t safi)
|
|
|
|
{
|
|
|
|
struct bgp_adj_in *ain;
|
|
|
|
|
2020-03-27 00:11:58 +01:00
|
|
|
for (ain = bgp_dest->adj_in; ain; ain = ain->next) {
|
2018-12-12 22:18:15 +01:00
|
|
|
struct bgp_path_info *path =
|
2020-03-27 00:11:58 +01:00
|
|
|
bgp_dest_get_bgp_path_info(bgp_dest);
|
2018-03-29 11:15:18 +02:00
|
|
|
mpls_label_t *label = NULL;
|
|
|
|
uint32_t num_labels = 0;
|
|
|
|
|
2018-10-03 00:34:03 +02:00
|
|
|
if (path && path->extra) {
|
|
|
|
label = path->extra->label;
|
|
|
|
num_labels = path->extra->num_labels;
|
2018-03-29 11:15:18 +02:00
|
|
|
}
|
2021-08-15 16:22:50 +02:00
|
|
|
(void)bgp_update(ain->peer, bgp_dest_get_prefix(bgp_dest),
|
2020-03-22 05:02:18 +01:00
|
|
|
ain->addpath_rx_id, ain->attr, afi, safi,
|
|
|
|
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, label,
|
|
|
|
num_labels, 1, NULL);
|
2018-03-29 11:15:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-08 13:36:56 +01:00
|
|
|
/*
|
|
|
|
* The act of a soft reconfig in revalidation is really expensive
|
|
|
|
* coupled with the fact that the download of a full rpki state
|
|
|
|
* from a rpki server can be expensive, let's break up the revalidation
|
|
|
|
* to a point in time in the future to allow other bgp events
|
|
|
|
* to take place too.
|
|
|
|
*/
|
|
|
|
struct rpki_revalidate_peer {
|
|
|
|
afi_t afi;
|
|
|
|
safi_t safi;
|
|
|
|
struct peer *peer;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void bgp_rpki_revalidate_peer(struct thread *thread)
|
|
|
|
{
|
|
|
|
struct rpki_revalidate_peer *rvp = THREAD_ARG(thread);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Here's the expensive bit of gnomish deviousness
|
|
|
|
*/
|
|
|
|
bgp_soft_reconfig_in(rvp->peer, rvp->afi, rvp->safi);
|
|
|
|
|
|
|
|
XFREE(MTYPE_BGP_RPKI_REVALIDATE, rvp);
|
|
|
|
}
|
|
|
|
|
2018-03-29 11:15:18 +02:00
|
|
|
static void revalidate_all_routes(void)
|
|
|
|
{
|
|
|
|
struct bgp *bgp;
|
|
|
|
struct listnode *node;
|
|
|
|
|
|
|
|
for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) {
|
2018-07-19 17:58:05 +02:00
|
|
|
struct peer *peer;
|
|
|
|
struct listnode *peer_listnode;
|
2018-03-29 11:15:18 +02:00
|
|
|
|
2018-07-19 17:58:05 +02:00
|
|
|
for (ALL_LIST_ELEMENTS_RO(bgp->peer, peer_listnode, peer)) {
|
2022-11-06 13:52:40 +01:00
|
|
|
afi_t afi;
|
|
|
|
safi_t safi;
|
2018-07-19 17:58:05 +02:00
|
|
|
|
2022-11-06 13:52:40 +01:00
|
|
|
FOREACH_AFI_SAFI (afi, safi) {
|
2022-11-08 13:36:56 +01:00
|
|
|
struct rpki_revalidate_peer *rvp;
|
|
|
|
|
2022-11-08 13:16:53 +01:00
|
|
|
if (!bgp->rib[afi][safi])
|
2022-11-06 13:52:40 +01:00
|
|
|
continue;
|
2022-05-03 14:09:52 +02:00
|
|
|
|
2022-11-08 13:11:18 +01:00
|
|
|
if (!peer_established(peer))
|
|
|
|
continue;
|
2022-11-08 13:36:56 +01:00
|
|
|
|
|
|
|
rvp = XCALLOC(MTYPE_BGP_RPKI_REVALIDATE,
|
|
|
|
sizeof(*rvp));
|
|
|
|
rvp->peer = peer;
|
|
|
|
rvp->afi = afi;
|
|
|
|
rvp->safi = safi;
|
|
|
|
|
|
|
|
thread_add_event(
|
|
|
|
bm->master, bgp_rpki_revalidate_peer,
|
|
|
|
rvp, 0,
|
|
|
|
&peer->t_revalidate_all[afi][safi]);
|
2018-03-29 11:15:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rpki_update_cb_sync_rtr(struct pfx_table *p __attribute__((unused)),
|
|
|
|
const struct pfx_record rec,
|
|
|
|
const bool added __attribute__((unused)))
|
|
|
|
{
|
2022-04-05 13:14:00 +02:00
|
|
|
if (is_stopping() ||
|
|
|
|
atomic_load_explicit(&rtr_update_overflow, memory_order_seq_cst))
|
2018-03-29 11:15:18 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
int retval =
|
|
|
|
write(rpki_sync_socket_rtr, &rec, sizeof(struct pfx_record));
|
2018-07-18 15:41:34 +02:00
|
|
|
if (retval == -1 && (errno == EAGAIN || errno == EWOULDBLOCK))
|
|
|
|
atomic_store_explicit(&rtr_update_overflow, 1,
|
|
|
|
memory_order_seq_cst);
|
|
|
|
|
|
|
|
else if (retval != sizeof(struct pfx_record))
|
2018-03-29 11:15:18 +02:00
|
|
|
RPKI_DEBUG("Could not write to rpki_sync_socket_rtr");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rpki_init_sync_socket(void)
|
|
|
|
{
|
|
|
|
int fds[2];
|
2018-07-18 15:41:34 +02:00
|
|
|
const char *msg;
|
2018-03-29 11:15:18 +02:00
|
|
|
|
|
|
|
RPKI_DEBUG("initializing sync socket");
|
|
|
|
if (socketpair(PF_LOCAL, SOCK_DGRAM, 0, fds) != 0) {
|
2018-07-18 15:41:34 +02:00
|
|
|
msg = "could not open rpki sync socketpair";
|
|
|
|
goto err;
|
2018-03-29 11:15:18 +02:00
|
|
|
}
|
|
|
|
rpki_sync_socket_rtr = fds[0];
|
|
|
|
rpki_sync_socket_bgpd = fds[1];
|
2018-07-18 15:41:34 +02:00
|
|
|
|
|
|
|
if (set_nonblocking(rpki_sync_socket_rtr) != 0) {
|
|
|
|
msg = "could not set rpki_sync_socket_rtr to non blocking";
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (set_nonblocking(rpki_sync_socket_bgpd) != 0) {
|
|
|
|
msg = "could not set rpki_sync_socket_bgpd to non blocking";
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2022-05-03 14:09:52 +02:00
|
|
|
|
2018-03-29 11:15:18 +02:00
|
|
|
thread_add_read(bm->master, bgpd_sync_callback, NULL,
|
2022-05-03 14:09:52 +02:00
|
|
|
rpki_sync_socket_bgpd, NULL);
|
2018-07-18 15:41:34 +02:00
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
err:
|
|
|
|
zlog_err("RPKI: %s", msg);
|
|
|
|
abort();
|
|
|
|
|
2018-03-29 11:15:18 +02:00
|
|
|
}
|
|
|
|
|
2017-11-10 13:56:24 +01:00
|
|
|
static int bgp_rpki_init(struct thread_master *master)
|
|
|
|
{
|
2022-05-03 14:35:22 +02:00
|
|
|
rpki_debug = false;
|
|
|
|
rtr_is_running = false;
|
|
|
|
rtr_is_stopping = false;
|
2022-05-03 14:13:23 +02:00
|
|
|
rtr_is_synced = false;
|
2017-11-10 13:56:24 +01:00
|
|
|
|
|
|
|
cache_list = list_new();
|
|
|
|
cache_list->del = (void (*)(void *)) & free_cache;
|
|
|
|
|
|
|
|
polling_period = POLLING_PERIOD_DEFAULT;
|
|
|
|
expire_interval = EXPIRE_INTERVAL_DEFAULT;
|
|
|
|
retry_interval = RETRY_INTERVAL_DEFAULT;
|
|
|
|
install_cli_commands();
|
2018-03-29 11:15:18 +02:00
|
|
|
rpki_init_sync_socket();
|
2017-11-10 13:56:24 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int bgp_rpki_fini(void)
|
|
|
|
{
|
|
|
|
stop();
|
2018-10-02 11:39:51 +02:00
|
|
|
list_delete(&cache_list);
|
2017-11-10 13:56:24 +01:00
|
|
|
|
2018-03-29 11:15:18 +02:00
|
|
|
close(rpki_sync_socket_rtr);
|
|
|
|
close(rpki_sync_socket_bgpd);
|
|
|
|
|
2017-11-10 13:56:24 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int bgp_rpki_module_init(void)
|
|
|
|
{
|
|
|
|
lrtr_set_alloc_functions(malloc_wrapper, realloc_wrapper, free_wrapper);
|
|
|
|
|
bgpd: Display RPKI validation state if we have it
When dumping data about prefixes in bgp. Let's dump the
rpki validation state as well:
Output if rpki is turned on:
janelle# show rpki prefix 2003::/19
Prefix Prefix Length Origin-AS
2003:: 19 - 19 3320
janelle# show bgp ipv6 uni 2003::/19
BGP routing table entry for 2003::/19
Paths: (1 available, best #1, table default)
Not advertised to any peer
15096 6939 3320
::ffff:4113:867a from 65.19.134.122 (193.72.216.231)
(fe80::e063:daff:fe79:1dab) (used)
Origin IGP, valid, external, best (First path received), validation-state: valid
Last update: Sat Mar 6 09:20:51 2021
janelle# show rpki prefix 8.8.8.0/24
Prefix Prefix Length Origin-AS
janelle# show bgp ipv4 uni 8.8.8.0/24
BGP routing table entry for 8.8.8.0/24
Paths: (1 available, best #1, table default)
Advertised to non peer-group peers:
100.99.229.142
15096 6939 15169
65.19.134.122 from 65.19.134.122 (193.72.216.231)
Origin IGP, valid, external, best (First path received), validation-state: not found
Last update: Sat Mar 6 09:21:25 2021
Example output when rpki is not configured:
eva# show bgp ipv4 uni 8.8.8.0/24
BGP routing table entry for 8.8.8.0/24
Paths: (1 available, best #1, table default)
Advertised to non peer-group peers:
janelle(192.168.161.137)
64539 15096 6939 15169
192.168.161.137(janelle) from janelle(192.168.161.137) (192.168.44.1)
Origin IGP, valid, external, bestpath-from-AS 64539, best (First path received)
Last update: Sat Mar 6 09:33:51 2021
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-03-06 15:31:45 +01:00
|
|
|
hook_register(bgp_rpki_prefix_status, rpki_validate_prefix);
|
2017-11-10 13:56:24 +01:00
|
|
|
hook_register(frr_late_init, bgp_rpki_init);
|
2022-09-26 04:18:52 +02:00
|
|
|
hook_register(frr_early_fini, bgp_rpki_fini);
|
2017-11-10 13:56:24 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-05-03 14:13:23 +02:00
|
|
|
static void sync_expired(struct thread *thread)
|
2022-04-05 15:54:19 +02:00
|
|
|
{
|
|
|
|
if (!rtr_mgr_conf_in_sync(rtr_config)) {
|
2022-05-03 14:13:23 +02:00
|
|
|
RPKI_DEBUG("rtr_mgr is not synced, retrying.");
|
|
|
|
thread_add_timer(bm->master, sync_expired, NULL,
|
2022-04-05 15:54:19 +02:00
|
|
|
BGP_RPKI_CACHE_SERVER_SYNC_RETRY_TIMEOUT,
|
2022-05-03 14:13:23 +02:00
|
|
|
&t_rpki_sync);
|
2022-04-05 15:54:19 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-05-03 14:13:23 +02:00
|
|
|
RPKI_DEBUG("rtr_mgr sync is done.");
|
|
|
|
|
|
|
|
rtr_is_synced = true;
|
2022-04-05 15:54:19 +02:00
|
|
|
}
|
|
|
|
|
2017-11-10 13:56:24 +01:00
|
|
|
static int start(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2022-05-03 14:35:22 +02:00
|
|
|
rtr_is_stopping = false;
|
2022-05-03 14:13:23 +02:00
|
|
|
rtr_is_synced = false;
|
2018-07-18 15:41:34 +02:00
|
|
|
rtr_update_overflow = 0;
|
2018-03-29 11:15:18 +02:00
|
|
|
|
2017-11-10 13:56:24 +01:00
|
|
|
if (list_isempty(cache_list)) {
|
|
|
|
RPKI_DEBUG(
|
|
|
|
"No caches were found in config. Prefix validation is off.");
|
|
|
|
return ERROR;
|
|
|
|
}
|
|
|
|
RPKI_DEBUG("Init rtr_mgr.");
|
|
|
|
int groups_len = listcount(cache_list);
|
|
|
|
struct rtr_mgr_group *groups = get_groups();
|
|
|
|
|
2018-03-29 11:15:18 +02:00
|
|
|
RPKI_DEBUG("Polling period: %d", polling_period);
|
2017-11-10 13:56:24 +01:00
|
|
|
ret = rtr_mgr_init(&rtr_config, groups, groups_len, polling_period,
|
2018-03-29 11:15:18 +02:00
|
|
|
expire_interval, retry_interval,
|
2022-05-03 14:09:52 +02:00
|
|
|
rpki_update_cb_sync_rtr, NULL, NULL, NULL);
|
2017-11-10 13:56:24 +01:00
|
|
|
if (ret == RTR_ERROR) {
|
|
|
|
RPKI_DEBUG("Init rtr_mgr failed.");
|
|
|
|
return ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
RPKI_DEBUG("Starting rtr_mgr.");
|
|
|
|
ret = rtr_mgr_start(rtr_config);
|
|
|
|
if (ret == RTR_ERROR) {
|
|
|
|
RPKI_DEBUG("Starting rtr_mgr failed.");
|
|
|
|
rtr_mgr_free(rtr_config);
|
|
|
|
return ERROR;
|
|
|
|
}
|
2022-04-05 15:54:19 +02:00
|
|
|
|
2022-05-03 14:13:23 +02:00
|
|
|
thread_add_timer(bm->master, sync_expired, NULL, 0, &t_rpki_sync);
|
2017-11-10 13:56:24 +01:00
|
|
|
|
|
|
|
XFREE(MTYPE_BGP_RPKI_CACHE_GROUP, groups);
|
|
|
|
|
2022-05-03 14:35:22 +02:00
|
|
|
rtr_is_running = true;
|
2022-05-03 14:13:23 +02:00
|
|
|
|
2017-11-10 13:56:24 +01:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void stop(void)
|
|
|
|
{
|
2022-05-03 14:35:22 +02:00
|
|
|
rtr_is_stopping = true;
|
2022-04-05 13:10:16 +02:00
|
|
|
if (is_running()) {
|
2022-05-03 14:13:23 +02:00
|
|
|
THREAD_OFF(t_rpki_sync);
|
2017-11-10 13:56:24 +01:00
|
|
|
rtr_mgr_stop(rtr_config);
|
|
|
|
rtr_mgr_free(rtr_config);
|
2022-05-03 14:35:22 +02:00
|
|
|
rtr_is_running = false;
|
2017-11-10 13:56:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int reset(bool force)
|
|
|
|
{
|
2022-04-05 13:10:16 +02:00
|
|
|
if (is_running() && !force)
|
2017-11-10 13:56:24 +01:00
|
|
|
return SUCCESS;
|
|
|
|
|
|
|
|
RPKI_DEBUG("Resetting RPKI Session");
|
|
|
|
stop();
|
|
|
|
return start();
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct rtr_mgr_group *get_connected_group(void)
|
|
|
|
{
|
2018-06-18 16:27:02 +02:00
|
|
|
if (!cache_list || list_isempty(cache_list))
|
2017-11-10 13:56:24 +01:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return rtr_mgr_get_first_group(rtr_config);
|
|
|
|
}
|
|
|
|
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
static void print_prefix_table_by_asn(struct vty *vty, as_t as,
|
|
|
|
json_object *json)
|
2020-02-20 16:37:37 +01:00
|
|
|
{
|
|
|
|
unsigned int number_of_ipv4_prefixes = 0;
|
|
|
|
unsigned int number_of_ipv6_prefixes = 0;
|
|
|
|
struct rtr_mgr_group *group = get_connected_group();
|
|
|
|
struct rpki_for_each_record_arg arg;
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
json_object *json_records = NULL;
|
2020-02-20 16:37:37 +01:00
|
|
|
|
|
|
|
arg.vty = vty;
|
|
|
|
arg.as = as;
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
arg.json = NULL;
|
2022-11-25 17:51:33 +01:00
|
|
|
arg.asnotation = bgp_get_asnotation(bgp_lookup_by_vrf_id(VRF_DEFAULT));
|
2020-02-20 16:37:37 +01:00
|
|
|
|
|
|
|
if (!group) {
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
if (!json)
|
|
|
|
vty_out(vty, "Cannot find a connected group.\n");
|
2020-02-20 16:37:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct pfx_table *pfx_table = group->sockets[0]->pfx_table;
|
|
|
|
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
if (!json) {
|
|
|
|
vty_out(vty, "RPKI/RTR prefix table\n");
|
|
|
|
vty_out(vty, "%-40s %s %s\n", "Prefix", "Prefix Length",
|
|
|
|
"Origin-AS");
|
|
|
|
} else {
|
|
|
|
json_records = json_object_new_array();
|
|
|
|
json_object_object_add(json, "prefixes", json_records);
|
|
|
|
arg.json = json_records;
|
|
|
|
}
|
2020-02-20 16:37:37 +01:00
|
|
|
|
|
|
|
arg.prefix_amount = &number_of_ipv4_prefixes;
|
|
|
|
pfx_table_for_each_ipv4_record(pfx_table, print_record_by_asn, &arg);
|
|
|
|
|
|
|
|
arg.prefix_amount = &number_of_ipv6_prefixes;
|
|
|
|
pfx_table_for_each_ipv6_record(pfx_table, print_record_by_asn, &arg);
|
|
|
|
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
if (!json) {
|
|
|
|
vty_out(vty, "Number of IPv4 Prefixes: %u\n",
|
|
|
|
number_of_ipv4_prefixes);
|
|
|
|
vty_out(vty, "Number of IPv6 Prefixes: %u\n",
|
|
|
|
number_of_ipv6_prefixes);
|
|
|
|
} else {
|
|
|
|
json_object_int_add(json, "ipv4PrefixCount",
|
|
|
|
number_of_ipv4_prefixes);
|
|
|
|
json_object_int_add(json, "ipv6PrefixCount",
|
|
|
|
number_of_ipv6_prefixes);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (json)
|
|
|
|
vty_json(vty, json);
|
2020-02-20 16:37:37 +01:00
|
|
|
}
|
|
|
|
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
static void print_prefix_table(struct vty *vty, json_object *json)
|
2017-11-10 13:56:24 +01:00
|
|
|
{
|
|
|
|
struct rpki_for_each_record_arg arg;
|
|
|
|
|
|
|
|
unsigned int number_of_ipv4_prefixes = 0;
|
|
|
|
unsigned int number_of_ipv6_prefixes = 0;
|
|
|
|
struct rtr_mgr_group *group = get_connected_group();
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
json_object *json_records = NULL;
|
2017-11-10 13:56:24 +01:00
|
|
|
|
|
|
|
arg.vty = vty;
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
arg.json = NULL;
|
2022-11-25 17:51:33 +01:00
|
|
|
arg.asnotation = bgp_get_asnotation(bgp_lookup_by_vrf_id(VRF_DEFAULT));
|
2017-11-10 13:56:24 +01:00
|
|
|
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
if (!group) {
|
|
|
|
if (!json)
|
|
|
|
vty_out(vty, "Cannot find a connected group.\n");
|
2017-11-10 13:56:24 +01:00
|
|
|
return;
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
}
|
2017-11-10 13:56:24 +01:00
|
|
|
|
|
|
|
struct pfx_table *pfx_table = group->sockets[0]->pfx_table;
|
|
|
|
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
if (!json) {
|
|
|
|
vty_out(vty, "RPKI/RTR prefix table\n");
|
|
|
|
vty_out(vty, "%-40s %s %s\n", "Prefix", "Prefix Length",
|
|
|
|
"Origin-AS");
|
|
|
|
} else {
|
|
|
|
json_records = json_object_new_array();
|
|
|
|
json_object_object_add(json, "prefixes", json_records);
|
|
|
|
arg.json = json_records;
|
|
|
|
}
|
2017-11-10 13:56:24 +01:00
|
|
|
|
|
|
|
arg.prefix_amount = &number_of_ipv4_prefixes;
|
2019-03-23 11:57:09 +01:00
|
|
|
pfx_table_for_each_ipv4_record(pfx_table, print_record_cb, &arg);
|
2017-11-10 13:56:24 +01:00
|
|
|
|
|
|
|
arg.prefix_amount = &number_of_ipv6_prefixes;
|
2019-03-23 11:57:09 +01:00
|
|
|
pfx_table_for_each_ipv6_record(pfx_table, print_record_cb, &arg);
|
2017-11-10 13:56:24 +01:00
|
|
|
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
if (!json) {
|
|
|
|
vty_out(vty, "Number of IPv4 Prefixes: %u\n",
|
|
|
|
number_of_ipv4_prefixes);
|
|
|
|
vty_out(vty, "Number of IPv6 Prefixes: %u\n",
|
|
|
|
number_of_ipv6_prefixes);
|
|
|
|
} else {
|
|
|
|
json_object_int_add(json, "ipv4PrefixCount",
|
|
|
|
number_of_ipv4_prefixes);
|
|
|
|
json_object_int_add(json, "ipv6PrefixCount",
|
|
|
|
number_of_ipv6_prefixes);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (json)
|
|
|
|
vty_json(vty, json);
|
2017-11-10 13:56:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rpki_validate_prefix(struct peer *peer, struct attr *attr,
|
2018-08-09 00:08:22 +02:00
|
|
|
const struct prefix *prefix)
|
2017-11-10 13:56:24 +01:00
|
|
|
{
|
|
|
|
struct assegment *as_segment;
|
|
|
|
as_t as_number = 0;
|
|
|
|
struct lrtr_ip_addr ip_addr_prefix;
|
|
|
|
enum pfxv_state result;
|
|
|
|
|
|
|
|
if (!is_synchronized())
|
2022-04-05 14:52:40 +02:00
|
|
|
return RPKI_NOT_BEING_USED;
|
2017-11-10 13:56:24 +01:00
|
|
|
|
|
|
|
// No aspath means route comes from iBGP
|
|
|
|
if (!attr->aspath || !attr->aspath->segments) {
|
|
|
|
// Set own as number
|
|
|
|
as_number = peer->bgp->as;
|
|
|
|
} else {
|
|
|
|
as_segment = attr->aspath->segments;
|
|
|
|
// Find last AsSegment
|
|
|
|
while (as_segment->next)
|
|
|
|
as_segment = as_segment->next;
|
|
|
|
|
|
|
|
if (as_segment->type == AS_SEQUENCE) {
|
|
|
|
// Get rightmost asn
|
|
|
|
as_number = as_segment->as[as_segment->length - 1];
|
|
|
|
} else if (as_segment->type == AS_CONFED_SEQUENCE
|
|
|
|
|| as_segment->type == AS_CONFED_SET) {
|
|
|
|
// Set own as number
|
|
|
|
as_number = peer->bgp->as;
|
|
|
|
} else {
|
|
|
|
// RFC says: "Take distinguished value NONE as asn"
|
|
|
|
// which means state is unknown
|
|
|
|
return RPKI_NOTFOUND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the prefix in requested format
|
|
|
|
switch (prefix->family) {
|
|
|
|
case AF_INET:
|
|
|
|
ip_addr_prefix.ver = LRTR_IPV4;
|
|
|
|
ip_addr_prefix.u.addr4.addr = ntohl(prefix->u.prefix4.s_addr);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AF_INET6:
|
|
|
|
ip_addr_prefix.ver = LRTR_IPV6;
|
|
|
|
ipv6_addr_to_host_byte_order(prefix->u.prefix6.s6_addr32,
|
|
|
|
ip_addr_prefix.u.addr6.addr);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2022-04-05 14:52:40 +02:00
|
|
|
return RPKI_NOT_BEING_USED;
|
2017-11-10 13:56:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Do the actual validation
|
|
|
|
rtr_mgr_validate(rtr_config, as_number, &ip_addr_prefix,
|
|
|
|
prefix->prefixlen, &result);
|
|
|
|
|
|
|
|
// Print Debug output
|
|
|
|
switch (result) {
|
|
|
|
case BGP_PFXV_STATE_VALID:
|
|
|
|
RPKI_DEBUG(
|
2020-10-18 13:33:54 +02:00
|
|
|
"Validating Prefix %pFX from asn %u Result: VALID",
|
|
|
|
prefix, as_number);
|
2017-11-10 13:56:24 +01:00
|
|
|
return RPKI_VALID;
|
|
|
|
case BGP_PFXV_STATE_NOT_FOUND:
|
|
|
|
RPKI_DEBUG(
|
2020-10-18 13:33:54 +02:00
|
|
|
"Validating Prefix %pFX from asn %u Result: NOT FOUND",
|
|
|
|
prefix, as_number);
|
2017-11-10 13:56:24 +01:00
|
|
|
return RPKI_NOTFOUND;
|
|
|
|
case BGP_PFXV_STATE_INVALID:
|
|
|
|
RPKI_DEBUG(
|
2020-10-18 13:33:54 +02:00
|
|
|
"Validating Prefix %pFX from asn %u Result: INVALID",
|
|
|
|
prefix, as_number);
|
2017-11-10 13:56:24 +01:00
|
|
|
return RPKI_INVALID;
|
|
|
|
default:
|
|
|
|
RPKI_DEBUG(
|
2020-10-18 13:33:54 +02:00
|
|
|
"Validating Prefix %pFX from asn %u Result: CANNOT VALIDATE",
|
|
|
|
prefix, as_number);
|
2017-11-10 13:56:24 +01:00
|
|
|
break;
|
|
|
|
}
|
2022-04-05 14:52:40 +02:00
|
|
|
return RPKI_NOT_BEING_USED;
|
2017-11-10 13:56:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int add_cache(struct cache *cache)
|
|
|
|
{
|
|
|
|
uint8_t preference = cache->preference;
|
|
|
|
struct rtr_mgr_group group;
|
|
|
|
|
|
|
|
group.preference = preference;
|
|
|
|
group.sockets_len = 1;
|
|
|
|
group.sockets = &cache->rtr_socket;
|
|
|
|
|
2022-04-05 13:10:16 +02:00
|
|
|
if (is_running()) {
|
2018-07-01 22:54:51 +02:00
|
|
|
init_tr_socket(cache);
|
|
|
|
|
|
|
|
if (rtr_mgr_add_group(rtr_config, &group) != RTR_SUCCESS) {
|
|
|
|
free_tr_socket(cache);
|
|
|
|
return ERROR;
|
|
|
|
}
|
2017-11-10 13:56:24 +01:00
|
|
|
}
|
|
|
|
|
2019-08-22 15:49:58 +02:00
|
|
|
listnode_add(cache_list, cache);
|
|
|
|
|
2017-11-10 13:56:24 +01:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int add_tcp_cache(const char *host, const char *port,
|
2021-09-02 17:12:06 +02:00
|
|
|
const uint8_t preference, const char *bindaddr)
|
2017-11-10 13:56:24 +01:00
|
|
|
{
|
|
|
|
struct rtr_socket *rtr_socket;
|
|
|
|
struct tr_tcp_config *tcp_config =
|
2020-03-24 14:36:04 +01:00
|
|
|
XCALLOC(MTYPE_BGP_RPKI_CACHE, sizeof(struct tr_tcp_config));
|
2017-11-10 13:56:24 +01:00
|
|
|
struct tr_socket *tr_socket =
|
|
|
|
XMALLOC(MTYPE_BGP_RPKI_CACHE, sizeof(struct tr_socket));
|
|
|
|
struct cache *cache =
|
|
|
|
XMALLOC(MTYPE_BGP_RPKI_CACHE, sizeof(struct cache));
|
|
|
|
|
|
|
|
tcp_config->host = XSTRDUP(MTYPE_BGP_RPKI_CACHE, host);
|
|
|
|
tcp_config->port = XSTRDUP(MTYPE_BGP_RPKI_CACHE, port);
|
2021-09-02 17:12:06 +02:00
|
|
|
if (bindaddr)
|
|
|
|
tcp_config->bindaddr = XSTRDUP(MTYPE_BGP_RPKI_CACHE, bindaddr);
|
|
|
|
else
|
|
|
|
tcp_config->bindaddr = NULL;
|
2017-11-10 13:56:24 +01:00
|
|
|
|
|
|
|
rtr_socket = create_rtr_socket(tr_socket);
|
|
|
|
|
|
|
|
cache->type = TCP;
|
|
|
|
cache->tr_socket = tr_socket;
|
|
|
|
cache->tr_config.tcp_config = tcp_config;
|
|
|
|
cache->rtr_socket = rtr_socket;
|
|
|
|
cache->preference = preference;
|
|
|
|
|
2019-08-22 15:49:58 +02:00
|
|
|
int ret = add_cache(cache);
|
|
|
|
if (ret != SUCCESS) {
|
|
|
|
free_cache(cache);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2017-11-10 13:56:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(FOUND_SSH)
|
|
|
|
static int add_ssh_cache(const char *host, const unsigned int port,
|
|
|
|
const char *username, const char *client_privkey_path,
|
|
|
|
const char *server_pubkey_path,
|
2021-09-02 17:12:06 +02:00
|
|
|
const uint8_t preference, const char *bindaddr)
|
2017-11-10 13:56:24 +01:00
|
|
|
{
|
|
|
|
struct tr_ssh_config *ssh_config =
|
2020-03-24 14:36:04 +01:00
|
|
|
XCALLOC(MTYPE_BGP_RPKI_CACHE, sizeof(struct tr_ssh_config));
|
2017-11-10 13:56:24 +01:00
|
|
|
struct cache *cache =
|
|
|
|
XMALLOC(MTYPE_BGP_RPKI_CACHE, sizeof(struct cache));
|
|
|
|
struct tr_socket *tr_socket =
|
|
|
|
XMALLOC(MTYPE_BGP_RPKI_CACHE, sizeof(struct tr_socket));
|
|
|
|
struct rtr_socket *rtr_socket;
|
|
|
|
|
|
|
|
ssh_config->port = port;
|
|
|
|
ssh_config->host = XSTRDUP(MTYPE_BGP_RPKI_CACHE, host);
|
2021-09-02 17:12:06 +02:00
|
|
|
if (bindaddr)
|
|
|
|
ssh_config->bindaddr = XSTRDUP(MTYPE_BGP_RPKI_CACHE, bindaddr);
|
|
|
|
else
|
|
|
|
ssh_config->bindaddr = NULL;
|
2017-11-10 13:56:24 +01:00
|
|
|
|
|
|
|
ssh_config->username = XSTRDUP(MTYPE_BGP_RPKI_CACHE, username);
|
|
|
|
ssh_config->client_privkey_path =
|
|
|
|
XSTRDUP(MTYPE_BGP_RPKI_CACHE, client_privkey_path);
|
|
|
|
ssh_config->server_hostkey_path =
|
|
|
|
XSTRDUP(MTYPE_BGP_RPKI_CACHE, server_pubkey_path);
|
|
|
|
|
|
|
|
rtr_socket = create_rtr_socket(tr_socket);
|
|
|
|
|
|
|
|
cache->type = SSH;
|
|
|
|
cache->tr_socket = tr_socket;
|
|
|
|
cache->tr_config.ssh_config = ssh_config;
|
|
|
|
cache->rtr_socket = rtr_socket;
|
|
|
|
cache->preference = preference;
|
|
|
|
|
2019-08-22 15:49:58 +02:00
|
|
|
int ret = add_cache(cache);
|
|
|
|
if (ret != SUCCESS) {
|
|
|
|
free_cache(cache);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2017-11-10 13:56:24 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void free_cache(struct cache *cache)
|
|
|
|
{
|
|
|
|
if (cache->type == TCP) {
|
|
|
|
XFREE(MTYPE_BGP_RPKI_CACHE, cache->tr_config.tcp_config->host);
|
|
|
|
XFREE(MTYPE_BGP_RPKI_CACHE, cache->tr_config.tcp_config->port);
|
2022-04-05 10:12:22 +02:00
|
|
|
XFREE(MTYPE_BGP_RPKI_CACHE,
|
|
|
|
cache->tr_config.tcp_config->bindaddr);
|
2017-11-10 13:56:24 +01:00
|
|
|
XFREE(MTYPE_BGP_RPKI_CACHE, cache->tr_config.tcp_config);
|
|
|
|
}
|
|
|
|
#if defined(FOUND_SSH)
|
|
|
|
else {
|
|
|
|
XFREE(MTYPE_BGP_RPKI_CACHE, cache->tr_config.ssh_config->host);
|
|
|
|
XFREE(MTYPE_BGP_RPKI_CACHE,
|
|
|
|
cache->tr_config.ssh_config->username);
|
|
|
|
XFREE(MTYPE_BGP_RPKI_CACHE,
|
|
|
|
cache->tr_config.ssh_config->client_privkey_path);
|
|
|
|
XFREE(MTYPE_BGP_RPKI_CACHE,
|
|
|
|
cache->tr_config.ssh_config->server_hostkey_path);
|
2022-04-05 10:12:22 +02:00
|
|
|
XFREE(MTYPE_BGP_RPKI_CACHE,
|
|
|
|
cache->tr_config.ssh_config->bindaddr);
|
2017-11-10 13:56:24 +01:00
|
|
|
XFREE(MTYPE_BGP_RPKI_CACHE, cache->tr_config.ssh_config);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
XFREE(MTYPE_BGP_RPKI_CACHE, cache->tr_socket);
|
|
|
|
XFREE(MTYPE_BGP_RPKI_CACHE, cache->rtr_socket);
|
|
|
|
XFREE(MTYPE_BGP_RPKI_CACHE, cache);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int config_write(struct vty *vty)
|
|
|
|
{
|
|
|
|
struct listnode *cache_node;
|
|
|
|
struct cache *cache;
|
|
|
|
|
2020-11-20 14:44:25 +01:00
|
|
|
if (rpki_debug)
|
|
|
|
vty_out(vty, "debug rpki\n");
|
|
|
|
|
|
|
|
vty_out(vty, "!\n");
|
|
|
|
vty_out(vty, "rpki\n");
|
2021-08-16 16:59:20 +02:00
|
|
|
|
2022-06-21 17:49:10 +02:00
|
|
|
if (polling_period != POLLING_PERIOD_DEFAULT)
|
|
|
|
vty_out(vty, " rpki polling_period %d\n", polling_period);
|
2021-08-16 16:59:20 +02:00
|
|
|
if (retry_interval != RETRY_INTERVAL_DEFAULT)
|
|
|
|
vty_out(vty, " rpki retry_interval %d\n", retry_interval);
|
|
|
|
if (expire_interval != EXPIRE_INTERVAL_DEFAULT)
|
|
|
|
vty_out(vty, " rpki expire_interval %d\n", expire_interval);
|
|
|
|
|
2020-11-20 14:44:25 +01:00
|
|
|
for (ALL_LIST_ELEMENTS_RO(cache_list, cache_node, cache)) {
|
|
|
|
switch (cache->type) {
|
|
|
|
struct tr_tcp_config *tcp_config;
|
2017-11-13 15:50:50 +01:00
|
|
|
#if defined(FOUND_SSH)
|
2020-11-20 14:44:25 +01:00
|
|
|
struct tr_ssh_config *ssh_config;
|
2017-11-13 15:50:50 +01:00
|
|
|
#endif
|
2020-11-20 14:44:25 +01:00
|
|
|
case TCP:
|
|
|
|
tcp_config = cache->tr_config.tcp_config;
|
2021-09-07 21:24:57 +02:00
|
|
|
vty_out(vty, " rpki cache %s %s ", tcp_config->host,
|
2020-11-20 14:44:25 +01:00
|
|
|
tcp_config->port);
|
2021-09-07 21:24:57 +02:00
|
|
|
if (tcp_config->bindaddr)
|
|
|
|
vty_out(vty, "source %s ",
|
|
|
|
tcp_config->bindaddr);
|
2020-11-20 14:44:25 +01:00
|
|
|
break;
|
2017-11-10 13:56:24 +01:00
|
|
|
#if defined(FOUND_SSH)
|
2020-11-20 14:44:25 +01:00
|
|
|
case SSH:
|
|
|
|
ssh_config = cache->tr_config.ssh_config;
|
2021-09-07 21:24:57 +02:00
|
|
|
vty_out(vty, " rpki cache %s %u %s %s %s ",
|
|
|
|
ssh_config->host, ssh_config->port,
|
|
|
|
ssh_config->username,
|
2020-11-20 14:44:25 +01:00
|
|
|
ssh_config->client_privkey_path,
|
|
|
|
ssh_config->server_hostkey_path != NULL
|
|
|
|
? ssh_config->server_hostkey_path
|
|
|
|
: " ");
|
2021-09-07 21:24:57 +02:00
|
|
|
if (ssh_config->bindaddr)
|
|
|
|
vty_out(vty, "source %s ",
|
|
|
|
ssh_config->bindaddr);
|
2020-11-20 14:44:25 +01:00
|
|
|
break;
|
2017-11-10 13:56:24 +01:00
|
|
|
#endif
|
2020-11-20 14:44:25 +01:00
|
|
|
default:
|
|
|
|
break;
|
2017-11-10 13:56:24 +01:00
|
|
|
}
|
2020-11-20 14:44:25 +01:00
|
|
|
|
|
|
|
vty_out(vty, "preference %hhu\n", cache->preference);
|
2017-11-10 13:56:24 +01:00
|
|
|
}
|
2021-08-08 21:38:50 +02:00
|
|
|
vty_out(vty, "exit\n");
|
2020-11-20 14:44:25 +01:00
|
|
|
|
|
|
|
return 1;
|
2017-11-10 13:56:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN_NOSH (rpki,
|
|
|
|
rpki_cmd,
|
|
|
|
"rpki",
|
|
|
|
"Enable rpki and enter rpki configuration mode\n")
|
|
|
|
{
|
|
|
|
vty->node = RPKI_NODE;
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2022-06-20 19:31:18 +02:00
|
|
|
DEFPY (no_rpki,
|
|
|
|
no_rpki_cmd,
|
|
|
|
"no rpki",
|
|
|
|
NO_STR
|
|
|
|
"Enable rpki and enter rpki configuration mode\n")
|
|
|
|
{
|
|
|
|
rpki_delete_all_cache_nodes();
|
|
|
|
stop();
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2017-11-10 13:56:24 +01:00
|
|
|
DEFUN (bgp_rpki_start,
|
|
|
|
bgp_rpki_start_cmd,
|
|
|
|
"rpki start",
|
|
|
|
RPKI_OUTPUT_STRING
|
|
|
|
"start rpki support\n")
|
|
|
|
{
|
|
|
|
if (listcount(cache_list) == 0)
|
|
|
|
vty_out(vty,
|
|
|
|
"Could not start rpki because no caches are configured\n");
|
|
|
|
|
|
|
|
if (!is_running()) {
|
|
|
|
if (start() == ERROR) {
|
|
|
|
RPKI_DEBUG("RPKI failed to start");
|
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (bgp_rpki_stop,
|
|
|
|
bgp_rpki_stop_cmd,
|
|
|
|
"rpki stop",
|
|
|
|
RPKI_OUTPUT_STRING
|
|
|
|
"start rpki support\n")
|
|
|
|
{
|
|
|
|
if (is_running())
|
|
|
|
stop();
|
|
|
|
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFPY (rpki_polling_period,
|
|
|
|
rpki_polling_period_cmd,
|
|
|
|
"rpki polling_period (1-86400)$pp",
|
|
|
|
RPKI_OUTPUT_STRING
|
|
|
|
"Set polling period\n"
|
|
|
|
"Polling period value\n")
|
|
|
|
{
|
|
|
|
polling_period = pp;
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_rpki_polling_period,
|
|
|
|
no_rpki_polling_period_cmd,
|
2022-05-02 18:36:22 +02:00
|
|
|
"no rpki polling_period [(1-86400)]",
|
2017-11-10 13:56:24 +01:00
|
|
|
NO_STR
|
|
|
|
RPKI_OUTPUT_STRING
|
2022-05-02 18:36:22 +02:00
|
|
|
"Set polling period back to default\n"
|
|
|
|
"Polling period value\n")
|
2017-11-10 13:56:24 +01:00
|
|
|
{
|
|
|
|
polling_period = POLLING_PERIOD_DEFAULT;
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFPY (rpki_expire_interval,
|
|
|
|
rpki_expire_interval_cmd,
|
|
|
|
"rpki expire_interval (600-172800)$tmp",
|
|
|
|
RPKI_OUTPUT_STRING
|
|
|
|
"Set expire interval\n"
|
|
|
|
"Expire interval value\n")
|
|
|
|
{
|
2018-03-17 20:08:13 +01:00
|
|
|
if ((unsigned int)tmp >= polling_period) {
|
2017-11-10 13:56:24 +01:00
|
|
|
expire_interval = tmp;
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
vty_out(vty, "%% Expiry interval must be polling period or larger\n");
|
|
|
|
return CMD_WARNING_CONFIG_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_rpki_expire_interval,
|
|
|
|
no_rpki_expire_interval_cmd,
|
2022-05-02 18:36:22 +02:00
|
|
|
"no rpki expire_interval [(600-172800)]",
|
2017-11-10 13:56:24 +01:00
|
|
|
NO_STR
|
|
|
|
RPKI_OUTPUT_STRING
|
2022-05-02 18:36:22 +02:00
|
|
|
"Set expire interval back to default\n"
|
|
|
|
"Expire interval value\n")
|
2017-11-10 13:56:24 +01:00
|
|
|
{
|
|
|
|
expire_interval = polling_period * 2;
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFPY (rpki_retry_interval,
|
|
|
|
rpki_retry_interval_cmd,
|
|
|
|
"rpki retry_interval (1-7200)$tmp",
|
|
|
|
RPKI_OUTPUT_STRING
|
|
|
|
"Set retry interval\n"
|
|
|
|
"retry interval value\n")
|
|
|
|
{
|
|
|
|
retry_interval = tmp;
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_rpki_retry_interval,
|
|
|
|
no_rpki_retry_interval_cmd,
|
2022-05-02 18:36:22 +02:00
|
|
|
"no rpki retry_interval [(1-7200)]",
|
2017-11-10 13:56:24 +01:00
|
|
|
NO_STR
|
|
|
|
RPKI_OUTPUT_STRING
|
2022-05-02 18:36:22 +02:00
|
|
|
"Set retry interval back to default\n"
|
|
|
|
"retry interval value\n")
|
2017-11-10 13:56:24 +01:00
|
|
|
{
|
|
|
|
retry_interval = RETRY_INTERVAL_DEFAULT;
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2021-09-02 17:12:06 +02:00
|
|
|
DEFPY(rpki_cache, rpki_cache_cmd,
|
2022-06-20 21:22:07 +02:00
|
|
|
"rpki cache <A.B.C.D|WORD> <TCPPORT|(1-65535)$sshport SSH_UNAME SSH_PRIVKEY [SERVER_PUBKEY]> [source <A.B.C.D>$bindaddr] preference (1-255)",
|
2021-09-02 17:12:06 +02:00
|
|
|
RPKI_OUTPUT_STRING
|
|
|
|
"Install a cache server to current group\n"
|
2022-06-20 21:22:07 +02:00
|
|
|
"IP address of cache server\n"
|
|
|
|
"Hostname of cache server\n"
|
2021-09-02 17:12:06 +02:00
|
|
|
"TCP port number\n"
|
|
|
|
"SSH port number\n"
|
|
|
|
"SSH user name\n"
|
|
|
|
"Path to own SSH private key\n"
|
|
|
|
"Path to Public key of cache server\n"
|
2021-09-07 21:24:57 +02:00
|
|
|
"Configure source IP address of RPKI connection\n"
|
|
|
|
"Define a Source IP Address\n"
|
2021-09-02 17:12:06 +02:00
|
|
|
"Preference of the cache server\n"
|
|
|
|
"Preference value\n")
|
2017-11-10 13:56:24 +01:00
|
|
|
{
|
2018-07-07 22:34:25 +02:00
|
|
|
int return_value;
|
2019-08-22 15:48:05 +02:00
|
|
|
struct listnode *cache_node;
|
|
|
|
struct cache *current_cache;
|
|
|
|
|
|
|
|
for (ALL_LIST_ELEMENTS_RO(cache_list, cache_node, current_cache)) {
|
|
|
|
if (current_cache->preference == preference) {
|
|
|
|
vty_out(vty,
|
|
|
|
"Cache with preference %ld is already configured\n",
|
|
|
|
preference);
|
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-10 13:56:24 +01:00
|
|
|
|
|
|
|
// use ssh connection
|
|
|
|
if (ssh_uname) {
|
|
|
|
#if defined(FOUND_SSH)
|
2022-06-20 21:22:07 +02:00
|
|
|
return_value =
|
|
|
|
add_ssh_cache(cache, sshport, ssh_uname, ssh_privkey,
|
|
|
|
server_pubkey, preference, bindaddr_str);
|
2017-11-10 13:56:24 +01:00
|
|
|
#else
|
2018-07-07 22:34:25 +02:00
|
|
|
return_value = SUCCESS;
|
2017-11-10 13:56:24 +01:00
|
|
|
vty_out(vty,
|
2020-03-27 12:35:23 +01:00
|
|
|
"ssh sockets are not supported. Please recompile rtrlib and frr with ssh support. If you want to use it\n");
|
2017-11-10 13:56:24 +01:00
|
|
|
#endif
|
|
|
|
} else { // use tcp connection
|
2021-09-02 17:12:06 +02:00
|
|
|
return_value =
|
|
|
|
add_tcp_cache(cache, tcpport, preference, bindaddr_str);
|
2017-11-10 13:56:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (return_value == ERROR) {
|
|
|
|
vty_out(vty, "Could not create new rpki cache\n");
|
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFPY (no_rpki_cache,
|
|
|
|
no_rpki_cache_cmd,
|
2022-06-20 21:22:07 +02:00
|
|
|
"no rpki cache <A.B.C.D|WORD> <TCPPORT|(1-65535)$sshport SSH_UNAME SSH_PRIVKEY [SERVER_PUBKEY]> [source <A.B.C.D>$bindaddr] preference (1-255)",
|
2017-11-10 13:56:24 +01:00
|
|
|
NO_STR
|
|
|
|
RPKI_OUTPUT_STRING
|
2022-06-20 20:01:14 +02:00
|
|
|
"Install a cache server to current group\n"
|
2022-06-20 21:22:07 +02:00
|
|
|
"IP address of cache server\n"
|
|
|
|
"Hostname of cache server\n"
|
2017-11-10 13:56:24 +01:00
|
|
|
"TCP port number\n"
|
|
|
|
"SSH port number\n"
|
2022-06-20 20:01:14 +02:00
|
|
|
"SSH user name\n"
|
|
|
|
"Path to own SSH private key\n"
|
|
|
|
"Path to Public key of cache server\n"
|
|
|
|
"Configure source IP address of RPKI connection\n"
|
|
|
|
"Define a Source IP Address\n"
|
2017-11-10 13:56:24 +01:00
|
|
|
"Preference of the cache server\n"
|
|
|
|
"Preference value\n")
|
|
|
|
{
|
|
|
|
struct cache *cache_p = find_cache(preference);
|
|
|
|
|
2019-02-07 17:16:19 +01:00
|
|
|
if (!cache_p) {
|
2022-06-20 21:41:20 +02:00
|
|
|
vty_out(vty, "Could not find cache with preference %ld\n",
|
|
|
|
preference);
|
2017-11-10 13:56:24 +01:00
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
|
2022-04-05 13:10:16 +02:00
|
|
|
if (is_running() && listcount(cache_list) == 1) {
|
2019-08-22 16:55:04 +02:00
|
|
|
stop();
|
2022-04-05 13:10:16 +02:00
|
|
|
} else if (is_running()) {
|
2017-11-10 13:56:24 +01:00
|
|
|
if (rtr_mgr_remove_group(rtr_config, preference) == RTR_ERROR) {
|
2022-06-20 21:41:20 +02:00
|
|
|
vty_out(vty,
|
|
|
|
"Could not remove cache with preference %ld\n",
|
|
|
|
preference);
|
2017-11-10 13:56:24 +01:00
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
listnode_delete(cache_list, cache_p);
|
|
|
|
free_cache(cache_p);
|
|
|
|
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
DEFPY (show_rpki_prefix_table,
|
2017-11-10 13:56:24 +01:00
|
|
|
show_rpki_prefix_table_cmd,
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
"show rpki prefix-table [json$uj]",
|
2017-11-10 13:56:24 +01:00
|
|
|
SHOW_STR
|
|
|
|
RPKI_OUTPUT_STRING
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
"Show validated prefixes which were received from RPKI Cache\n"
|
|
|
|
JSON_STR)
|
2017-11-10 13:56:24 +01:00
|
|
|
{
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
struct json_object *json = NULL;
|
|
|
|
|
|
|
|
if (!is_synchronized()) {
|
|
|
|
if (!uj)
|
|
|
|
vty_out(vty, "No connection to RPKI cache server.\n");
|
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (uj)
|
|
|
|
json = json_object_new_object();
|
2017-11-10 13:56:24 +01:00
|
|
|
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
print_prefix_table(vty, json);
|
2017-11-10 13:56:24 +01:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
DEFPY (show_rpki_as_number,
|
|
|
|
show_rpki_as_number_cmd,
|
2022-11-25 17:51:33 +01:00
|
|
|
"show rpki as-number ASNUM$by_asn [json$uj]",
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
SHOW_STR
|
|
|
|
RPKI_OUTPUT_STRING
|
|
|
|
"Lookup by ASN in prefix table\n"
|
|
|
|
"AS Number\n"
|
|
|
|
JSON_STR)
|
2020-02-20 16:37:37 +01:00
|
|
|
{
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
struct json_object *json = NULL;
|
2022-11-25 17:51:33 +01:00
|
|
|
as_t as;
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
|
2020-02-20 16:37:37 +01:00
|
|
|
if (!is_synchronized()) {
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
if (!uj)
|
|
|
|
vty_out(vty, "No Connection to RPKI cache server.\n");
|
2020-02-20 16:37:37 +01:00
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
2022-11-25 17:51:33 +01:00
|
|
|
if (!asn_str2asn(by_asn, &as)) {
|
|
|
|
if (!uj)
|
|
|
|
vty_out(vty, "Invalid AS value: %s.\n", by_asn);
|
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
if (uj)
|
|
|
|
json = json_object_new_object();
|
|
|
|
|
2022-11-25 17:51:33 +01:00
|
|
|
print_prefix_table_by_asn(vty, as, json);
|
2020-02-20 16:37:37 +01:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2019-03-23 11:57:09 +01:00
|
|
|
DEFPY (show_rpki_prefix,
|
|
|
|
show_rpki_prefix_cmd,
|
2022-11-25 17:51:33 +01:00
|
|
|
"show rpki prefix <A.B.C.D/M|X:X::X:X/M> [ASNUM$asn] [json$uj]",
|
2019-03-23 11:57:09 +01:00
|
|
|
SHOW_STR
|
|
|
|
RPKI_OUTPUT_STRING
|
|
|
|
"Lookup IP prefix and optionally ASN in prefix table\n"
|
|
|
|
"IPv4 prefix\n"
|
|
|
|
"IPv6 prefix\n"
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
"AS Number\n"
|
|
|
|
JSON_STR)
|
2019-03-23 11:57:09 +01:00
|
|
|
{
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
json_object *json = NULL;
|
|
|
|
json_object *json_records = NULL;
|
2022-11-25 17:51:33 +01:00
|
|
|
as_t as;
|
|
|
|
enum asnotation_mode asnotation;
|
2019-03-23 11:57:09 +01:00
|
|
|
|
|
|
|
if (!is_synchronized()) {
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
if (!uj)
|
|
|
|
vty_out(vty, "No Connection to RPKI cache server.\n");
|
2019-03-23 11:57:09 +01:00
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct lrtr_ip_addr addr;
|
|
|
|
char addr_str[INET6_ADDRSTRLEN];
|
|
|
|
size_t addr_len = strchr(prefix_str, '/') - prefix_str;
|
|
|
|
|
|
|
|
memset(addr_str, 0, sizeof(addr_str));
|
|
|
|
memcpy(addr_str, prefix_str, addr_len);
|
|
|
|
|
|
|
|
if (lrtr_ip_str_to_addr(addr_str, &addr) != 0) {
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
if (!json)
|
|
|
|
vty_out(vty, "Invalid IP prefix\n");
|
2019-03-23 11:57:09 +01:00
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
|
2022-11-25 17:51:33 +01:00
|
|
|
if (asn && !asn_str2asn(asn, &as)) {
|
|
|
|
if (!uj)
|
|
|
|
vty_out(vty, "Invalid AS value: %s.\n", asn);
|
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
|
2019-03-23 11:57:09 +01:00
|
|
|
struct pfx_record *matches = NULL;
|
|
|
|
unsigned int match_count = 0;
|
|
|
|
enum pfxv_state result;
|
|
|
|
|
|
|
|
if (pfx_table_validate_r(rtr_config->pfx_table, &matches, &match_count,
|
2022-11-25 17:51:33 +01:00
|
|
|
as, &addr, prefix->prefixlen,
|
|
|
|
&result) != PFX_SUCCESS) {
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
if (!json)
|
|
|
|
vty_out(vty, "Prefix lookup failed\n");
|
2019-03-23 11:57:09 +01:00
|
|
|
return CMD_WARNING;
|
|
|
|
}
|
|
|
|
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
if (uj)
|
|
|
|
json = json_object_new_object();
|
|
|
|
|
|
|
|
if (!json) {
|
|
|
|
vty_out(vty, "%-40s %s %s\n", "Prefix", "Prefix Length",
|
|
|
|
"Origin-AS");
|
|
|
|
} else {
|
|
|
|
json_records = json_object_new_array();
|
|
|
|
json_object_object_add(json, "prefixes", json_records);
|
|
|
|
}
|
|
|
|
|
2022-11-25 17:51:33 +01:00
|
|
|
asnotation = bgp_get_asnotation(bgp_lookup_by_vrf_id(VRF_DEFAULT));
|
2019-03-23 11:57:09 +01:00
|
|
|
for (size_t i = 0; i < match_count; ++i) {
|
|
|
|
const struct pfx_record *record = &matches[i];
|
|
|
|
|
2022-11-25 17:51:33 +01:00
|
|
|
if (record->max_len >= prefix->prefixlen &&
|
|
|
|
((as != 0 && (uint32_t)as == record->asn) || as == 0)) {
|
|
|
|
print_record(&matches[i], vty, json_records,
|
|
|
|
asnotation);
|
2019-03-23 11:57:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
bgpd: Add JSON output for `show rpki prefix` and other show commands
```
spine1-debian-11# sh rpki prefix 192.168.100.1/32
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
spine1-debian-11# sh rpki prefix 192.168.100.1/32 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
}
]
}
```
```
spine1-debian-11# sh rpki as-number 47583 json
{
"prefixes":[
{
"prefix":"192.168.100.1",
"prefixLenMin":32,
"prefixLenMax":32,
"asn":47583
},
{
"prefix":"2606:4700:7000::",
"prefixLenMin":48,
"prefixLenMax":48,
"asn":47583
}
],
"ipv4PrefixCount":1,
"ipv6PrefixCount":1
}
spine1-debian-11# sh rpki as-number 47583
RPKI/RTR prefix table
Prefix Prefix Length Origin-AS
192.168.100.1 32 - 32 47583
2606:4700:7000:: 48 - 48 47583
Number of IPv4 Prefixes: 1
Number of IPv6 Prefixes: 1
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-30 08:05:34 +02:00
|
|
|
if (json)
|
|
|
|
vty_json(vty, json);
|
|
|
|
|
2019-03-23 11:57:09 +01:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2022-05-24 14:43:47 +02:00
|
|
|
DEFPY (show_rpki_cache_server,
|
2017-11-10 13:56:24 +01:00
|
|
|
show_rpki_cache_server_cmd,
|
2022-05-24 14:43:47 +02:00
|
|
|
"show rpki cache-server [json$uj]",
|
2017-11-10 13:56:24 +01:00
|
|
|
SHOW_STR
|
|
|
|
RPKI_OUTPUT_STRING
|
2022-05-24 14:43:47 +02:00
|
|
|
"Show configured cache server\n"
|
|
|
|
JSON_STR)
|
2017-11-10 13:56:24 +01:00
|
|
|
{
|
2022-05-24 14:43:47 +02:00
|
|
|
struct json_object *json = NULL;
|
|
|
|
struct json_object *json_server = NULL;
|
|
|
|
struct json_object *json_servers = NULL;
|
2017-11-10 13:56:24 +01:00
|
|
|
struct listnode *cache_node;
|
|
|
|
struct cache *cache;
|
|
|
|
|
2022-05-24 14:43:47 +02:00
|
|
|
if (uj) {
|
|
|
|
json = json_object_new_object();
|
|
|
|
json_servers = json_object_new_array();
|
|
|
|
json_object_object_add(json, "servers", json_servers);
|
|
|
|
}
|
|
|
|
|
2017-11-10 13:56:24 +01:00
|
|
|
for (ALL_LIST_ELEMENTS_RO(cache_list, cache_node, cache)) {
|
2019-02-07 17:12:16 +01:00
|
|
|
if (cache->type == TCP) {
|
2022-05-24 14:43:47 +02:00
|
|
|
if (!json) {
|
2022-06-20 21:49:32 +02:00
|
|
|
vty_out(vty,
|
|
|
|
"host: %s port: %s, preference: %hhu\n",
|
2022-05-24 14:43:47 +02:00
|
|
|
cache->tr_config.tcp_config->host,
|
2022-06-20 21:49:32 +02:00
|
|
|
cache->tr_config.tcp_config->port,
|
|
|
|
cache->preference);
|
2022-05-24 14:43:47 +02:00
|
|
|
} else {
|
|
|
|
json_server = json_object_new_object();
|
|
|
|
json_object_string_add(json_server, "mode",
|
|
|
|
"tcp");
|
|
|
|
json_object_string_add(
|
|
|
|
json_server, "host",
|
|
|
|
cache->tr_config.tcp_config->host);
|
|
|
|
json_object_string_add(
|
|
|
|
json_server, "port",
|
|
|
|
cache->tr_config.tcp_config->port);
|
2022-06-20 21:49:32 +02:00
|
|
|
json_object_int_add(json_server, "preference",
|
|
|
|
cache->preference);
|
2022-05-24 14:43:47 +02:00
|
|
|
json_object_array_add(json_servers,
|
|
|
|
json_server);
|
|
|
|
}
|
2019-02-07 17:12:16 +01:00
|
|
|
|
2019-05-07 17:00:30 +02:00
|
|
|
#if defined(FOUND_SSH)
|
2019-02-07 17:12:16 +01:00
|
|
|
} else if (cache->type == SSH) {
|
2022-05-24 14:43:47 +02:00
|
|
|
if (!json) {
|
|
|
|
vty_out(vty,
|
2022-06-20 21:49:32 +02:00
|
|
|
"host: %s port: %d username: %s server_hostkey_path: %s client_privkey_path: %s, preference: %hhu\n",
|
2022-05-24 14:43:47 +02:00
|
|
|
cache->tr_config.ssh_config->host,
|
|
|
|
cache->tr_config.ssh_config->port,
|
|
|
|
cache->tr_config.ssh_config->username,
|
|
|
|
cache->tr_config.ssh_config
|
|
|
|
->server_hostkey_path,
|
|
|
|
cache->tr_config.ssh_config
|
2022-06-20 21:49:32 +02:00
|
|
|
->client_privkey_path,
|
|
|
|
cache->preference);
|
2022-05-24 14:43:47 +02:00
|
|
|
} else {
|
|
|
|
json_server = json_object_new_object();
|
|
|
|
json_object_string_add(json_server, "mode",
|
|
|
|
"ssh");
|
|
|
|
json_object_string_add(
|
|
|
|
json_server, "host",
|
|
|
|
cache->tr_config.ssh_config->host);
|
|
|
|
json_object_int_add(
|
|
|
|
json_server, "port",
|
|
|
|
cache->tr_config.ssh_config->port);
|
|
|
|
json_object_string_add(
|
|
|
|
json_server, "username",
|
|
|
|
cache->tr_config.ssh_config->username);
|
|
|
|
json_object_string_add(
|
|
|
|
json_server, "serverHostkeyPath",
|
|
|
|
cache->tr_config.ssh_config
|
|
|
|
->server_hostkey_path);
|
|
|
|
json_object_string_add(
|
|
|
|
json_server, "clientPrivkeyPath",
|
|
|
|
cache->tr_config.ssh_config
|
|
|
|
->client_privkey_path);
|
2022-06-20 21:49:32 +02:00
|
|
|
json_object_int_add(json_server, "preference",
|
|
|
|
cache->preference);
|
2022-05-24 14:43:47 +02:00
|
|
|
json_object_array_add(json_servers,
|
|
|
|
json_server);
|
|
|
|
}
|
2019-05-07 17:00:30 +02:00
|
|
|
#endif
|
2019-02-07 17:12:16 +01:00
|
|
|
}
|
2017-11-10 13:56:24 +01:00
|
|
|
}
|
|
|
|
|
2022-05-24 14:43:47 +02:00
|
|
|
if (json)
|
|
|
|
vty_json(vty, json);
|
|
|
|
|
2017-11-10 13:56:24 +01:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
bgpd: Add JSON output for `show rpki cache-connection`
```
spine1-debian-11# sh rpki cache-connection
Connected to group 1
rpki tcp cache 192.168.10.17 8283 pref 1 (connected)
rpki tcp cache 192.168.10.17 8282 pref 2
spine1-debian-11# sh rpki cache-connection json
{
"connectedGroup":1,
"connections":[
{
"mode":"tcp",
"host":"192.168.10.17",
"port":"8283",
"preference":1,
"state":"connected"
},
{
"mode":"tcp",
"host":"192.168.10.17",
"port":"8282",
"preference":2,
"state":"disconnected"
}
]
}
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-23 18:40:45 +02:00
|
|
|
DEFPY (show_rpki_cache_connection,
|
2017-11-10 13:56:24 +01:00
|
|
|
show_rpki_cache_connection_cmd,
|
bgpd: Add JSON output for `show rpki cache-connection`
```
spine1-debian-11# sh rpki cache-connection
Connected to group 1
rpki tcp cache 192.168.10.17 8283 pref 1 (connected)
rpki tcp cache 192.168.10.17 8282 pref 2
spine1-debian-11# sh rpki cache-connection json
{
"connectedGroup":1,
"connections":[
{
"mode":"tcp",
"host":"192.168.10.17",
"port":"8283",
"preference":1,
"state":"connected"
},
{
"mode":"tcp",
"host":"192.168.10.17",
"port":"8282",
"preference":2,
"state":"disconnected"
}
]
}
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-23 18:40:45 +02:00
|
|
|
"show rpki cache-connection [json$uj]",
|
2017-11-10 13:56:24 +01:00
|
|
|
SHOW_STR
|
|
|
|
RPKI_OUTPUT_STRING
|
bgpd: Add JSON output for `show rpki cache-connection`
```
spine1-debian-11# sh rpki cache-connection
Connected to group 1
rpki tcp cache 192.168.10.17 8283 pref 1 (connected)
rpki tcp cache 192.168.10.17 8282 pref 2
spine1-debian-11# sh rpki cache-connection json
{
"connectedGroup":1,
"connections":[
{
"mode":"tcp",
"host":"192.168.10.17",
"port":"8283",
"preference":1,
"state":"connected"
},
{
"mode":"tcp",
"host":"192.168.10.17",
"port":"8282",
"preference":2,
"state":"disconnected"
}
]
}
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-23 18:40:45 +02:00
|
|
|
"Show to which RPKI Cache Servers we have a connection\n"
|
|
|
|
JSON_STR)
|
2017-11-10 13:56:24 +01:00
|
|
|
{
|
bgpd: Add JSON output for `show rpki cache-connection`
```
spine1-debian-11# sh rpki cache-connection
Connected to group 1
rpki tcp cache 192.168.10.17 8283 pref 1 (connected)
rpki tcp cache 192.168.10.17 8282 pref 2
spine1-debian-11# sh rpki cache-connection json
{
"connectedGroup":1,
"connections":[
{
"mode":"tcp",
"host":"192.168.10.17",
"port":"8283",
"preference":1,
"state":"connected"
},
{
"mode":"tcp",
"host":"192.168.10.17",
"port":"8282",
"preference":2,
"state":"disconnected"
}
]
}
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-23 18:40:45 +02:00
|
|
|
struct json_object *json = NULL;
|
|
|
|
struct json_object *json_conn = NULL;
|
|
|
|
struct json_object *json_conns = NULL;
|
|
|
|
struct listnode *cache_node;
|
|
|
|
struct cache *cache;
|
|
|
|
struct rtr_mgr_group *group;
|
|
|
|
|
|
|
|
if (uj)
|
|
|
|
json = json_object_new_object();
|
|
|
|
|
2020-11-20 14:44:25 +01:00
|
|
|
if (!is_synchronized()) {
|
bgpd: Add JSON output for `show rpki cache-connection`
```
spine1-debian-11# sh rpki cache-connection
Connected to group 1
rpki tcp cache 192.168.10.17 8283 pref 1 (connected)
rpki tcp cache 192.168.10.17 8282 pref 2
spine1-debian-11# sh rpki cache-connection json
{
"connectedGroup":1,
"connections":[
{
"mode":"tcp",
"host":"192.168.10.17",
"port":"8283",
"preference":1,
"state":"connected"
},
{
"mode":"tcp",
"host":"192.168.10.17",
"port":"8282",
"preference":2,
"state":"disconnected"
}
]
}
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-23 18:40:45 +02:00
|
|
|
if (!json)
|
|
|
|
vty_out(vty, "No connection to RPKI cache server.\n");
|
|
|
|
else
|
|
|
|
vty_json(vty, json);
|
2020-11-20 14:44:25 +01:00
|
|
|
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
bgpd: Add JSON output for `show rpki cache-connection`
```
spine1-debian-11# sh rpki cache-connection
Connected to group 1
rpki tcp cache 192.168.10.17 8283 pref 1 (connected)
rpki tcp cache 192.168.10.17 8282 pref 2
spine1-debian-11# sh rpki cache-connection json
{
"connectedGroup":1,
"connections":[
{
"mode":"tcp",
"host":"192.168.10.17",
"port":"8283",
"preference":1,
"state":"connected"
},
{
"mode":"tcp",
"host":"192.168.10.17",
"port":"8282",
"preference":2,
"state":"disconnected"
}
]
}
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-23 18:40:45 +02:00
|
|
|
group = get_connected_group();
|
2020-11-20 14:44:25 +01:00
|
|
|
if (!group) {
|
bgpd: Add JSON output for `show rpki cache-connection`
```
spine1-debian-11# sh rpki cache-connection
Connected to group 1
rpki tcp cache 192.168.10.17 8283 pref 1 (connected)
rpki tcp cache 192.168.10.17 8282 pref 2
spine1-debian-11# sh rpki cache-connection json
{
"connectedGroup":1,
"connections":[
{
"mode":"tcp",
"host":"192.168.10.17",
"port":"8283",
"preference":1,
"state":"connected"
},
{
"mode":"tcp",
"host":"192.168.10.17",
"port":"8282",
"preference":2,
"state":"disconnected"
}
]
}
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-23 18:40:45 +02:00
|
|
|
if (!json)
|
|
|
|
vty_out(vty, "Cannot find a connected group.\n");
|
|
|
|
else
|
|
|
|
vty_json(vty, json);
|
|
|
|
|
2020-11-20 14:44:25 +01:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
bgpd: Add JSON output for `show rpki cache-connection`
```
spine1-debian-11# sh rpki cache-connection
Connected to group 1
rpki tcp cache 192.168.10.17 8283 pref 1 (connected)
rpki tcp cache 192.168.10.17 8282 pref 2
spine1-debian-11# sh rpki cache-connection json
{
"connectedGroup":1,
"connections":[
{
"mode":"tcp",
"host":"192.168.10.17",
"port":"8283",
"preference":1,
"state":"connected"
},
{
"mode":"tcp",
"host":"192.168.10.17",
"port":"8282",
"preference":2,
"state":"disconnected"
}
]
}
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-23 18:40:45 +02:00
|
|
|
|
|
|
|
if (!json) {
|
|
|
|
vty_out(vty, "Connected to group %d\n", group->preference);
|
|
|
|
} else {
|
|
|
|
json_conns = json_object_new_array();
|
|
|
|
json_object_int_add(json, "connectedGroup", group->preference);
|
|
|
|
json_object_object_add(json, "connections", json_conns);
|
|
|
|
}
|
|
|
|
|
2020-11-20 14:44:25 +01:00
|
|
|
for (ALL_LIST_ELEMENTS_RO(cache_list, cache_node, cache)) {
|
2022-05-03 16:47:10 +02:00
|
|
|
struct tr_tcp_config *tcp_config;
|
2017-11-13 15:50:50 +01:00
|
|
|
#if defined(FOUND_SSH)
|
2022-05-03 16:47:10 +02:00
|
|
|
struct tr_ssh_config *ssh_config;
|
2017-11-13 15:50:50 +01:00
|
|
|
#endif
|
2022-05-03 16:47:10 +02:00
|
|
|
switch (cache->type) {
|
|
|
|
case TCP:
|
|
|
|
tcp_config = cache->tr_config.tcp_config;
|
bgpd: Add JSON output for `show rpki cache-connection`
```
spine1-debian-11# sh rpki cache-connection
Connected to group 1
rpki tcp cache 192.168.10.17 8283 pref 1 (connected)
rpki tcp cache 192.168.10.17 8282 pref 2
spine1-debian-11# sh rpki cache-connection json
{
"connectedGroup":1,
"connections":[
{
"mode":"tcp",
"host":"192.168.10.17",
"port":"8283",
"preference":1,
"state":"connected"
},
{
"mode":"tcp",
"host":"192.168.10.17",
"port":"8282",
"preference":2,
"state":"disconnected"
}
]
}
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-23 18:40:45 +02:00
|
|
|
|
|
|
|
if (!json) {
|
|
|
|
vty_out(vty,
|
|
|
|
"rpki tcp cache %s %s pref %hhu%s\n",
|
|
|
|
tcp_config->host, tcp_config->port,
|
|
|
|
cache->preference,
|
|
|
|
cache->rtr_socket->state ==
|
|
|
|
RTR_ESTABLISHED
|
|
|
|
? " (connected)"
|
|
|
|
: "");
|
|
|
|
} else {
|
|
|
|
json_conn = json_object_new_object();
|
|
|
|
json_object_string_add(json_conn, "mode",
|
|
|
|
"tcp");
|
|
|
|
json_object_string_add(json_conn, "host",
|
|
|
|
tcp_config->host);
|
|
|
|
json_object_string_add(json_conn, "port",
|
|
|
|
tcp_config->port);
|
|
|
|
json_object_int_add(json_conn, "preference",
|
|
|
|
cache->preference);
|
|
|
|
json_object_string_add(
|
|
|
|
json_conn, "state",
|
|
|
|
cache->rtr_socket->state ==
|
|
|
|
RTR_ESTABLISHED
|
|
|
|
? "connected"
|
|
|
|
: "disconnected");
|
|
|
|
json_object_array_add(json_conns, json_conn);
|
|
|
|
}
|
2022-05-03 16:47:10 +02:00
|
|
|
break;
|
2017-11-10 13:56:24 +01:00
|
|
|
#if defined(FOUND_SSH)
|
2022-05-03 16:47:10 +02:00
|
|
|
case SSH:
|
|
|
|
ssh_config = cache->tr_config.ssh_config;
|
bgpd: Add JSON output for `show rpki cache-connection`
```
spine1-debian-11# sh rpki cache-connection
Connected to group 1
rpki tcp cache 192.168.10.17 8283 pref 1 (connected)
rpki tcp cache 192.168.10.17 8282 pref 2
spine1-debian-11# sh rpki cache-connection json
{
"connectedGroup":1,
"connections":[
{
"mode":"tcp",
"host":"192.168.10.17",
"port":"8283",
"preference":1,
"state":"connected"
},
{
"mode":"tcp",
"host":"192.168.10.17",
"port":"8282",
"preference":2,
"state":"disconnected"
}
]
}
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-23 18:40:45 +02:00
|
|
|
|
|
|
|
if (!json) {
|
|
|
|
vty_out(vty,
|
|
|
|
"rpki ssh cache %s %u pref %hhu%s\n",
|
|
|
|
ssh_config->host, ssh_config->port,
|
|
|
|
cache->preference,
|
|
|
|
cache->rtr_socket->state ==
|
|
|
|
RTR_ESTABLISHED
|
|
|
|
? " (connected)"
|
|
|
|
: "");
|
|
|
|
} else {
|
|
|
|
json_conn = json_object_new_object();
|
|
|
|
json_object_string_add(json_conn, "mode",
|
|
|
|
"ssh");
|
|
|
|
json_object_string_add(json_conn, "host",
|
|
|
|
ssh_config->host);
|
2022-05-24 13:56:45 +02:00
|
|
|
json_object_int_add(json_conn, "port",
|
|
|
|
ssh_config->port);
|
bgpd: Add JSON output for `show rpki cache-connection`
```
spine1-debian-11# sh rpki cache-connection
Connected to group 1
rpki tcp cache 192.168.10.17 8283 pref 1 (connected)
rpki tcp cache 192.168.10.17 8282 pref 2
spine1-debian-11# sh rpki cache-connection json
{
"connectedGroup":1,
"connections":[
{
"mode":"tcp",
"host":"192.168.10.17",
"port":"8283",
"preference":1,
"state":"connected"
},
{
"mode":"tcp",
"host":"192.168.10.17",
"port":"8282",
"preference":2,
"state":"disconnected"
}
]
}
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-23 18:40:45 +02:00
|
|
|
json_object_int_add(json_conn, "preference",
|
|
|
|
cache->preference);
|
|
|
|
json_object_string_add(
|
|
|
|
json_conn, "state",
|
|
|
|
cache->rtr_socket->state ==
|
|
|
|
RTR_ESTABLISHED
|
|
|
|
? "connected"
|
|
|
|
: "disconnected");
|
|
|
|
json_object_array_add(json_conns, json_conn);
|
|
|
|
}
|
2022-05-03 16:47:10 +02:00
|
|
|
break;
|
2017-11-10 13:56:24 +01:00
|
|
|
#endif
|
2022-05-03 16:47:10 +02:00
|
|
|
default:
|
|
|
|
break;
|
2017-11-10 13:56:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
bgpd: Add JSON output for `show rpki cache-connection`
```
spine1-debian-11# sh rpki cache-connection
Connected to group 1
rpki tcp cache 192.168.10.17 8283 pref 1 (connected)
rpki tcp cache 192.168.10.17 8282 pref 2
spine1-debian-11# sh rpki cache-connection json
{
"connectedGroup":1,
"connections":[
{
"mode":"tcp",
"host":"192.168.10.17",
"port":"8283",
"preference":1,
"state":"connected"
},
{
"mode":"tcp",
"host":"192.168.10.17",
"port":"8282",
"preference":2,
"state":"disconnected"
}
]
}
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-23 18:40:45 +02:00
|
|
|
if (json)
|
|
|
|
vty_json(vty, json);
|
|
|
|
|
2017-11-10 13:56:24 +01:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2018-09-09 00:03:19 +02:00
|
|
|
static int config_on_exit(struct vty *vty)
|
2017-11-10 13:56:24 +01:00
|
|
|
{
|
2018-08-22 22:05:04 +02:00
|
|
|
reset(false);
|
2018-09-09 00:03:19 +02:00
|
|
|
return 1;
|
2017-11-10 13:56:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (rpki_reset,
|
|
|
|
rpki_reset_cmd,
|
|
|
|
"rpki reset",
|
|
|
|
RPKI_OUTPUT_STRING
|
|
|
|
"reset rpki\n")
|
|
|
|
{
|
|
|
|
return reset(true) == SUCCESS ? CMD_SUCCESS : CMD_WARNING;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (debug_rpki,
|
|
|
|
debug_rpki_cmd,
|
|
|
|
"debug rpki",
|
|
|
|
DEBUG_STR
|
2017-11-14 09:51:28 +01:00
|
|
|
"Enable debugging for rpki\n")
|
2017-11-10 13:56:24 +01:00
|
|
|
{
|
2022-05-03 14:35:22 +02:00
|
|
|
rpki_debug = true;
|
2017-11-10 13:56:24 +01:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_debug_rpki,
|
|
|
|
no_debug_rpki_cmd,
|
|
|
|
"no debug rpki",
|
|
|
|
NO_STR
|
|
|
|
DEBUG_STR
|
2017-11-14 09:51:28 +01:00
|
|
|
"Disable debugging for rpki\n")
|
2017-11-10 13:56:24 +01:00
|
|
|
{
|
2022-05-03 14:35:22 +02:00
|
|
|
rpki_debug = false;
|
2017-11-10 13:56:24 +01:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2020-10-30 08:45:43 +01:00
|
|
|
DEFUN_YANG (match_rpki,
|
2017-11-10 13:56:24 +01:00
|
|
|
match_rpki_cmd,
|
|
|
|
"match rpki <valid|invalid|notfound>",
|
|
|
|
MATCH_STR
|
|
|
|
RPKI_OUTPUT_STRING
|
|
|
|
"Valid prefix\n"
|
|
|
|
"Invalid prefix\n"
|
|
|
|
"Prefix not found\n")
|
|
|
|
{
|
2020-10-30 08:45:43 +01:00
|
|
|
const char *xpath =
|
|
|
|
"./match-condition[condition='frr-bgp-route-map:rpki']";
|
|
|
|
char xpath_value[XPATH_MAXLEN];
|
2020-02-14 21:32:40 +01:00
|
|
|
|
2020-10-30 08:45:43 +01:00
|
|
|
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
|
|
|
|
snprintf(xpath_value, sizeof(xpath_value),
|
|
|
|
"%s/rmap-match-condition/frr-bgp-route-map:rpki", xpath);
|
|
|
|
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, argv[2]->arg);
|
|
|
|
|
|
|
|
return nb_cli_apply_changes(vty, NULL);
|
2017-11-10 13:56:24 +01:00
|
|
|
}
|
|
|
|
|
2020-10-30 08:45:43 +01:00
|
|
|
DEFUN_YANG (no_match_rpki,
|
2017-11-10 13:56:24 +01:00
|
|
|
no_match_rpki_cmd,
|
|
|
|
"no match rpki <valid|invalid|notfound>",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
RPKI_OUTPUT_STRING
|
|
|
|
"Valid prefix\n"
|
|
|
|
"Invalid prefix\n"
|
|
|
|
"Prefix not found\n")
|
|
|
|
{
|
2020-10-30 08:45:43 +01:00
|
|
|
const char *xpath =
|
|
|
|
"./match-condition[condition='frr-bgp-route-map:rpki']";
|
2017-11-10 13:56:24 +01:00
|
|
|
|
2022-10-10 15:17:54 +02:00
|
|
|
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
|
2020-10-30 08:45:43 +01:00
|
|
|
return nb_cli_apply_changes(vty, NULL);
|
2017-11-10 13:56:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void install_cli_commands(void)
|
|
|
|
{
|
|
|
|
// TODO: make config write work
|
2018-09-08 22:31:43 +02:00
|
|
|
install_node(&rpki_node);
|
2017-11-10 13:56:24 +01:00
|
|
|
install_default(RPKI_NODE);
|
|
|
|
install_element(CONFIG_NODE, &rpki_cmd);
|
2019-04-03 22:47:44 +02:00
|
|
|
install_element(ENABLE_NODE, &rpki_cmd);
|
2022-06-20 19:31:18 +02:00
|
|
|
install_element(CONFIG_NODE, &no_rpki_cmd);
|
|
|
|
|
2017-11-10 13:56:24 +01:00
|
|
|
|
|
|
|
install_element(ENABLE_NODE, &bgp_rpki_start_cmd);
|
|
|
|
install_element(ENABLE_NODE, &bgp_rpki_stop_cmd);
|
|
|
|
|
|
|
|
/* Install rpki reset command */
|
2022-05-03 14:44:11 +02:00
|
|
|
install_element(ENABLE_NODE, &rpki_reset_cmd);
|
2017-11-10 13:56:24 +01:00
|
|
|
install_element(RPKI_NODE, &rpki_reset_cmd);
|
|
|
|
|
|
|
|
/* Install rpki polling period commands */
|
|
|
|
install_element(RPKI_NODE, &rpki_polling_period_cmd);
|
|
|
|
install_element(RPKI_NODE, &no_rpki_polling_period_cmd);
|
|
|
|
|
|
|
|
/* Install rpki expire interval commands */
|
|
|
|
install_element(RPKI_NODE, &rpki_expire_interval_cmd);
|
|
|
|
install_element(RPKI_NODE, &no_rpki_expire_interval_cmd);
|
|
|
|
|
|
|
|
/* Install rpki retry interval commands */
|
|
|
|
install_element(RPKI_NODE, &rpki_retry_interval_cmd);
|
|
|
|
install_element(RPKI_NODE, &no_rpki_retry_interval_cmd);
|
|
|
|
|
|
|
|
/* Install rpki cache commands */
|
|
|
|
install_element(RPKI_NODE, &rpki_cache_cmd);
|
|
|
|
install_element(RPKI_NODE, &no_rpki_cache_cmd);
|
|
|
|
|
|
|
|
/* Install show commands */
|
2019-04-03 22:47:44 +02:00
|
|
|
install_element(VIEW_NODE, &show_rpki_prefix_table_cmd);
|
|
|
|
install_element(VIEW_NODE, &show_rpki_cache_connection_cmd);
|
|
|
|
install_element(VIEW_NODE, &show_rpki_cache_server_cmd);
|
|
|
|
install_element(VIEW_NODE, &show_rpki_prefix_cmd);
|
2020-02-20 16:37:37 +01:00
|
|
|
install_element(VIEW_NODE, &show_rpki_as_number_cmd);
|
2017-11-10 13:56:24 +01:00
|
|
|
|
|
|
|
/* Install debug commands */
|
|
|
|
install_element(CONFIG_NODE, &debug_rpki_cmd);
|
|
|
|
install_element(ENABLE_NODE, &debug_rpki_cmd);
|
|
|
|
install_element(CONFIG_NODE, &no_debug_rpki_cmd);
|
|
|
|
install_element(ENABLE_NODE, &no_debug_rpki_cmd);
|
|
|
|
|
|
|
|
/* Install route match */
|
|
|
|
route_map_install_match(&route_match_rpki_cmd);
|
|
|
|
install_element(RMAP_NODE, &match_rpki_cmd);
|
|
|
|
install_element(RMAP_NODE, &no_match_rpki_cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
FRR_MODULE_SETUP(.name = "bgpd_rpki", .version = "0.3.6",
|
|
|
|
.description = "Enable RPKI support for FRR.",
|
|
|
|
.init = bgp_rpki_module_init,
|
2021-02-21 07:07:15 +01:00
|
|
|
);
|