]> git.puffer.fish Git - matthieu/frr.git/commitdiff
staticd: Added afi-safi as a key in route-list
authorvdhingra <vdhingra@vmware.com>
Thu, 2 Jul 2020 06:54:50 +0000 (23:54 -0700)
committervdhingra <vdhingra@vmware.com>
Thu, 16 Jul 2020 15:40:45 +0000 (08:40 -0700)
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>
staticd/static_nb.h
staticd/static_nb_config.c
staticd/static_vty.c
yang/frr-staticd.yang

index 9116ac8e51f0f4a79cec871bb61a2411d466b77a..e46c156265f7ecd2267f2369f9a2d01eff19377b 100644 (file)
@@ -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 */
index 282299eefe4c07f49985fce13e6f77d84de19e8b..40c4d85fb688c3cf44ed3644be19a7caeb0a9e63 100644 (file)
@@ -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) {
index 311462db7ab29824bb794befd7484227a3e86b3d..63b425771a47045fc81de8b5c57c79ef57ec0763 100644 (file)
@@ -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);
 
index d7a6b1d0418ff894aa20e2b4edfee78299e97d26..281b4903c072a8474f524d60f740d5ea0656430a 100644 (file)
@@ -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;