diff options
-rw-r--r-- | sbin/route/keywords.h | 4 | ||||
-rw-r--r-- | sbin/route/keywords.sh | 3 | ||||
-rw-r--r-- | sbin/route/route.c | 29 | ||||
-rw-r--r-- | sbin/route/show.c | 16 |
4 files changed, 34 insertions, 18 deletions
diff --git a/sbin/route/keywords.h b/sbin/route/keywords.h index 4296c55f06b..3793352c3cc 100644 --- a/sbin/route/keywords.h +++ b/sbin/route/keywords.h @@ -1,4 +1,4 @@ -/* $OpenBSD: keywords.h,v 1.22 2008/05/06 03:40:51 claudio Exp $ */ +/* $OpenBSD: keywords.h,v 1.23 2008/05/07 06:06:25 claudio Exp $ */ /* WARNING! This file was generated by keywords.sh */ @@ -47,6 +47,7 @@ enum { K_OUT, K_POP, K_PREFIXLEN, + K_PRIORITY, K_PROTO1, K_PROTO2, K_PUSH, @@ -102,6 +103,7 @@ struct keytab keywords[] = { { "out", K_OUT }, { "pop", K_POP }, { "prefixlen", K_PREFIXLEN }, + { "priority", K_PRIORITY }, { "proto1", K_PROTO1 }, { "proto2", K_PROTO2 }, { "push", K_PUSH }, diff --git a/sbin/route/keywords.sh b/sbin/route/keywords.sh index 3fedaa05994..0edd835b71f 100644 --- a/sbin/route/keywords.sh +++ b/sbin/route/keywords.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $OpenBSD: keywords.sh,v 1.21 2008/05/06 03:40:31 claudio Exp $ +# $OpenBSD: keywords.sh,v 1.22 2008/05/07 06:06:25 claudio Exp $ # $NetBSD: keywords.sh,v 1.2 1996/11/15 18:57:21 gwr Exp $ # @(#)keywords 8.2 (Berkeley) 3/19/94 # @@ -47,6 +47,7 @@ nostatic out pop prefixlen +priority proto1 proto2 push diff --git a/sbin/route/route.c b/sbin/route/route.c index ce5f008cf44..258b49b1fb4 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.116 2008/05/06 12:53:32 claudio Exp $ */ +/* $OpenBSD: route.c,v 1.117 2008/05/07 06:06:25 claudio Exp $ */ /* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */ /* @@ -102,7 +102,7 @@ void mask_addr(union sockunion *, union sockunion *, int); int inet6_makenetandmask(struct sockaddr_in6 *); int getaddr(int, char *, struct hostent **); void getmplslabel(char *, int); -int rtmsg(int, int, int); +int rtmsg(int, int, int, u_short); __dead void usage(char *); void set_metric(char *, int); void inet_makenetandmask(u_int32_t, struct sockaddr_in *, int); @@ -345,10 +345,12 @@ set_metric(char *value, int key) int newroute(int argc, char **argv) { + const char *errstr; char *cmd, *dest = "", *gateway = "", *error; int ishost = 0, ret = 0, attempts, oerrno, flags = RTF_STATIC; int fmask = 0; int key; + u_short prio = 0; struct hostent *hp = NULL; if (uid) @@ -516,6 +518,14 @@ newroute(int argc, char **argv) usage(1+*argv); set_metric(*++argv, key); break; + case K_PRIORITY: + if (!--argc) + usage(1+*argv); + prio = strtonum(*++argv, 0, RTP_MAX, &errstr); + if (errstr) + errx(1, "priority is %s: %s", errstr, + *argv); + break; default: usage(1+*argv); /* NOTREACHED */ @@ -564,7 +574,7 @@ newroute(int argc, char **argv) flags |= RTF_GATEWAY; for (attempts = 1; ; attempts++) { errno = 0; - if ((ret = rtmsg(*cmd, flags, fmask)) == 0) + if ((ret = rtmsg(*cmd, flags, fmask, prio)) == 0) break; if (errno != ENETUNREACH && errno != ESRCH) break; @@ -1000,7 +1010,7 @@ struct { } m_rtmsg; int -rtmsg(int cmd, int flags, int fmask) +rtmsg(int cmd, int flags, int fmask, u_short prio) { static int seq; char *cp = m_rtmsg.m_space; @@ -1040,6 +1050,7 @@ rtmsg(int cmd, int flags, int fmask) rtm.rtm_rmx = rt_metrics; rtm.rtm_inits = rtm_inits; rtm.rtm_tableid = tableid; + rtm.rtm_priority = prio; if (rtm_addrs & RTA_NETMASK) mask_addr(&so_dst, &so_mask, RTA_DST); @@ -1122,7 +1133,7 @@ char *msgtypes[] = { }; char metricnames[] = -"\011pksent\010rttvar\7rtt\6ssthresh\5sendpipe\4recvpipe\3expire\2hopcount\1mtu"; +"\011priority\010rttvar\7rtt\6ssthresh\5sendpipe\4recvpipe\3expire\2hopcount\1mtu"; char routeflags[] = "\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE\010MASK_PRESENT\011CLONING" "\012XRESOLVE\013LLINFO\014STATIC\015BLACKHOLE\016PROTO3\017PROTO2\020PROTO1\021CLONED\022SOURCE\023MPATH\024JUMBO"; @@ -1130,7 +1141,7 @@ char ifnetflags[] = "\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5PTP\6NOTRAILERS\7RUNNING\010NOARP\011PPROMISC" "\012ALLMULTI\013OACTIVE\014SIMPLEX\015LINK0\016LINK1\017LINK2\020MULTICAST"; char addrnames[] = -"\1DST\2GATEWAY\3NETMASK\4GENMASK\5IFP\6IFA\7AUTHOR\010BRD\13LABEL"; +"\1DST\2GATEWAY\3NETMASK\4GENMASK\5IFP\6IFA\7AUTHOR\010BRD\013LABEL"; const char * get_linkstate(int mt, int link_state) @@ -1226,7 +1237,8 @@ print_rtmsg(struct rt_msghdr *rtm, int msglen) printf("\n"); break; default: - printf("table: %u, pid: %ld, seq %d, errno %d, flags:", + printf("priority %d, ", rtm->rtm_priority); + printf("table %u, pid: %ld, seq %d, errno %d\nflags:", rtm->rtm_tableid, (long)rtm->rtm_pid, rtm->rtm_seq, rtm->rtm_errno); bprintf(stdout, rtm->rtm_flags, routeflags); @@ -1314,9 +1326,8 @@ print_getmsg(struct rt_msghdr *rtm, int msglen) #define lock(f) ((rtm->rtm_rmx.rmx_locks & __CONCAT(RTV_,f)) ? 'L' : ' ') #define msec(u) (((u) + 500) / 1000) /* usec to msec */ - printf("%s\n", " use hopcount mtu expire"); + printf("%s\n", " use mtu expire"); printf("%8llu ", rtm->rtm_rmx.rmx_pksent); - printf("%8u%c ", rtm->rtm_rmx.rmx_hopcount, lock(HOPCOUNT)); printf("%8u%c ", rtm->rtm_rmx.rmx_mtu, lock(MTU)); if (rtm->rtm_rmx.rmx_expire) rtm->rtm_rmx.rmx_expire -= time(NULL); diff --git a/sbin/route/show.c b/sbin/route/show.c index a082bd66868..86071141229 100644 --- a/sbin/route/show.c +++ b/sbin/route/show.c @@ -1,4 +1,4 @@ -/* $OpenBSD: show.c,v 1.65 2008/05/06 03:44:14 claudio Exp $ */ +/* $OpenBSD: show.c,v 1.66 2008/05/07 06:06:25 claudio Exp $ */ /* $NetBSD: show.c,v 1.1 1996/11/15 18:01:41 gwr Exp $ */ /* @@ -247,10 +247,11 @@ pr_rthdr(int af) "Flags", "Refs", "Use", "Mtu", "Interface"); break; default: - printf("%-*.*s %-*.*s %-6.6s %6.6s %8.8s %6.6s %s\n", + printf("%-*.*s %-*.*s %-6.6s %5.5s %8.8s %5.5s %4.4s %s\n", WID_DST(af), WID_DST(af), "Destination", WID_GW(af), WID_GW(af), "Gateway", - "Flags", "Refs", "Use", "Mtu", "Interface"); + "Flags", "Refs", "Use", "Mtu", "Prio", "Iface"); + break; } } @@ -301,14 +302,15 @@ p_rtentry(struct rt_msghdr *rtm) p_sockaddr(rti_info[RTAX_GATEWAY], NULL, RTF_HOST, WID_GW(sa->sa_family)); p_flags(rtm->rtm_flags, "%-6.6s "); - printf("%6u %8llu ", rtm->rtm_rmx.rmx_refcnt, + printf("%5u %8llu ", rtm->rtm_rmx.rmx_refcnt, rtm->rtm_rmx.rmx_pksent); if (rtm->rtm_rmx.rmx_mtu) - printf("%6u ", rtm->rtm_rmx.rmx_mtu); + printf("%5u ", rtm->rtm_rmx.rmx_mtu); else - printf("%6s ", "-"); + printf("%5s ", "-"); putchar((rtm->rtm_rmx.rmx_locks & RTV_MTU) ? 'L' : ' '); - printf(" %.16s", if_indextoname(rtm->rtm_index, ifbuf)); + printf(" %2d %.16s", rtm->rtm_priority, + if_indextoname(rtm->rtm_index, ifbuf)); putchar('\n'); } |