forked from Mirror/frr
zebra: Moving afi-safi identity to lib
afi-safi identity handling should be in the common place. Signed-off-by: VishalDhingra <vdhingra@vmware.com>
This commit is contained in:
parent
88fa5104a0
commit
755100ac89
|
@ -1191,3 +1191,38 @@ const char *yang_nexthop_type2str(uint32_t ntype)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const char *yang_afi_safi_value2identity(afi_t afi, safi_t safi)
|
||||
{
|
||||
if (afi == AFI_IP && safi == SAFI_UNICAST)
|
||||
return "frr-routing:ipv4-unicast";
|
||||
if (afi == AFI_IP6 && safi == SAFI_UNICAST)
|
||||
return "frr-routing:ipv6-unicast";
|
||||
if (afi == AFI_IP && safi == SAFI_MULTICAST)
|
||||
return "frr-routing:ipv4-multicast";
|
||||
if (afi == AFI_IP6 && safi == SAFI_MULTICAST)
|
||||
return "frr-routing:ipv6-multicast";
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void yang_afi_safi_identity2value(const char *key, afi_t *afi, safi_t *safi)
|
||||
{
|
||||
if (strmatch(key, "frr-routing:ipv4-unicast")) {
|
||||
*afi = AFI_IP;
|
||||
*safi = SAFI_UNICAST;
|
||||
} else if (strmatch(key, "frr-routing:ipv6-unicast")) {
|
||||
*afi = AFI_IP6;
|
||||
*safi = SAFI_UNICAST;
|
||||
} else if (strmatch(key, "frr-routing:ipv4-multicast")) {
|
||||
*afi = AFI_IP;
|
||||
*safi = SAFI_MULTICAST;
|
||||
} else if (strmatch(key, "frr-routing:ipv6-multicast")) {
|
||||
*afi = AFI_IP6;
|
||||
*safi = SAFI_MULTICAST;
|
||||
} else {
|
||||
*afi = AFI_UNSPEC;
|
||||
*safi = SAFI_UNSPEC;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -191,6 +191,9 @@ extern struct yang_data *yang_data_new_date_and_time(const char *xpath,
|
|||
/* nexthop enum2str */
|
||||
extern const char *yang_nexthop_type2str(uint32_t ntype);
|
||||
|
||||
const char *yang_afi_safi_value2identity(afi_t afi, safi_t safi);
|
||||
void yang_afi_safi_identity2value(const char *key, afi_t *afi, safi_t *safi);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -72,6 +72,35 @@ module frr-routing {
|
|||
"This identity represents an IPv6 address family.";
|
||||
}
|
||||
|
||||
identity afi-safi-type {
|
||||
description
|
||||
"Base identity type (AFI,SAFI) tuples for RIB";
|
||||
}
|
||||
|
||||
identity ipv4-unicast {
|
||||
base afi-safi-type;
|
||||
description
|
||||
"This identity represents the IPv4 unicast address family.";
|
||||
}
|
||||
|
||||
identity ipv6-unicast {
|
||||
base afi-safi-type;
|
||||
description
|
||||
"This identity represents the IPv6 unicast address family.";
|
||||
}
|
||||
|
||||
identity ipv4-multicast {
|
||||
base afi-safi-type;
|
||||
description
|
||||
"This identity represents the IPv4 multicast address family.";
|
||||
}
|
||||
|
||||
identity ipv6-multicast {
|
||||
base afi-safi-type;
|
||||
description
|
||||
"This identity represents the IPv6 multicast address family.";
|
||||
}
|
||||
|
||||
identity control-plane-protocol {
|
||||
description
|
||||
"Base identity from which control-plane protocol identities are
|
||||
|
|
|
@ -77,35 +77,6 @@ module frr-zebra {
|
|||
"Initial revision.";
|
||||
}
|
||||
|
||||
identity afi-safi-type {
|
||||
description
|
||||
"Base identity type (AFI,SAFI) tuples for RIB";
|
||||
}
|
||||
|
||||
identity ipv4-unicast {
|
||||
base afi-safi-type;
|
||||
description
|
||||
"This identity represents the IPv4 unicast address family.";
|
||||
}
|
||||
|
||||
identity ipv6-unicast {
|
||||
base afi-safi-type;
|
||||
description
|
||||
"This identity represents the IPv6 unicast address family.";
|
||||
}
|
||||
|
||||
identity ipv4-multicast {
|
||||
base afi-safi-type;
|
||||
description
|
||||
"This identity represents the IPv4 multicast address family.";
|
||||
}
|
||||
|
||||
identity ipv6-multicast {
|
||||
base afi-safi-type;
|
||||
description
|
||||
"This identity represents the IPv6 multicast address family.";
|
||||
}
|
||||
|
||||
typedef unix-timestamp {
|
||||
type uint32;
|
||||
units "seconds";
|
||||
|
@ -634,7 +605,7 @@ module frr-zebra {
|
|||
key "afi-safi-name table-id";
|
||||
leaf afi-safi-name {
|
||||
type identityref {
|
||||
base afi-safi-type;
|
||||
base frr-rt:afi-safi-type;
|
||||
}
|
||||
description
|
||||
"AFI, SAFI name.";
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "vrf.h"
|
||||
#include "libfrr.h"
|
||||
#include "routemap.h"
|
||||
#include "routing_nb.h"
|
||||
|
||||
#include "zebra/zebra_router.h"
|
||||
#include "zebra/zebra_errors.h"
|
||||
|
@ -258,6 +259,7 @@ static const struct frr_yang_module_info *const zebra_yang_modules[] = {
|
|||
&frr_route_map_info,
|
||||
&frr_zebra_info,
|
||||
&frr_vrf_info,
|
||||
&frr_routing_info,
|
||||
};
|
||||
|
||||
FRR_DAEMON_INFO(
|
||||
|
|
|
@ -22,40 +22,6 @@
|
|||
#include "libfrr.h"
|
||||
#include "zebra_nb.h"
|
||||
|
||||
const char *zebra_afi_safi_value2identity(afi_t afi, safi_t safi)
|
||||
{
|
||||
if (afi == AFI_IP && safi == SAFI_UNICAST)
|
||||
return "ipv4-unicast";
|
||||
if (afi == AFI_IP6 && safi == SAFI_UNICAST)
|
||||
return "ipv6-unicast";
|
||||
if (afi == AFI_IP && safi == SAFI_MULTICAST)
|
||||
return "ipv4-multicast";
|
||||
if (afi == AFI_IP6 && safi == SAFI_MULTICAST)
|
||||
return "ipv6-multicast";
|
||||
|
||||
return " ";
|
||||
}
|
||||
|
||||
void zebra_afi_safi_identity2value(const char *key, afi_t *afi, safi_t *safi)
|
||||
{
|
||||
if (strmatch(key, "frr-zebra:ipv4-unicast")) {
|
||||
*afi = AFI_IP;
|
||||
*safi = SAFI_UNICAST;
|
||||
} else if (strmatch(key, "frr-zebra:ipv6-unicast")) {
|
||||
*afi = AFI_IP6;
|
||||
*safi = SAFI_UNICAST;
|
||||
} else if (strmatch(key, "frr-zebra:ipv4-multicast")) {
|
||||
*afi = AFI_IP;
|
||||
*safi = SAFI_MULTICAST;
|
||||
} else if (strmatch(key, "frr-zebra:ipv6-multicast")) {
|
||||
*afi = AFI_IP6;
|
||||
*safi = SAFI_MULTICAST;
|
||||
} else {
|
||||
*afi = AFI_UNSPEC;
|
||||
*safi = SAFI_UNSPEC;
|
||||
}
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
const struct frr_yang_module_info frr_zebra_info = {
|
||||
.name = "frr-zebra",
|
||||
|
|
|
@ -26,10 +26,6 @@ extern "C" {
|
|||
|
||||
extern const struct frr_yang_module_info frr_zebra_info;
|
||||
|
||||
/* helper functions */
|
||||
const char *zebra_afi_safi_value2identity(afi_t afi, safi_t safi);
|
||||
void zebra_afi_safi_identity2value(const char *key, afi_t *afi, safi_t *safi);
|
||||
|
||||
/* prototypes */
|
||||
int get_route_information_rpc(struct nb_cb_rpc_args *args);
|
||||
int get_v6_mroute_info_rpc(struct nb_cb_rpc_args *args);
|
||||
|
|
|
@ -1242,7 +1242,7 @@ int lib_vrf_zebra_ribs_rib_create(struct nb_cb_create_args *args)
|
|||
table_id = zvrf->table_id;
|
||||
|
||||
afi_safi_name = yang_dnode_get_string(args->dnode, "./afi-safi-name");
|
||||
zebra_afi_safi_identity2value(afi_safi_name, &afi, &safi);
|
||||
yang_afi_safi_identity2value(afi_safi_name, &afi, &safi);
|
||||
|
||||
zrt = zebra_router_find_zrt(zvrf, table_id, afi, safi);
|
||||
|
||||
|
|
|
@ -185,9 +185,8 @@ int lib_vrf_zebra_ribs_rib_get_keys(struct nb_cb_get_keys_args *args)
|
|||
|
||||
args->keys->num = 2;
|
||||
|
||||
snprintfrr(args->keys->key[0], sizeof(args->keys->key[0]), "%s:%s",
|
||||
"frr-zebra",
|
||||
zebra_afi_safi_value2identity(zrt->afi, zrt->safi));
|
||||
snprintfrr(args->keys->key[0], sizeof(args->keys->key[0]), "%s",
|
||||
yang_afi_safi_value2identity(zrt->afi, zrt->safi));
|
||||
snprintfrr(args->keys->key[1], sizeof(args->keys->key[1]), "%u",
|
||||
zrt->tableid);
|
||||
|
||||
|
@ -205,7 +204,7 @@ lib_vrf_zebra_ribs_rib_lookup_entry(struct nb_cb_lookup_entry_args *args)
|
|||
|
||||
zvrf = zebra_vrf_lookup_by_id(vrf->vrf_id);
|
||||
|
||||
zebra_afi_safi_identity2value(args->keys->key[0], &afi, &safi);
|
||||
yang_afi_safi_identity2value(args->keys->key[0], &afi, &safi);
|
||||
table_id = yang_str2uint32(args->keys->key[1]);
|
||||
/* table_id 0 assume vrf's table_id. */
|
||||
if (!table_id)
|
||||
|
|
Loading…
Reference in a new issue