summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPascal Mathis <mail@pascalmathis.com>2018-08-14 17:36:41 +0200
committerPascal Mathis <mail@pascalmathis.com>2018-08-14 19:40:42 +0200
commit89e5e9f028210c35b7b609532e7a7e840e26901c (patch)
tree374c9e71c38ed221e64f3eabdf5a48fa42493561
parent6c705218232ce1513b2a43fa4e2307cc378a52f1 (diff)
bgpd: Always show CIDR mask when displaying routes
Classful networking has been obsolete for ages and there is currently an inconsistency between `show ip route` and `show bgp`, where the first one always displays the CIDR mask while the second one hides classful network masks. This commit adjusts the behavior of `show bgp` to always show the CIDR mask for a route, even when it is classful. Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
-rw-r--r--bgpd/bgp_route.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index d0dbb4221d..1ded492a20 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -6245,24 +6245,14 @@ static void route_vty_out_route(struct prefix *p, struct vty *vty,
json_object *json)
{
int len = 0;
- uint32_t destination;
char buf[BUFSIZ];
if (p->family == AF_INET) {
if (!json) {
- len = vty_out(vty, "%s",
- inet_ntop(p->family, &p->u.prefix, buf,
- BUFSIZ));
- destination = ntohl(p->u.prefix4.s_addr);
-
- if ((IN_CLASSC(destination) && p->prefixlen == 24)
- || (IN_CLASSB(destination) && p->prefixlen == 16)
- || (IN_CLASSA(destination) && p->prefixlen == 8)
- || p->u.prefix4.s_addr == 0) {
- /* When mask is natural,
- mask is not displayed. */
- } else
- len += vty_out(vty, "/%d", p->prefixlen);
+ len = vty_out(
+ vty, "%s/%d",
+ inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ),
+ p->prefixlen);
} else {
json_object_string_add(json, "prefix",
inet_ntop(p->family,