Skip to content

Commit 4f9995d

Browse files
committed
staticd, bgp: fix srv6 encap-value displayed with _ instead of .
When configuring an srv6 route with encap option, the displayed option in running config differs: > ubuntu2404(config)# ipv6 route 5::6/128 loop0 segments 1::1 encap-behavior H_Encaps_Red > ubuntu2404(config)# do show ipv6 route > [..] > S>* 5::6/128 [1/0] is directly connected, loop0, seg6 1::1, encap behavior H.Encaps.Red, weight 1, 00:00:02 > ubuntu2404(config)# do show running-config > [..] > ipv6 route 5::6/128 loop0 segments 1::1 encap-behavior H.Encaps.Red Modify output in running-config wherever the encap-behavior is used. Use _ instead. Fixes: 5323ad0 ("staticd: Add SRv6 encap behavior in show running-config") Fixes: dbd77b1 ("bgpd: add encap red support to L3VPN seg6 routes") Signed-off-by: Philippe Guibert <[email protected]>
1 parent f58a727 commit 4f9995d

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

bgpd/bgp_vty.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20113,7 +20113,7 @@ int bgp_config_write(struct vty *vty)
2011320113
bgp->srv6_locator_name);
2011420114
if (bgp->srv6_encap_behavior != SRV6_HEADEND_BEHAVIOR_H_ENCAPS)
2011520115
vty_out(vty, " encap-behavior %s\n",
20116-
srv6_headend_behavior2str(bgp->srv6_encap_behavior));
20116+
srv6_headend_behavior2str(bgp->srv6_encap_behavior, true));
2011720117
vty_endframe(vty, " exit\n");
2011820118
}
2011920119

lib/nexthop.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,8 +1398,9 @@ void nexthop_json_helper(json_object *json_nexthop,
13981398
->seg[0]);
13991399
json_object_object_add(json_nexthop, "seg6", json_seg6);
14001400
json_object_string_add(json_nexthop, "srv6EncapBehavior",
1401-
srv6_headend_behavior2str(
1402-
nexthop->nh_srv6->seg6_segs->encap_behavior));
1401+
srv6_headend_behavior2str(nexthop->nh_srv6->seg6_segs
1402+
->encap_behavior,
1403+
false));
14031404
} else {
14041405
if (nexthop->nh_srv6->seg6_segs) {
14051406
json_segs = json_object_new_array();
@@ -1417,9 +1418,10 @@ void nexthop_json_helper(json_object *json_nexthop,
14171418
json_object_object_add(json_nexthop, "seg6",
14181419
json_segs);
14191420
json_object_string_add(json_nexthop, "srv6EncapBehavior",
1420-
srv6_headend_behavior2str(
1421-
nexthop->nh_srv6->seg6_segs
1422-
->encap_behavior));
1421+
srv6_headend_behavior2str(nexthop->nh_srv6
1422+
->seg6_segs
1423+
->encap_behavior,
1424+
false));
14231425
}
14241426
}
14251427
}
@@ -1553,8 +1555,9 @@ void nexthop_vty_helper(struct vty *vty, const struct nexthop *nexthop,
15531555
if (nexthop->nh_srv6->seg6_segs->encap_behavior !=
15541556
SRV6_HEADEND_BEHAVIOR_H_ENCAPS)
15551557
vty_out(vty, ", encap behavior %s",
1556-
srv6_headend_behavior2str(
1557-
nexthop->nh_srv6->seg6_segs->encap_behavior));
1558+
srv6_headend_behavior2str(nexthop->nh_srv6->seg6_segs
1559+
->encap_behavior,
1560+
false));
15581561
}
15591562
}
15601563

lib/srv6.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -380,19 +380,20 @@ struct srv6_sid_ctx {
380380
ifindex_t ifindex;
381381
};
382382

383-
static inline const char *srv6_headend_behavior2str(enum srv6_headend_behavior behavior)
383+
static inline const char *srv6_headend_behavior2str(enum srv6_headend_behavior behavior,
384+
bool running_conf)
384385
{
385386
switch (behavior) {
386387
case SRV6_HEADEND_BEHAVIOR_H_INSERT:
387-
return "H.Insert";
388+
return running_conf ? "H_Insert" : "H.Insert";
388389
case SRV6_HEADEND_BEHAVIOR_H_ENCAPS:
389-
return "H.Encaps";
390+
return running_conf ? "H_Encaps" : "H.Encaps";
390391
case SRV6_HEADEND_BEHAVIOR_H_ENCAPS_RED:
391-
return "H.Encaps.Red";
392+
return running_conf ? "H_Encaps_Red" : "H.Encaps.Red";
392393
case SRV6_HEADEND_BEHAVIOR_H_ENCAPS_L2:
393-
return "H.Encaps.L2";
394+
return running_conf ? "H_Encaps_L2" : "H.Encaps.L2";
394395
case SRV6_HEADEND_BEHAVIOR_H_ENCAPS_L2_RED:
395-
return "H.Encaps.L2.Red";
396+
return running_conf ? "H_Encaps_L2_Red" : "H.Encaps.L2.Red";
396397
}
397398

398399
return "unknown";

staticd/static_vty.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1612,7 +1612,7 @@ static void nexthop_cli_show(struct vty *vty, const struct lyd_node *route,
16121612

16131613
if (srv6_encap_behavior != SRV6_HEADEND_BEHAVIOR_H_ENCAPS || show_defaults)
16141614
vty_out(vty, " encap-behavior %s",
1615-
srv6_headend_behavior2str(srv6_encap_behavior));
1615+
srv6_headend_behavior2str(srv6_encap_behavior, true));
16161616
}
16171617

16181618
nexthop_vrf = yang_dnode_get_string(nexthop, "vrf");

0 commit comments

Comments
 (0)