]> git.proxmox.com Git - mirror_frr.git/commitdiff
staticd: handle `distance` value
authorChristian Hopps <chopps@labn.net>
Tue, 28 Feb 2023 04:57:17 +0000 (23:57 -0500)
committerChristian Hopps <chopps@gmail.com>
Wed, 22 Mar 2023 05:22:56 +0000 (05:22 +0000)
Signed-off-by: Christian Hopps <chopps@labn.net>
staticd/static_vty.c

index bfffbe6a6065ca76f068a7bfda57bf2ad7b474f4..2761b63e81fbce71410fafb11ed4b78974d4470a 100644 (file)
@@ -285,8 +285,7 @@ static int static_route_nb_run(struct vty *vty, struct static_route_args *args)
                                nb_cli_enqueue_change(vty, ab_xpath,
                                                      NB_OP_MODIFY, "false");
                }
-               if (type == STATIC_IPV4_GATEWAY
-                   || type == STATIC_IPV6_GATEWAY
+               if (type == STATIC_IPV4_GATEWAY || type == STATIC_IPV6_GATEWAY
                    || type == STATIC_IPV4_GATEWAY_IFNAME
                    || type == STATIC_IPV6_GATEWAY_IFNAME) {
                        strlcpy(ab_xpath, xpath_nexthop, sizeof(ab_xpath));
@@ -368,25 +367,52 @@ static int static_route_nb_run(struct vty *vty, struct static_route_args *args)
 
                ret = nb_cli_apply_changes(vty, "%s", xpath_prefix);
        } else {
-               if (args->source)
-                       snprintf(ab_xpath, sizeof(ab_xpath),
-                                FRR_DEL_S_ROUTE_SRC_NH_KEY_NO_DISTANCE_XPATH,
-                                "frr-staticd:staticd", "staticd", args->vrf,
-                                buf_prefix,
-                                yang_afi_safi_value2identity(args->afi,
-                                                             args->safi),
-                                buf_src_prefix, table_id, buf_nh_type,
-                                args->nexthop_vrf, buf_gate_str,
-                                args->interface_name);
-               else
-                       snprintf(ab_xpath, sizeof(ab_xpath),
-                                FRR_DEL_S_ROUTE_NH_KEY_NO_DISTANCE_XPATH,
-                                "frr-staticd:staticd", "staticd", args->vrf,
-                                buf_prefix,
-                                yang_afi_safi_value2identity(args->afi,
-                                                             args->safi),
-                                table_id, buf_nh_type, args->nexthop_vrf,
-                                buf_gate_str, args->interface_name);
+               if (args->source) {
+                       if (args->distance)
+                               snprintf(
+                                       ab_xpath, sizeof(ab_xpath),
+                                       FRR_DEL_S_ROUTE_SRC_NH_KEY_XPATH,
+                                       "frr-staticd:staticd", "staticd", args->vrf,
+                                       buf_prefix,
+                                       yang_afi_safi_value2identity(args->afi,
+                                                                    args->safi),
+                                       buf_src_prefix, table_id, distance,
+                                       buf_nh_type, args->nexthop_vrf, buf_gate_str,
+                                       args->interface_name);
+                       else
+                               snprintf(
+                                       ab_xpath, sizeof(ab_xpath),
+                                       FRR_DEL_S_ROUTE_SRC_NH_KEY_NO_DISTANCE_XPATH,
+                                       "frr-staticd:staticd", "staticd", args->vrf,
+                                       buf_prefix,
+                                       yang_afi_safi_value2identity(args->afi,
+                                                                    args->safi),
+                                       buf_src_prefix, table_id, buf_nh_type,
+                                       args->nexthop_vrf, buf_gate_str,
+                                       args->interface_name);
+               } else {
+                       if (args->distance)
+                               snprintf(
+                                       ab_xpath, sizeof(ab_xpath),
+                                       FRR_DEL_S_ROUTE_NH_KEY_XPATH,
+                                       "frr-staticd:staticd", "staticd",
+                                       args->vrf, buf_prefix,
+                                       yang_afi_safi_value2identity(args->afi,
+                                                                    args->safi),
+                                       table_id, distance, buf_nh_type,
+                                       args->nexthop_vrf, buf_gate_str,
+                                       args->interface_name);
+                       else
+                               snprintf(
+                                       ab_xpath, sizeof(ab_xpath),
+                                       FRR_DEL_S_ROUTE_NH_KEY_NO_DISTANCE_XPATH,
+                                       "frr-staticd:staticd", "staticd",
+                                       args->vrf, buf_prefix,
+                                       yang_afi_safi_value2identity(args->afi,
+                                                                    args->safi),
+                                       table_id, buf_nh_type, args->nexthop_vrf,
+                                       buf_gate_str, args->interface_name);
+               }
 
                dnode = yang_dnode_get(vty->candidate_config->dnode, ab_xpath);
                if (!dnode) {