On 2016 Sep 17 (Sat) at 13:15:56 +0200 (+0200), Peter Hessler wrote:
:On 2016 Sep 17 (Sat) at 04:50:29 -0600 (-0600), Theo de Raadt wrote:
::> route(8) for the ramdisks is not built with SMALL, so adding SMALL
::> won't help.
::
::Then you'll help it. By compiling them SMALL.
:
:Happilly.
:
:Tested on an amd64 bsd.rd. dhclient, route add, route del, route show,
:all still work, and it's slightly smaller.
:
:text data bss dec hex
:213397 8896 36896 259189 3f475 obj/route
:212677 8896 36896 258469 3f1a5 obj/route-SMALL
:
:
:OK?
:
:Index: distrib/special/route/Makefile
:===================================================================
:RCS file: /cvs/openbsd/src/distrib/special/route/Makefile,v
:retrieving revision 1.1
:diff -u -p -u -p -r1.1 Makefile
:--- distrib/special/route/Makefile 23 Dec 2014 17:16:03 -0000 1.1
:+++ distrib/special/route/Makefile 17 Sep 2016 11:09:59 -0000
:@@ -4,7 +4,7 @@ PROG= route
: MAN= route.8
: SRCS= route.c show.c
:
:-CFLAGS+= -Wall
:+CFLAGS+= -Wall -DSMALL
:
: route.o .depend lint tags: keywords.h
:
:
And with sbin/route/route.c updated to use SMALL
Index: sbin/route/route.c
===================================================================
RCS file: /cvs/openbsd/src/sbin/route/route.c,v
retrieving revision 1.191
diff -u -p -u -p -r1.191 route.c
--- sbin/route/route.c 15 Sep 2016 12:51:20 -0000 1.191
+++ sbin/route/route.c 17 Sep 2016 10:57:02 -0000
@@ -41,6 +41,10 @@
#include <netinet/in.h>
#include <netmpls/mpls.h>
+#ifndef SMALL
+#include <net/bfd.h>
+#endif
+
#include <arpa/inet.h>
#include <netdb.h>
@@ -90,6 +94,10 @@ void sodump(sup, char *);
char *priorityname(uint8_t);
uint8_t getpriority(char *);
void print_getmsg(struct rt_msghdr *, int);
+#ifndef SMALL
+const char *bfd_printstate(unsigned int);
+void print_bfdmsg(struct rt_msghdr *);
+#endif
const char *get_linkstate(int, int);
void print_rtmsg(struct rt_msghdr *, int);
void pmsg_common(struct rt_msghdr *);
@@ -1334,7 +1342,9 @@ print_rtmsg(struct rt_msghdr *rtm, int m
printf("\n");
break;
case RTM_BFD:
- printf("bfd\n"); /* XXX - expand*/
+#ifndef SMALL
+ print_bfdmsg(rtm);
+#endif
break;
default:
printf(", priority %d, table %u, ifidx %u, ",
@@ -1526,6 +1536,53 @@ print_getmsg(struct rt_msghdr *rtm, int
}
#undef RTA_IGN
}
+
+#ifndef SMALL
+const char *
+bfd_printstate(unsigned int state)
+{
+ switch (state) {
+ case BFD_STATE_ADMINDOWN: return("admindown");
+ case BFD_STATE_DOWN: return("down");
+ case BFD_STATE_INIT: return("init");
+ case BFD_STATE_UP: return("up");
+ }
+ return "invalid";
+}
+
+void
+print_bfdmsg(struct rt_msghdr *rtm)
+{
+ struct bfd_msghdr *bfdm = (struct bfd_msghdr *)rtm;
+
+ printf(" mode ");
+ switch (bfdm->bm_mode) {
+ case BFD_MODE_ASYNC:
+ printf("async");
+ break;
+ case BFD_MODE_DEMAND:
+ printf("demand");
+ break;
+ }
+ printf(" state %s", bfd_printstate(bfdm->bm_state));
+ printf(" remotestate %s", bfd_printstate(bfdm->bm_remotestate));
+ printf(" laststate %s", bfd_printstate(bfdm->bm_laststate));
+
+ printf(" error %d", bfdm->bm_error);
+ printf(" localdiscr %u", bfdm->bm_localdiscr);
+ printf(" remotediscr %u", bfdm->bm_remotediscr);
+ printf(" localdiag %u", bfdm->bm_localdiag);
+ printf(" remotediag %u", bfdm->bm_remotediag);
+ printf(" uptime %lld", bfdm->bm_uptime);
+ printf(" lastuptime %lld", bfdm->bm_lastuptime);
+
+ printf(" mintx %u", bfdm->bm_mintx);
+ printf(" minrx %u", bfdm->bm_minrx);
+ printf(" multiplier %u", bfdm->bm_multiplier);
+
+ pmsg_addrs(((char *)rtm + rtm->rtm_hdrlen), rtm->rtm_addrs);
+}
+#endif /* !SMALL */
void
pmsg_common(struct rt_msghdr *rtm)