struct bgp_nexthop_cache *bnc)
{
if (peer->hostname
- && CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHOW_HOSTNAME) && bnc
- && CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED))
+ && CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME))
return peer->hostname;
return NULL;
}
struct bgp_path_info *path, int display, safi_t safi,
json_object *json_paths)
{
+ int len;
struct attr *attr = path->attr;
json_object *json_path = NULL;
json_object *json_nexthops = NULL;
: "ipv6");
json_object_boolean_true_add(json_nexthop_global,
"used");
- } else
- vty_out(vty, "%s%s",
- nexthop_hostname ? nexthop_hostname : nexthop,
- vrf_id_str);
+ } else {
+ if (nexthop_hostname)
+ len = vty_out(vty, "%s(%s)%s", nexthop,
+ nexthop_hostname, vrf_id_str);
+ else
+ len = vty_out(vty, "%s%s", nexthop, vrf_id_str);
+
+ len = 16 - len;
+ if (len < 1)
+ vty_out(vty, "\n%*s", 36, " ");
+ else
+ vty_out(vty, "%*s", len, " ");
+ }
} else if (safi == SAFI_EVPN) {
if (json_paths) {
json_nexthop_global = json_object_new_object();
"ipv4");
json_object_boolean_true_add(json_nexthop_global,
"used");
- } else
- vty_out(vty, "%-16s%s",
- nexthop_hostname ? nexthop_hostname
- : inet_ntoa(attr->nexthop),
- vrf_id_str);
+ } else {
+ if (nexthop_hostname)
+ len = vty_out(vty, "%pI4(%s)%s", &attr->nexthop,
+ nexthop_hostname, vrf_id_str);
+ else
+ len = vty_out(vty, "%pI4%s", &attr->nexthop,
+ vrf_id_str);
+
+ len = 16 - len;
+ if (len < 1)
+ vty_out(vty, "\n%*s", 36, " ");
+ else
+ vty_out(vty, "%*s", len, " ");
+ }
} else if (safi == SAFI_FLOWSPEC) {
if (attr->nexthop.s_addr != INADDR_ANY) {
if (json_paths) {
json_nexthop_global,
"used");
} else {
- vty_out(vty, "%-16s",
- nexthop_hostname
- ? nexthop_hostname
- : inet_ntoa(attr->nexthop));
+ if (nexthop_hostname)
+ len = vty_out(vty, "%pI4(%s)%s",
+ &attr->nexthop,
+ nexthop_hostname,
+ vrf_id_str);
+ else
+ len = vty_out(vty, "%pI4%s",
+ &attr->nexthop,
+ vrf_id_str);
+
+ len = 16 - len;
+ if (len < 1)
+ vty_out(vty, "\n%*s", 36, " ");
+ else
+ vty_out(vty, "%*s", len, " ");
}
}
} else if (p->family == AF_INET && !BGP_ATTR_NEXTHOP_AFI_IP6(attr)) {
json_object_boolean_true_add(json_nexthop_global,
"used");
} else {
- char buf[BUFSIZ];
+ if (nexthop_hostname)
+ len = vty_out(vty, "%pI4(%s)%s", &attr->nexthop,
+ nexthop_hostname, vrf_id_str);
+ else
+ len = vty_out(vty, "%pI4%s", &attr->nexthop,
+ vrf_id_str);
- snprintf(buf, sizeof(buf), "%s%s",
- nexthop_hostname ? nexthop_hostname
- : inet_ntoa(attr->nexthop),
- vrf_id_str);
- vty_out(vty, "%-16s", buf);
+ len = 16 - len;
+ if (len < 1)
+ vty_out(vty, "\n%*s", 36, " ");
+ else
+ vty_out(vty, "%*s", len, " ");
}
}
/* IPv6 Next Hop */
else if (p->family == AF_INET6 || BGP_ATTR_NEXTHOP_AFI_IP6(attr)) {
- int len;
char buf[BUFSIZ];
if (json_paths) {
else
vty_out(vty, "%*s", len, " ");
} else {
- len = vty_out(
- vty, "%s%s",
- nexthop_hostname
- ? nexthop_hostname
- : inet_ntop(
- AF_INET6,
- &attr->mp_nexthop_local,
- buf, BUFSIZ),
- vrf_id_str);
+ if (nexthop_hostname)
+ len = vty_out(
+ vty, "%pI6(%s)%s",
+ &attr->mp_nexthop_local,
+ nexthop_hostname,
+ vrf_id_str);
+ else
+ len = vty_out(
+ vty, "%pI6%s",
+ &attr->mp_nexthop_local,
+ vrf_id_str);
+
len = 16 - len;
if (len < 1)
vty_out(vty, "%*s", len, " ");
}
} else {
- len = vty_out(
- vty, "%s%s",
- nexthop_hostname
- ? nexthop_hostname
- : inet_ntop(
- AF_INET6,
- &attr->mp_nexthop_global,
- buf, BUFSIZ),
- vrf_id_str);
+ if (nexthop_hostname)
+ len = vty_out(vty, "%pI6(%s)%s",
+ &attr->mp_nexthop_global,
+ nexthop_hostname,
+ vrf_id_str);
+ else
+ len = vty_out(vty, "%pI6%s",
+ &attr->mp_nexthop_global,
+ vrf_id_str);
+
len = 16 - len;
if (len < 1)
{
json_object *json_status = NULL;
json_object *json_net = NULL;
+ int len;
char buff[BUFSIZ];
/* Route status display. */
inet_ntoa(attr->nexthop));
} else if (p->family == AF_INET6
|| BGP_ATTR_NEXTHOP_AFI_IP6(attr)) {
- int len;
char buf[BUFSIZ];
len = vty_out(
json_object_string_add(
json_nexthop_global, "hostname",
nexthop_hostname);
- } else
- vty_out(vty, " %s",
- nexthop_hostname
- ? nexthop_hostname
- : inet_ntoa(
- attr->mp_nexthop_global_in));
+ } else {
+ if (nexthop_hostname)
+ vty_out(vty, " %pI4(%s)",
+ &attr->mp_nexthop_global_in,
+ nexthop_hostname);
+ else
+ vty_out(vty, " %pI4",
+ &attr->mp_nexthop_global_in);
+ }
} else {
if (json_paths) {
json_object_string_add(
json_object_string_add(
json_nexthop_global, "hostname",
nexthop_hostname);
- } else
- vty_out(vty, " %s",
- nexthop_hostname
- ? nexthop_hostname
- : inet_ntoa(attr->nexthop));
+ } else {
+ if (nexthop_hostname)
+ vty_out(vty, " %pI4(%s)",
+ &attr->nexthop,
+ nexthop_hostname);
+ else
+ vty_out(vty, " %pI4",
+ &attr->nexthop);
+ }
}
if (json_paths)
json_object_string_add(json_nexthop_global, "scope",
"global");
} else {
- vty_out(vty, " %s",
- nexthop_hostname
- ? nexthop_hostname
- : inet_ntop(AF_INET6,
- &attr->mp_nexthop_global,
- buf, INET6_ADDRSTRLEN));
+ if (nexthop_hostname)
+ vty_out(vty, " %pI6(%s)",
+ &attr->mp_nexthop_global,
+ nexthop_hostname);
+ else
+ vty_out(vty, " %pI6",
+ &attr->mp_nexthop_global);
}
}
{ .val_bool = true, .match_profile = "datacenter", },
{ .val_bool = false },
)
+FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME,
+ { .val_bool = true, .match_profile = "datacenter", },
+ { .val_bool = false },
+)
FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES,
{ .val_bool = true, .match_profile = "datacenter", },
{ .val_bool = false },
SET_FLAG((*bgp)->flags, BGP_FLAG_IMPORT_CHECK);
if (DFLT_BGP_SHOW_HOSTNAME)
SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_HOSTNAME);
+ if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME)
+ SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME);
if (DFLT_BGP_LOG_NEIGHBOR_CHANGES)
SET_FLAG((*bgp)->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
if (DFLT_BGP_DETERMINISTIC_MED)
return CMD_SUCCESS;
}
+/* Display hostname in certain command outputs */
+DEFUN (bgp_default_show_nexthop_hostname,
+ bgp_default_show_nexthop_hostname_cmd,
+ "bgp default show-nexthop-hostname",
+ "BGP specific commands\n"
+ "Configure BGP defaults\n"
+ "Show hostname for nexthop in certain command outputs\n")
+{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ SET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME);
+ return CMD_SUCCESS;
+}
+
+DEFUN (no_bgp_default_show_nexthop_hostname,
+ no_bgp_default_show_nexthop_hostname_cmd,
+ "no bgp default show-nexthop-hostname",
+ NO_STR
+ "BGP specific commands\n"
+ "Configure BGP defaults\n"
+ "Show hostname for nexthop in certain command outputs\n")
+{
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME);
+ return CMD_SUCCESS;
+}
+
/* "bgp network import-check" configuration. */
DEFUN (bgp_network_import_check,
bgp_network_import_check_cmd,
? ""
: "no ");
+ /* BGP default show-nexthop-hostname */
+ if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME)
+ != SAVE_BGP_SHOW_HOSTNAME)
+ vty_out(vty, " %sbgp default show-nexthop-hostname\n",
+ CHECK_FLAG(bgp->flags,
+ BGP_FLAG_SHOW_NEXTHOP_HOSTNAME)
+ ? ""
+ : "no ");
+
/* BGP default subgroup-pkt-queue-max. */
if (bgp->default_subgroup_pkt_queue_max
!= BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX)
install_element(BGP_NODE, &bgp_default_show_hostname_cmd);
install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd);
+ /* bgp default show-nexthop-hostname */
+ install_element(BGP_NODE, &bgp_default_show_nexthop_hostname_cmd);
+ install_element(BGP_NODE, &no_bgp_default_show_nexthop_hostname_cmd);
+
/* "bgp default subgroup-pkt-queue-max" commands. */
install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd);
install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd);