Skip to content

Commit

Permalink
pbrd: make show pbr map detail actually work
Browse files Browse the repository at this point in the history
The `detail` keyword was doing literally nothing. Changed the
default show to be a bit more user friendly and detail
to give the information you might would need for
debugging.

alfred# show pbr map
  pbr-map TEST1 valid: 1
    Seq: 222 rule: 521
    Installed: yes Reason: Valid
        SRC Match: 2.2.2.2/32
        Nexthop-Group: blue(10000) Installed: yes
    Seq: 333 rule: 632
    Installed: yes Reason: Valid
        SRC Match: 3.3.3.3/32
        Nexthop-Group: blue(10000) Installed: yes
    Seq: 444 rule: 743
    Installed: yes Reason: Valid
        SRC Match: 4.4.4.4/32
        Nexthop-Group: blue(10000) Installed: yes
    Seq: 555 rule: 854
    Installed: yes Reason: Valid
        SRC Match: 5.5.5.5/32
        Nexthop-Group: red(10001) Installed: yes
    Seq: 666 rule: 965
    Installed: yes Reason: Valid
        SRC Match: 6.6.6.6/32
     nexthop 1.1.1.1
        Installed: yes Tableid: 10002
alfred# show pbr map detail
  pbr-map TEST1 valid: 1
    Seq: 222 rule: 521
    Installed: 1(1) Reason: Valid
        SRC Match: 2.2.2.2/32
        Nexthop-Group: blue(10000) Installed: 1(1)
    Seq: 333 rule: 632
    Installed: 1(2) Reason: Valid
        SRC Match: 3.3.3.3/32
        Nexthop-Group: blue(10000) Installed: 1(1)
    Seq: 444 rule: 743
    Installed: 1(3) Reason: Valid
        SRC Match: 4.4.4.4/32
        Nexthop-Group: blue(10000) Installed: 1(1)
    Seq: 555 rule: 854
    Installed: 1(4) Reason: Valid
        SRC Match: 5.5.5.5/32
        Nexthop-Group: red(10001) Installed: 1(1)
    Seq: 666 rule: 965
    Installed: 1(5) Reason: Valid
        SRC Match: 6.6.6.6/32
     nexthop 1.1.1.1
        Installed: 1(1) Tableid: 10002
alfred#

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
  • Loading branch information
sworleys committed Dec 6, 2019
1 parent 1eaa836 commit 3259cde
Showing 1 changed file with 38 additions and 13 deletions.
51 changes: 38 additions & 13 deletions pbrd/pbr_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,10 +532,17 @@ static void vty_show_pbrms(struct vty *vty,

if (pbrms->reason)
pbr_map_reason_string(pbrms->reason, rbuf, sizeof(rbuf));
vty_out(vty,
" Seq: %u rule: %u Installed: %" PRIu64 "(%u) Reason: %s\n",
pbrms->seqno, pbrms->ruleno, pbrms->installed, pbrms->unique,
pbrms->reason ? rbuf : "Valid");

vty_out(vty, " Seq: %u rule: %u\n", pbrms->seqno, pbrms->ruleno);

if (detail)
vty_out(vty, " Installed: %" PRIu64 "(%u) Reason: %s\n",
pbrms->installed, pbrms->unique,
pbrms->reason ? rbuf : "Valid");
else
vty_out(vty, " Installed: %s Reason: %s\n",
pbrms->installed ? "yes" : "no",
pbrms->reason ? rbuf : "Valid");

if (pbrms->src)
vty_out(vty, "\tSRC Match: %s\n",
Expand All @@ -547,23 +554,41 @@ static void vty_show_pbrms(struct vty *vty,
vty_out(vty, "\tMARK Match: %u\n", pbrms->mark);

if (pbrms->nhgrp_name) {
vty_out(vty, "\tNexthop-Group: %s(%u) Installed: %u(%d)\n",
pbrms->nhgrp_name, pbr_nht_get_table(pbrms->nhgrp_name),
pbrms->nhs_installed,
pbr_nht_get_installed(pbrms->nhgrp_name));
if (detail)
vty_out(vty,
"\tNexthop-Group: %s(%u) Installed: %u(%d)\n",
pbrms->nhgrp_name,
pbr_nht_get_table(pbrms->nhgrp_name),
pbrms->nhs_installed,
pbr_nht_get_installed(pbrms->nhgrp_name));
else
vty_out(vty, "\tNexthop-Group: %s(%u) Installed: %s\n",
pbrms->nhgrp_name,
pbr_nht_get_table(pbrms->nhgrp_name),
pbr_nht_get_installed(pbrms->nhgrp_name)
? "yes"
: "no");
} else if (pbrms->nhg) {
vty_out(vty, " ");
nexthop_group_write_nexthop(vty, pbrms->nhg->nexthop);
vty_out(vty, "\tInstalled: %u(%d) Tableid: %d\n",
pbrms->nhs_installed,
pbr_nht_get_installed(pbrms->internal_nhg_name),
pbr_nht_get_table(pbrms->internal_nhg_name));
if (detail)
vty_out(vty, "\tInstalled: %u(%d) Tableid: %d\n",
pbrms->nhs_installed,
pbr_nht_get_installed(pbrms->internal_nhg_name),
pbr_nht_get_table(pbrms->internal_nhg_name));
else
vty_out(vty, "\tInstalled: %s Tableid: %d\n",
pbr_nht_get_installed(pbrms->internal_nhg_name)
? "yes"
: "no",
pbr_nht_get_table(pbrms->internal_nhg_name));

} else if (pbrms->vrf_unchanged) {
vty_out(vty, "\tVRF Unchanged (use interface vrf)\n");
} else if (pbrms->vrf_lookup) {
vty_out(vty, "\tVRF Lookup: %s\n", pbrms->vrf_name);
} else {
vty_out(vty, "\tNexthop-Group: Unknown Installed: 0(0)\n");
vty_out(vty, "\tNexthop-Group: Unknown Installed: no\n");
}
}

Expand Down

0 comments on commit 3259cde

Please sign in to comment.