I have a lot of routes from various sources and would like to just look at the ones from a particular source. So I figure this would help me. Make sense to anyone else? Or is '-v' and grep deemed sufficient?
.... Ken Index: route.8 =================================================================== RCS file: /cvs/src/sbin/route/route.8,v retrieving revision 1.64 diff -u -p -r1.64 route.8 --- route.8 20 Dec 2009 15:35:13 -0000 1.64 +++ route.8 20 Sep 2010 04:24:05 -0000 @@ -165,6 +165,7 @@ are shown. .Cm show .Op Ar family .Op Fl gateway +.Op Fl label Ar label .Xc Print out the route table similar to "netstat -r" (see .Xr netstat 1 ) . @@ -173,6 +174,10 @@ If .Fl gateway is specified, only routes whose gateway are in the same address family as the destination are shown. +.Pp +If +.Fl label +is specified, only routes with the specified label are shown. .El .Pp The other commands relating to adding, changing, or deleting routes Index: route.c =================================================================== RCS file: /cvs/src/sbin/route/route.c,v retrieving revision 1.149 diff -u -p -r1.149 route.c --- route.c 4 Sep 2010 08:06:09 -0000 1.149 +++ route.c 20 Sep 2010 04:24:05 -0000 @@ -63,14 +63,7 @@ const struct if_status_description if_status_descriptions[] = LINK_STATE_DESCRIPTIONS; -union sockunion { - struct sockaddr sa; - struct sockaddr_in sin; - struct sockaddr_in6 sin6; - struct sockaddr_dl sdl; - struct sockaddr_rtlabel rtlabel; - struct sockaddr_mpls smpls; -} so_dst, so_gate, so_mask, so_genmask, so_ifa, so_ifp, so_label, so_src; +union sockunion so_dst, so_gate, so_mask, so_genmask, so_ifa, so_ifp, so_label, so_src; typedef union sockunion *sup; pid_t pid; @@ -681,6 +674,11 @@ show(int argc, char *argv[]) break; case K_GATEWAY: Fflag = 1; + break; + case K_LABEL: + if (!--argc) + usage(1+*argv); + getlabel(*++argv); break; default: usage(*argv); Index: show.c =================================================================== RCS file: /cvs/src/sbin/route/show.c,v retrieving revision 1.87 diff -u -p -r1.87 show.c --- show.c 29 Jul 2010 16:35:40 -0000 1.87 +++ show.c 20 Sep 2010 04:24:05 -0000 @@ -64,6 +64,7 @@ char *label_print(struct sockaddr *); extern int nflag; extern int Fflag; extern int verbose; +extern union sockunion so_label; #define PLEN (LONG_BIT / 4 + 2) /* XXX this is also defined in netstat.h */ @@ -285,14 +286,26 @@ p_rtentry(struct rt_msghdr *rtm) struct sockaddr *sa = (struct sockaddr *)((char *)rtm + rtm->rtm_hdrlen); struct sockaddr *mask, *rti_info[RTAX_MAX]; char ifbuf[IF_NAMESIZE]; + char *label; if (sa->sa_family == AF_KEY) return; get_rtaddrs(rtm->rtm_addrs, sa, rti_info); + if (Fflag && rti_info[RTAX_GATEWAY]->sa_family != sa->sa_family) { return; } + + if (strlen(so_label.rtlabel.sr_label)) { + if (!rti_info[RTAX_LABEL]) + return; + label = ((struct sockaddr_rtlabel *)rti_info[RTAX_LABEL])-> + sr_label; + if (strcmp(label, so_label.rtlabel.sr_label)) + return; + } + if (old_af != sa->sa_family) { old_af = sa->sa_family; pr_family(sa->sa_family); Index: show.h =================================================================== RCS file: /cvs/src/sbin/route/show.h,v retrieving revision 1.7 diff -u -p -r1.7 show.h --- show.h 23 Mar 2010 15:01:50 -0000 1.7 +++ show.h 20 Sep 2010 04:24:05 -0000 @@ -19,6 +19,15 @@ #ifndef __SHOW_H__ #define __SHOW_H__ +union sockunion { + struct sockaddr sa; + struct sockaddr_in sin; + struct sockaddr_in6 sin6; + struct sockaddr_dl sdl; + struct sockaddr_rtlabel rtlabel; + struct sockaddr_mpls smpls; +}; + void p_rttables(int, u_int); char *routename(struct sockaddr *); char *netname(struct sockaddr *, struct sockaddr *);