Skip to content

Commit

Permalink
staticd: Added afi-safi as a key in route-list
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
vishaldhingra committed Jul 16, 2020
1 parent 755100a commit 314825f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
4 changes: 2 additions & 2 deletions staticd/static_nb.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ int routing_control_plane_protocols_name_validate(
#define FRR_STATIC_ROUTE_INFO_KEY_XPATH \
"/frr-routing:routing/control-plane-protocols/" \
"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']"


Expand All @@ -150,7 +150,7 @@ int routing_control_plane_protocols_name_validate(
#define FRR_S_ROUTE_SRC_INFO_KEY_XPATH \
"/frr-routing:routing/control-plane-protocols/" \
"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']"

/* route-list/frr-nexthops */
Expand Down
27 changes: 17 additions & 10 deletions staticd/static_nb_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,11 +421,25 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_cr
struct route_node *rn;
const struct lyd_node *vrf_dnode;
struct prefix prefix;
const char *afi_safi;
afi_t prefix_afi;
afi_t afi;
safi_t safi = SAFI_UNICAST;
safi_t safi;

switch (args->event) {
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_ABORT:
break;
Expand All @@ -436,15 +450,8 @@ int routing_control_plane_protocols_control_plane_protocol_staticd_route_list_cr
s_vrf = vrf->info;

yang_dnode_get_prefix(&prefix, args->dnode, "./prefix");
afi = family2afi(prefix.family);

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;
}
afi_safi = yang_dnode_get_string(args->dnode, "./afi-safi");
yang_afi_safi_identity2value(afi_safi, &afi, &safi);

rn = static_add_route(afi, safi, &prefix, NULL, s_vrf);
if (!rn) {
Expand Down
4 changes: 4 additions & 0 deletions staticd/static_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,14 @@ static int static_route_leak(struct vty *vty, const char *svrf,
FRR_S_ROUTE_SRC_INFO_KEY_XPATH,
"frr-staticd:staticd", "staticd", svrf,
buf_prefix,
yang_afi_safi_value2identity(afi, safi),
buf_src_prefix, distance);
else
snprintf(xpath_prefix, sizeof(xpath_prefix),
FRR_STATIC_ROUTE_INFO_KEY_XPATH,
"frr-staticd:staticd", "staticd", svrf,
buf_prefix,
yang_afi_safi_value2identity(afi, safi),
distance);

nb_cli_enqueue_change(vty, xpath_prefix, NB_OP_CREATE, NULL);
Expand Down Expand Up @@ -288,13 +290,15 @@ static int static_route_leak(struct vty *vty, const char *svrf,
FRR_DEL_S_ROUTE_SRC_NH_KEY_XPATH,
"frr-staticd:staticd", "staticd", svrf,
buf_prefix,
yang_afi_safi_value2identity(afi, safi),
buf_src_prefix, distance, buf_nh_type, nh_svrf,
buf_gate_str, ifname);
else
snprintf(ab_xpath, sizeof(ab_xpath),
FRR_DEL_S_ROUTE_NH_KEY_XPATH,
"frr-staticd:staticd", "staticd", svrf,
buf_prefix,
yang_afi_safi_value2identity(afi, safi),
distance, buf_nh_type, nh_svrf, buf_gate_str,
ifname);

Expand Down
9 changes: 8 additions & 1 deletion yang/frr-staticd.yang
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,21 @@ module frr-staticd {
"Support for a 'staticd' pseudo-protocol instance
consists of a list of routes.";
list route-list {
key "prefix";
key "prefix afi-safi";
description
"List of staticd IP routes.";
leaf prefix {
type inet:ip-prefix;
description
"IP prefix.";
}
leaf afi-safi {
type identityref {
base frr-rt:afi-safi-type;
}
description
"AFI-SAFI type.";
}

uses staticd-prefix-attributes;

Expand Down

0 comments on commit 314825f

Please sign in to comment.