staticd: Added afi-safi as a key in route-list

To address the ip mroute command there is a need to add
safi as a key. So adding the afi-safi-type identityref
as a key.

Signed-off-by: VishalDhingra <vdhingra@vmware.com>
This commit is contained in:
vdhingra 2020-07-01 23:54:50 -07:00
parent 755100ac89
commit 314825ff91
4 changed files with 31 additions and 13 deletions

View File

@ -125,7 +125,7 @@ int routing_control_plane_protocols_name_validate(
#define FRR_STATIC_ROUTE_INFO_KEY_XPATH \ #define FRR_STATIC_ROUTE_INFO_KEY_XPATH \
"/frr-routing:routing/control-plane-protocols/" \ "/frr-routing:routing/control-plane-protocols/" \
"control-plane-protocol[type='%s'][name='%s'][vrf='%s']/" \ "control-plane-protocol[type='%s'][name='%s'][vrf='%s']/" \
"frr-staticd:staticd/route-list[prefix='%s']" \ "frr-staticd:staticd/route-list[prefix='%s'][afi-safi='%s']/" \
"path-list[distance='%u']" "path-list[distance='%u']"
@ -150,7 +150,7 @@ int routing_control_plane_protocols_name_validate(
#define FRR_S_ROUTE_SRC_INFO_KEY_XPATH \ #define FRR_S_ROUTE_SRC_INFO_KEY_XPATH \
"/frr-routing:routing/control-plane-protocols/" \ "/frr-routing:routing/control-plane-protocols/" \
"control-plane-protocol[type='%s'][name='%s'][vrf='%s']/" \ "control-plane-protocol[type='%s'][name='%s'][vrf='%s']/" \
"frr-staticd:staticd/route-list[prefix='%s']" \ "frr-staticd:staticd/route-list[prefix='%s'][afi-safi='%s']/" \
"src-list[src-prefix='%s']/path-list[distance='%u']" "src-list[src-prefix='%s']/path-list[distance='%u']"
/* route-list/frr-nexthops */ /* route-list/frr-nexthops */

View File

@ -421,11 +421,25 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_cr
struct route_node *rn; struct route_node *rn;
const struct lyd_node *vrf_dnode; const struct lyd_node *vrf_dnode;
struct prefix prefix; struct prefix prefix;
const char *afi_safi;
afi_t prefix_afi;
afi_t afi; afi_t afi;
safi_t safi = SAFI_UNICAST; safi_t safi;
switch (args->event) { switch (args->event) {
case NB_EV_VALIDATE: case NB_EV_VALIDATE:
yang_dnode_get_prefix(&prefix, args->dnode, "./prefix");
afi_safi = yang_dnode_get_string(args->dnode, "./afi-safi");
yang_afi_safi_identity2value(afi_safi, &afi, &safi);
prefix_afi = family2afi(prefix.family);
if (afi != prefix_afi) {
flog_warn(
EC_LIB_NB_CB_CONFIG_VALIDATE,
"route node %s creation failed",
yang_dnode_get_string(args->dnode, "./prefix"));
return NB_ERR_VALIDATION;
}
break;
case NB_EV_PREPARE: case NB_EV_PREPARE:
case NB_EV_ABORT: case NB_EV_ABORT:
break; break;
@ -436,15 +450,8 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_cr
s_vrf = vrf->info; s_vrf = vrf->info;
yang_dnode_get_prefix(&prefix, args->dnode, "./prefix"); yang_dnode_get_prefix(&prefix, args->dnode, "./prefix");
afi = family2afi(prefix.family); afi_safi = yang_dnode_get_string(args->dnode, "./afi-safi");
yang_afi_safi_identity2value(afi_safi, &afi, &safi);
if (afi == AFI_IP) {
if (IN_MULTICAST(ntohl(prefix.u.prefix4.s_addr)))
safi = SAFI_MULTICAST;
} else {
if (IN6_IS_ADDR_MULTICAST(&prefix.u.prefix6))
safi = SAFI_MULTICAST;
}
rn = static_add_route(afi, safi, &prefix, NULL, s_vrf); rn = static_add_route(afi, safi, &prefix, NULL, s_vrf);
if (!rn) { if (!rn) {

View File

@ -174,12 +174,14 @@ static int static_route_leak(struct vty *vty, const char *svrf,
FRR_S_ROUTE_SRC_INFO_KEY_XPATH, FRR_S_ROUTE_SRC_INFO_KEY_XPATH,
"frr-staticd:staticd", "staticd", svrf, "frr-staticd:staticd", "staticd", svrf,
buf_prefix, buf_prefix,
yang_afi_safi_value2identity(afi, safi),
buf_src_prefix, distance); buf_src_prefix, distance);
else else
snprintf(xpath_prefix, sizeof(xpath_prefix), snprintf(xpath_prefix, sizeof(xpath_prefix),
FRR_STATIC_ROUTE_INFO_KEY_XPATH, FRR_STATIC_ROUTE_INFO_KEY_XPATH,
"frr-staticd:staticd", "staticd", svrf, "frr-staticd:staticd", "staticd", svrf,
buf_prefix, buf_prefix,
yang_afi_safi_value2identity(afi, safi),
distance); distance);
nb_cli_enqueue_change(vty, xpath_prefix, NB_OP_CREATE, NULL); nb_cli_enqueue_change(vty, xpath_prefix, NB_OP_CREATE, NULL);
@ -288,6 +290,7 @@ static int static_route_leak(struct vty *vty, const char *svrf,
FRR_DEL_S_ROUTE_SRC_NH_KEY_XPATH, FRR_DEL_S_ROUTE_SRC_NH_KEY_XPATH,
"frr-staticd:staticd", "staticd", svrf, "frr-staticd:staticd", "staticd", svrf,
buf_prefix, buf_prefix,
yang_afi_safi_value2identity(afi, safi),
buf_src_prefix, distance, buf_nh_type, nh_svrf, buf_src_prefix, distance, buf_nh_type, nh_svrf,
buf_gate_str, ifname); buf_gate_str, ifname);
else else
@ -295,6 +298,7 @@ static int static_route_leak(struct vty *vty, const char *svrf,
FRR_DEL_S_ROUTE_NH_KEY_XPATH, FRR_DEL_S_ROUTE_NH_KEY_XPATH,
"frr-staticd:staticd", "staticd", svrf, "frr-staticd:staticd", "staticd", svrf,
buf_prefix, buf_prefix,
yang_afi_safi_value2identity(afi, safi),
distance, buf_nh_type, nh_svrf, buf_gate_str, distance, buf_nh_type, nh_svrf, buf_gate_str,
ifname); ifname);

View File

@ -99,7 +99,7 @@ module frr-staticd {
"Support for a 'staticd' pseudo-protocol instance "Support for a 'staticd' pseudo-protocol instance
consists of a list of routes."; consists of a list of routes.";
list route-list { list route-list {
key "prefix"; key "prefix afi-safi";
description description
"List of staticd IP routes."; "List of staticd IP routes.";
leaf prefix { leaf prefix {
@ -107,6 +107,13 @@ module frr-staticd {
description description
"IP prefix."; "IP prefix.";
} }
leaf afi-safi {
type identityref {
base frr-rt:afi-safi-type;
}
description
"AFI-SAFI type.";
}
uses staticd-prefix-attributes; uses staticd-prefix-attributes;