diff options
-rw-r--r-- | staticd/static_nb.h | 4 | ||||
-rw-r--r-- | staticd/static_nb_config.c | 27 | ||||
-rw-r--r-- | staticd/static_vty.c | 4 | ||||
-rw-r--r-- | yang/frr-staticd.yang | 9 |
4 files changed, 31 insertions, 13 deletions
diff --git a/staticd/static_nb.h b/staticd/static_nb.h index 9116ac8e5..e46c15626 100644 --- a/staticd/static_nb.h +++ b/staticd/static_nb.h @@ -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']" @@ -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 */ diff --git a/staticd/static_nb_config.c b/staticd/static_nb_config.c index 282299eef..40c4d85fb 100644 --- a/staticd/static_nb_config.c +++ b/staticd/static_nb_config.c @@ -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; @@ -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) { diff --git a/staticd/static_vty.c b/staticd/static_vty.c index 311462db7..63b425771 100644 --- a/staticd/static_vty.c +++ b/staticd/static_vty.c @@ -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); @@ -288,6 +290,7 @@ 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 @@ -295,6 +298,7 @@ static int static_route_leak(struct vty *vty, const char *svrf, 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); diff --git a/yang/frr-staticd.yang b/yang/frr-staticd.yang index d7a6b1d04..281b4903c 100644 --- a/yang/frr-staticd.yang +++ b/yang/frr-staticd.yang @@ -99,7 +99,7 @@ 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 { @@ -107,6 +107,13 @@ module frr-staticd { description "IP prefix."; } + leaf afi-safi { + type identityref { + base frr-rt:afi-safi-type; + } + description + "AFI-SAFI type."; + } uses staticd-prefix-attributes; |