On Fri, Nov 04, 2022 at 09:12:13AM +0100, Theo Buehler wrote:
> On Thu, Nov 03, 2022 at 03:26:35PM +0100, Claudio Jeker wrote:
> > Noticed while figuring out the kroute bug with MPLS.
> > I think it would be nice to know the MPLS label of a fib MPLS route.
> > 
> > bgpctl show fib table 13
> > flags: B = BGP, C = Connected, S = Static
> >        N = BGP Nexthop reachable via this route
> >        r = reject route, b = blackhole route
> > 
> > flags prio destination                      gateway                         
> > C        1 127.0.0.1/32                     link#129
> > B       48 192.168.44.0/24                  10.12.57.2 mpls 44
> > C        1 192.168.237.242/32               link#128
> > 
> > Not sure if the keyword should be "mpls" or "label".
> 
> I think something containing mpls is clearer. Did you deliberately use
> mpls in output.c and mplslabel in output_json.c?

Yes. The JSON label can be explicit while for the text output I prefer
something short to not overflow the line.
 
> ok
> 
> > -- 
> > :wq Claudio
> > 
> > Index: bgpctl.h
> > ===================================================================
> > RCS file: /cvs/src/usr.sbin/bgpctl/bgpctl.h,v
> > retrieving revision 1.17
> > diff -u -p -r1.17 bgpctl.h
> > --- bgpctl.h        17 Oct 2022 12:01:19 -0000      1.17
> > +++ bgpctl.h        3 Nov 2022 14:21:14 -0000
> > @@ -58,3 +58,5 @@ const char        *fmt_community(uint16_t, uint
> >  const char *fmt_large_community(uint32_t, uint32_t, uint32_t);
> >  const char *fmt_ext_community(uint8_t *);
> >  const char *fmt_set_type(struct ctl_show_set *);
> > +
> > +#define MPLS_LABEL_OFFSET 12
> > Index: output.c
> > ===================================================================
> > RCS file: /cvs/src/usr.sbin/bgpctl/output.c,v
> > retrieving revision 1.30
> > diff -u -p -r1.30 output.c
> > --- output.c        17 Oct 2022 12:01:19 -0000      1.30
> > +++ output.c        3 Nov 2022 14:21:33 -0000
> > @@ -477,6 +477,8 @@ show_fib(struct kroute_full *kf)
> >             printf("link#%u", kf->ifindex);
> >     else
> >             printf("%s", log_addr(&kf->nexthop));
> > +   if (kf->flags & F_MPLS)
> > +           printf(" mpls %d", ntohl(kf->mplslabel) >> MPLS_LABEL_OFFSET);
> >     printf("\n");
> >  }
> >  
> > Index: output_json.c
> > ===================================================================
> > RCS file: /cvs/src/usr.sbin/bgpctl/output_json.c,v
> > retrieving revision 1.24
> > diff -u -p -r1.24 output_json.c
> > --- output_json.c   17 Oct 2022 12:01:19 -0000      1.24
> > +++ output_json.c   3 Nov 2022 14:22:48 -0000
> > @@ -385,6 +385,9 @@ json_fib(struct kroute_full *kf)
> >     else
> >             json_do_printf("nexthop", "%s", log_addr(&kf->nexthop));
> >  
> > +   if (kf->flags & F_CONNECTED)
> > +           json_do_printf("mplslabel", "%d",
> > +               ntohl(kf->mplslabel) >> MPLS_LABEL_OFFSET);
> >     json_do_end();
> >  }
> >  
> > 
> 

-- 
:wq Claudio

Reply via email to