mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-05 11:30:55 +00:00
bgpd: Convert RPKI states to an enum and use them
Convert the rpki states to an enum and use them in the code Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
parent
694df37daf
commit
fdeb5a8135
@ -71,6 +71,7 @@
|
||||
#include "bgpd/bgp_mac.h"
|
||||
#include "bgpd/bgp_network.h"
|
||||
#include "bgpd/bgp_trace.h"
|
||||
#include "bgpd/bgp_rpki.h"
|
||||
|
||||
#ifdef ENABLE_BGP_VNC
|
||||
#include "bgpd/rfapi/rfapi_backend.h"
|
||||
@ -7551,18 +7552,20 @@ static const char *bgp_origin2str(uint8_t origin)
|
||||
return "n/a";
|
||||
}
|
||||
|
||||
static const char *bgp_rpki_validation2str(int v_state)
|
||||
static const char *bgp_rpki_validation2str(enum rpki_states v_state)
|
||||
{
|
||||
switch (v_state) {
|
||||
case 1:
|
||||
case RPKI_NOT_BEING_USED:
|
||||
return "not used";
|
||||
case RPKI_VALID:
|
||||
return "valid";
|
||||
case 2:
|
||||
case RPKI_NOTFOUND:
|
||||
return "not found";
|
||||
case 3:
|
||||
case RPKI_INVALID:
|
||||
return "invalid";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
assert(!"We should never get here this is a dev escape");
|
||||
return "ERROR";
|
||||
}
|
||||
|
||||
@ -9582,7 +9585,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
|
||||
int i;
|
||||
char *nexthop_hostname =
|
||||
bgp_nexthop_hostname(path->peer, path->nexthop);
|
||||
int rpki_validation_state = 0;
|
||||
enum rpki_states rpki_validation_state = RPKI_NOT_BEING_USED;
|
||||
|
||||
if (json_paths) {
|
||||
json_path = json_object_new_object();
|
||||
@ -10190,10 +10193,11 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
|
||||
}
|
||||
|
||||
const struct prefix *p = bgp_dest_get_prefix(bn);
|
||||
|
||||
if (p->family == AF_INET || p->family == AF_INET6)
|
||||
rpki_validation_state = hook_call(bgp_rpki_prefix_status,
|
||||
path->peer, path->attr, p);
|
||||
if (rpki_validation_state) {
|
||||
if (rpki_validation_state != RPKI_NOT_BEING_USED) {
|
||||
if (json_paths)
|
||||
json_object_string_add(
|
||||
json_path, "rpkiValidationState",
|
||||
|
@ -47,6 +47,8 @@
|
||||
#include "bgpd/bgp_attr.h"
|
||||
#include "bgpd/bgp_aspath.h"
|
||||
#include "bgpd/bgp_route.h"
|
||||
#include "bgpd/bgp_rpki.h"
|
||||
|
||||
#include "lib/network.h"
|
||||
#include "lib/thread.h"
|
||||
#ifndef VTYSH_EXTRACT_PL
|
||||
@ -63,10 +65,6 @@
|
||||
DEFINE_MTYPE_STATIC(BGPD, BGP_RPKI_CACHE, "BGP RPKI Cache server");
|
||||
DEFINE_MTYPE_STATIC(BGPD, BGP_RPKI_CACHE_GROUP, "BGP RPKI Cache server group");
|
||||
|
||||
#define RPKI_VALID 1
|
||||
#define RPKI_NOTFOUND 2
|
||||
#define RPKI_INVALID 3
|
||||
|
||||
#define POLLING_PERIOD_DEFAULT 3600
|
||||
#define EXPIRE_INTERVAL_DEFAULT 7200
|
||||
#define RETRY_INTERVAL_DEFAULT 600
|
||||
|
33
bgpd/bgp_rpki.h
Normal file
33
bgpd/bgp_rpki.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* bgp_rpki code
|
||||
* Copyright (C) 2021 NVIDIA Corporation and Mellanox Technologies, LTD
|
||||
* All Rights Reserved
|
||||
* Donald Sharp
|
||||
*
|
||||
* This file is part of FRR.
|
||||
*
|
||||
* FRR is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* FRR is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; see the file COPYING; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#ifndef __BGP_RPKI_H__
|
||||
#define __BGP_RPKI_H__
|
||||
|
||||
enum rpki_states {
|
||||
RPKI_NOT_BEING_USED,
|
||||
RPKI_VALID,
|
||||
RPKI_NOTFOUND,
|
||||
RPKI_INVALID
|
||||
};
|
||||
|
||||
#endif
|
@ -176,6 +176,7 @@ noinst_HEADERS += \
|
||||
bgpd/bgp_pbr.h \
|
||||
bgpd/bgp_rd.h \
|
||||
bgpd/bgp_regex.h \
|
||||
bgpd/bgp_rpki.h \
|
||||
bgpd/bgp_route.h \
|
||||
bgpd/bgp_script.h \
|
||||
bgpd/bgp_table.h \
|
||||
|
Loading…
Reference in New Issue
Block a user