diff options
39 files changed, 560 insertions, 224 deletions
diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index d94dcdd362..a94ff5ef64 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -1940,7 +1940,7 @@ DEFUN(show_bgp_l2vpn_evpn_com, /* For testing purpose, static route of EVPN RT-5. */ DEFUN(evpnrt5_network, evpnrt5_network_cmd, - "network <A.B.C.D/M|X:X::X:X/M> rd ASN:NN_OR_IP-ADDRESS:NN ethtag WORD label WORD esi WORD gwip <A.B.C.D|X:X::X:X> routermac WORD [route-map WORD]", + "network <A.B.C.D/M|X:X::X:X/M> rd ASN:NN_OR_IP-ADDRESS:NN ethtag WORD label WORD esi WORD gwip <A.B.C.D|X:X::X:X> routermac WORD [route-map RMAP_NAME]", "Specify a network to announce via BGP\n" "IP prefix\n" "IPv6 prefix\n" @@ -3812,7 +3812,7 @@ DEFUN_HIDDEN (no_bgp_evpn_advertise_vni_subnet, DEFUN (bgp_evpn_advertise_type5, bgp_evpn_advertise_type5_cmd, - "advertise " BGP_AFI_CMD_STR "" BGP_SAFI_CMD_STR " [gateway-ip] [route-map WORD]", + "advertise " BGP_AFI_CMD_STR "" BGP_SAFI_CMD_STR " [gateway-ip] [route-map RMAP_NAME]", "Advertise prefix routes\n" BGP_AFI_HELP_STR BGP_SAFI_HELP_STR diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index b70662c458..cc4ff57f4e 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -2339,7 +2339,7 @@ DEFUN (vpnv4_network, DEFUN (vpnv4_network_route_map, vpnv4_network_route_map_cmd, - "network A.B.C.D/M rd ASN:NN_OR_IP-ADDRESS:NN <tag|label> (0-1048575) route-map WORD", + "network A.B.C.D/M rd ASN:NN_OR_IP-ADDRESS:NN <tag|label> (0-1048575) route-map RMAP_NAME", "Specify a network to announce via BGP\n" "IPv4 prefix\n" "Specify Route Distinguisher\n" @@ -2384,7 +2384,7 @@ DEFUN (no_vpnv4_network, DEFUN (vpnv6_network, vpnv6_network_cmd, - "network X:X::X:X/M rd ASN:NN_OR_IP-ADDRESS:NN <tag|label> (0-1048575) [route-map WORD]", + "network X:X::X:X/M rd ASN:NN_OR_IP-ADDRESS:NN <tag|label> (0-1048575) [route-map RMAP_NAME]", "Specify a network to announce via BGP\n" "IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n" "Specify Route Distinguisher\n" diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 6e3e45618e..f9d01913a8 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -6860,7 +6860,7 @@ DEFPY(bgp_network, bgp_network_cmd, "[no] network \ <A.B.C.D/M$prefix|A.B.C.D$address [mask A.B.C.D$netmask]> \ - [{route-map WORD$map_name|label-index (0-1048560)$label_index| \ + [{route-map RMAP_NAME$map_name|label-index (0-1048560)$label_index| \ backdoor$backdoor}]", NO_STR "Specify a network to announce via BGP\n" @@ -6897,7 +6897,7 @@ DEFPY(bgp_network, DEFPY(ipv6_bgp_network, ipv6_bgp_network_cmd, "[no] network X:X::X:X/M$prefix \ - [{route-map WORD$map_name|label-index (0-1048560)$label_index}]", + [{route-map RMAP_NAME$map_name|label-index (0-1048560)$label_index}]", NO_STR "Specify a network to announce via BGP\n" "IPv6 prefix\n" @@ -12228,7 +12228,7 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd, |community-list <(1-500)|COMMUNITY_LIST_NAME> [exact-match]\ |filter-list AS_PATH_FILTER_NAME\ |prefix-list WORD\ - |route-map WORD\ + |route-map RMAP_NAME\ |rpki <invalid|valid|notfound>\ |version (1-4294967295)\ |alias ALIAS_NAME\ @@ -13963,7 +13963,7 @@ DEFPY (show_ip_bgp_instance_neighbor_bestpath_route, DEFPY (show_ip_bgp_instance_neighbor_advertised_route, show_ip_bgp_instance_neighbor_advertised_route_cmd, - "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] [all$all] neighbors <A.B.C.D|X:X::X:X|WORD> <advertised-routes|received-routes|filtered-routes> [route-map WORD] [json$uj | wide$wide]", + "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] [all$all] neighbors <A.B.C.D|X:X::X:X|WORD> <advertised-routes|received-routes|filtered-routes> [route-map RMAP_NAME$route_map] [json$uj | wide$wide]", SHOW_STR IP_STR BGP_STR @@ -13985,7 +13985,6 @@ DEFPY (show_ip_bgp_instance_neighbor_advertised_route, { afi_t afi = AFI_IP6; safi_t safi = SAFI_UNICAST; - char *rmap_name = NULL; char *peerstr = NULL; struct bgp *bgp = NULL; struct peer *peer; @@ -14033,11 +14032,8 @@ DEFPY (show_ip_bgp_instance_neighbor_advertised_route, else if (argv_find(argv, argc, "filtered-routes", &idx)) type = bgp_show_adj_route_filtered; - if (argv_find(argv, argc, "route-map", &idx)) - rmap_name = argv[++idx]->arg; - if (!all) - return peer_adj_routes(vty, peer, afi, safi, type, rmap_name, + return peer_adj_routes(vty, peer, afi, safi, type, route_map, show_flags); if (uj) vty_out(vty, "{\n"); @@ -14066,7 +14062,7 @@ DEFPY (show_ip_bgp_instance_neighbor_advertised_route, false)); peer_adj_routes(vty, peer, afi, safi, type, - rmap_name, show_flags); + route_map, show_flags); } } } else { @@ -14090,7 +14086,7 @@ DEFPY (show_ip_bgp_instance_neighbor_advertised_route, false)); peer_adj_routes(vty, peer, afi, safi, type, - rmap_name, show_flags); + route_map, show_flags); } } } diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 17ea915c27..bb88adbfc2 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -6673,7 +6673,7 @@ ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, DEFUN (neighbor_default_originate_rmap, neighbor_default_originate_rmap_cmd, - "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", + "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Originate default route to this neighbor\n" @@ -6690,7 +6690,7 @@ DEFUN (neighbor_default_originate_rmap, ALIAS_HIDDEN( neighbor_default_originate_rmap, neighbor_default_originate_rmap_hidden_cmd, - "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", + "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Originate default route to this neighbor\n" "Route-map to specify criteria to originate default\n" @@ -6698,7 +6698,7 @@ ALIAS_HIDDEN( DEFUN (no_neighbor_default_originate, no_neighbor_default_originate_cmd, - "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", + "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 @@ -6714,7 +6714,7 @@ DEFUN (no_neighbor_default_originate, ALIAS_HIDDEN( no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, - "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", + "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Originate default route to this neighbor\n" "Route-map to specify criteria to originate default\n" @@ -7627,7 +7627,7 @@ static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, DEFUN (neighbor_route_map, neighbor_route_map_cmd, - "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", + "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Apply route map to neighbor\n" @@ -7644,7 +7644,7 @@ DEFUN (neighbor_route_map, } ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, - "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", + "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Apply route map to neighbor\n" "Name of route map\n" @@ -7653,7 +7653,7 @@ ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, DEFUN (no_neighbor_route_map, no_neighbor_route_map_cmd, - "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", + "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 @@ -7670,7 +7670,7 @@ DEFUN (no_neighbor_route_map, } ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, - "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", + "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Apply route map to neighbor\n" "Name of route map\n" @@ -15494,7 +15494,7 @@ ALIAS_HIDDEN( DEFUN (bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_cmd, - "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", + "redistribute " FRR_IP_REDIST_STR_BGPD " route-map RMAP_NAME", "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD "Route map reference\n" @@ -15523,7 +15523,7 @@ DEFUN (bgp_redistribute_ipv4_rmap, ALIAS_HIDDEN( bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, - "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", + "redistribute " FRR_IP_REDIST_STR_BGPD " route-map RMAP_NAME", "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD "Route map reference\n" "Pointer to route-map entries\n") @@ -15565,7 +15565,7 @@ ALIAS_HIDDEN( DEFUN (bgp_redistribute_ipv4_rmap_metric, bgp_redistribute_ipv4_rmap_metric_cmd, - "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", + "redistribute " FRR_IP_REDIST_STR_BGPD " route-map RMAP_NAME metric (0-4294967295)", "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD "Route map reference\n" @@ -15602,7 +15602,7 @@ ALIAS_HIDDEN( bgp_redistribute_ipv4_rmap_metric, bgp_redistribute_ipv4_rmap_metric_hidden_cmd, "redistribute " FRR_IP_REDIST_STR_BGPD - " route-map WORD metric (0-4294967295)", + " route-map RMAP_NAME metric (0-4294967295)", "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD "Route map reference\n" "Pointer to route-map entries\n" @@ -15611,7 +15611,7 @@ ALIAS_HIDDEN( DEFUN (bgp_redistribute_ipv4_metric_rmap, bgp_redistribute_ipv4_metric_rmap_cmd, - "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", + "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map RMAP_NAME", "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD "Metric for redistributed routes\n" @@ -15648,7 +15648,7 @@ ALIAS_HIDDEN( bgp_redistribute_ipv4_metric_rmap, bgp_redistribute_ipv4_metric_rmap_hidden_cmd, "redistribute " FRR_IP_REDIST_STR_BGPD - " metric (0-4294967295) route-map WORD", + " metric (0-4294967295) route-map RMAP_NAME", "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD "Metric for redistributed routes\n" "Default metric\n" @@ -15689,7 +15689,7 @@ ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, DEFUN (bgp_redistribute_ipv4_ospf_rmap, bgp_redistribute_ipv4_ospf_rmap_cmd, - "redistribute <ospf|table> (1-65535) route-map WORD", + "redistribute <ospf|table> (1-65535) route-map RMAP_NAME", "Redistribute information from another routing protocol\n" "Open Shortest Path First (OSPFv2)\n" "Non-main Kernel Routing Table\n" @@ -15722,7 +15722,7 @@ DEFUN (bgp_redistribute_ipv4_ospf_rmap, ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, - "redistribute <ospf|table> (1-65535) route-map WORD", + "redistribute <ospf|table> (1-65535) route-map RMAP_NAME", "Redistribute information from another routing protocol\n" "Open Shortest Path First (OSPFv2)\n" "Non-main Kernel Routing Table\n" @@ -15776,7 +15776,7 @@ ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, bgp_redistribute_ipv4_ospf_rmap_metric_cmd, - "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", + "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)", "Redistribute information from another routing protocol\n" "Open Shortest Path First (OSPFv2)\n" "Non-main Kernel Routing Table\n" @@ -15818,7 +15818,7 @@ DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, ALIAS_HIDDEN( bgp_redistribute_ipv4_ospf_rmap_metric, bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, - "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", + "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)", "Redistribute information from another routing protocol\n" "Open Shortest Path First (OSPFv2)\n" "Non-main Kernel Routing Table\n" @@ -15830,7 +15830,7 @@ ALIAS_HIDDEN( DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, bgp_redistribute_ipv4_ospf_metric_rmap_cmd, - "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", + "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME", "Redistribute information from another routing protocol\n" "Open Shortest Path First (OSPFv2)\n" "Non-main Kernel Routing Table\n" @@ -15872,7 +15872,7 @@ DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, ALIAS_HIDDEN( bgp_redistribute_ipv4_ospf_metric_rmap, bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, - "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", + "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME", "Redistribute information from another routing protocol\n" "Open Shortest Path First (OSPFv2)\n" "Non-main Kernel Routing Table\n" @@ -15884,7 +15884,7 @@ ALIAS_HIDDEN( DEFUN (no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_cmd, - "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", + "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]", NO_STR "Redistribute information from another routing protocol\n" "Open Shortest Path First (OSPFv2)\n" @@ -15912,7 +15912,7 @@ DEFUN (no_bgp_redistribute_ipv4_ospf, ALIAS_HIDDEN( no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, - "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", + "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]", NO_STR "Redistribute information from another routing protocol\n" "Open Shortest Path First (OSPFv2)\n" @@ -15925,7 +15925,7 @@ ALIAS_HIDDEN( DEFUN (no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_cmd, - "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", + "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map RMAP_NAME}]", NO_STR "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD @@ -15949,7 +15949,7 @@ DEFUN (no_bgp_redistribute_ipv4, ALIAS_HIDDEN( no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, "no redistribute " FRR_IP_REDIST_STR_BGPD - " [{metric (0-4294967295)|route-map WORD}]", + " [{metric (0-4294967295)|route-map RMAP_NAME}]", NO_STR "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD "Metric for redistributed routes\n" @@ -15979,7 +15979,7 @@ DEFUN (bgp_redistribute_ipv6, DEFUN (bgp_redistribute_ipv6_rmap, bgp_redistribute_ipv6_rmap_cmd, - "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", + "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map RMAP_NAME", "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD "Route map reference\n" @@ -16036,7 +16036,7 @@ DEFUN (bgp_redistribute_ipv6_metric, DEFUN (bgp_redistribute_ipv6_rmap_metric, bgp_redistribute_ipv6_rmap_metric_cmd, - "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", + "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map RMAP_NAME metric (0-4294967295)", "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD "Route map reference\n" @@ -16072,7 +16072,7 @@ DEFUN (bgp_redistribute_ipv6_rmap_metric, DEFUN (bgp_redistribute_ipv6_metric_rmap, bgp_redistribute_ipv6_metric_rmap_cmd, - "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", + "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map RMAP_NAME", "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD "Metric for redistributed routes\n" @@ -16108,7 +16108,7 @@ DEFUN (bgp_redistribute_ipv6_metric_rmap, DEFUN (no_bgp_redistribute_ipv6, no_bgp_redistribute_ipv6_cmd, - "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", + "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map RMAP_NAME}]", NO_STR "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD @@ -19175,7 +19175,7 @@ void bgp_vty_init(void) install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); - /* import|export vpn [route-map WORD] */ + /* import|export vpn [route-map RMAP_NAME] */ install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); diff --git a/doc/user/ldpd.rst b/doc/user/ldpd.rst index 149e851891..682443a456 100644 --- a/doc/user/ldpd.rst +++ b/doc/user/ldpd.rst @@ -128,6 +128,21 @@ LDP Configuration the IPv4 or IPv6 transport-address used by the LDP protocol to talk on this interface. +.. clicmd:: ttl-security disable + + Located under the LDP address-family node, use this command to disable the + GTSM procedures described in RFC 6720 (for the IPv4 address-family) and + RFC 7552 (for the IPv6 address-family). + + Since GTSM is mandatory for LDPv6, the only effect of disabling GTSM for the + IPv6 address-family is that *ldpd* will not discard packets with a hop limit + below 255. This may be necessary to interoperate with older implementations. + Outgoing packets will still be sent using a hop limit of 255 for maximum + compatibility. + + If GTSM is enabled, multi-hop neighbors should have either GTSM disabled + individually or configured with an appropriate ttl-security hops distance. + .. clicmd:: neighbor A.B.C.D password PASSWORD The following command located under MPLS router node configures the router @@ -143,6 +158,19 @@ LDP Configuration this time of non response, the LDP established session will be considered as set to down. By default, no holdtime is configured for the LDP devices. +.. clicmd:: neighbor A.B.C.D ttl-security disable + + Located under the MPLS LDP node, use this command to override the global + configuration and enable/disable GTSM for the specified neighbor. + +.. clicmd:: neighbor A.B.C.D ttl-security hops (1-254) + + Located under the MPLS LDP node, use this command to set the maximum number + of hops the specified neighbor may be away. When GTSM is enabled for this + neighbor, incoming packets are required to have a TTL/hop limit of 256 + minus this value, ensuring they have not passed through more than the + expected number of hops. The default value is 1. + .. clicmd:: discovery hello holdtime HOLDTIME .. clicmd:: discovery hello interval INTERVAL diff --git a/doc/user/routeserver.rst b/doc/user/routeserver.rst index 5100d679f7..969cd17920 100644 --- a/doc/user/routeserver.rst +++ b/doc/user/routeserver.rst @@ -183,7 +183,7 @@ in order to support the route server features. that moment, every announcement received by the route server will be also considered for the new Loc-RIB. -.. clicmd:: neigbor A.B.C.D|X.X::X.X|peer-group route-map WORD import|export +.. clicmd:: neigbor A.B.C.D|X.X::X.X|peer-group route-map WORD in|out This set of commands can be used to specify the route-map that represents the Import or Export policy of a peer which is configured as a RS-client @@ -372,20 +372,20 @@ the policies for client RA): address-family ipv6 neighbor 2001:0DB8::A activate neighbor 2001:0DB8::A route-server-client - neighbor 2001:0DB8::A route-map RSCLIENT-A-IMPORT import - neighbor 2001:0DB8::A route-map RSCLIENT-A-EXPORT export + neighbor 2001:0DB8::A route-map RSCLIENT-A-IMPORT in + neighbor 2001:0DB8::A route-map RSCLIENT-A-EXPORT out neighbor 2001:0DB8::A soft-reconfiguration inbound neighbor 2001:0DB8::B activate neighbor 2001:0DB8::B route-server-client - neighbor 2001:0DB8::B route-map RSCLIENT-B-IMPORT import - neighbor 2001:0DB8::B route-map RSCLIENT-B-EXPORT export + neighbor 2001:0DB8::B route-map RSCLIENT-B-IMPORT in + neighbor 2001:0DB8::B route-map RSCLIENT-B-EXPORT out neighbor 2001:0DB8::B soft-reconfiguration inbound neighbor 2001:0DB8::C activate neighbor 2001:0DB8::C route-server-client - neighbor 2001:0DB8::C route-map RSCLIENT-C-IMPORT import - neighbor 2001:0DB8::C route-map RSCLIENT-C-EXPORT export + neighbor 2001:0DB8::C route-map RSCLIENT-C-IMPORT in + neighbor 2001:0DB8::C route-map RSCLIENT-C-EXPORT out neighbor 2001:0DB8::C soft-reconfiguration inbound exit-address-family ! @@ -501,7 +501,7 @@ do it: .. code-block:: frr - neighbor 2001:0DB8::A route-map RSCLIENT-A-IMPORT import + neighbor 2001:0DB8::A route-map RSCLIENT-A-IMPORT in ... ! ... diff --git a/isisd/isis_cli.c b/isisd/isis_cli.c index 2bf9eadaba..bbc569ec1c 100644 --- a/isisd/isis_cli.c +++ b/isisd/isis_cli.c @@ -1206,7 +1206,7 @@ void cli_show_isis_mpls_te_export(struct vty *vty, const struct lyd_node *dnode, * XPath: /frr-isisd:isis/instance/default-information-originate */ DEFPY_YANG(isis_default_originate, isis_default_originate_cmd, - "[no] default-information originate <ipv4|ipv6>$ip <level-1|level-2>$level [always]$always [{metric (0-16777215)$metric|route-map WORD$rmap}]", + "[no] default-information originate <ipv4|ipv6>$ip <level-1|level-2>$level [always]$always [{metric (0-16777215)$metric|route-map RMAP_NAME$rmap}]", NO_STR "Control distribution of default information\n" "Distribute a default route\n" @@ -1286,7 +1286,7 @@ void cli_show_isis_def_origin_ipv6(struct vty *vty, DEFPY_YANG(isis_redistribute, isis_redistribute_cmd, "[no] redistribute <ipv4$ip " PROTO_IP_REDIST_STR "$proto|ipv6$ip " PROTO_IP6_REDIST_STR "$proto> <level-1|level-2>$level" - "[{metric (0-16777215)|route-map WORD}]", + "[{metric (0-16777215)|route-map RMAP_NAME$route_map}]", NO_STR REDIST_STR "Redistribute IPv4 routes\n" PROTO_IP_REDIST_HELP diff --git a/isisd/isis_redist.c b/isisd/isis_redist.c index 45d69bc352..dd82c5057b 100644 --- a/isisd/isis_redist.c +++ b/isisd/isis_redist.c @@ -544,7 +544,7 @@ void isis_redist_area_finish(struct isis_area *area) DEFUN (isis_redistribute, isis_redistribute_cmd, "redistribute <ipv4 " PROTO_IP_REDIST_STR "|ipv6 " PROTO_IP6_REDIST_STR ">" - " [{metric (0-16777215)|route-map WORD}]", + " [{metric (0-16777215)|route-map RMAP_NAME}]", REDIST_STR "Redistribute IPv4 routes\n" PROTO_IP_REDIST_HELP @@ -636,7 +636,7 @@ DEFUN (no_isis_redistribute, DEFUN (isis_default_originate, isis_default_originate_cmd, - "default-information originate <ipv4|ipv6> [always] [{metric (0-16777215)|route-map WORD}]", + "default-information originate <ipv4|ipv6> [always] [{metric (0-16777215)|route-map RMAP_NAME}]", "Control distribution of default information\n" "Distribute a default route\n" "Distribute default route for IPv4\n" diff --git a/lib/nexthop.c b/lib/nexthop.c index e17eeb8303..248acd2700 100644 --- a/lib/nexthop.c +++ b/lib/nexthop.c @@ -922,6 +922,34 @@ int nexthop_str2backups(const char *str, int *num_backups, return ret; } +ssize_t printfrr_nhs(struct fbuf *buf, const struct nexthop *nexthop) +{ + ssize_t ret = 0; + + if (!nexthop) + return bputs(buf, "(null)"); + + switch (nexthop->type) { + case NEXTHOP_TYPE_IFINDEX: + ret += bprintfrr(buf, "if %u", nexthop->ifindex); + break; + case NEXTHOP_TYPE_IPV4: + case NEXTHOP_TYPE_IPV4_IFINDEX: + ret += bprintfrr(buf, "%pI4 if %u", &nexthop->gate.ipv4, + nexthop->ifindex); + break; + case NEXTHOP_TYPE_IPV6: + case NEXTHOP_TYPE_IPV6_IFINDEX: + ret += bprintfrr(buf, "%pI6 if %u", &nexthop->gate.ipv6, + nexthop->ifindex); + break; + case NEXTHOP_TYPE_BLACKHOLE: + ret += bputs(buf, "blackhole"); + break; + } + return ret; +} + /* * nexthop printing variants: * %pNHvv @@ -1010,27 +1038,7 @@ static ssize_t printfrr_nh(struct fbuf *buf, struct printfrr_eargs *ea, case 's': ea->fmt++; - if (!nexthop) - return bputs(buf, "(null)"); - - switch (nexthop->type) { - case NEXTHOP_TYPE_IFINDEX: - ret += bprintfrr(buf, "if %u", nexthop->ifindex); - break; - case NEXTHOP_TYPE_IPV4: - case NEXTHOP_TYPE_IPV4_IFINDEX: - ret += bprintfrr(buf, "%pI4 if %u", &nexthop->gate.ipv4, - nexthop->ifindex); - break; - case NEXTHOP_TYPE_IPV6: - case NEXTHOP_TYPE_IPV6_IFINDEX: - ret += bprintfrr(buf, "%pI6 if %u", &nexthop->gate.ipv6, - nexthop->ifindex); - break; - case NEXTHOP_TYPE_BLACKHOLE: - ret += bputs(buf, "blackhole"); - break; - } + ret += printfrr_nhs(buf, nexthop); return ret; case 'c': ea->fmt++; diff --git a/lib/nexthop.h b/lib/nexthop.h index 320b46315e..c13f1b1376 100644 --- a/lib/nexthop.h +++ b/lib/nexthop.h @@ -260,6 +260,7 @@ int nexthop_str2backups(const char *str, int *num_backups, #pragma FRR printfrr_ext "%pNH" (struct nexthop *) #endif +ssize_t printfrr_nhs(struct fbuf *buf, const struct nexthop *nh); #ifdef __cplusplus } #endif diff --git a/lib/routemap.c b/lib/routemap.c index 722693ea27..7fd5a96e5b 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -3270,7 +3270,7 @@ void route_map_counter_decrement(struct route_map *map) } DEFUN_HIDDEN(show_route_map_pfx_tbl, show_route_map_pfx_tbl_cmd, - "show route-map WORD prefix-table", + "show route-map RMAP_NAME prefix-table", SHOW_STR "route-map\n" "route-map name\n" diff --git a/lib/stream.c b/lib/stream.c index c15baa0a2c..011e921c0d 100644 --- a/lib/stream.c +++ b/lib/stream.c @@ -145,8 +145,7 @@ struct stream *stream_dup(const struct stream *s) STREAM_VERIFY_SANE(s); - if ((snew = stream_new(s->endp)) == NULL) - return NULL; + snew = stream_new(s->endp); return (stream_copy(snew, s)); } diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c index c210b4476c..ae3ce2f0c7 100644 --- a/ospf6d/ospf6_asbr.c +++ b/ospf6d/ospf6_asbr.c @@ -1661,7 +1661,7 @@ void ospf6_asbr_redistribute_remove(int type, ifindex_t ifindex, DEFPY (ospf6_redistribute, ospf6_redistribute_cmd, - "redistribute " FRR_REDIST_STR_OSPF6D "[{metric (0-16777214)|metric-type (1-2)$metric_type|route-map WORD$rmap_str}]", + "redistribute " FRR_REDIST_STR_OSPF6D "[{metric (0-16777214)|metric-type (1-2)$metric_type|route-map RMAP_NAME$rmap_str}]", "Redistribute\n" FRR_REDIST_HELP_STR_OSPF6D "Metric for redistributed routes\n" @@ -1715,7 +1715,7 @@ DEFPY (ospf6_redistribute, DEFUN (no_ospf6_redistribute, no_ospf6_redistribute_cmd, - "no redistribute " FRR_REDIST_STR_OSPF6D "[{metric (0-16777214)|metric-type (1-2)|route-map WORD}]", + "no redistribute " FRR_REDIST_STR_OSPF6D "[{metric (0-16777214)|metric-type (1-2)|route-map RMAP_NAME}]", NO_STR "Redistribute\n" FRR_REDIST_HELP_STR_OSPF6D @@ -1893,7 +1893,7 @@ static void ospf6_redistribute_default_set(struct ospf6 *ospf6, int originate) /* Default Route originate. */ DEFPY (ospf6_default_route_originate, ospf6_default_route_originate_cmd, - "default-information originate [{always$always|metric (0-16777214)$mval|metric-type (1-2)$mtype|route-map WORD$rtmap}]", + "default-information originate [{always$always|metric (0-16777214)$mval|metric-type (1-2)$mtype|route-map RMAP_NAME$rtmap}]", "Control distribution of default route\n" "Distribute a default route\n" "Always advertise default route\n" @@ -1951,7 +1951,7 @@ DEFPY (ospf6_default_route_originate, DEFPY (no_ospf6_default_information_originate, no_ospf6_default_information_originate_cmd, - "no default-information originate [{always|metric (0-16777214)|metric-type (1-2)|route-map WORD}]", + "no default-information originate [{always|metric (0-16777214)|metric-type (1-2)|route-map RMAP_NAME}]", NO_STR "Control distribution of default information\n" "Distribute a default route\n" diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index e5985a8660..ee665cd25c 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -9116,7 +9116,7 @@ DEFUN (no_ip_ospf_passive, DEFUN (ospf_redistribute_source, ospf_redistribute_source_cmd, - "redistribute " FRR_REDIST_STR_OSPFD " [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]", + "redistribute " FRR_REDIST_STR_OSPFD " [{metric (0-16777214)|metric-type (1-2)|route-map RMAP_NAME}]", REDIST_STR FRR_REDIST_HELP_STR_OSPFD "Metric for redistributed routes\n" @@ -9160,8 +9160,8 @@ DEFUN (ospf_redistribute_source, update = true; /* Get route-map */ - if (argv_find(argv, argc, "WORD", &idx)) { - ospf_routemap_set(red, argv[idx]->arg); + if (argv_find(argv, argc, "route-map", &idx)) { + ospf_routemap_set(red, argv[idx + 1]->arg); } else ospf_routemap_unset(red); @@ -9175,7 +9175,7 @@ DEFUN (ospf_redistribute_source, DEFUN (no_ospf_redistribute_source, no_ospf_redistribute_source_cmd, - "no redistribute " FRR_REDIST_STR_OSPFD " [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]", + "no redistribute " FRR_REDIST_STR_OSPFD " [{metric (0-16777214)|metric-type (1-2)|route-map RMAP_NAME}]", NO_STR REDIST_STR FRR_REDIST_HELP_STR_OSPFD @@ -9207,7 +9207,7 @@ DEFUN (no_ospf_redistribute_source, DEFUN (ospf_redistribute_instance_source, ospf_redistribute_instance_source_cmd, - "redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]", + "redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map RMAP_NAME}]", REDIST_STR "Open Shortest Path First\n" "Non-main Kernel Routing Table\n" @@ -9283,7 +9283,7 @@ DEFUN (ospf_redistribute_instance_source, DEFUN (no_ospf_redistribute_instance_source, no_ospf_redistribute_instance_source_cmd, - "no redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map WORD}]", + "no redistribute <ospf|table> (1-65535) [{metric (0-16777214)|metric-type (1-2)|route-map RMAP_NAME}]", NO_STR REDIST_STR "Open Shortest Path First\n" @@ -9378,7 +9378,7 @@ DEFUN (no_ospf_distribute_list_out, /* Default information originate. */ DEFUN (ospf_default_information_originate, ospf_default_information_originate_cmd, - "default-information originate [{always|metric (0-16777214)|metric-type (1-2)|route-map WORD}]", + "default-information originate [{always|metric (0-16777214)|metric-type (1-2)|route-map RMAP_NAME}]", "Control distribution of default information\n" "Distribute a default route\n" "Always advertise default route\n" @@ -9418,8 +9418,8 @@ DEFUN (ospf_default_information_originate, } idx = 1; /* Get route-map */ - if (argv_find(argv, argc, "WORD", &idx)) - rtmap = argv[idx]->arg; + if (argv_find(argv, argc, "route-map", &idx)) + rtmap = argv[idx]->arg + 1; /* To check if user is providing same route map */ if ((!rtmap && !ROUTEMAP_NAME(red)) || @@ -9450,7 +9450,7 @@ DEFUN (ospf_default_information_originate, DEFUN (no_ospf_default_information_originate, no_ospf_default_information_originate_cmd, - "no default-information originate [{always|metric (0-16777214)|metric-type (1-2)|route-map WORD}]", + "no default-information originate [{always|metric (0-16777214)|metric-type (1-2)|route-map RMAP_NAME}]", NO_STR "Control distribution of default information\n" "Distribute a default route\n" diff --git a/pimd/pim_addr.h b/pimd/pim_addr.h index 90862520af..cb868bc7e1 100644 --- a/pimd/pim_addr.h +++ b/pimd/pim_addr.h @@ -35,6 +35,7 @@ typedef struct in_addr pim_addr; #define ipaddr_pim ipaddr_v4 #define PIM_MAX_BITLEN IPV4_MAX_BITLEN #define PIM_AF_NAME "ip" +#define PIMREG "pimreg" #define PIM_ADDR_FUNCNAME(name) ipv4_##name @@ -58,6 +59,7 @@ typedef struct in6_addr pim_addr; #define ipaddr_pim ipaddr_v6 #define PIM_MAX_BITLEN IPV6_MAX_BITLEN #define PIM_AF_NAME "ipv6" +#define PIMREG "pim6reg" #define PIM_ADDR_FUNCNAME(name) ipv6_##name diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c index 2e03bac945..6b132ee6b0 100644 --- a/pimd/pim_cmd_common.c +++ b/pimd/pim_cmd_common.c @@ -3305,11 +3305,7 @@ void pim_cmd_show_ip_multicast_helper(struct pim_instance *pim, struct vty *vty) vty_out(vty, "\n"); pim_zebra_zclient_update(vty); -#if PIM_IPV == 4 pim_zlookup_show_ip_multicast(vty); -#else - /* TBD */ -#endif vty_out(vty, "\n"); vty_out(vty, "Maximum highest VifIndex: %d\n", PIM_MAX_USABLE_VIFS); diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index 65889fd57b..4e92a2c5dc 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -1040,7 +1040,8 @@ int pim_if_add_vif(struct interface *ifp, bool ispimreg, bool is_vxlan_term) pim_ifp->pim->iface_vif_index[pim_ifp->mroute_vif_index] = 1; - gm_ifp_update(ifp); + if (!ispimreg) + gm_ifp_update(ifp); /* if the device qualifies as pim_vxlan iif/oif update vxlan entries */ pim_vxlan_add_vif(ifp); @@ -1546,9 +1547,9 @@ void pim_if_create_pimreg(struct pim_instance *pim) if (!pim->regiface) { if (pim->vrf->vrf_id == VRF_DEFAULT) - strlcpy(pimreg_name, "pimreg", sizeof(pimreg_name)); + strlcpy(pimreg_name, PIMREG, sizeof(pimreg_name)); else - snprintf(pimreg_name, sizeof(pimreg_name), "pimreg%u", + snprintf(pimreg_name, sizeof(pimreg_name), PIMREG "%u", pim->vrf->data.l.table_id); pim->regiface = if_get_by_name(pimreg_name, pim->vrf->vrf_id, @@ -1718,7 +1719,7 @@ static int pim_ifp_up(struct interface *ifp) * If we have a pimreg device callback and it's for a specific * table set the master appropriately */ - if (sscanf(ifp->name, "pimreg%" SCNu32, &table_id) == 1) { + if (sscanf(ifp->name, "" PIMREG "%" SCNu32, &table_id) == 1) { struct vrf *vrf; RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { if ((table_id == vrf->data.l.table_id) diff --git a/pimd/pim_oil.c b/pimd/pim_oil.c index 8fa2c96034..3bfb31e0c6 100644 --- a/pimd/pim_oil.c +++ b/pimd/pim_oil.c @@ -429,6 +429,8 @@ int pim_channel_add_oif(struct channel_oil *channel_oil, struct interface *oif, /* Prevent single protocol from subscribing same interface to channel (S,G) multiple times */ if (channel_oil->oif_flags[pim_ifp->mroute_vif_index] & proto_mask) { + channel_oil->oif_flags[pim_ifp->mroute_vif_index] |= proto_mask; + if (PIM_DEBUG_MROUTE) { zlog_debug( "%s %s: existing protocol mask %u requested OIF %s (vif_index=%d, min_ttl=%d) for channel (S,G)=(%pPAs,%pPAs)", diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c index 3da0a35303..2b798b14b2 100644 --- a/pimd/pim_rp.c +++ b/pimd/pim_rp.c @@ -267,10 +267,15 @@ struct rp_info *pim_rp_find_match_group(struct pim_instance *pim, } rp_info = rn->info; - if (PIM_DEBUG_PIM_TRACE) - zlog_debug("Lookedup: %p for rp_info: %p(%pFX) Lock: %d", rn, - rp_info, &rp_info->group, - route_node_get_lock_count(rn)); + if (PIM_DEBUG_PIM_TRACE) { + if (best) + zlog_debug( + "Lookedup(%pFX): prefix_list match %s, rn %p found: %pFX", + group, best->plist, rn, &rp_info->group); + else + zlog_debug("Lookedup(%pFX): rn %p found:%pFX", group, + rn, &rp_info->group); + } route_unlock_node(rn); diff --git a/ripd/rip_cli.c b/ripd/rip_cli.c index 58c28e54c0..73442bf16f 100644 --- a/ripd/rip_cli.c +++ b/ripd/rip_cli.c @@ -439,7 +439,7 @@ void cli_show_rip_non_passive_interface(struct vty *vty, */ DEFPY_YANG (rip_redistribute, rip_redistribute_cmd, - "[no] redistribute " FRR_REDIST_STR_RIPD "$protocol [{metric (0-16)|route-map WORD}]", + "[no] redistribute " FRR_REDIST_STR_RIPD "$protocol [{metric (0-16)|route-map RMAP_NAME$route_map}]", NO_STR REDIST_STR FRR_REDIST_HELP_STR_RIPD diff --git a/ripngd/ripng_cli.c b/ripngd/ripng_cli.c index 5bf3103a78..ded2f4358e 100644 --- a/ripngd/ripng_cli.c +++ b/ripngd/ripng_cli.c @@ -300,7 +300,7 @@ void cli_show_ripng_passive_interface(struct vty *vty, */ DEFPY_YANG (ripng_redistribute, ripng_redistribute_cmd, - "[no] redistribute " FRR_REDIST_STR_RIPNGD "$protocol [{metric (0-16)|route-map WORD}]", + "[no] redistribute " FRR_REDIST_STR_RIPNGD "$protocol [{metric (0-16)|route-map RMAP_NAME$route_map}]", NO_STR REDIST_STR FRR_REDIST_HELP_STR_RIPNGD diff --git a/tests/topotests/ldp_topo1/r1/show_ip_ospf_neighbor.json b/tests/topotests/ldp_topo1/r1/show_ip_ospf_neighbor.json new file mode 100644 index 0000000000..d9192f1104 --- /dev/null +++ b/tests/topotests/ldp_topo1/r1/show_ip_ospf_neighbor.json @@ -0,0 +1,14 @@ +{ + "neighbors": { + "2.2.2.2": [ + { + "dbSummaryCounter": 0, + "retransmitCounter": 0, + "priority": 1, + "converged": "Full", + "address": "10.0.1.2", + "requestCounter": 0 + } + ] + } +} diff --git a/tests/topotests/ldp_topo1/r2/show_ip_ospf_neighbor.json b/tests/topotests/ldp_topo1/r2/show_ip_ospf_neighbor.json new file mode 100644 index 0000000000..ea78592bd5 --- /dev/null +++ b/tests/topotests/ldp_topo1/r2/show_ip_ospf_neighbor.json @@ -0,0 +1,42 @@ +{ + "neighbors": { + "1.1.1.1": [ + { + "dbSummaryCounter": 0, + "retransmitCounter": 0, + "priority": 1, + "converged": "Full", + "address": "10.0.1.1", + "requestCounter": 0 + } + ], + "3.3.3.3": [ + { + "dbSummaryCounter": 0, + "retransmitCounter": 0, + "priority": 1, + "converged": "Full", + "address": "10.0.2.3", + "requestCounter": 0 + }, + { + "dbSummaryCounter": 0, + "retransmitCounter": 0, + "priority": 1, + "converged": "Full", + "address": "10.0.3.3", + "requestCounter": 0 + } + ], + "4.4.4.4": [ + { + "dbSummaryCounter": 0, + "retransmitCounter": 0, + "priority": 1, + "converged": "Full", + "address": "10.0.2.4", + "requestCounter": 0 + } + ] + } +} diff --git a/tests/topotests/ldp_topo1/r3/show_ip_ospf_neighbor.json b/tests/topotests/ldp_topo1/r3/show_ip_ospf_neighbor.json new file mode 100644 index 0000000000..d3c50247ea --- /dev/null +++ b/tests/topotests/ldp_topo1/r3/show_ip_ospf_neighbor.json @@ -0,0 +1,32 @@ +{ + "neighbors": { + "2.2.2.2": [ + { + "dbSummaryCounter": 0, + "retransmitCounter": 0, + "priority": 1, + "converged": "Full", + "address": "10.0.2.2", + "requestCounter": 0 + }, + { + "dbSummaryCounter": 0, + "retransmitCounter": 0, + "priority": 1, + "converged": "Full", + "address": "10.0.3.2", + "requestCounter": 0 + } + ], + "4.4.4.4": [ + { + "dbSummaryCounter": 0, + "retransmitCounter": 0, + "priority": 1, + "converged": "Full", + "address": "10.0.2.4", + "requestCounter": 0 + } + ] + } +} diff --git a/tests/topotests/ldp_topo1/r4/show_ip_ospf_neighbor.json b/tests/topotests/ldp_topo1/r4/show_ip_ospf_neighbor.json new file mode 100644 index 0000000000..20751a2884 --- /dev/null +++ b/tests/topotests/ldp_topo1/r4/show_ip_ospf_neighbor.json @@ -0,0 +1,24 @@ +{ + "neighbors": { + "2.2.2.2": [ + { + "dbSummaryCounter": 0, + "retransmitCounter": 0, + "priority": 1, + "converged": "Full", + "address": "10.0.2.2", + "requestCounter": 0 + } + ], + "3.3.3.3": [ + { + "dbSummaryCounter": 0, + "retransmitCounter": 0, + "priority": 1, + "converged": "Full", + "address": "10.0.2.3", + "requestCounter": 0 + } + ] + } +} diff --git a/tests/topotests/ldp_topo1/test_ldp_topo1.py b/tests/topotests/ldp_topo1/test_ldp_topo1.py index 8d69787236..cb8adfb55d 100644 --- a/tests/topotests/ldp_topo1/test_ldp_topo1.py +++ b/tests/topotests/ldp_topo1/test_ldp_topo1.py @@ -63,9 +63,15 @@ import os import re import sys import pytest +import json +from functools import partial from time import sleep from lib.topolog import logger +# Save the Current Working Directory to find configuration files. +CWD = os.path.dirname(os.path.realpath(__file__)) +sys.path.append(os.path.join(CWD, "../")) + sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from lib import topotest from lib.topogen import Topogen, get_topogen @@ -104,6 +110,29 @@ def build_topo(tgen): ##################################################### ## +## Helper functions +## +##################################################### + + +def router_compare_json_output(rname, command, reference, count=60, wait=1): + "Compare router JSON output" + + logger.info('Comparing router "%s" "%s" output', rname, command) + + tgen = get_topogen() + filename = "{}/{}/{}".format(CWD, rname, reference) + expected = json.loads(open(filename).read()) + + # Run test function until we get an result. + test_func = partial(topotest.router_json_cmp, tgen.gears[rname], command, expected) + _, diff = topotest.run_and_expect(test_func, None, count, wait) + assertmsg = '"{}" JSON output mismatches the expected result'.format(rname) + assert diff is None, assertmsg + + +##################################################### +## ## Tests starting ## ##################################################### @@ -218,6 +247,19 @@ def test_mpls_interfaces(): assert fatal_error == "", fatal_error +def test_ospf_convergence(): + logger.info("Test: check OSPF adjacencies") + + # Skip if previous fatal error condition is raised + if fatal_error != "": + pytest.skip(fatal_error) + + for rname in ["r1", "r2", "r3", "r4"]: + router_compare_json_output( + rname, "show ip ospf neighbor json", "show_ip_ospf_neighbor.json" + ) + + def test_mpls_ldp_neighbor_establish(): global fatal_error net = get_topogen().net @@ -510,9 +552,10 @@ def test_mpls_ldp_binding(): else: print("r%s ok" % i) - assert ( - failures == 0 - ), "MPLS LDP Interface binding output for router r%s:\n%s" % (i, diff) + assert failures == 0, "MPLS LDP binding output for router r%s:\n%s" % ( + i, + diff, + ) # Make sure that all daemons are running for i in range(1, 5): diff --git a/tests/topotests/ldp_vpls_topo1/r1/ldpd.conf b/tests/topotests/ldp_vpls_topo1/r1/ldpd.conf index 594ec5a58f..a19e5ccacb 100644 --- a/tests/topotests/ldp_vpls_topo1/r1/ldpd.conf +++ b/tests/topotests/ldp_vpls_topo1/r1/ldpd.conf @@ -14,6 +14,7 @@ mpls ldp ! address-family ipv4 discovery transport-address 1.1.1.1 + ttl-security disable label local allocate host-routes ! interface r1-eth1 diff --git a/tests/topotests/ldp_vpls_topo1/r2/ldpd.conf b/tests/topotests/ldp_vpls_topo1/r2/ldpd.conf index ffb4f0974a..447b3f140a 100644 --- a/tests/topotests/ldp_vpls_topo1/r2/ldpd.conf +++ b/tests/topotests/ldp_vpls_topo1/r2/ldpd.conf @@ -14,6 +14,7 @@ mpls ldp ! address-family ipv4 discovery transport-address 2.2.2.2 + ttl-security disable label local allocate host-routes ! interface r2-eth1 diff --git a/tests/topotests/ldp_vpls_topo1/r3/ldpd.conf b/tests/topotests/ldp_vpls_topo1/r3/ldpd.conf index c95471ffd8..ab51471499 100644 --- a/tests/topotests/ldp_vpls_topo1/r3/ldpd.conf +++ b/tests/topotests/ldp_vpls_topo1/r3/ldpd.conf @@ -14,6 +14,7 @@ mpls ldp ! address-family ipv4 discovery transport-address 3.3.3.3 + ttl-security disable label local allocate host-routes ! interface r3-eth1 diff --git a/tests/topotests/lib/common_config.py b/tests/topotests/lib/common_config.py index 26113b72b1..0e9e0ba403 100644 --- a/tests/topotests/lib/common_config.py +++ b/tests/topotests/lib/common_config.py @@ -3365,8 +3365,9 @@ def verify_rib( nh_found = False for st_rt in ip_list: - st_rt = str(ipaddress.ip_network(frr_unicode(st_rt))) - + st_rt = str( + ipaddress.ip_network(frr_unicode(st_rt), strict=False) + ) _addr_type = validate_ip_address(st_rt) if _addr_type != addr_type: continue @@ -3531,8 +3532,8 @@ def verify_rib( if nh_found: logger.info( - "[DUT: {}]: Found next_hop {} for all bgp" - " routes in RIB".format(router, next_hop) + "[DUT: {}]: Found next_hop {} for" + " RIB routes: {}".format(router, next_hop, found_routes) ) if len(missing_routes) > 0: @@ -3596,7 +3597,7 @@ def verify_rib( nh_found = False for st_rt in ip_list: - st_rt = str(ipaddress.ip_network(frr_unicode(st_rt))) + st_rt = str(ipaddress.ip_network(frr_unicode(st_rt), strict=False)) _addr_type = validate_ip_address(st_rt) if _addr_type != addr_type: @@ -3753,8 +3754,9 @@ def verify_fib_routes(tgen, addr_type, dut, input_dict, next_hop=None): nh_found = False for st_rt in ip_list: - st_rt = str(ipaddress.ip_network(frr_unicode(st_rt))) - + st_rt = str( + ipaddress.ip_network(frr_unicode(st_rt), strict=False) + ) _addr_type = validate_ip_address(st_rt) if _addr_type != addr_type: continue @@ -3858,7 +3860,7 @@ def verify_fib_routes(tgen, addr_type, dut, input_dict, next_hop=None): nh_found = False for st_rt in ip_list: - st_rt = str(ipaddress.ip_network(frr_unicode(st_rt))) + st_rt = str(ipaddress.ip_network(frr_unicode(st_rt), strict=False)) _addr_type = validate_ip_address(st_rt) if _addr_type != addr_type: diff --git a/tests/topotests/lib/pim.py b/tests/topotests/lib/pim.py index b0889373ce..5d623c94e1 100644 --- a/tests/topotests/lib/pim.py +++ b/tests/topotests/lib/pim.py @@ -525,6 +525,9 @@ def verify_pim_neighbors(tgen, topo, dut=None, iface=None, nbr_ip=None, expected if "pim" not in data: continue + if "pim" in data and data["pim"] == "disable": + continue + if "pim" in data and data["pim"] == "enable": local_interface = data["interface"] diff --git a/tests/topotests/multicast_pim_bsm_topo1/test_mcast_pim_bsmp_01.py b/tests/topotests/multicast_pim_bsm_topo1/test_mcast_pim_bsmp_01.py index ceac78d88b..4610c5f15a 100644 --- a/tests/topotests/multicast_pim_bsm_topo1/test_mcast_pim_bsmp_01.py +++ b/tests/topotests/multicast_pim_bsm_topo1/test_mcast_pim_bsmp_01.py @@ -84,6 +84,7 @@ from lib.common_config import ( run_frr_cmd, required_linux_kernel_version, topo_daemons, + verify_rib, ) from lib.pim import ( @@ -106,6 +107,7 @@ from lib.pim import ( clear_pim_interface_traffic, get_pim_interface_traffic, McastTesterHelper, + verify_pim_neighbors, ) from lib.topolog import logger from lib.topojson import build_config_from_json @@ -180,6 +182,10 @@ def setup_module(mod): # Creating configuration from JSON build_config_from_json(tgen, topo) + # Verify PIM neighbors + result = verify_pim_neighbors(tgen, topo) + assert result is True, " Verify PIM neighbor: Failed Error: {}".format(result) + # XXX Replace this using "with McastTesterHelper()... " in each test if possible. global app_helper app_helper = McastTesterHelper(tgen) @@ -306,6 +312,14 @@ def pre_config_to_bsm(tgen, topo, tc_name, bsr, sender, receiver, fhr, rp, lhr, result = create_static_routes(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) + # Verifying static routes are installed + for dut, _nexthop in zip([fhr, rp, lhr], [next_hop, next_hop_rp, next_hop_lhr]): + input_routes = {dut: input_dict[dut]} + result = verify_rib(tgen, "ipv4", dut, input_routes, _nexthop) + assert result is True, "Testcase {} : Failed \n Error {}".format( + tc_name, result + ) + # RP Mapping rp_mapping = topo["routers"][bsr]["bsm"]["bsr_packets"][packet]["rp_mapping"] @@ -328,11 +342,24 @@ def pre_config_to_bsm(tgen, topo, tc_name, bsr, sender, receiver, fhr, rp, lhr, result = create_static_routes(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) + # Verifying static routes are installed + result = verify_rib(tgen, "ipv4", fhr, input_dict, next_hop_fhr) + assert result is True, "Testcase {} : Failed \n Error {}".format( + tc_name, result + ) + input_dict = { lhr: {"static_routes": [{"network": rp_list, "next_hop": next_hop_lhr}]}, } result = create_static_routes(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) + + # Verifying static routes are installed + result = verify_rib(tgen, "ipv4", lhr, input_dict, next_hop_lhr) + assert result is True, "Testcase {} : Failed \n Error {}".format( + tc_name, result + ) + return True @@ -443,6 +470,23 @@ def test_BSR_higher_prefer_ip_p0(request): result = create_static_routes(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) + # Verifying static routes are installed + for dut, _nexthop in zip(["i1", "l1"], [next_hop_rp, next_hop_lhr]): + input_routes = {dut: input_dict[dut]} + result = verify_rib(tgen, "ipv4", dut, input_routes, _nexthop) + assert result is True, "Testcase {} : Failed \n Error {}".format( + tc_name, result + ) + + for bsr_add, next_hop in zip([BSR1_ADDR, BSR2_ADDR], [NEXT_HOP1, NEXT_HOP2]): + input_routes = { + "f1": {"static_routes": [{"network": bsr_add, "next_hop": next_hop}]} + } + result = verify_rib(tgen, "ipv4", "f1", input_routes, next_hop) + assert result is True, "Testcase {} : Failed \n Error {}".format( + tc_name, result + ) + # Use scapy to send pre-defined packet from senser to receiver step("Send BSR packet from b1 to FHR") result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet9") @@ -626,6 +670,24 @@ def test_BSR_CRP_with_blackhole_address_p1(request): result = create_static_routes(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) + # Verifying static routes are installed + for dut, _nexthop in zip(["i1", "l1"], [next_hop_rp, next_hop_lhr]): + input_routes = {dut: input_dict[dut]} + result = verify_rib(tgen, "ipv4", dut, input_routes, _nexthop) + assert result is True, "Testcase {} : Failed \n Error {}".format( + tc_name, result + ) + + input_routes = { + "f1": {"static_routes": [{"network": CRP, "next_hop": next_hop_fhr}]} + } + result = verify_rib(tgen, "ipv4", "f1", input_routes, expected=False) + assert ( + result is not True + ), "Testcase {} : Failed \n " "Route is still present \n Error {}".format( + tc_name, result + ) + # Use scapy to send pre-defined packet from senser to receiver group = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet9"]["group"] @@ -642,6 +704,10 @@ def test_BSR_CRP_with_blackhole_address_p1(request): result = create_static_routes(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) + # Verifying static routes are installed + result = verify_rib(tgen, "ipv4", "f1", input_dict) + assert result is True, "Testcase {} : Failed \n Error {}".format(tc_name, result) + intf_f1_i1 = topo["routers"]["f1"]["links"]["i1"]["interface"] step("Verify bsm transit count is not increamented" "show ip pim interface traffic") state_dict = {"f1": {intf_f1_i1: ["bsmTx"]}} @@ -694,6 +760,28 @@ def test_BSR_CRP_with_blackhole_address_p1(request): result = create_static_routes(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) + # Verifying static routes are installed + input_dict = { + "f1": {"static_routes": [{"network": BSR1_ADDR, "next_hop": NEXT_HOP1}]} + } + result = verify_rib(tgen, "ipv4", "f1", input_dict, NEXT_HOP1) + assert result is True, "Testcase {} : Failed \n Error {}".format(tc_name, result) + + input_dict = { + "f1": { + "static_routes": [ + {"network": [BSR1_ADDR, CRP], "next_hop": "blackhole", "delete": True} + ] + } + } + result = verify_rib(tgen, "ipv4", "f1", input_dict, expected=False) + assert result is not True, ( + "Testcase {} : Failed \n " + "Routes:[{}, {}] are still present \n Error {}".format( + tc_name, BSR1_ADDR, CRP, result + ) + ) + step("Sending BSR after removing black-hole address for BSR and candidate RP") step("Send BSR packet from b1 to FHR") result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet9") @@ -1614,6 +1702,14 @@ def test_iif_join_state_p0(request): result = create_static_routes(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) + # Verifying static routes are installed + result = verify_rib(tgen, "ipv4", "l1", input_dict, expected=False) + assert ( + result is not True + ), "Testcase {} : Failed \n " "Routes:{} are still present \n Error {}".format( + tc_name, rp_ip, result + ) + # Check RP unreachable step("Check RP unreachability") iif = "Unknown" @@ -1654,6 +1750,10 @@ def test_iif_join_state_p0(request): result = create_static_routes(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) + # Verifying static routes are installed + result = verify_rib(tgen, "ipv4", "l1", input_dict, next_hop_lhr) + assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) + # Verify that (*,G) installed in mroute again iif = "l1-i1-eth0" result = verify_mroutes(tgen, dut, src_addr, GROUP_ADDRESS, iif, oil) diff --git a/tests/topotests/multicast_pim_bsm_topo2/test_mcast_pim_bsmp_02.py b/tests/topotests/multicast_pim_bsm_topo2/test_mcast_pim_bsmp_02.py index 2d6062bf3c..191615cbbe 100644 --- a/tests/topotests/multicast_pim_bsm_topo2/test_mcast_pim_bsmp_02.py +++ b/tests/topotests/multicast_pim_bsm_topo2/test_mcast_pim_bsmp_02.py @@ -68,6 +68,7 @@ from lib.common_config import ( run_frr_cmd, required_linux_kernel_version, topo_daemons, + verify_rib, ) from lib.pim import ( @@ -86,6 +87,7 @@ from lib.pim import ( clear_mroute, clear_pim_interface_traffic, McastTesterHelper, + verify_pim_neighbors, ) from lib.topolog import logger from lib.topojson import build_config_from_json @@ -160,6 +162,10 @@ def setup_module(mod): # Creating configuration from JSON build_config_from_json(tgen, topo) + # Verify PIM neighbors + result = verify_pim_neighbors(tgen, topo) + assert result is True, " Verify PIM neighbor: Failed Error: {}".format(result) + # XXX Replace this using "with McastTesterHelper()... " in each test if possible. global app_helper app_helper = McastTesterHelper(tgen) @@ -247,6 +253,14 @@ def pre_config_to_bsm(tgen, topo, tc_name, bsr, sender, receiver, fhr, rp, lhr, result = create_static_routes(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) + # Verifying static routes are installed + for dut, _nexthop in zip([fhr, rp, lhr], [next_hop, next_hop_rp, next_hop_lhr]): + input_routes = {dut: input_dict[dut]} + result = verify_rib(tgen, "ipv4", dut, input_routes, _nexthop) + assert result is True, "Testcase {} : Failed \n Error {}".format( + tc_name, result + ) + # Add kernel route for source group = topo["routers"][bsr]["bsm"]["bsr_packets"][packet]["pkt_dst"] bsr_interface = topo["routers"][bsr]["links"][fhr]["interface"] @@ -285,11 +299,24 @@ def pre_config_to_bsm(tgen, topo, tc_name, bsr, sender, receiver, fhr, rp, lhr, result = create_static_routes(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) + # Verifying static routes are installed + result = verify_rib(tgen, "ipv4", fhr, input_dict, next_hop_fhr) + assert result is True, "Testcase {} : Failed \n Error {}".format( + tc_name, result + ) + input_dict = { lhr: {"static_routes": [{"network": rp_list, "next_hop": next_hop_lhr}]}, } result = create_static_routes(tgen, input_dict) assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) + + # Verifying static routes are installed + result = verify_rib(tgen, "ipv4", lhr, input_dict, next_hop_lhr) + assert result is True, "Testcase {} : Failed \n Error {}".format( + tc_name, result + ) + return True diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 828d2d73b0..a52bd7b116 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -1672,7 +1672,7 @@ DEFUNSH(VTYSH_ZEBRA, srv6_locator, srv6_locator_cmd, #ifdef HAVE_BGPD DEFUNSH(VTYSH_BGPD, router_bgp, router_bgp_cmd, - "router bgp [(1-4294967295) [<view|vrf> WORD]]", + "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", ROUTER_STR BGP_STR AS_STR "BGP view\nBGP VRF\n" "View/VRF name\n") diff --git a/zebra/zebra_nb_config.c b/zebra/zebra_nb_config.c index 87356408d0..dfb55b0d6d 100644 --- a/zebra/zebra_nb_config.c +++ b/zebra/zebra_nb_config.c @@ -1163,22 +1163,20 @@ int lib_vrf_zebra_l3vni_id_modify(struct nb_cb_modify_args *args) * if zebra vrf already mapped to different vni id. */ pn_dnode = yang_dnode_get_parent(args->dnode, "vrf"); - if (pn_dnode) { - vrfname = yang_dnode_get_string(pn_dnode, "./name"); - zvrf = zebra_vrf_lookup_by_name(vrfname); - if (!zvrf) { - snprintf(args->errmsg, args->errmsg_len, - "zebra vrf info not found for vrf:%s.", - vrfname); - return NB_ERR_VALIDATION; - } - if (zvrf->l3vni && zvrf->l3vni != vni) { - snprintf( - args->errmsg, args->errmsg_len, - "vni %u cannot be configured as vni %u is already configured under the vrf", - vni, zvrf->l3vni); - return NB_ERR_VALIDATION; - } + vrfname = yang_dnode_get_string(pn_dnode, "./name"); + zvrf = zebra_vrf_lookup_by_name(vrfname); + if (!zvrf) { + snprintf(args->errmsg, args->errmsg_len, + "zebra vrf info not found for vrf:%s.", + vrfname); + return NB_ERR_VALIDATION; + } + if (zvrf->l3vni && zvrf->l3vni != vni) { + snprintf( + args->errmsg, args->errmsg_len, + "vni %u cannot be configured as vni %u is already configured under the vrf", + vni, zvrf->l3vni); + return NB_ERR_VALIDATION; } /* Check if this VNI is already present in the system */ diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index cf09902d52..500f4b0f1b 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -324,8 +324,8 @@ static int zebra_nhg_insert_id(struct nhg_hash_entry *nhe) if (hash_lookup(zrouter.nhgs_id, nhe)) { flog_err( EC_ZEBRA_NHG_TABLE_INSERT_FAILED, - "Failed inserting NHG id=%u into the ID hash table, entry already exists", - nhe->id); + "Failed inserting NHG %pNG into the ID hash table, entry already exists", + nhe); return -1; } @@ -358,10 +358,9 @@ zebra_nhg_connect_depends(struct nhg_hash_entry *nhe, if (!zebra_nhg_depends_is_empty(nhe)) { frr_each(nhg_connected_tree, &nhe->nhg_depends, rb_node_dep) { if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s: nhe %p (%u), dep %p (%u)", - __func__, nhe, nhe->id, - rb_node_dep->nhe, - rb_node_dep->nhe->id); + zlog_debug("%s: nhe %p (%pNG), dep %p (%pNG)", + __func__, nhe, nhe, rb_node_dep->nhe, + rb_node_dep->nhe); zebra_nhg_dependents_add(rb_node_dep->nhe, nhe); } @@ -470,9 +469,9 @@ static void *zebra_nhg_hash_alloc(void *arg) else { if (IS_ZEBRA_DEBUG_NHG) zlog_debug( - "Failed to lookup an interface with ifindex=%d in vrf=%u for NHE id=%u", + "Failed to lookup an interface with ifindex=%d in vrf=%u for NHE %pNG", nhe->nhg.nexthop->ifindex, - nhe->nhg.nexthop->vrf_id, nhe->id); + nhe->nhg.nexthop->vrf_id, nhe); } } @@ -706,9 +705,7 @@ static bool zebra_nhe_find(struct nhg_hash_entry **nhe, /* return value */ (*nhe) = hash_lookup(zrouter.nhgs, lookup); if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s: lookup => %p (%u)", - __func__, (*nhe), - (*nhe) ? (*nhe)->id : 0); + zlog_debug("%s: lookup => %p (%pNG)", __func__, *nhe, *nhe); /* If we found an existing object, we're done */ if (*nhe) @@ -745,8 +742,8 @@ static bool zebra_nhe_find(struct nhg_hash_entry **nhe, /* return value */ *nhe = newnhe; if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s: => created %p (%u)", __func__, newnhe, - newnhe->id); + zlog_debug("%s: => created %p (%pNG)", __func__, newnhe, + newnhe); /* Only hash/lookup the depends if the first lookup * fails to find something. This should hopefully save a @@ -928,8 +925,7 @@ static struct nhg_hash_entry *zebra_nhg_find_nexthop(uint32_t id, zebra_nhg_find(&nhe, id, &nhg, NULL, vrf_id, afi, type, from_dplane); if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s: nh %pNHv => %p (%u)", - __func__, nh, nhe, nhe ? nhe->id : 0); + zlog_debug("%s: nh %pNHv => %p (%pNG)", __func__, nh, nhe, nhe); return nhe; } @@ -1096,7 +1092,7 @@ static void zebra_nhg_release_all_deps(struct nhg_hash_entry *nhe) static void zebra_nhg_release(struct nhg_hash_entry *nhe) { if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s: nhe %p (%u)", __func__, nhe, nhe->id); + zlog_debug("%s: nhe %p (%pNG)", __func__, nhe, nhe); zebra_nhg_release_all_deps(nhe); @@ -1135,8 +1131,8 @@ static void zebra_nhg_handle_kernel_state_change(struct nhg_hash_entry *nhe, if (nhe->refcnt) { flog_err( EC_ZEBRA_NHG_SYNC, - "Kernel %s a nexthop group with ID (%u) that we are still using for a route, sending it back down", - (is_delete ? "deleted" : "updated"), nhe->id); + "Kernel %s a nexthop group with ID (%pNG) that we are still using for a route, sending it back down", + (is_delete ? "deleted" : "updated"), nhe); UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED); zebra_nhg_install_kernel(nhe); @@ -1199,7 +1195,7 @@ static int nhg_ctx_process_new(struct nhg_ctx *ctx) } if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s: nhe %p (%u) is new", __func__, nhe, nhe->id); + zlog_debug("%s: nhe %p (%pNG) is new", __func__, nhe, nhe); /* * If daemon nhg from the kernel, add a refcnt here to indicate the @@ -1389,8 +1385,7 @@ static struct nhg_hash_entry *depends_find_singleton(const struct nexthop *nh, nexthop_del_srv6_seg6(&lookup); if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s: nh %pNHv => %p (%u)", - __func__, nh, nhe, nhe ? nhe->id : 0); + zlog_debug("%s: nh %pNHv => %p (%pNG)", __func__, nh, nhe, nhe); return nhe; } @@ -1413,10 +1408,10 @@ static struct nhg_hash_entry *depends_find(const struct nexthop *nh, afi_t afi, if (IS_ZEBRA_DEBUG_NHG_DETAIL) { - zlog_debug("%s: nh %pNHv %s => %p (%u)", __func__, nh, + zlog_debug("%s: nh %pNHv %s => %p (%pNG)", __func__, nh, CHECK_FLAG(nh->flags, NEXTHOP_FLAG_RECURSIVE) ? "(R)" : "", - nhe, nhe ? nhe->id : 0); + nhe, nhe); } done: @@ -1495,8 +1490,7 @@ struct nhg_hash_entry *zebra_nhg_rib_find(uint32_t id, zebra_nhg_find(&nhe, id, nhg, NULL, vrf_id, rt_afi, type, false); if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s: => nhe %p (%u)", - __func__, nhe, nhe ? nhe->id : 0); + zlog_debug("%s: => nhe %p (%pNG)", __func__, nhe, nhe); return nhe; } @@ -1514,13 +1508,12 @@ zebra_nhg_rib_find_nhe(struct nhg_hash_entry *rt_nhe, afi_t rt_afi) } if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s: rt_nhe %p (%u)", __func__, rt_nhe, rt_nhe->id); + zlog_debug("%s: rt_nhe %p (%pNG)", __func__, rt_nhe, rt_nhe); zebra_nhe_find(&nhe, rt_nhe, NULL, rt_afi, false); if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s: => nhe %p (%u)", - __func__, nhe, nhe ? nhe->id : 0); + zlog_debug("%s: => nhe %p (%pNG)", __func__, nhe, nhe); return nhe; } @@ -1604,16 +1597,16 @@ void zebra_nhg_free(struct nhg_hash_entry *nhe) if (IS_ZEBRA_DEBUG_NHG_DETAIL) { /* Group or singleton? */ if (nhe->nhg.nexthop && nhe->nhg.nexthop->next) - zlog_debug("%s: nhe %p (%u), refcnt %d", - __func__, nhe, nhe->id, nhe->refcnt); + zlog_debug("%s: nhe %p (%pNG), refcnt %d", __func__, + nhe, nhe, nhe->refcnt); else - zlog_debug("%s: nhe %p (%u), refcnt %d, NH %pNHv", - __func__, nhe, nhe->id, nhe->refcnt, + zlog_debug("%s: nhe %p (%pNG), refcnt %d, NH %pNHv", + __func__, nhe, nhe, nhe->refcnt, nhe->nhg.nexthop); } if (nhe->refcnt) - zlog_debug("nhe_id=%u hash refcnt=%d", nhe->id, nhe->refcnt); + zlog_debug("nhe_id=%pNG hash refcnt=%d", nhe, nhe->refcnt); zebra_nhg_free_members(nhe); @@ -1629,9 +1622,8 @@ void zebra_nhg_hash_free(void *p) void zebra_nhg_decrement_ref(struct nhg_hash_entry *nhe) { if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s: nhe %p (%u) %d => %d", - __func__, nhe, nhe->id, nhe->refcnt, - nhe->refcnt - 1); + zlog_debug("%s: nhe %p (%pNG) %d => %d", __func__, nhe, nhe, + nhe->refcnt, nhe->refcnt - 1); nhe->refcnt--; @@ -1645,9 +1637,8 @@ void zebra_nhg_decrement_ref(struct nhg_hash_entry *nhe) void zebra_nhg_increment_ref(struct nhg_hash_entry *nhe) { if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s: nhe %p (%u) %d => %d", - __func__, nhe, nhe->id, nhe->refcnt, - nhe->refcnt + 1); + zlog_debug("%s: nhe %p (%pNG) %d => %d", __func__, nhe, nhe, + nhe->refcnt, nhe->refcnt + 1); nhe->refcnt++; @@ -2287,9 +2278,9 @@ static int nexthop_active(struct nexthop *nexthop, struct nhg_hash_entry *nhe, } if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s: CONNECT match %p (%u), newhop %pNHv", - __func__, match, - match->nhe->id, newhop); + zlog_debug( + "%s: CONNECT match %p (%pNG), newhop %pNHv", + __func__, match, match->nhe, newhop); return 1; } else if (CHECK_FLAG(flags, ZEBRA_FLAG_ALLOW_RECURSION)) { @@ -2302,9 +2293,9 @@ static int nexthop_active(struct nexthop *nexthop, struct nhg_hash_entry *nhe, /* Only useful if installed */ if (!CHECK_FLAG(match->status, ROUTE_ENTRY_INSTALLED)) { if (IS_ZEBRA_DEBUG_RIB_DETAILED) - zlog_debug("%s: match %p (%u) not installed", - __func__, match, - match->nhe->id); + zlog_debug( + "%s: match %p (%pNG) not installed", + __func__, match, match->nhe); goto done_with_match; } @@ -2319,9 +2310,10 @@ static int nexthop_active(struct nexthop *nexthop, struct nhg_hash_entry *nhe, continue; if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s: RECURSIVE match %p (%u), newhop %pNHv", - __func__, match, - match->nhe->id, newhop); + zlog_debug( + "%s: RECURSIVE match %p (%pNG), newhop %pNHv", + __func__, match, match->nhe, + newhop); SET_FLAG(nexthop->flags, NEXTHOP_FLAG_RECURSIVE); @@ -2355,9 +2347,10 @@ static int nexthop_active(struct nexthop *nexthop, struct nhg_hash_entry *nhe, continue; if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s: RECURSIVE match backup %p (%u), newhop %pNHv", - __func__, match, - match->nhe->id, newhop); + zlog_debug( + "%s: RECURSIVE match backup %p (%pNG), newhop %pNHv", + __func__, match, match->nhe, + newhop); SET_FLAG(nexthop->flags, NEXTHOP_FLAG_RECURSIVE); @@ -2702,9 +2695,8 @@ int nexthop_active_update(struct route_node *rn, struct route_entry *re) curr_nhe = zebra_nhe_copy(re->nhe, re->nhe->id); if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s: re %p nhe %p (%u), curr_nhe %p", - __func__, re, re->nhe, re->nhe->id, - curr_nhe); + zlog_debug("%s: re %p nhe %p (%pNG), curr_nhe %p", __func__, re, + re->nhe, re->nhe, curr_nhe); /* Clear the existing id, if any: this will avoid any confusion * if the id exists, and will also force the creation @@ -2742,9 +2734,10 @@ backups_done: new_nhe = zebra_nhg_rib_find_nhe(curr_nhe, rt_afi); if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s: re %p CHANGED: nhe %p (%u) => new_nhe %p (%u)", - __func__, re, re->nhe, - re->nhe->id, new_nhe, new_nhe->id); + zlog_debug( + "%s: re %p CHANGED: nhe %p (%pNG) => new_nhe %p (%pNG)", + __func__, re, re->nhe, re->nhe, new_nhe, + new_nhe); route_entry_update_nhe(re, new_nhe); } @@ -2803,8 +2796,8 @@ static uint8_t zebra_nhg_nhe2grp_internal(struct nh_grp *grp, if (!depend) { flog_err( EC_ZEBRA_NHG_FIB_UPDATE, - "Failed to recursively resolve Nexthop Hash Entry in the group id=%u", - nhe->id); + "Failed to recursively resolve Nexthop Hash Entry in the group id=%pNG", + nhe); continue; } } @@ -2909,8 +2902,8 @@ void zebra_nhg_install_kernel(struct nhg_hash_entry *nhe) case ZEBRA_DPLANE_REQUEST_FAILURE: flog_err( EC_ZEBRA_DP_INSTALL_FAIL, - "Failed to install Nexthop ID (%u) into the kernel", - nhe->id); + "Failed to install Nexthop ID (%pNG) into the kernel", + nhe); break; case ZEBRA_DPLANE_REQUEST_SUCCESS: SET_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED); @@ -2932,8 +2925,8 @@ void zebra_nhg_uninstall_kernel(struct nhg_hash_entry *nhe) case ZEBRA_DPLANE_REQUEST_FAILURE: flog_err( EC_ZEBRA_DP_DELETE_FAIL, - "Failed to uninstall Nexthop ID (%u) from the kernel", - nhe->id); + "Failed to uninstall Nexthop ID (%pNG) from the kernel", + nhe); break; case ZEBRA_DPLANE_REQUEST_SUCCESS: UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED); @@ -3006,8 +2999,8 @@ void zebra_nhg_dplane_result(struct zebra_dplane_ctx *ctx) !PROTO_OWNED(nhe))) flog_err( EC_ZEBRA_DP_INSTALL_FAIL, - "Failed to install Nexthop ID (%u) into the kernel", - nhe->id); + "Failed to install Nexthop (%pNG) into the kernel", + nhe); } break; @@ -3358,14 +3351,14 @@ struct nhg_hash_entry *zebra_nhg_proto_del(uint32_t id, int type) if (nhe->refcnt > 1) { if (IS_ZEBRA_DEBUG_NHG) zlog_debug( - "%s: id %u, still being used by routes refcnt %u", - __func__, nhe->id, nhe->refcnt); + "%s: %pNG, still being used by routes refcnt %u", + __func__, nhe, nhe->refcnt); return nhe; } if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s: deleted nhe %p (%u), vrf %d, type %s", __func__, - nhe, nhe->id, nhe->vrf_id, + zlog_debug("%s: deleted nhe %p (%pNG), vrf %d, type %s", + __func__, nhe, nhe, nhe->vrf_id, zebra_route_string(nhe->type)); return nhe; @@ -3388,8 +3381,8 @@ static void zebra_nhg_score_proto_entry(struct hash_bucket *bucket, void *arg) if (nhe->type == iter->type && PROTO_OWNED(nhe)) { if (IS_ZEBRA_DEBUG_NHG_DETAIL) zlog_debug( - "%s: found nhe %p (%u), vrf %d, type %s after client disconnect", - __func__, nhe, nhe->id, nhe->vrf_id, + "%s: found nhe %p (%pNG), vrf %d, type %s after client disconnect", + __func__, nhe, nhe, nhe->vrf_id, zebra_route_string(nhe->type)); /* Add to removal list */ @@ -3425,3 +3418,32 @@ unsigned long zebra_nhg_score_proto(int type) return count; } + +printfrr_ext_autoreg_p("NG", printfrr_nhghe); +static ssize_t printfrr_nhghe(struct fbuf *buf, struct printfrr_eargs *ea, + const void *ptr) +{ + const struct nhg_hash_entry *nhe = ptr; + const struct nhg_connected *dep; + ssize_t ret = 0; + + if (!nhe) + return bputs(buf, "[NULL]"); + + ret += bprintfrr(buf, "%u[", nhe->id); + if (nhe->ifp) + ret += printfrr_nhs(buf, nhe->nhg.nexthop); + else { + int count = zebra_nhg_depends_count(nhe); + + frr_each (nhg_connected_tree_const, &nhe->nhg_depends, dep) { + ret += bprintfrr(buf, "%u", dep->nhe->id); + if (count > 1) + ret += bputs(buf, "/"); + count--; + } + } + + ret += bputs(buf, "]"); + return ret; +} diff --git a/zebra/zebra_nhg.h b/zebra/zebra_nhg.h index 3fbf778be2..0863d90a7e 100644 --- a/zebra/zebra_nhg.h +++ b/zebra/zebra_nhg.h @@ -364,6 +364,10 @@ extern void zebra_nhg_mark_keep(void); struct route_entry; /* Forward ref to avoid circular includes */ extern int nexthop_active_update(struct route_node *rn, struct route_entry *re); +#ifdef _FRR_ATTRIBUTE_PRINTFRR +#pragma FRR printfrr_ext "%pNG" (const struct nhg_hash_entry *) +#endif + #ifdef __cplusplus } #endif diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c index fda5ef02cf..3127d2d304 100644 --- a/zebra/zebra_ptm.c +++ b/zebra/zebra_ptm.c @@ -1294,10 +1294,6 @@ static void zebra_ptm_send_bfdd(struct stream *msg) /* Create copy for replication. */ msgc = stream_dup(msg); - if (msgc == NULL) { - zlog_debug("%s: not enough memory", __func__); - return; - } /* Send message to all running BFDd daemons. */ for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client)) { @@ -1308,10 +1304,6 @@ static void zebra_ptm_send_bfdd(struct stream *msg) /* Allocate more messages. */ msg = stream_dup(msgc); - if (msg == NULL) { - zlog_debug("%s: not enough memory", __func__); - return; - } } stream_free(msgc); @@ -1326,10 +1318,6 @@ static void zebra_ptm_send_clients(struct stream *msg) /* Create copy for replication. */ msgc = stream_dup(msg); - if (msgc == NULL) { - zlog_debug("%s: not enough memory", __func__); - return; - } /* Send message to all running client daemons. */ for (ALL_LIST_ELEMENTS_RO(zrouter.client_list, node, client)) { @@ -1340,10 +1328,6 @@ static void zebra_ptm_send_clients(struct stream *msg) /* Allocate more messages. */ msg = stream_dup(msgc); - if (msg == NULL) { - zlog_debug("%s: not enough memory", __func__); - return; - } } stream_free(msgc); diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 3756f8153c..be19b07d9d 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -3704,7 +3704,7 @@ static int zebra_ip_config(struct vty *vty) DEFUN (ip_zebra_import_table_distance, ip_zebra_import_table_distance_cmd, - "ip import-table (1-252) [distance (1-255)] [route-map WORD]", + "ip import-table (1-252) [distance (1-255)] [route-map RMAP_NAME]", IP_STR "import routes from non-main kernel table\n" "kernel routing table id\n" |
