From: Christian Hopps Date: Tue, 28 Feb 2023 04:57:17 +0000 (-0500) Subject: staticd: handle `distance` value X-Git-Tag: base_9.0~274^2~6 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=1462450eaa75476d63313bbab4377614fb0d7998;p=matthieu%2Ffrr.git staticd: handle `distance` value Signed-off-by: Christian Hopps --- diff --git a/staticd/static_vty.c b/staticd/static_vty.c index bfffbe6a60..2761b63e81 100644 --- a/staticd/static_vty.c +++ b/staticd/static_vty.c @@ -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) {