CVS commit: src/sbin/route

2021-01-02 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Jan  2 22:02:27 UTC 2021

Modified Files:
src/sbin/route: route.8

Log Message:
route(8): group RTF_GATEWAY and ~RTF_GATEWAY (-iface).

While here, tweak RTF_GATEWAY description.  Passive voice elsewhere in
this table is used to talk about the routes themselves, while here
it's about packets.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sbin/route/route.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.8
diff -u src/sbin/route/route.8:1.64 src/sbin/route/route.8:1.65
--- src/sbin/route/route.8:1.64	Sat Jan  2 20:36:02 2021
+++ src/sbin/route/route.8	Sat Jan  2 22:02:27 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: route.8,v 1.64 2021/01/02 20:36:02 uwe Exp $
+.\"	$NetBSD: route.8,v 1.65 2021/01/02 22:02:27 uwe Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -295,7 +295,6 @@ display and may be set (or sometimes cle
 by indicating the following corresponding modifiers:
 .Bl -column "ID" "xnoblackhole" "xRTF_BLACKHOLE" "x"
 .It Sy "ID" Ta Sy "Modifier" Ta Sy " Flag Bit" Ta Sy "Description"
-.It Li " " Ta -iface Ta ~RTF_GATEWAY Ta destination is directly reachable
 .It Li 1 Ta -proto1 Ta " RTF_PROTO1" Ta set protocol specific flag #1
 .It Li 2 Ta -proto2 Ta " RTF_PROTO2" Ta set protocol specific flag #2
 .It Li B Ta -blackhole Ta " RTF_BLACKHOLE" Ta discard pkts (during updates)
@@ -308,7 +307,8 @@ by indicating the following correspondin
 .It Li C Ta -connected Ta " RTF_CONNECTED" Ta  treat as a connected route
 .It Li " " Ta -noconnected Ta ~RTF_CONNECTED Ta stop treating a connected route
 .It Li D Ta "" Ta " RTF_DYNAMIC" Ta created dynamically (redirect)
-.It Li G Ta "" Ta " RTF_GATEWAY" Ta forwarded to dest by intermediary
+.It Li G Ta "" Ta " RTF_GATEWAY" Ta forward to dest by intermediary
+.It Li " " Ta -iface Ta ~RTF_GATEWAY Ta destination is directly reachable
 .It Li H Ta "" Ta " RTF_HOST" Ta host entry (net otherwise)
 .It Li L Ta "" Ta " RTF_LLDATA" Ta local link, generated by ARP or NDP
 .It Li l Ta "" Ta " RTF_LOCAL" Ta route represents a local address



CVS commit: src/sbin/route

2021-01-02 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Jan  2 20:36:02 UTC 2021

Modified Files:
src/sbin/route: route.8

Log Message:
route(8): be consistent about capitalization.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sbin/route/route.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.8
diff -u src/sbin/route/route.8:1.63 src/sbin/route/route.8:1.64
--- src/sbin/route/route.8:1.63	Sat Jan  2 19:50:42 2021
+++ src/sbin/route/route.8	Sat Jan  2 20:36:02 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: route.8,v 1.63 2021/01/02 19:50:42 uwe Exp $
+.\"	$NetBSD: route.8,v 1.64 2021/01/02 20:36:02 uwe Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -300,7 +300,7 @@ by indicating the following correspondin
 .It Li 2 Ta -proto2 Ta " RTF_PROTO2" Ta set protocol specific flag #2
 .It Li B Ta -blackhole Ta " RTF_BLACKHOLE" Ta discard pkts (during updates)
 .It Li " " Ta -noblackhole Ta ~RTF_BLACKHOLE Ta clear blackhole flag
-.It Li b Ta "" Ta " RTF_BROADCAST" Ta Route represents a broadcast address
+.It Li b Ta "" Ta " RTF_BROADCAST" Ta route represents a broadcast address
 .It Li C Ta -cloning Ta " RTF_CLONING" Ta  (deprecated) same as
 .Fl connected
 .It Li " " Ta -nocloning Ta ~RTF_CLONING Ta (deprecated) same as
@@ -311,7 +311,7 @@ by indicating the following correspondin
 .It Li G Ta "" Ta " RTF_GATEWAY" Ta forwarded to dest by intermediary
 .It Li H Ta "" Ta " RTF_HOST" Ta host entry (net otherwise)
 .It Li L Ta "" Ta " RTF_LLDATA" Ta local link, generated by ARP or NDP
-.It Li l Ta "" Ta " RTF_LOCAL" Ta Route represents a local address
+.It Li l Ta "" Ta " RTF_LOCAL" Ta route represents a local address
 .It Li M Ta "" Ta " RTF_MODIFIED" Ta modified dynamically (redirect)
 .It Li p Ta -proxy Ta " RTF_ANNOUNCE" Ta make entry a link level proxy
 .It Li R Ta -reject Ta " RTF_REJECT" Ta send ICMP unreachable on match



CVS commit: src/sbin/route

2021-01-02 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Jan  2 19:50:42 UTC 2021

Modified Files:
src/sbin/route: route.8

Log Message:
route(8): don't split -blackhole and -noblackhole.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sbin/route/route.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.8
diff -u src/sbin/route/route.8:1.62 src/sbin/route/route.8:1.63
--- src/sbin/route/route.8:1.62	Sat Aug 29 19:27:08 2020
+++ src/sbin/route/route.8	Sat Jan  2 19:50:42 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: route.8,v 1.62 2020/08/29 19:27:08 christos Exp $
+.\"	$NetBSD: route.8,v 1.63 2021/01/02 19:50:42 uwe Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -299,8 +299,8 @@ by indicating the following correspondin
 .It Li 1 Ta -proto1 Ta " RTF_PROTO1" Ta set protocol specific flag #1
 .It Li 2 Ta -proto2 Ta " RTF_PROTO2" Ta set protocol specific flag #2
 .It Li B Ta -blackhole Ta " RTF_BLACKHOLE" Ta discard pkts (during updates)
-.It Li b Ta "" Ta " RTF_BROADCAST" Ta Route represents a broadcast address
 .It Li " " Ta -noblackhole Ta ~RTF_BLACKHOLE Ta clear blackhole flag
+.It Li b Ta "" Ta " RTF_BROADCAST" Ta Route represents a broadcast address
 .It Li C Ta -cloning Ta " RTF_CLONING" Ta  (deprecated) same as
 .Fl connected
 .It Li " " Ta -nocloning Ta ~RTF_CLONING Ta (deprecated) same as



CVS commit: src/sbin/route

2020-08-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Aug 29 19:27:40 UTC 2020

Modified Files:
src/sbin/route: rtutil.c

Log Message:
Instead of defining RTF_LLINFO, use RTF_LLDATA


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sbin/route/rtutil.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/rtutil.c
diff -u src/sbin/route/rtutil.c:1.10 src/sbin/route/rtutil.c:1.11
--- src/sbin/route/rtutil.c:1.10	Thu Jul 13 04:26:29 2017
+++ src/sbin/route/rtutil.c	Sat Aug 29 15:27:40 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtutil.c,v 1.10 2017/07/13 08:26:29 manu Exp $	*/
+/*	$NetBSD: rtutil.c,v 1.11 2020/08/29 19:27:40 christos Exp $	*/
 /*	$OpenBSD: show.c,v 1.1 2006/05/27 19:16:37 claudio Exp $	*/
 
 /*
@@ -59,12 +59,6 @@
 #include "prog_ops.h"
 #include "rtutil.h"
 
-/*
- * Keep to handle ARP/NDP entries (fake routes)
- * for backward compatibility.
- */
-#define RTF_LLINFO	0x400
-
 #define PLEN(LONG_BIT / 4 + 2)
 #define PFKEYV2_CHUNK sizeof(u_int64_t)
 static char *link_print(const struct sockaddr *);
@@ -89,7 +83,7 @@ static const struct bits bits[] = {
 	/* { RTF_CLONING,	'C' }, */
 	{ RTF_CONNECTED, 'C' },
 	/* { RTF_XRESOLVE,	'X' }, */
-	{ RTF_LLINFO,	'L' },
+	{ RTF_LLDATA,	'L' },
 	{ RTF_STATIC,	'S' },
 	{ RTF_PROTO1,	'1' },
 	{ RTF_PROTO2,	'2' },
@@ -268,7 +262,7 @@ p_rtentry(struct rt_msghdr *rtm, int fla
 	char		 ifbuf[IF_NAMESIZE];
 #endif
 
-	if ((flags & RT_LFLAG) && (rtm->rtm_flags & RTF_LLINFO))
+	if ((flags & RT_LFLAG) && (rtm->rtm_flags & RTF_LLDATA))
 		return;
 
 	if (old_af != sa->sa_family) {



CVS commit: src/sbin/route

2020-08-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Aug 29 19:28:32 UTC 2020

Modified Files:
src/sbin/route: show.c

Log Message:
Make the "interesting" flags match the netstat ones, so:

route show -inet
netstat -r -f inet

outputs match.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sbin/route/show.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/show.c
diff -u src/sbin/route/show.c:1.50 src/sbin/route/show.c:1.51
--- src/sbin/route/show.c:1.50	Mon Apr  4 03:37:07 2016
+++ src/sbin/route/show.c	Sat Aug 29 15:28:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: show.c,v 1.50 2016/04/04 07:37:07 ozaki-r Exp $	*/
+/*	$NetBSD: show.c,v 1.51 2020/08/29 19:28:32 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "from: @(#)route.c	8.3 (Berkeley) 3/9/94";
 #else
-__RCSID("$NetBSD: show.c,v 1.50 2016/04/04 07:37:07 ozaki-r Exp $");
+__RCSID("$NetBSD: show.c,v 1.51 2020/08/29 19:28:32 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -132,8 +132,10 @@ void
 show(int argc, char *const *argv, int flags)
 {
 	int af, rflags;
-	static int interesting = RTF_UP | RTF_GATEWAY | RTF_HOST |
-	RTF_REJECT | RTF_LOCAL | RTF_BROADCAST;
+	static int interesting = RTF_ANNOUNCE | RTF_BLACKHOLE | RTF_BROADCAST |
+	RTF_CONNECTED | RTF_DYNAMIC | RTF_GATEWAY | RTF_HOST | RTF_LLDATA |
+	RTF_LOCAL | RTF_MODIFIED | RTF_PROTO1 | RTF_PROTO2 | RTF_REJECT |
+	RTF_STATIC | RTF_UP;
 
 	parse_show_opts(argc, argv, , , NULL, true);
 	p_rttables(af, flags, rflags, interesting);



CVS commit: src/sbin/route

2020-08-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Aug 29 19:27:08 UTC 2020

Modified Files:
src/sbin/route: route.8

Log Message:
Document 'L'


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sbin/route/route.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.8
diff -u src/sbin/route/route.8:1.61 src/sbin/route/route.8:1.62
--- src/sbin/route/route.8:1.61	Tue Jul 31 17:22:09 2018
+++ src/sbin/route/route.8	Sat Aug 29 15:27:08 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: route.8,v 1.61 2018/07/31 21:22:09 sevan Exp $
+.\"	$NetBSD: route.8,v 1.62 2020/08/29 19:27:08 christos Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)route.8	8.4 (Berkeley) 6/1/94
 .\"
-.Dd July 31, 2018
+.Dd August 29, 2020
 .Dt ROUTE 8
 .Os
 .Sh NAME
@@ -310,6 +310,7 @@ by indicating the following correspondin
 .It Li D Ta "" Ta " RTF_DYNAMIC" Ta created dynamically (redirect)
 .It Li G Ta "" Ta " RTF_GATEWAY" Ta forwarded to dest by intermediary
 .It Li H Ta "" Ta " RTF_HOST" Ta host entry (net otherwise)
+.It Li L Ta "" Ta " RTF_LLDATA" Ta local link, generated by ARP or NDP
 .It Li l Ta "" Ta " RTF_LOCAL" Ta Route represents a local address
 .It Li M Ta "" Ta " RTF_MODIFIED" Ta modified dynamically (redirect)
 .It Li p Ta -proxy Ta " RTF_ANNOUNCE" Ta make entry a link level proxy



CVS commit: src/sbin/route

2020-04-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr  2 18:32:32 UTC 2020

Modified Files:
src/sbin/route: prog_ops.h route.c route_hostops.c route_rumpops.c

Log Message:
Add a prog_setsockopt (thanks kre@)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sbin/route/prog_ops.h
cvs rdiff -u -r1.167 -r1.168 src/sbin/route/route.c
cvs rdiff -u -r1.1 -r1.2 src/sbin/route/route_hostops.c \
src/sbin/route/route_rumpops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/prog_ops.h
diff -u src/sbin/route/prog_ops.h:1.3 src/sbin/route/prog_ops.h:1.4
--- src/sbin/route/prog_ops.h:1.3	Thu Nov  6 16:29:32 2014
+++ src/sbin/route/prog_ops.h	Thu Apr  2 14:32:31 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: prog_ops.h,v 1.3 2014/11/06 21:29:32 christos Exp $	*/
+/*  $NetBSD: prog_ops.h,v 1.4 2020/04/02 18:32:31 christos Exp $	*/
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -36,36 +36,50 @@
 struct prog_ops {
 	int (*op_init)(void);
 
-	int (*op_sysctl)(const int *, u_int, void *, size_t *,
-			 const void *, size_t);
-
 	int (*op_socket)(int, int, int);
+	int (*op_setsockopt)(int, int, int, const void *, socklen_t);
+
+
 	int (*op_open)(const char *, int, ...);
 	pid_t (*op_getpid)(void);
 
 	ssize_t (*op_read)(int, void *, size_t);
 	ssize_t (*op_write)(int, const void *, size_t);
 
+	int (*op_sysctl)(const int *, u_int, void *, size_t *,
+			 const void *, size_t);
 
 	int (*op_shutdown)(int, int);
 };
 extern const struct prog_ops prog_ops;
 
 #define prog_init prog_ops.op_init
+
 #define prog_socket prog_ops.op_socket
+#define prog_setsockopt prog_ops.op_setsockopt
+
 #define prog_open prog_ops.op_open
 #define prog_getpid prog_ops.op_getpid
+
 #define prog_read prog_ops.op_read
 #define prog_write prog_ops.op_write
+
 #define prog_sysctl prog_ops.op_sysctl
+
 #define prog_shutdown prog_ops.op_shutdown
+
 #else
 #define prog_init ((int (*)(void))NULL)
+
 #define prog_socket socket
+#define prog_setsockopt setsockopt
+
 #define prog_open open
 #define prog_getpid getpid
+
 #define prog_read read
 #define prog_write write
+
 #define prog_sysctl sysctl
 #define prog_shutdown shutdown
 #endif

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.167 src/sbin/route/route.c:1.168
--- src/sbin/route/route.c:1.167	Sat Mar 14 18:26:39 2020
+++ src/sbin/route/route.c	Thu Apr  2 14:32:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.167 2020/03/14 22:26:39 roy Exp $	*/
+/*	$NetBSD: route.c,v 1.168 2020/04/02 18:32:31 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)route.c	8.6 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: route.c,v 1.167 2020/03/14 22:26:39 roy Exp $");
+__RCSID("$NetBSD: route.c,v 1.168 2020/04/02 18:32:31 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -212,7 +212,7 @@ main(int argc, char * const *argv)
 		int on = 1;
 
 		sock = prog_socket(PF_ROUTE, SOCK_RAW, 0);
-		if (setsockopt(sock, SOL_SOCKET, SO_RERROR,
+		if (prog_setsockopt(sock, SOL_SOCKET, SO_RERROR,
 		, sizeof(on)) == -1)
 			warn("SO_RERROR");
 	}

Index: src/sbin/route/route_hostops.c
diff -u src/sbin/route/route_hostops.c:1.1 src/sbin/route/route_hostops.c:1.2
--- src/sbin/route/route_hostops.c:1.1	Mon Dec 13 12:39:47 2010
+++ src/sbin/route/route_hostops.c	Thu Apr  2 14:32:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: route_hostops.c,v 1.1 2010/12/13 17:39:47 pooka Exp $	*/
+/*	$NetBSD: route_hostops.c,v 1.2 2020/04/02 18:32:31 christos Exp $	*/
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: route_hostops.c,v 1.1 2010/12/13 17:39:47 pooka Exp $");
+__RCSID("$NetBSD: route_hostops.c,v 1.2 2020/04/02 18:32:31 christos Exp $");
 #endif /* !lint */
 
 #include 
@@ -41,14 +41,17 @@ __RCSID("$NetBSD: route_hostops.c,v 1.1 
 #include "prog_ops.h"
 
 const struct prog_ops prog_ops = {
-	.op_socket = socket,
-	.op_open = open,
-	.op_getpid = getpid,
 
-	.op_read = read,
-	.op_write = write,
+	.op_socket =		socket,
+	.op_setsockopt =	setsockopt,
 
-	.op_sysctl = sysctl,
+	.op_open =		open,
+	.op_getpid =		getpid,
 
-	.op_shutdown = shutdown,
+	.op_read =		read,
+	.op_write =		write,
+
+	.op_sysctl =		sysctl,
+
+	.op_shutdown =		shutdown,
 };
Index: src/sbin/route/route_rumpops.c
diff -u src/sbin/route/route_rumpops.c:1.1 src/sbin/route/route_rumpops.c:1.2
--- src/sbin/route/route_rumpops.c:1.1	Mon Dec 13 12:39:47 2010
+++ src/sbin/route/route_rumpops.c	Thu Apr  2 14:32:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: route_rumpops.c,v 1.1 2010/12/13 17:39:47 pooka Exp $	*/
+/*	$NetBSD: route_rumpops.c,v 1.2 2020/04/02 18:32:31 christos Exp $	*/
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: route_rumpops.c,v 1.1 2010/12/13 17:39:47 pooka 

CVS commit: src/sbin/route

2020-03-14 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sat Mar 14 22:26:39 UTC 2020

Modified Files:
src/sbin/route: route.c

Log Message:
route: Enable receive error reporting on the routing socket


To generate a diff of this commit:
cvs rdiff -u -r1.166 -r1.167 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.166 src/sbin/route/route.c:1.167
--- src/sbin/route/route.c:1.166	Sat Feb 22 00:42:15 2020
+++ src/sbin/route/route.c	Sat Mar 14 22:26:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.166 2020/02/22 00:42:15 kamil Exp $	*/
+/*	$NetBSD: route.c,v 1.167 2020/03/14 22:26:39 roy Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)route.c	8.6 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: route.c,v 1.166 2020/02/22 00:42:15 kamil Exp $");
+__RCSID("$NetBSD: route.c,v 1.167 2020/03/14 22:26:39 roy Exp $");
 #endif
 #endif /* not lint */
 
@@ -208,8 +208,14 @@ main(int argc, char * const *argv)
 	pid = prog_getpid();
 	if (tflag)
 		sock = prog_open("/dev/null", O_WRONLY, 0);
-	else
+	else {
+		int on = 1;
+
 		sock = prog_socket(PF_ROUTE, SOCK_RAW, 0);
+		if (setsockopt(sock, SOL_SOCKET, SO_RERROR,
+		, sizeof(on)) == -1)
+			warn("SO_RERROR");
+	}
 	if (sock < 0)
 		err(EXIT_FAILURE, "socket");
 



CVS commit: src/sbin/route

2020-02-21 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Feb 22 00:42:15 UTC 2020

Modified Files:
src/sbin/route: route.c

Log Message:
Avoid undefined behavior

route.c:1523:20, left shift of 1073741824 by 1 places cannot be represented
in type 'int'


To generate a diff of this commit:
cvs rdiff -u -r1.165 -r1.166 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.165 src/sbin/route/route.c:1.166
--- src/sbin/route/route.c:1.165	Wed Jan 22 19:22:06 2020
+++ src/sbin/route/route.c	Sat Feb 22 00:42:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.165 2020/01/22 19:22:06 roy Exp $	*/
+/*	$NetBSD: route.c,v 1.166 2020/02/22 00:42:15 kamil Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)route.c	8.6 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: route.c,v 1.165 2020/01/22 19:22:06 roy Exp $");
+__RCSID("$NetBSD: route.c,v 1.166 2020/02/22 00:42:15 kamil Exp $");
 #endif
 #endif /* not lint */
 
@@ -1498,7 +1498,7 @@ print_getmsg(struct rt_msghdr *rtm, int 
 	struct sockaddr_dl *ifp = NULL;
 	struct sockaddr *sa;
 	char *cp;
-	int i;
+	unsigned int i;
 
 	if (! shortoutput) {
 		(void)printf("   route to: %s\n",



CVS commit: src/sbin/route

2020-01-22 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Jan 22 19:22:06 UTC 2020

Modified Files:
src/sbin/route: route.c

Log Message:
route: address flags are more useful than interface flags for address msgs


To generate a diff of this commit:
cvs rdiff -u -r1.164 -r1.165 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.164 src/sbin/route/route.c:1.165
--- src/sbin/route/route.c:1.164	Wed Jan 22 17:55:41 2020
+++ src/sbin/route/route.c	Wed Jan 22 19:22:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.164 2020/01/22 17:55:41 roy Exp $	*/
+/*	$NetBSD: route.c,v 1.165 2020/01/22 19:22:06 roy Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)route.c	8.6 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: route.c,v 1.164 2020/01/22 17:55:41 roy Exp $");
+__RCSID("$NetBSD: route.c,v 1.165 2020/01/22 19:22:06 roy Exp $");
 #endif
 #endif /* not lint */
 
@@ -1375,7 +1375,7 @@ print_rtmsg(struct rt_msghdr *rtm, int m
 	case RTM_DELADDR:
 	case RTM_CHGADDR:
 		ifam = (struct ifa_msghdr *)rtm;
-		(void)printf("pid %d, metric %d, flags: ",
+		(void)printf("pid %d, metric %d, addrflags: ",
 		ifam->ifam_pid, ifam->ifam_metric);
 		struct sockaddr *sa = (struct sockaddr *)(ifam + 1);
 		const char *bits;
@@ -1390,7 +1390,7 @@ print_rtmsg(struct rt_msghdr *rtm, int m
 			bits = unknownflags;
 			break;
 		}
-		bprintf(stdout, ifam->ifam_flags, bits);
+		bprintf(stdout, ifam->ifam_addrflags, bits);
 		pmsg_addrs((char *)(ifam + 1), ifam->ifam_addrs);
 		break;
 	case RTM_IEEE80211:



CVS commit: src/sbin/route

2020-01-22 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Jan 22 17:55:41 UTC 2020

Modified Files:
src/sbin/route: route.c

Log Message:
route: Decode the correct flags for interface address messages


To generate a diff of this commit:
cvs rdiff -u -r1.163 -r1.164 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.163 src/sbin/route/route.c:1.164
--- src/sbin/route/route.c:1.163	Mon Sep  2 00:30:01 2019
+++ src/sbin/route/route.c	Wed Jan 22 17:55:41 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.163 2019/09/02 00:30:01 roy Exp $	*/
+/*	$NetBSD: route.c,v 1.164 2020/01/22 17:55:41 roy Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)route.c	8.6 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: route.c,v 1.163 2019/09/02 00:30:01 roy Exp $");
+__RCSID("$NetBSD: route.c,v 1.164 2020/01/22 17:55:41 roy Exp $");
 #endif
 #endif /* not lint */
 
@@ -54,6 +54,7 @@ __RCSID("$NetBSD: route.c,v 1.163 2019/0
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1301,9 +1302,12 @@ const char * const msgtypes[] = {
 	[RTM_CHGADDR] = "RTM_CHGADDR: address being changed on iface",
 };
 
+const char unknownflags[] = "\020";
 const char metricnames[] = RTVBITS;
 const char routeflags[] = RTFBITS;
 const char ifnetflags[] = IFFBITS;
+const char in_ifflags[] = IN_IFFBITS;
+const char in6_ifflags[] = IN6_IFFBITS;
 const char addrnames[] = RTABITS;
 
 
@@ -1373,7 +1377,20 @@ print_rtmsg(struct rt_msghdr *rtm, int m
 		ifam = (struct ifa_msghdr *)rtm;
 		(void)printf("pid %d, metric %d, flags: ",
 		ifam->ifam_pid, ifam->ifam_metric);
-		bprintf(stdout, ifam->ifam_flags, routeflags);
+		struct sockaddr *sa = (struct sockaddr *)(ifam + 1);
+		const char *bits;
+		switch (sa->sa_family) {
+		case AF_INET:
+			bits = in_ifflags;
+			break;
+		case AF_INET6:
+			bits = in6_ifflags;
+			break;
+		default:
+			bits = unknownflags;
+			break;
+		}
+		bprintf(stdout, ifam->ifam_flags, bits);
 		pmsg_addrs((char *)(ifam + 1), ifam->ifam_addrs);
 		break;
 	case RTM_IEEE80211:



CVS commit: src/sbin/route

2018-08-14 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Tue Aug 14 20:53:07 UTC 2018

Modified Files:
src/sbin/route: route.c

Log Message:
Resolve every route(4) message type before printing anything more about it
other than the type and length.

This solves the issue where RTM_ONEWADDR is received and it tries to
parse route information from it.


To generate a diff of this commit:
cvs rdiff -u -r1.159 -r1.160 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.159 src/sbin/route/route.c:1.160
--- src/sbin/route/route.c:1.159	Fri Mar 23 11:57:33 2018
+++ src/sbin/route/route.c	Tue Aug 14 20:53:07 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.159 2018/03/23 11:57:33 roy Exp $	*/
+/*	$NetBSD: route.c,v 1.160 2018/08/14 20:53:07 roy Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)route.c	8.6 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: route.c,v 1.159 2018/03/23 11:57:33 roy Exp $");
+__RCSID("$NetBSD: route.c,v 1.160 2018/08/14 20:53:07 roy Exp $");
 #endif
 #endif /* not lint */
 
@@ -1459,11 +1459,14 @@ print_rtmsg(struct rt_msghdr *rtm, int m
 		}
 		printf("\n");
 		break;
-	default:
+	case RTM_ADD:
+	case RTM_DELETE:
+	case RTM_GET:
 		(void)printf("pid %d, seq %d, errno %d, flags: ",
 			rtm->rtm_pid, rtm->rtm_seq, rtm->rtm_errno);
 		bprintf(stdout, rtm->rtm_flags, routeflags);
 		pmsg_common(rtm);
+		break;
 	}
 }
 



CVS commit: src/sbin/route

2018-07-31 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Tue Jul 31 21:22:09 UTC 2018

Modified Files:
src/sbin/route: route.8

Log Message:
Remove references to XNS


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sbin/route/route.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.8
diff -u src/sbin/route/route.8:1.60 src/sbin/route/route.8:1.61
--- src/sbin/route/route.8:1.60	Tue Jul  4 06:54:20 2017
+++ src/sbin/route/route.8	Tue Jul 31 21:22:09 2018
@@ -1,4 +1,4 @@
-.\"	$NetBSD: route.8,v 1.60 2017/07/04 06:54:20 wiz Exp $
+.\"	$NetBSD: route.8,v 1.61 2018/07/31 21:22:09 sevan Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)route.8	8.4 (Berkeley) 6/1/94
 .\"
-.Dd June 16, 2017
+.Dd July 31, 2018
 .Dt ROUTE 8
 .Os
 .Sh NAME
@@ -164,7 +164,6 @@ command is specified,
 .Nm
 will ``flush'' the routing tables of all gateway entries.
 When the address family is specified by any of the
-.Fl xns ,
 .Fl atalk ,
 .Fl inet ,
 .Fl inet6 ,
@@ -244,15 +243,12 @@ the gateway given is the address of this
 indicating the interface to be used for transmission.
 .Pp
 The optional modifiers
-.Fl xns ,
 .Fl atalk ,
 and
 .Fl link
 specify that all subsequent addresses are in the
-.Tn XNS ,
-or
 .Tn AppleTalk
-address families,
+address family,
 or are specified as link-level addresses in the form described in
 .Xr link_addr 3 ,
 and the names must be numeric specifications rather than
@@ -429,7 +425,6 @@ These privileges are enforced by the ker
 .Xr route 4 ,
 .Xr routed 8 ,
 .Xr sysctl 8
-.\" .Xr XNSrouted 8
 .Sh HISTORY
 The
 .Nm



CVS commit: src/sbin/route

2018-03-23 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Mar 23 11:57:33 UTC 2018

Modified Files:
src/sbin/route: route.c

Log Message:
Handle the routing socket overflowing gracefully.


To generate a diff of this commit:
cvs rdiff -u -r1.158 -r1.159 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.158 src/sbin/route/route.c:1.159
--- src/sbin/route/route.c:1.158	Wed Dec 13 17:42:44 2017
+++ src/sbin/route/route.c	Fri Mar 23 11:57:33 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.158 2017/12/13 17:42:44 christos Exp $	*/
+/*	$NetBSD: route.c,v 1.159 2018/03/23 11:57:33 roy Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)route.c	8.6 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: route.c,v 1.158 2017/12/13 17:42:44 christos Exp $");
+__RCSID("$NetBSD: route.c,v 1.159 2018/03/23 11:57:33 roy Exp $");
 #endif
 #endif /* not lint */
 
@@ -341,8 +341,10 @@ flushroutes(int argc, char * const argv[
 			continue;
 		rtm->rtm_type = RTM_DELETE;
 		rtm->rtm_seq = seqno;
-		if ((rlen = prog_write(sock, next,
-		rtm->rtm_msglen)) < 0) {
+		do {
+			rlen = prog_write(sock, next, rtm->rtm_msglen);
+		} while (rlen == -1 && errno == ENOBUFS);
+		if (rlen == -1) {
 			warnx("writing to routing socket: %s",
 			route_strerror(errno));
 			return 1;
@@ -1139,6 +1141,10 @@ monitor(int argc, char * const *argv)
 	for(i = 0; count == 0 || i < count; i++) {
 		time_t now;
 		n = prog_read(sock, , sizeof(u));
+		if (n == -1) {
+			warn("read");
+			continue;
+		}
 		now = time(NULL);
 		(void)printf("got message of size %d on %s", n, ctime());
 		print_rtmsg(, n);
@@ -1214,7 +1220,10 @@ rtmsg(int cmd, int flags, struct sou *so
 	}
 	if (debugonly)
 		return 0;
-	if ((rlen = prog_write(sock, (char *)_rtmsg, l)) < 0) {
+	do {
+		rlen = prog_write(sock, (char *)_rtmsg, l);
+	} while (rlen == -1 && errno == ENOBUFS);
+	if (rlen == -1) {
 		warnx("writing to routing socket: %s", route_strerror(errno));
 		return -1;
 	}



CVS commit: src/sbin/route

2017-12-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec 13 17:42:44 UTC 2017

Modified Files:
src/sbin/route: Makefile route.c

Log Message:
Use the definitions from the standard header files and replace homebrew
snprintb with the libutil one.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sbin/route/Makefile
cvs rdiff -u -r1.157 -r1.158 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/Makefile
diff -u src/sbin/route/Makefile:1.30 src/sbin/route/Makefile:1.31
--- src/sbin/route/Makefile:1.30	Tue Oct 10 15:30:06 2017
+++ src/sbin/route/Makefile	Wed Dec 13 12:42:44 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.30 2017/10/10 19:30:06 christos Exp $
+#	$NetBSD: Makefile,v 1.31 2017/12/13 17:42:44 christos Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/5/93
 
 .include 
@@ -17,6 +17,9 @@ DPADD.rump += ${LIBRUMPRES}
 CPPFLAGS+=-DINET6
 .endif
 
+LDADD+=-lutil
+DPADD+=${LIBUTIL}
+
 # The Makefile over in ../../distrib/utils/x_route
 # would like keywords.[ch] to always exist here, so
 # they are now checked in as sources.

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.157 src/sbin/route/route.c:1.158
--- src/sbin/route/route.c:1.157	Wed Dec 13 06:31:42 2017
+++ src/sbin/route/route.c	Wed Dec 13 12:42:44 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.157 2017/12/13 11:31:42 uwe Exp $	*/
+/*	$NetBSD: route.c,v 1.158 2017/12/13 17:42:44 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)route.c	8.6 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: route.c,v 1.157 2017/12/13 11:31:42 uwe Exp $");
+__RCSID("$NetBSD: route.c,v 1.158 2017/12/13 17:42:44 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -68,6 +68,7 @@ __RCSID("$NetBSD: route.c,v 1.157 2017/1
 #include 
 #include 
 #include 
+#include 
 
 #include "keywords.h"
 #include "extern.h"
@@ -1291,14 +1292,10 @@ const char * const msgtypes[] = {
 	[RTM_CHGADDR] = "RTM_CHGADDR: address being changed on iface",
 };
 
-const char metricnames[] =
-"\011pksent\010rttvar\7rtt\6ssthresh\5sendpipe\4recvpipe\3expire\2hopcount\1mtu";
-const char routeflags[] =
-"\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE\010MASK_PRESENT\011CONNECTED\012XRESOLVE\013LLINFO\014STATIC\015BLACKHOLE\016CLONED\017PROTO2\020PROTO1\023LOCAL\024BROADCAST";
-const char ifnetflags[] =
-"\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5PTP\6NOTRAILERS\7RUNNING\010NOARP\011PROMISC\012ALLMULTI\013OACTIVE\014SIMPLEX\015LINK0\016LINK1\017LINK2\020MULTICAST";
-const char addrnames[] =
-"\1DST\2GATEWAY\3NETMASK\4GENMASK\5IFP\6IFA\7AUTHOR\010BRD\011TAG";
+const char metricnames[] = RTVBITS;
+const char routeflags[] = RTFBITS;
+const char ifnetflags[] = IFFBITS;
+const char addrnames[] = RTABITS;
 
 
 #ifndef SMALL
@@ -1659,30 +1656,10 @@ pmsg_addrs(const char *cp, int addrs)
 static void
 bprintf(FILE *fp, int b, const char *f)
 {
-	int i;
-	int gotsome = 0;
-	const uint8_t *s = (const uint8_t *)f;
+	char buf[1024];
 
-	if (b == 0) {
-		fputs("none", fp);
-		return;
-	}
-	while ((i = *s++) != 0) {
-		if (b & (1 << (i-1))) {
-			if (gotsome == 0)
-i = '<';
-			else
-i = ',';
-			(void)putc(i, fp);
-			gotsome = 1;
-			for (; (i = *s) > 32; s++)
-(void)putc(i, fp);
-		} else
-			while (*s > 32)
-s++;
-	}
-	if (gotsome)
-		(void)putc('>', fp);
+	snprintb(buf, sizeof(buf), f, b);
+	fputs(buf, fp);
 }
 
 int



CVS commit: src/sbin/route

2017-12-13 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed Dec 13 11:31:42 UTC 2017

Modified Files:
src/sbin/route: route.c

Log Message:
Fix typo in flag name.  We should probably just use IFFBITS string
that  defines.

PR bin/52815


To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.156 src/sbin/route/route.c:1.157
--- src/sbin/route/route.c:1.156	Fri Jun 16 04:40:16 2017
+++ src/sbin/route/route.c	Wed Dec 13 11:31:42 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.156 2017/06/16 04:40:16 ozaki-r Exp $	*/
+/*	$NetBSD: route.c,v 1.157 2017/12/13 11:31:42 uwe Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)route.c	8.6 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: route.c,v 1.156 2017/06/16 04:40:16 ozaki-r Exp $");
+__RCSID("$NetBSD: route.c,v 1.157 2017/12/13 11:31:42 uwe Exp $");
 #endif
 #endif /* not lint */
 
@@ -1296,7 +1296,7 @@ const char metricnames[] =
 const char routeflags[] =
 "\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE\010MASK_PRESENT\011CONNECTED\012XRESOLVE\013LLINFO\014STATIC\015BLACKHOLE\016CLONED\017PROTO2\020PROTO1\023LOCAL\024BROADCAST";
 const char ifnetflags[] =
-"\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5PTP\6NOTRAILERS\7RUNNING\010NOARP\011PPROMISC\012ALLMULTI\013OACTIVE\014SIMPLEX\015LINK0\016LINK1\017LINK2\020MULTICAST";
+"\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5PTP\6NOTRAILERS\7RUNNING\010NOARP\011PROMISC\012ALLMULTI\013OACTIVE\014SIMPLEX\015LINK0\016LINK1\017LINK2\020MULTICAST";
 const char addrnames[] =
 "\1DST\2GATEWAY\3NETMASK\4GENMASK\5IFP\6IFA\7AUTHOR\010BRD\011TAG";
 



CVS commit: src/sbin/route

2017-07-13 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Jul 13 08:26:29 UTC 2017

Modified Files:
src/sbin/route: rtutil.c

Log Message:
Fix route and netstat -r output when built with -DSMALL

A missing \n caused the routing table to be printed all in one line
if -DSMALL was used.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sbin/route/rtutil.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/rtutil.c
diff -u src/sbin/route/rtutil.c:1.9 src/sbin/route/rtutil.c:1.10
--- src/sbin/route/rtutil.c:1.9	Wed Jun 28 04:14:53 2017
+++ src/sbin/route/rtutil.c	Thu Jul 13 08:26:29 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtutil.c,v 1.9 2017/06/28 04:14:53 ozaki-r Exp $	*/
+/*	$NetBSD: rtutil.c,v 1.10 2017/07/13 08:26:29 manu Exp $	*/
 /*	$OpenBSD: show.c,v 1.1 2006/05/27 19:16:37 claudio Exp $	*/
 
 /*
@@ -304,6 +304,8 @@ p_rtentry(struct rt_msghdr *rtm, int fla
 	putchar('\n');
 	if (flags & RT_VFLAG)
 		p_rtrmx(>rtm_rmx);
+#else
+	putchar('\n');
 #endif
 }
 



CVS commit: src/sbin/route

2017-07-04 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Jul  4 06:54:20 UTC 2017

Modified Files:
src/sbin/route: route.8

Log Message:
Use Ex.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sbin/route/route.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.8
diff -u src/sbin/route/route.8:1.59 src/sbin/route/route.8:1.60
--- src/sbin/route/route.8:1.59	Mon Jul  3 21:33:42 2017
+++ src/sbin/route/route.8	Tue Jul  4 06:54:20 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: route.8,v 1.59 2017/07/03 21:33:42 wiz Exp $
+.\"	$NetBSD: route.8,v 1.60 2017/07/04 06:54:20 wiz Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -376,9 +376,7 @@ and
 As such, only the super-user may modify
 the routing tables.
 .Sh EXIT STATUS
-The
-.Nm
-utility exits 0 on success, and >0 if an error occurs.
+.Ex -std route
 This includes the use of the
 .Cm get
 command to look up a route that is incomplete.



CVS commit: src/sbin/route

2017-06-19 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon Jun 19 09:46:33 UTC 2017

Modified Files:
src/sbin/route: route.8

Log Message:
Remove unnecessary Pp.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sbin/route/route.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.8
diff -u src/sbin/route/route.8:1.57 src/sbin/route/route.8:1.58
--- src/sbin/route/route.8:1.57	Fri Jun 16 04:40:16 2017
+++ src/sbin/route/route.8	Mon Jun 19 09:46:33 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: route.8,v 1.57 2017/06/16 04:40:16 ozaki-r Exp $
+.\"	$NetBSD: route.8,v 1.58 2017/06/19 09:46:33 wiz Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -65,7 +65,6 @@ but a rich command language, enabling th
 any arbitrary request that could be delivered via the
 programmatic interface discussed in
 .Xr route 4 .
-.Pp
 .Bl -tag -width Ds
 .It Fl d
 Turn on debugging



CVS commit: src/sbin/route

2017-06-15 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Jun 16 04:40:16 UTC 2017

Modified Files:
src/sbin/route: route.8 route.c

Log Message:
Support -c  option for route monitor

route command exits if it receives  routing messages where
 is a value specified by -c.

The option is useful to get only particular message(s) in a test script.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sbin/route/route.8
cvs rdiff -u -r1.155 -r1.156 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.8
diff -u src/sbin/route/route.8:1.56 src/sbin/route/route.8:1.57
--- src/sbin/route/route.8:1.56	Mon Apr  4 07:37:07 2016
+++ src/sbin/route/route.8	Fri Jun 16 04:40:16 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: route.8,v 1.56 2016/04/04 07:37:07 ozaki-r Exp $
+.\"	$NetBSD: route.8,v 1.57 2017/06/16 04:40:16 ozaki-r Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)route.8	8.4 (Berkeley) 6/1/94
 .\"
-.Dd March 30, 2016
+.Dd June 16, 2017
 .Dt ROUTE 8
 .Os
 .Sh NAME
@@ -139,8 +139,17 @@ The monitor command has the syntax
 .Nm
 .Op Fl n
 .Cm monitor
+.Op Fl c Ar count
 .Ed
 .Pp
+If
+.Ar count
+is specified,
+.Nm
+exits after receiving
+.Ar count
+routing messages.
+.Pp
 The flush command has the syntax
 .Pp
 .Bd -filled -offset indent -compact

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.155 src/sbin/route/route.c:1.156
--- src/sbin/route/route.c:1.155	Fri Mar 17 16:13:44 2017
+++ src/sbin/route/route.c	Fri Jun 16 04:40:16 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.155 2017/03/17 16:13:44 roy Exp $	*/
+/*	$NetBSD: route.c,v 1.156 2017/06/16 04:40:16 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)route.c	8.6 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: route.c,v 1.155 2017/03/17 16:13:44 roy Exp $");
+__RCSID("$NetBSD: route.c,v 1.156 2017/06/16 04:40:16 ozaki-r Exp $");
 #endif
 #endif /* not lint */
 
@@ -108,7 +108,7 @@ static char *netmask_string(const struct
 static int prefixlen(const char *, struct sou *);
 #ifndef SMALL
 static void interfaces(void);
-__dead static void monitor(void);
+static void monitor(int, char * const *);
 static int print_getmsg(struct rt_msghdr *, int, struct sou *);
 static const char *linkstate(struct if_msghdr *);
 static sup readtag(sup, const char *);
@@ -236,7 +236,7 @@ main(int argc, char * const *argv)
 
 #ifndef SMALL
 	case K_MONITOR:
-		monitor();
+		monitor(argc, argv);
 		return 0;
 
 #endif /* SMALL */
@@ -1105,20 +1105,37 @@ interfaces(void)
 }
 
 static void
-monitor(void)
+monitor(int argc, char * const *argv)
 {
-	int n;
+	int i, n;
 	union {
 		char msg[2048];
 		struct rt_msghdr hdr;
 	} u;
+	int count = 0;
+
+	/* usage: route monitor [-c ] */
+
+	/* eat "monitor" */
+	argc -= 1;
+	argv += 1;
+
+	/* parse [-c ] */
+	if (argc > 0) {
+		if (argc != 2)
+			usage(argv[0]);
+		if (strcmp(argv[0], "-c") != 0)
+			usage(argv[0]);
+
+		count = atoi(argv[1]);
+	}
 
 	verbose = 1;
 	if (debugonly) {
 		interfaces();
 		exit(0);
 	}
-	for(;;) {
+	for(i = 0; count == 0 || i < count; i++) {
 		time_t now;
 		n = prog_read(sock, , sizeof(u));
 		now = time(NULL);



CVS commit: src/sbin/route

2017-03-17 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Mar 17 16:13:44 UTC 2017

Modified Files:
src/sbin/route: route.c

Log Message:
Report the PID for the process changing the address.


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.155 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.154 src/sbin/route/route.c:1.155
--- src/sbin/route/route.c:1.154	Mon Apr  4 07:37:07 2016
+++ src/sbin/route/route.c	Fri Mar 17 16:13:44 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.154 2016/04/04 07:37:07 ozaki-r Exp $	*/
+/*	$NetBSD: route.c,v 1.155 2017/03/17 16:13:44 roy Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)route.c	8.6 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: route.c,v 1.154 2016/04/04 07:37:07 ozaki-r Exp $");
+__RCSID("$NetBSD: route.c,v 1.155 2017/03/17 16:13:44 roy Exp $");
 #endif
 #endif /* not lint */
 
@@ -1348,7 +1348,8 @@ print_rtmsg(struct rt_msghdr *rtm, int m
 	case RTM_DELADDR:
 	case RTM_CHGADDR:
 		ifam = (struct ifa_msghdr *)rtm;
-		(void)printf("metric %d, flags: ", ifam->ifam_metric);
+		(void)printf("pid %d, metric %d, flags: ",
+		ifam->ifam_pid, ifam->ifam_metric);
 		bprintf(stdout, ifam->ifam_flags, routeflags);
 		pmsg_addrs((char *)(ifam + 1), ifam->ifam_addrs);
 		break;



CVS commit: src/sbin/route

2016-01-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 23 21:05:51 UTC 2016

Modified Files:
src/sbin/route: route.c rtutil.c show.c

Log Message:
no need for 


To generate a diff of this commit:
cvs rdiff -u -r1.152 -r1.153 src/sbin/route/route.c
cvs rdiff -u -r1.6 -r1.7 src/sbin/route/rtutil.c
cvs rdiff -u -r1.48 -r1.49 src/sbin/route/show.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.152 src/sbin/route/route.c:1.153
--- src/sbin/route/route.c:1.152	Sun Jan 17 10:59:26 2016
+++ src/sbin/route/route.c	Sat Jan 23 16:05:51 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.152 2016/01/17 15:59:26 christos Exp $	*/
+/*	$NetBSD: route.c,v 1.153 2016/01/23 21:05:51 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)route.c	8.6 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: route.c,v 1.152 2016/01/17 15:59:26 christos Exp $");
+__RCSID("$NetBSD: route.c,v 1.153 2016/01/23 21:05:51 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -47,7 +47,6 @@ __RCSID("$NetBSD: route.c,v 1.152 2016/0
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 

Index: src/sbin/route/rtutil.c
diff -u src/sbin/route/rtutil.c:1.6 src/sbin/route/rtutil.c:1.7
--- src/sbin/route/rtutil.c:1.6	Mon Mar 23 14:33:17 2015
+++ src/sbin/route/rtutil.c	Sat Jan 23 16:05:51 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtutil.c,v 1.6 2015/03/23 18:33:17 roy Exp $	*/
+/*	$NetBSD: rtutil.c,v 1.7 2016/01/23 21:05:51 christos Exp $	*/
 /*	$OpenBSD: show.c,v 1.1 2006/05/27 19:16:37 claudio Exp $	*/
 
 /*
@@ -33,7 +33,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 

Index: src/sbin/route/show.c
diff -u src/sbin/route/show.c:1.48 src/sbin/route/show.c:1.49
--- src/sbin/route/show.c:1.48	Mon Mar 23 14:33:17 2015
+++ src/sbin/route/show.c	Sat Jan 23 16:05:51 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: show.c,v 1.48 2015/03/23 18:33:17 roy Exp $	*/
+/*	$NetBSD: show.c,v 1.49 2016/01/23 21:05:51 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -34,14 +34,13 @@
 #if 0
 static char sccsid[] = "from: @(#)route.c	8.3 (Berkeley) 3/9/94";
 #else
-__RCSID("$NetBSD: show.c,v 1.48 2015/03/23 18:33:17 roy Exp $");
+__RCSID("$NetBSD: show.c,v 1.49 2016/01/23 21:05:51 christos Exp $");
 #endif
 #endif /* not lint */
 
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 



CVS commit: src/sbin/route

2016-01-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 17 15:59:26 UTC 2016

Modified Files:
src/sbin/route: route.c

Log Message:
PR/50671: David Binderman: fix memory leak.


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.152 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.151 src/sbin/route/route.c:1.152
--- src/sbin/route/route.c:1.151	Mon Mar 23 14:33:17 2015
+++ src/sbin/route/route.c	Sun Jan 17 10:59:26 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.151 2015/03/23 18:33:17 roy Exp $	*/
+/*	$NetBSD: route.c,v 1.152 2016/01/17 15:59:26 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)route.c	8.6 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: route.c,v 1.151 2015/03/23 18:33:17 roy Exp $");
+__RCSID("$NetBSD: route.c,v 1.152 2016/01/17 15:59:26 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -660,22 +660,22 @@ newroute(int argc, char *const *argv)
 		} else
 			break;
 	}
-	if (*cmd == 'g')
-		return ret != 0;
-	if (!qflag) {
-		oerrno = errno;
-		(void)printf("%s %s %s", cmd, ishost? "host" : "net", dest);
-		if (*gateway) {
-			(void)printf(": gateway %s", gateway);
-			if (attempts > 1 && ret == 0 && af == AF_INET)
-			(void)printf(" (%s)",
-			inet_ntoa(soup->so_gate->sin.sin_addr));
-		}
-		if (ret == 0)
-			(void)printf("\n");
-		else
-			(void)printf(": %s\n", route_strerror(oerrno));
+	if (*cmd == 'g' || qflag)
+		goto out;
+
+	oerrno = errno;
+	(void)printf("%s %s %s", cmd, ishost? "host" : "net", dest);
+	if (*gateway) {
+		(void)printf(": gateway %s", gateway);
+		if (attempts > 1 && ret == 0 && af == AF_INET)
+		(void)printf(" (%s)",
+			inet_ntoa(soup->so_gate->sin.sin_addr));
 	}
+	if (ret == 0)
+		(void)printf("\n");
+	else
+		(void)printf(": %s\n", route_strerror(oerrno));
+out:
 	free(sou.so_dst);
 	free(sou.so_gate);
 	free(sou.so_mask);



CVS commit: src/sbin/route

2015-09-13 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Sep 14 05:12:52 UTC 2015

Modified Files:
src/sbin/route: Makefile

Log Message:
Include a few additional libc functions in rump.route to make it work with inet6

getaddrinfo and if_nametoindex are newly added to interpret interface names
in IPv6 link-local addresses. if_nametoindex looks not used in rump.route,
but it is needed because it is used indirectly from getaddrinfo.

>From s-yamaguchi@IIJ


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sbin/route/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/Makefile
diff -u src/sbin/route/Makefile:1.28 src/sbin/route/Makefile:1.29
--- src/sbin/route/Makefile:1.28	Fri May 15 06:58:59 2015
+++ src/sbin/route/Makefile	Mon Sep 14 05:12:52 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.28 2015/05/15 06:58:59 ozaki-r Exp $
+#	$NetBSD: Makefile,v 1.29 2015/09/14 05:12:52 ozaki-r Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/5/93
 
 .include 
@@ -8,7 +8,8 @@ MAN=	route.8
 SRCS=	route.c show.c keywords.c rtutil.c
 
 .PATH:		${.CURDIR}/../../lib/libc/net
-RUMPSRCS= if_indextoname.c getifaddrs.c getnameinfo.c
+RUMPSRCS=	getaddrinfo.c getifaddrs.c getnameinfo.c
+RUMPSRCS+=	if_indextoname.c if_nametoindex.c
 .if (${MKRUMP} != "no")
 CPPFLAGS+= -DRUMP_ACTION
 .endif



CVS commit: src/sbin/route

2015-04-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Apr 22 03:07:55 UTC 2015

Modified Files:
src/sbin/route: Makefile

Log Message:
Fix rump.route shows host's interface names

Let it use rump-ified if_indextoname and getifaddrs
to get rump kernel's interfaces, which is the same way
as ifconfig.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sbin/route/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/Makefile
diff -u src/sbin/route/Makefile:1.26 src/sbin/route/Makefile:1.27
--- src/sbin/route/Makefile:1.26	Thu Nov  6 21:29:32 2014
+++ src/sbin/route/Makefile	Wed Apr 22 03:07:55 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.26 2014/11/06 21:29:32 christos Exp $
+#	$NetBSD: Makefile,v 1.27 2015/04/22 03:07:55 ozaki-r Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/5/93
 
 .include bsd.own.mk
@@ -7,6 +7,12 @@ RUMPPRG=route
 MAN=	route.8
 SRCS=	route.c show.c keywords.c rtutil.c
 
+.PATH:		${.CURDIR}/../../lib/libc/net
+RUMPSRCS= if_indextoname.c getifaddrs.c
+.if (${MKRUMP} != no)
+CPPFLAGS+= -DRUMP_ACTION
+.endif
+
 .if (${USE_INET6} != no)
 CPPFLAGS+=-DINET6
 .endif



CVS commit: src/sbin/route

2015-02-26 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Thu Feb 26 09:56:11 UTC 2015

Modified Files:
src/sbin/route: route.8 route.c rtutil.c show.c

Log Message:
Teach route(8) about RTF_LOCAL.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sbin/route/route.8
cvs rdiff -u -r1.149 -r1.150 src/sbin/route/route.c
cvs rdiff -u -r1.4 -r1.5 src/sbin/route/rtutil.c
cvs rdiff -u -r1.46 -r1.47 src/sbin/route/show.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.8
diff -u src/sbin/route/route.8:1.53 src/sbin/route/route.8:1.54
--- src/sbin/route/route.8:1.53	Mon Dec  1 20:30:27 2014
+++ src/sbin/route/route.8	Thu Feb 26 09:56:11 2015
@@ -1,4 +1,4 @@
-.\	$NetBSD: route.8,v 1.53 2014/12/01 20:30:27 christos Exp $
+.\	$NetBSD: route.8,v 1.54 2015/02/26 09:56:11 roy Exp $
 .\
 .\ Copyright (c) 1983, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\ @(#)route.8	8.4 (Berkeley) 6/1/94
 .\
-.Dd December 1, 2014
+.Dd February 26, 2015
 .Dt ROUTE 8
 .Os
 .Sh NAME
@@ -304,6 +304,7 @@ by indicating the following correspondin
 .It Li G Ta  Ta  RTF_GATEWAY Ta forwarded to dest by intermediary
 .It Li H Ta  Ta  RTF_HOST Ta host entry (net otherwise)
 .It Li L Ta -llinfo Ta  RTF_LLINFO Ta translate proto to link addr
+.It Li l Ta  Ta  RTF_LOCAL Ta Route represents a local address
 .It Li M Ta  Ta  RTF_MODIFIED Ta modified dynamically (redirect)
 .It Li p Ta -proxy Ta  RTF_ANNOUNCE Ta make entry a link level proxy
 .It Li R Ta -reject Ta  RTF_REJECT Ta send ICMP unreachable on match

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.149 src/sbin/route/route.c:1.150
--- src/sbin/route/route.c:1.149	Sat Dec 20 13:15:48 2014
+++ src/sbin/route/route.c	Thu Feb 26 09:56:11 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.149 2014/12/20 13:15:48 prlw1 Exp $	*/
+/*	$NetBSD: route.c,v 1.150 2015/02/26 09:56:11 roy Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)route.c	8.6 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: route.c,v 1.149 2014/12/20 13:15:48 prlw1 Exp $);
+__RCSID($NetBSD: route.c,v 1.150 2015/02/26 09:56:11 roy Exp $);
 #endif
 #endif /* not lint */
 
@@ -1292,7 +1292,7 @@ const char * const msgtypes[] = {
 const char metricnames[] =
 \011pksent\010rttvar\7rtt\6ssthresh\5sendpipe\4recvpipe\3expire\2hopcount\1mtu;
 const char routeflags[] =
-\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE\010MASK_PRESENT\011CLONING\012XRESOLVE\013LLINFO\014STATIC\015BLACKHOLE\016CLONED\017PROTO2\020PROTO1;
+\1UP\2GATEWAY\3HOST\4REJECT\5DYNAMIC\6MODIFIED\7DONE\010MASK_PRESENT\011CLONING\012XRESOLVE\013LLINFO\014STATIC\015BLACKHOLE\016CLONED\017PROTO2\020PROTO1\023LOCAL;
 const char ifnetflags[] =
 \1UP\2BROADCAST\3DEBUG\4LOOPBACK\5PTP\6NOTRAILERS\7RUNNING\010NOARP\011PPROMISC\012ALLMULTI\013OACTIVE\014SIMPLEX\015LINK0\016LINK1\017LINK2\020MULTICAST;
 const char addrnames[] =

Index: src/sbin/route/rtutil.c
diff -u src/sbin/route/rtutil.c:1.4 src/sbin/route/rtutil.c:1.5
--- src/sbin/route/rtutil.c:1.4	Wed Jan  7 22:38:32 2015
+++ src/sbin/route/rtutil.c	Thu Feb 26 09:56:11 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtutil.c,v 1.4 2015/01/07 22:38:32 christos Exp $	*/
+/*	$NetBSD: rtutil.c,v 1.5 2015/02/26 09:56:11 roy Exp $	*/
 /*	$OpenBSD: show.c,v 1.1 2006/05/27 19:16:37 claudio Exp $	*/
 
 /*
@@ -92,6 +92,7 @@ static const struct bits bits[] = {
 	{ RTF_CLONED,	'c' },
 	/* { RTF_JUMBO,	'J' }, */
 	{ RTF_ANNOUNCE,	'p' },
+	{ RTF_LOCAL, 'l'},
 	{ 0, 0 }
 };
 

Index: src/sbin/route/show.c
diff -u src/sbin/route/show.c:1.46 src/sbin/route/show.c:1.47
--- src/sbin/route/show.c:1.46	Thu Nov  6 21:29:32 2014
+++ src/sbin/route/show.c	Thu Feb 26 09:56:11 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: show.c,v 1.46 2014/11/06 21:29:32 christos Exp $	*/
+/*	$NetBSD: show.c,v 1.47 2015/02/26 09:56:11 roy Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = from: @(#)route.c	8.3 (Berkeley) 3/9/94;
 #else
-__RCSID($NetBSD: show.c,v 1.46 2014/11/06 21:29:32 christos Exp $);
+__RCSID($NetBSD: show.c,v 1.47 2015/02/26 09:56:11 roy Exp $);
 #endif
 #endif /* not lint */
 
@@ -137,7 +137,7 @@ show(int argc, char *const *argv, int fl
 {
 	int af, rflags;
 	static int interesting = RTF_UP | RTF_GATEWAY | RTF_HOST |
-	RTF_REJECT | RTF_LLINFO;
+	RTF_REJECT | RTF_LLINFO | RTF_LOCAL;
 
 	parse_show_opts(argc, argv, af, rflags, NULL, true);
 	p_rttables(af, flags, rflags, interesting);



CVS commit: src/sbin/route

2015-01-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jan  7 22:38:32 UTC 2015

Modified Files:
src/sbin/route: rtutil.c rtutil.h

Log Message:
make netname4 match the netname6 signature avoiding a NULL pointer.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sbin/route/rtutil.c
cvs rdiff -u -r1.2 -r1.3 src/sbin/route/rtutil.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/rtutil.c
diff -u src/sbin/route/rtutil.c:1.3 src/sbin/route/rtutil.c:1.4
--- src/sbin/route/rtutil.c:1.3	Tue Nov 11 22:34:08 2014
+++ src/sbin/route/rtutil.c	Wed Jan  7 17:38:32 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtutil.c,v 1.3 2014/11/12 03:34:08 christos Exp $	*/
+/*	$NetBSD: rtutil.c,v 1.4 2015/01/07 22:38:32 christos Exp $	*/
 /*	$OpenBSD: show.c,v 1.1 2006/05/27 19:16:37 claudio Exp $	*/
 
 /*
@@ -552,21 +552,27 @@ routename6(const struct sockaddr_in6 *si
  * The address is assumed to be that of a net or subnet, not a host.
  */
 char *
-netname4(in_addr_t in, in_addr_t mask, int flags)
+netname4(const struct sockaddr_in* sa4, const struct sockaddr_in *mask, int flags)
 {
 	const char *cp = NULL;
 	struct netent *np = NULL;
 	int mbits;
+	in_addr_t in = sa4-sin_addr.s_addr;
+
+	if (mask) {
+		in_addr_t m = mask-sin_addr.s_addr ;
+		m = ntohl(m);
+		mbits = m ? 33 - ffs(m) : 0;
+	} else
+		mbits = 0;
 
 	in = ntohl(in);
-	mask = ntohl(mask);
-	if (!(flags  RT_NFLAG)  in != INADDR_ANY) {
+	if (in == INADDR_ANY  !mbits)
+		cp = default;
+	else if (!(flags  RT_NFLAG)  in != INADDR_ANY) {
 		if ((np = getnetbyaddr(in, AF_INET)) != NULL)
 			cp = np-n_name;
 	}
-	mbits = mask ? 33 - ffs(mask) : 0;
-	if (in == INADDR_ANY  !mbits)
-			cp = default;
 	if (cp)
 		strlcpy(line, cp, sizeof(line));
 #define C(x)	((x)  0xff)
@@ -582,7 +588,7 @@ netname4(in_addr_t in, in_addr_t mask, i
 		snprintf(line, sizeof(line), %u.%u.%u.%u/%d, C(in  24),
 		C(in  16), C(in  8), C(in), mbits);
 #undef C
-	return (line);
+	return line;
 }
 
 #ifdef INET6
@@ -693,8 +699,8 @@ netname(const struct sockaddr *sa, const
 	switch (sa-sa_family) {
 
 	case AF_INET:
-		return netname4(((const struct sockaddr_in *)sa)-sin_addr.s_addr,
-		((const struct sockaddr_in *)mask)-sin_addr.s_addr, flags);
+		return netname4((const struct sockaddr_in *)sa,
+		(const struct sockaddr_in *)mask, flags);
 #ifdef INET6
 	case AF_INET6:
 		return netname6((const struct sockaddr_in6 *)sa,

Index: src/sbin/route/rtutil.h
diff -u src/sbin/route/rtutil.h:1.2 src/sbin/route/rtutil.h:1.3
--- src/sbin/route/rtutil.h:1.2	Tue Nov 11 22:34:08 2014
+++ src/sbin/route/rtutil.h	Wed Jan  7 17:38:32 2015
@@ -53,7 +53,7 @@ char *routename6(const struct sockaddr_i
 char *netname6(const struct sockaddr_in6 *, const struct sockaddr_in6 *, int);
 #endif
 char *netname(const struct sockaddr *, const struct sockaddr *, int);
-char *netname4(in_addr_t, in_addr_t, int);
+char *netname4(const struct sockaddr_in *, const struct sockaddr_in *, int);
 
 char *mpls_ntoa(const struct sockaddr *);
 char *any_ntoa(const struct sockaddr *);



CVS commit: src/sbin/route

2014-12-17 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Wed Dec 17 10:56:09 UTC 2014

Modified Files:
src/sbin/route: route.c

Log Message:
Note that RTM_CHANGE can also change the gateway


To generate a diff of this commit:
cvs rdiff -u -r1.147 -r1.148 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.147 src/sbin/route/route.c:1.148
--- src/sbin/route/route.c:1.147	Wed Nov 12 03:34:08 2014
+++ src/sbin/route/route.c	Wed Dec 17 10:56:09 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.147 2014/11/12 03:34:08 christos Exp $	*/
+/*	$NetBSD: route.c,v 1.148 2014/12/17 10:56:09 roy Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)route.c	8.6 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: route.c,v 1.147 2014/11/12 03:34:08 christos Exp $);
+__RCSID($NetBSD: route.c,v 1.148 2014/12/17 10:56:09 roy Exp $);
 #endif
 #endif /* not lint */
 
@@ -1266,7 +1266,7 @@ mask_addr(struct sou *soup)
 const char * const msgtypes[] = {
 	[RTM_ADD] = RTM_ADD: Add Route,
 	[RTM_DELETE] = RTM_DELETE: Delete Route,
-	[RTM_CHANGE] = RTM_CHANGE: Change Metrics or flags,
+	[RTM_CHANGE] = RTM_CHANGE: Change Metrics, Flags or Gateway,
 	[RTM_GET] = RTM_GET: Report Metrics,
 	[RTM_LOSING] = RTM_LOSING: Kernel Suspects Partitioning,
 	[RTM_REDIRECT] = RTM_REDIRECT: Told to use different route,



CVS commit: src/sbin/route

2014-12-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec  1 20:30:27 UTC 2014

Modified Files:
src/sbin/route: route.8

Log Message:
Complete the routing argument table by including the ID's used in the routing
display.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sbin/route/route.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.8
diff -u src/sbin/route/route.8:1.52 src/sbin/route/route.8:1.53
--- src/sbin/route/route.8:1.52	Tue Nov 11 22:34:08 2014
+++ src/sbin/route/route.8	Mon Dec  1 15:30:27 2014
@@ -1,4 +1,4 @@
-.\	$NetBSD: route.8,v 1.52 2014/11/12 03:34:08 christos Exp $
+.\	$NetBSD: route.8,v 1.53 2014/12/01 20:30:27 christos Exp $
 .\
 .\ Copyright (c) 1983, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\ @(#)route.8	8.4 (Berkeley) 6/1/94
 .\
-.Dd November 11, 2014
+.Dd December 1, 2014
 .Dt ROUTE 8
 .Os
 .Sh NAME
@@ -286,26 +286,33 @@ is also available for similar purpose, i
 .Pp
 Routes have associated flags which influence operation of the protocols
 when sending to destinations matched by the routes.
-These flags may be set (or sometimes cleared)
+These flags are displayed using the following ID characters in the routing
+display and may be set (or sometimes cleared)
 by indicating the following corresponding modifiers:
-.Bd -literal
--cloning  RTF_CLONING- generates a new route on use
--nocloning   ~RTF_CLONING- stop generating new routes on use
--cloned   RTF_CLONED - cloned route generated by RTF_CLONING
--nocloned~RTF_CLONED - prevent removal with RTF_CLONING parent
--xresolve RTF_XRESOLVE   - emit mesg on use (for external lookup)
--iface   ~RTF_GATEWAY- destination is directly reachable
--static   RTF_STATIC - manually added route
--nostatic~RTF_STATIC - pretend route added by kernel or daemon
--reject   RTF_REJECT - emit an ICMP unreachable when matched
--noreject~RTF_REJECT - clear reject flag
--blackholeRTF_BLACKHOLE  - silently discard pkts (during updates)
--noblackhole ~RTF_BLACKHOLE  - clear blackhole flag
--proto1   RTF_PROTO1 - set protocol specific routing flag #1
--proto2   RTF_PROTO2 - set protocol specific routing flag #2
--llinfo   RTF_LLINFO - validly translates proto addr to link addr
--proxyRTF_ANNOUNCE   - make entry a link level proxy
-.Ed
+.Bl -column ID xnoblackhole xRTF_BLACKHOLE x
+.It Sy ID Ta Sy Modifier Ta Sy  Flag Bit Ta Sy Description
+.It Li   Ta -iface Ta ~RTF_GATEWAY Ta destination is directly reachable
+.It Li 1 Ta -proto1 Ta  RTF_PROTO1 Ta set protocol specific flag #1
+.It Li 2 Ta -proto2 Ta  RTF_PROTO2 Ta set protocol specific flag #2
+.It Li B Ta -blackhole Ta  RTF_BLACKHOLE Ta discard pkts (during updates)
+.It Li   Ta -noblackhole Ta ~RTF_BLACKHOLE Ta clear blackhole flag
+.It Li C Ta -cloning Ta  RTF_CLONING Ta  generates a new route on use
+.It Li   Ta -nocloning Ta ~RTF_CLONING Ta stop generating new routes on use
+.It Li c Ta -cloned Ta  RTF_CLONED Ta route generated by RTF_CLONING
+.It Li   Ta -nocloned Ta ~RTF_CLONED Ta deny removal with RTF_CLONING
+.It Li D Ta  Ta  RTF_DYNAMIC Ta created dynamically (redirect)
+.It Li G Ta  Ta  RTF_GATEWAY Ta forwarded to dest by intermediary
+.It Li H Ta  Ta  RTF_HOST Ta host entry (net otherwise)
+.It Li L Ta -llinfo Ta  RTF_LLINFO Ta translate proto to link addr
+.It Li M Ta  Ta  RTF_MODIFIED Ta modified dynamically (redirect)
+.It Li p Ta -proxy Ta  RTF_ANNOUNCE Ta make entry a link level proxy
+.It Li R Ta -reject Ta  RTF_REJECT Ta send ICMP unreachable on match
+.It Li   Ta -noreject Ta ~RTF_REJECT Ta clear reject flag
+.It Li S Ta -static Ta  RTF_STATIC Ta manually added route
+.It Li   Ta -nostatic Ta ~RTF_STATIC Ta pretend route added automatically
+.It Li U Ta  Ta  RTF_UP Ta route usable
+.It Li X Ta -xresolve Ta  RTF_XRESOLVE Ta emit mesg on use (for ext lookup)
+.El
 .Pp
 The optional modifiers
 .Fl rtt ,



CVS commit: src/sbin/route

2014-11-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Nov 12 03:34:08 UTC 2014

Modified Files:
src/sbin/route: route.8 route.c rtutil.c rtutil.h

Log Message:
PR/47704: Takahiro HAYASHI: Add -L flag


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sbin/route/route.8
cvs rdiff -u -r1.146 -r1.147 src/sbin/route/route.c
cvs rdiff -u -r1.2 -r1.3 src/sbin/route/rtutil.c
cvs rdiff -u -r1.1 -r1.2 src/sbin/route/rtutil.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.8
diff -u src/sbin/route/route.8:1.51 src/sbin/route/route.8:1.52
--- src/sbin/route/route.8:1.51	Fri Nov  7 09:57:08 2014
+++ src/sbin/route/route.8	Tue Nov 11 22:34:08 2014
@@ -1,4 +1,4 @@
-.\	$NetBSD: route.8,v 1.51 2014/11/07 14:57:08 christos Exp $
+.\	$NetBSD: route.8,v 1.52 2014/11/12 03:34:08 christos Exp $
 .\
 .\ Copyright (c) 1983, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\ @(#)route.8	8.4 (Berkeley) 6/1/94
 .\
-.Dd November 7, 2014
+.Dd November 11, 2014
 .Dt ROUTE 8
 .Os
 .Sh NAME
@@ -37,7 +37,7 @@
 .Nd manually manipulate the routing tables
 .Sh SYNOPSIS
 .Nm
-.Op Fl dfnqSsTtv
+.Op Fl dfLnqSsTtv
 .Ar command
 .Oo
 .Op Ar modifiers
@@ -81,6 +81,8 @@ or
 commands,
 .Nm
 removes the routes before performing the command.
+.It Fl L
+Don't show link layer entries in routing table.
 .It Fl n
 Bypasses attempts to print host and network names symbolically
 when reporting actions.

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.146 src/sbin/route/route.c:1.147
--- src/sbin/route/route.c:1.146	Fri Nov  7 09:57:08 2014
+++ src/sbin/route/route.c	Tue Nov 11 22:34:08 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.146 2014/11/07 14:57:08 christos Exp $	*/
+/*	$NetBSD: route.c,v 1.147 2014/11/12 03:34:08 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)route.c	8.6 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: route.c,v 1.146 2014/11/07 14:57:08 christos Exp $);
+__RCSID($NetBSD: route.c,v 1.147 2014/11/12 03:34:08 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -126,15 +126,16 @@ static void sockaddr(const char *, struc
 
 int	pid, rtm_addrs;
 int	sock;
-int	forcehost, forcenet, doflush, nflag, af, qflag, tflag, Sflag, Tflag;
-int	iflag, verbose, aflen = sizeof(struct sockaddr_in), rtag;
+int	forcehost, forcenet, doflush, af;
+int	iflag, Lflag, nflag, qflag, tflag, Sflag, Tflag;
+int	verbose, aflen = sizeof(struct sockaddr_in), rtag;
 int	locking, lockrest, debugonly, shortoutput;
 struct	rt_metrics rt_metrics;
 int	rtm_inits;
 short ns_nullh[] = {0,0,0};
 short ns_bh[] = {-1,-1,-1};
 
-static const char opts[] = dfnqSsTtv;
+static const char opts[] = dfLnqSsTtv;
 
 void
 usage(const char *cp)
@@ -168,6 +169,9 @@ main(int argc, char * const *argv)
 		case 'f':
 			doflush = 1;
 			break;
+		case 'L':
+			Lflag = RT_LFLAG;
+			break;
 		case 'n':
 			nflag = RT_NFLAG;
 			break;
@@ -228,7 +232,7 @@ main(int argc, char * const *argv)
 		return newroute(argc, argv);
 
 	case K_SHOW:
-		show(argc, argv, nflag|Tflag|verbose);
+		show(argc, argv, Lflag|nflag|Tflag|verbose);
 		return 0;
 
 #ifndef SMALL

Index: src/sbin/route/rtutil.c
diff -u src/sbin/route/rtutil.c:1.2 src/sbin/route/rtutil.c:1.3
--- src/sbin/route/rtutil.c:1.2	Fri Nov  7 19:47:32 2014
+++ src/sbin/route/rtutil.c	Tue Nov 11 22:34:08 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtutil.c,v 1.2 2014/11/08 00:47:32 christos Exp $	*/
+/*	$NetBSD: rtutil.c,v 1.3 2014/11/12 03:34:08 christos Exp $	*/
 /*	$OpenBSD: show.c,v 1.1 2006/05/27 19:16:37 claudio Exp $	*/
 
 /*
@@ -261,6 +261,9 @@ p_rtentry(struct rt_msghdr *rtm, int fla
 	char		 ifbuf[IF_NAMESIZE];
 #endif
 
+	if ((flags  RT_LFLAG)  (rtm-rtm_flags  RTF_LLINFO))
+		return;
+
 	if (old_af != sa-sa_family) {
 		old_af = sa-sa_family;
 		p_family(sa-sa_family);

Index: src/sbin/route/rtutil.h
diff -u src/sbin/route/rtutil.h:1.1 src/sbin/route/rtutil.h:1.2
--- src/sbin/route/rtutil.h:1.1	Thu Nov  6 16:29:32 2014
+++ src/sbin/route/rtutil.h	Tue Nov 11 22:34:08 2014
@@ -30,10 +30,11 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#define RT_AFLAG	1
-#define RT_TFLAG	2
-#define RT_VFLAG	4
-#define RT_NFLAG	8
+#define RT_AFLAG	__BIT(0)	/* show address field */
+#define RT_TFLAG	__BIT(1)	/* show tag field */
+#define RT_VFLAG	__BIT(2)	/* show verbose statistics */
+#define RT_NFLAG	__BIT(3)	/* numeric output */
+#define RT_LFLAG	__BIT(4)	/* don't show LLINFO entries */
 
 void p_rttables(int, int, int, int);
 void p_rthdr(int, int);



CVS commit: src/sbin/route

2014-11-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Nov  7 14:57:08 UTC 2014

Modified Files:
src/sbin/route: route.8 route.c

Log Message:
Now that the code can support tags and verbose route printing, enable them.
Also document previously undocumented flags.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sbin/route/route.8
cvs rdiff -u -r1.145 -r1.146 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.8
diff -u src/sbin/route/route.8:1.50 src/sbin/route/route.8:1.51
--- src/sbin/route/route.8:1.50	Tue Nov  5 02:42:48 2013
+++ src/sbin/route/route.8	Fri Nov  7 09:57:08 2014
@@ -1,4 +1,4 @@
-.\	$NetBSD: route.8,v 1.50 2013/11/05 07:42:48 kefren Exp $
+.\	$NetBSD: route.8,v 1.51 2014/11/07 14:57:08 christos Exp $
 .\
 .\ Copyright (c) 1983, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\ @(#)route.8	8.4 (Berkeley) 6/1/94
 .\
-.Dd November 5, 2013
+.Dd November 7, 2014
 .Dt ROUTE 8
 .Os
 .Sh NAME
@@ -37,7 +37,7 @@
 .Nd manually manipulate the routing tables
 .Sh SYNOPSIS
 .Nm
-.Op Fl fnqSsv
+.Op Fl dfnqSsTtv
 .Ar command
 .Oo
 .Op Ar modifiers
@@ -67,6 +67,8 @@ programmatic interface discussed in
 .Xr route 4 .
 .Pp
 .Bl -tag -width Ds
+.It Fl d
+Turn on debugging
 .It Fl f
 Remove all routes (as per
 .Cm flush ) .
@@ -96,6 +98,10 @@ instead of printing the flags that are s
 .Cm get
 command except for the actual gateway that will be used.
 How the gateway is printed depends on the type of route being looked up.
+.It Fl T
+Show tags in the route display.
+.It Fl t
+Test only, don't perform any actions.
 .It Fl v
 (verbose) Print additional details.
 .El

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.145 src/sbin/route/route.c:1.146
--- src/sbin/route/route.c:1.145	Thu Nov  6 16:29:32 2014
+++ src/sbin/route/route.c	Fri Nov  7 09:57:08 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.145 2014/11/06 21:29:32 christos Exp $	*/
+/*	$NetBSD: route.c,v 1.146 2014/11/07 14:57:08 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)route.c	8.6 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: route.c,v 1.145 2014/11/06 21:29:32 christos Exp $);
+__RCSID($NetBSD: route.c,v 1.146 2014/11/07 14:57:08 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -126,7 +126,7 @@ static void sockaddr(const char *, struc
 
 int	pid, rtm_addrs;
 int	sock;
-int	forcehost, forcenet, doflush, nflag, af, qflag, tflag, Sflag;
+int	forcehost, forcenet, doflush, nflag, af, qflag, tflag, Sflag, Tflag;
 int	iflag, verbose, aflen = sizeof(struct sockaddr_in), rtag;
 int	locking, lockrest, debugonly, shortoutput;
 struct	rt_metrics rt_metrics;
@@ -134,6 +134,7 @@ int	rtm_inits;
 short ns_nullh[] = {0,0,0};
 short ns_bh[] = {-1,-1,-1};
 
+static const char opts[] = dfnqSsTtv;
 
 void
 usage(const char *cp)
@@ -142,8 +143,7 @@ usage(const char *cp)
 	if (cp)
 		warnx(botched keyword: %s, cp);
 	(void)fprintf(stderr,
-	Usage: %s [ -fnqSsv ] cmd [[ -qualifers ] args ]\n,
-	getprogname());
+	Usage: %s [-%s] cmd [[-qualifers] args]\n, getprogname(), opts);
 	exit(1);
 	/* NOTREACHED */
 }
@@ -160,7 +160,7 @@ main(int argc, char * const *argv)
 	if (argc  2)
 		usage(NULL);
 
-	while ((ch = getopt(argc, argv, dfnqSstv)) != -1)
+	while ((ch = getopt(argc, argv, opts)) != -1)
 		switch (ch) {
 		case 'd':
 			debugonly = 1;
@@ -180,11 +180,14 @@ main(int argc, char * const *argv)
 		case 's':
 			shortoutput = 1;
 			break;
+		case 'T':
+			Tflag = RT_TFLAG;
+			break;
 		case 't':
 			tflag = 1;
 			break;
 		case 'v':
-			verbose = 1;
+			verbose = RT_VFLAG;
 			break;
 		case '?':
 		default:
@@ -225,7 +228,7 @@ main(int argc, char * const *argv)
 		return newroute(argc, argv);
 
 	case K_SHOW:
-		show(argc, argv, nflag);
+		show(argc, argv, nflag|Tflag|verbose);
 		return 0;
 
 #ifndef SMALL



CVS commit: src/sbin/route

2014-11-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov  8 00:47:32 UTC 2014

Modified Files:
src/sbin/route: rtutil.c

Log Message:
give a little more space


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sbin/route/rtutil.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/rtutil.c
diff -u src/sbin/route/rtutil.c:1.1 src/sbin/route/rtutil.c:1.2
--- src/sbin/route/rtutil.c:1.1	Thu Nov  6 16:29:32 2014
+++ src/sbin/route/rtutil.c	Fri Nov  7 19:47:32 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtutil.c,v 1.1 2014/11/06 21:29:32 christos Exp $	*/
+/*	$NetBSD: rtutil.c,v 1.2 2014/11/08 00:47:32 christos Exp $	*/
 /*	$OpenBSD: show.c,v 1.1 2006/05/27 19:16:37 claudio Exp $	*/
 
 /*
@@ -186,13 +186,14 @@ p_rttables(int paf, int flags, int pflag
 /* 
  * column widths; each followed by one space
  * width of destination/gateway column
- * strlen(fe80:::::@gif0) == 30, strlen(/128) == 4
+ * strlen(fe80:::::@gif0) == 30, strlen(/128) == 4 = 34
+ * strlen(:::::::) == 39
  */
 #ifndef INET6
 #define	WID_DST(af)	18	/* width of destination column */
 #define	WID_GW(af)	18	/* width of gateway column */
 #else
-#define	WID_DST(af)	((af) == AF_INET6 ? ((flags  RT_NFLAG) ? 34 : 18) : 18)
+#define	WID_DST(af)	((af) == AF_INET6 ? ((flags  RT_NFLAG) ? 39 : 18) : 18)
 #define	WID_GW(af)	((af) == AF_INET6 ? ((flags  RT_NFLAG) ? 30 : 18) : 18)
 #endif
 



CVS commit: src/sbin/route

2014-11-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Nov  6 21:29:32 UTC 2014

Modified Files:
src/sbin/route: Makefile extern.h prog_ops.h route.c show.c
Added Files:
src/sbin/route: rtutil.c rtutil.h

Log Message:
Factor out the netstat route printing code and use it here. There is no
point in having 2 different copies; fixes PR/49371


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sbin/route/Makefile
cvs rdiff -u -r1.14 -r1.15 src/sbin/route/extern.h
cvs rdiff -u -r1.2 -r1.3 src/sbin/route/prog_ops.h
cvs rdiff -u -r1.144 -r1.145 src/sbin/route/route.c
cvs rdiff -u -r0 -r1.1 src/sbin/route/rtutil.c src/sbin/route/rtutil.h
cvs rdiff -u -r1.45 -r1.46 src/sbin/route/show.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/Makefile
diff -u src/sbin/route/Makefile:1.25 src/sbin/route/Makefile:1.26
--- src/sbin/route/Makefile:1.25	Mon Dec 13 12:39:47 2010
+++ src/sbin/route/Makefile	Thu Nov  6 16:29:32 2014
@@ -1,11 +1,11 @@
-#	$NetBSD: Makefile,v 1.25 2010/12/13 17:39:47 pooka Exp $
+#	$NetBSD: Makefile,v 1.26 2014/11/06 21:29:32 christos Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/5/93
 
 .include bsd.own.mk
 
 RUMPPRG=route
 MAN=	route.8
-SRCS=	route.c show.c keywords.c
+SRCS=	route.c show.c keywords.c rtutil.c
 
 .if (${USE_INET6} != no)
 CPPFLAGS+=-DINET6

Index: src/sbin/route/extern.h
diff -u src/sbin/route/extern.h:1.14 src/sbin/route/extern.h:1.15
--- src/sbin/route/extern.h:1.14	Tue Oct 20 21:07:46 2009
+++ src/sbin/route/extern.h	Thu Nov  6 16:29:32 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: extern.h,v 1.14 2009/10/21 01:07:46 snj Exp $	*/
+/*	$NetBSD: extern.h,v 1.15 2014/11/06 21:29:32 christos Exp $	*/
 
 /*
  * Copyright (c) 1997 Christos Zoulas.  All rights reserved.
@@ -30,15 +30,11 @@ struct sockaddr_ns;
 
 void parse_show_opts(int, char * const *, int *, int *, const char **, bool);
 /* show.c */
-void show(int, char * const *);
+void show(int, char * const *, int);
 
 /* route.c */
 extern int nflag, Sflag;
 #define NOTDEFSTRING 0.0.0.0/xxx.xxx.xxx.xxx\0
 int keyword(const char *);
-int netmask_length(struct sockaddr *, int);
-char *netmask_string(const struct sockaddr *, int, int);
-const char *routename(const struct sockaddr *, struct sockaddr *, int);
-const char *netname(const struct sockaddr *, struct sockaddr *);
 const char *ns_print(struct sockaddr_ns *);
 void usage(const char *)__attribute__((__noreturn__));

Index: src/sbin/route/prog_ops.h
diff -u src/sbin/route/prog_ops.h:1.2 src/sbin/route/prog_ops.h:1.3
--- src/sbin/route/prog_ops.h:1.2	Mon Dec 13 14:19:10 2010
+++ src/sbin/route/prog_ops.h	Thu Nov  6 16:29:32 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: prog_ops.h,v 1.2 2010/12/13 19:19:10 pooka Exp $	*/
+/*  $NetBSD: prog_ops.h,v 1.3 2014/11/06 21:29:32 christos Exp $	*/
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -32,9 +32,13 @@
 #include sys/types.h
 
 #ifndef CRUNCHOPS
+/* XXX: Keep same order with netstat! */
 struct prog_ops {
 	int (*op_init)(void);
 
+	int (*op_sysctl)(const int *, u_int, void *, size_t *,
+			 const void *, size_t);
+
 	int (*op_socket)(int, int, int);
 	int (*op_open)(const char *, int, ...);
 	pid_t (*op_getpid)(void);
@@ -42,8 +46,6 @@ struct prog_ops {
 	ssize_t (*op_read)(int, void *, size_t);
 	ssize_t (*op_write)(int, const void *, size_t);
 
-	int (*op_sysctl)(const int *, u_int, void *, size_t *,
-			 const void *, size_t);
 
 	int (*op_shutdown)(int, int);
 };

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.144 src/sbin/route/route.c:1.145
--- src/sbin/route/route.c:1.144	Sat Oct 19 11:59:15 2013
+++ src/sbin/route/route.c	Thu Nov  6 16:29:32 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.144 2013/10/19 15:59:15 christos Exp $	*/
+/*	$NetBSD: route.c,v 1.145 2014/11/06 21:29:32 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)route.c	8.6 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: route.c,v 1.144 2013/10/19 15:59:15 christos Exp $);
+__RCSID($NetBSD: route.c,v 1.145 2014/11/06 21:29:32 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -73,6 +73,7 @@ __RCSID($NetBSD: route.c,v 1.144 2013/1
 #include keywords.h
 #include extern.h
 #include prog_ops.h
+#include rtutil.h
 
 union sockunion {
 	struct	sockaddr sa;
@@ -95,7 +96,6 @@ struct sou {
 		*so_ifp, *so_mpls;
 };
 
-static char *any_ntoa(const struct sockaddr *);
 static const char *route_strerror(int);
 static void set_metric(const char *, int);
 static int newroute(int, char *const *);
@@ -105,6 +105,7 @@ static int inet6_makenetandmask(const st
 #endif
 static int getaddr(int, const char *, struct hostent **, struct sou *);
 static int flushroutes(int, char *const [], int);
+static char *netmask_string(const struct sockaddr *, int, int);
 static int prefixlen(const char *, struct sou *);
 #ifndef SMALL
 static 

CVS commit: src/sbin/route

2013-11-04 Thread Mihai Chelaru
Module Name:src
Committed By:   kefren
Date:   Tue Nov  5 07:42:48 UTC 2013

Modified Files:
src/sbin/route: route.8

Log Message:
Remove esis reference


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sbin/route/route.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.8
diff -u src/sbin/route/route.8:1.49 src/sbin/route/route.8:1.50
--- src/sbin/route/route.8:1.49	Mon Oct  7 05:06:45 2013
+++ src/sbin/route/route.8	Tue Nov  5 07:42:48 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: route.8,v 1.49 2013/10/07 05:06:45 dholland Exp $
+.\	$NetBSD: route.8,v 1.50 2013/11/05 07:42:48 kefren Exp $
 .\
 .\ Copyright (c) 1983, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\ @(#)route.8	8.4 (Berkeley) 6/1/94
 .\
-.Dd July 24, 2013
+.Dd November 5, 2013
 .Dt ROUTE 8
 .Os
 .Sh NAME
@@ -401,7 +401,6 @@ Only root may modify the routing tables.
 These privileges are enforced by the kernel.
 .El
 .Sh SEE ALSO
-.Xr esis 4 ,
 .Xr mpls 4 ,
 .Xr netintro 4 ,
 .Xr route 4 ,



CVS commit: src/sbin/route

2013-10-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct 18 21:01:00 UTC 2013

Modified Files:
src/sbin/route: route.c

Log Message:
avoid pointer gymnastics


To generate a diff of this commit:
cvs rdiff -u -r1.140 -r1.141 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.140 src/sbin/route/route.c:1.141
--- src/sbin/route/route.c:1.140	Fri Mar  1 13:25:17 2013
+++ src/sbin/route/route.c	Fri Oct 18 17:01:00 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.140 2013/03/01 18:25:17 joerg Exp $	*/
+/*	$NetBSD: route.c,v 1.141 2013/10/18 21:01:00 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)route.c	8.6 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: route.c,v 1.140 2013/03/01 18:25:17 joerg Exp $);
+__RCSID($NetBSD: route.c,v 1.141 2013/10/18 21:01:00 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -543,8 +543,10 @@ routename(const struct sockaddr *sa, str
 		(IN6_IS_ADDR_LINKLOCAL(sin6.sin6_addr) ||
 		 IN6_IS_ADDR_MC_LINKLOCAL(sin6.sin6_addr)) 
 		sin6.sin6_scope_id == 0) {
-			sin6.sin6_scope_id =
-			ntohs(*(u_int16_t *)sin6.sin6_addr.s6_addr[2]);
+			uint16_t scope;
+			memcpy(scope, sin6.sin6_addr.s6_addr[2],
+			sizeof(scope));
+			sin6.sin6_scope_id = ntohs(scope);
 			sin6.sin6_addr.s6_addr[2] = 0;
 			sin6.sin6_addr.s6_addr[3] = 0;
 		}
@@ -710,8 +712,10 @@ netname(const struct sockaddr *sa, struc
 		(IN6_IS_ADDR_LINKLOCAL(sin6.sin6_addr) ||
 		 IN6_IS_ADDR_MC_LINKLOCAL(sin6.sin6_addr)) 
 		sin6.sin6_scope_id == 0) {
-			sin6.sin6_scope_id =
-			ntohs(*(u_int16_t *)sin6.sin6_addr.s6_addr[2]);
+			uint16_t scope;
+			memcpy(scope, sin6.sin6_addr.s6_addr[2],
+			sizeof(scope));
+			sin6.sin6_scope_id = ntohs(scope);
 			sin6.sin6_addr.s6_addr[2] = 0;
 			sin6.sin6_addr.s6_addr[3] = 0;
 		}
@@ -1259,8 +1263,10 @@ getaddr(int which, const char *s, struct
 		if ((IN6_IS_ADDR_LINKLOCAL(su-sin6.sin6_addr) ||
 		 IN6_IS_ADDR_MC_LINKLOCAL(su-sin6.sin6_addr)) 
 		su-sin6.sin6_scope_id) {
-			*(u_int16_t *)su-sin6.sin6_addr.s6_addr[2] =
-htons(su-sin6.sin6_scope_id);
+			uint16_t scope;
+			scope = htons(su-sin6.sin6_scope_id);
+			memcpy(su-sin6.sin6_addr.s6_addr[2], scope,
+			sizeof(scope));
 			su-sin6.sin6_scope_id = 0;
 		}
 #endif



CVS commit: src/sbin/route

2013-10-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Oct 19 00:39:39 UTC 2013

Modified Files:
src/sbin/route: route.c

Log Message:
use scopeid functions


To generate a diff of this commit:
cvs rdiff -u -r1.141 -r1.142 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.141 src/sbin/route/route.c:1.142
--- src/sbin/route/route.c:1.141	Fri Oct 18 17:01:00 2013
+++ src/sbin/route/route.c	Fri Oct 18 20:39:39 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.141 2013/10/18 21:01:00 christos Exp $	*/
+/*	$NetBSD: route.c,v 1.142 2013/10/19 00:39:39 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)route.c	8.6 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: route.c,v 1.141 2013/10/18 21:01:00 christos Exp $);
+__RCSID($NetBSD: route.c,v 1.142 2013/10/19 00:39:39 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -538,19 +538,7 @@ routename(const struct sockaddr *sa, str
 		memcpy(sin6, sa, sa-sa_len);
 		sin6.sin6_len = sizeof(struct sockaddr_in6);
 		sin6.sin6_family = AF_INET6;
-#ifdef __KAME__
-		if (sa-sa_len == sizeof(struct sockaddr_in6) 
-		(IN6_IS_ADDR_LINKLOCAL(sin6.sin6_addr) ||
-		 IN6_IS_ADDR_MC_LINKLOCAL(sin6.sin6_addr)) 
-		sin6.sin6_scope_id == 0) {
-			uint16_t scope;
-			memcpy(scope, sin6.sin6_addr.s6_addr[2],
-			sizeof(scope));
-			sin6.sin6_scope_id = ntohs(scope);
-			sin6.sin6_addr.s6_addr[2] = 0;
-			sin6.sin6_addr.s6_addr[3] = 0;
-		}
-#endif
+		inet6_getscopeid(sin6, 3);
 		nml = netmask_length(nm, AF_INET6);
 		if (IN6_IS_ADDR_UNSPECIFIED(sin6.sin6_addr)) {
 			if (nml == 0)
@@ -707,19 +695,7 @@ netname(const struct sockaddr *sa, struc
 		memcpy(sin6, sa, sa-sa_len);
 		sin6.sin6_len = sizeof(struct sockaddr_in6);
 		sin6.sin6_family = AF_INET6;
-#ifdef __KAME__
-		if (sa-sa_len == sizeof(struct sockaddr_in6) 
-		(IN6_IS_ADDR_LINKLOCAL(sin6.sin6_addr) ||
-		 IN6_IS_ADDR_MC_LINKLOCAL(sin6.sin6_addr)) 
-		sin6.sin6_scope_id == 0) {
-			uint16_t scope;
-			memcpy(scope, sin6.sin6_addr.s6_addr[2],
-			sizeof(scope));
-			sin6.sin6_scope_id = ntohs(scope);
-			sin6.sin6_addr.s6_addr[2] = 0;
-			sin6.sin6_addr.s6_addr[3] = 0;
-		}
-#endif
+		inet6_putscopeid(sin6, 3);
 		nml = netmask_length(nm, AF_INET6);
 		if (IN6_IS_ADDR_UNSPECIFIED(sin6.sin6_addr)) {
 			if (nml == 0)
@@ -1259,17 +1235,7 @@ getaddr(int which, const char *s, struct
 		}
 		memcpy(su-sin6, res-ai_addr, sizeof(su-sin6));
 		freeaddrinfo(res);
-#ifdef __KAME__
-		if ((IN6_IS_ADDR_LINKLOCAL(su-sin6.sin6_addr) ||
-		 IN6_IS_ADDR_MC_LINKLOCAL(su-sin6.sin6_addr)) 
-		su-sin6.sin6_scope_id) {
-			uint16_t scope;
-			scope = htons(su-sin6.sin6_scope_id);
-			memcpy(su-sin6.sin6_addr.s6_addr[2], scope,
-			sizeof(scope));
-			su-sin6.sin6_scope_id = 0;
-		}
-#endif
+		inet6_getscopeid(su-sin6, 3);
 		if (hints.ai_flags == AI_NUMERICHOST) {
 			if (slash)
 return prefixlen(slash + 1, soup);



CVS commit: src/sbin/route

2013-10-06 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Oct  7 05:06:45 UTC 2013

Modified Files:
src/sbin/route: route.8

Log Message:
english usage patrol


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sbin/route/route.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.8
diff -u src/sbin/route/route.8:1.48 src/sbin/route/route.8:1.49
--- src/sbin/route/route.8:1.48	Wed Jul 24 06:28:10 2013
+++ src/sbin/route/route.8	Mon Oct  7 05:06:45 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: route.8,v 1.48 2013/07/24 06:28:10 kefren Exp $
+.\	$NetBSD: route.8,v 1.49 2013/10/07 05:06:45 dholland Exp $
 .\
 .\ Copyright (c) 1983, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -244,19 +244,19 @@ symbolic names.
 .Pp
 The optional modifier
 .Fl tag
-specifies an address associated to the route.
+specifies an address associated with the route.
 How the address is used is specific to the address family of
 the destination and the interface used to forward the packet.
 Currently route tags are consumed only by the
 .Xr mpls 4
-stack, therefore
+stack; therefore
 .Nm
 assumes that the subsequent addresses are in the
 .Tn MPLS
 address family.
 See
 .Xr mpls 4
-for examples about setting routes involving MPLS.
+for examples of setting routes involving MPLS.
 .Pp
 The optional
 .Fl netmask



CVS commit: src/sbin/route

2013-07-24 Thread Mihai Chelaru
Module Name:src
Committed By:   kefren
Date:   Wed Jul 24 06:28:10 UTC 2013

Modified Files:
src/sbin/route: route.8

Log Message:
Add -tag description as suggested in PR/45071


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sbin/route/route.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.8
diff -u src/sbin/route/route.8:1.47 src/sbin/route/route.8:1.48
--- src/sbin/route/route.8:1.47	Fri Mar  1 18:25:17 2013
+++ src/sbin/route/route.8	Wed Jul 24 06:28:10 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: route.8,v 1.47 2013/03/01 18:25:17 joerg Exp $
+.\	$NetBSD: route.8,v 1.48 2013/07/24 06:28:10 kefren Exp $
 .\
 .\ Copyright (c) 1983, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\ @(#)route.8	8.4 (Berkeley) 6/1/94
 .\
-.Dd February 5, 2013
+.Dd July 24, 2013
 .Dt ROUTE 8
 .Os
 .Sh NAME
@@ -242,11 +242,16 @@ or are specified as link-level addresses
 and the names must be numeric specifications rather than
 symbolic names.
 .Pp
-The optional modifiers
-.Fl mpls
-and
+The optional modifier
 .Fl tag
-specify that all subsequent addresses are in the
+specifies an address associated to the route.
+How the address is used is specific to the address family of
+the destination and the interface used to forward the packet.
+Currently route tags are consumed only by the
+.Xr mpls 4
+stack, therefore
+.Nm
+assumes that the subsequent addresses are in the
 .Tn MPLS
 address family.
 See



CVS commit: src/sbin/route

2012-10-03 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Thu Oct  4 00:01:48 UTC 2012

Modified Files:
src/sbin/route: route.c

Log Message:
Fix fallout from 1.129 that converted sou::so_foo from unions to
pointers but missed (char *)soup-so_foo = (char *)soup-so_foo in
mask_addr().  It worked by luck - unless it didn't: due to pointer
numerology on amd64 route add -net ClassC without explicit /24 prefix
length specification would result into /16 destination instead of /24.


To generate a diff of this commit:
cvs rdiff -u -r1.138 -r1.139 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.138 src/sbin/route/route.c:1.139
--- src/sbin/route/route.c:1.138	Wed Aug  8 14:04:26 2012
+++ src/sbin/route/route.c	Thu Oct  4 00:01:48 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.138 2012/08/08 14:04:26 christos Exp $	*/
+/*	$NetBSD: route.c,v 1.139 2012/10/04 00:01:48 uwe Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)route.c	8.6 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: route.c,v 1.138 2012/08/08 14:04:26 christos Exp $);
+__RCSID($NetBSD: route.c,v 1.139 2012/10/04 00:01:48 uwe Exp $);
 #endif
 #endif /* not lint */
 
@@ -1648,11 +1648,11 @@ static void
 mask_addr(struct sou *soup)
 {
 	int olen = soup-so_mask-sa.sa_len;
-	char *cp1 = olen + (char *)soup-so_mask, *cp2;
+	char *cp1 = olen + (char *)soup-so_mask, *cp2;
 
-	for (soup-so_mask-sa.sa_len = 0; cp1  (char *)soup-so_mask; )
+	for (soup-so_mask-sa.sa_len = 0; cp1  (char *)soup-so_mask; )
 		if (*--cp1 != 0) {
-			soup-so_mask-sa.sa_len = 1 + cp1 - (char *)soup-so_mask;
+			soup-so_mask-sa.sa_len = 1 + cp1 - (char *)soup-so_mask;
 			break;
 		}
 	if ((rtm_addrs  RTA_DST) == 0)
@@ -1674,11 +1674,11 @@ mask_addr(struct sou *soup)
 		break;
 #endif /* SMALL */
 	}
-	cp1 = soup-so_mask-sa.sa_len + 1 + (char *)soup-so_dst;
-	cp2 = soup-so_dst-sa.sa_len + 1 + (char *)soup-so_dst;
+	cp1 = soup-so_mask-sa.sa_len + 1 + (char *)soup-so_dst;
+	cp2 = soup-so_dst-sa.sa_len + 1 + (char *)soup-so_dst;
 	while (cp2  cp1)
 		*--cp2 = 0;
-	cp2 = soup-so_mask-sa.sa_len + 1 + (char *)soup-so_mask;
+	cp2 = soup-so_mask-sa.sa_len + 1 + (char *)soup-so_mask;
 	while (cp1  soup-so_dst-sa.sa_data)
 		*--cp1 = *--cp2;
 #ifndef SMALL



CVS commit: src/sbin/route

2012-08-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug  8 14:04:26 UTC 2012

Modified Files:
src/sbin/route: route.c

Log Message:
remove useless rump headers.


To generate a diff of this commit:
cvs rdiff -u -r1.137 -r1.138 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.137 src/sbin/route/route.c:1.138
--- src/sbin/route/route.c:1.137	Fri Mar 16 22:13:44 2012
+++ src/sbin/route/route.c	Wed Aug  8 10:04:26 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.137 2012/03/17 02:13:44 christos Exp $	*/
+/*	$NetBSD: route.c,v 1.138 2012/08/08 14:04:26 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)route.c	8.6 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: route.c,v 1.137 2012/03/17 02:13:44 christos Exp $);
+__RCSID($NetBSD: route.c,v 1.138 2012/08/08 14:04:26 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -71,10 +71,6 @@ __RCSID($NetBSD: route.c,v 1.137 2012/0
 #include paths.h
 #include err.h
 
-#include rump/rump.h
-#include rump/rump_syscalls.h
-#include rump/rumpclient.h
-
 #include keywords.h
 #include extern.h
 #include prog_ops.h



CVS commit: src/sbin/route

2012-03-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar 17 02:13:45 UTC 2012

Modified Files:
src/sbin/route: route.c

Log Message:
PR/42179: Christoph Badura: Be a little friendlier about missing args.


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.136 src/sbin/route/route.c:1.137
--- src/sbin/route/route.c:1.136	Sun Dec 25 19:20:43 2011
+++ src/sbin/route/route.c	Fri Mar 16 22:13:44 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.136 2011/12/26 00:20:43 christos Exp $	*/
+/*	$NetBSD: route.c,v 1.137 2012/03/17 02:13:44 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)route.c	8.6 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: route.c,v 1.136 2011/12/26 00:20:43 christos Exp $);
+__RCSID($NetBSD: route.c,v 1.137 2012/03/17 02:13:44 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -1031,6 +1031,10 @@ newroute(int argc, char *const *argv)
 			}
 		}
 	}
+	if ((rtm_addrs  RTA_DST) == 0)
+		errx(EXIT_FAILURE, missing destination specification);
+	if (*cmd == 'a'  (rtm_addrs  RTA_GATEWAY) == 0)
+		errx(EXIT_FAILURE, missing gateway specification);
 	if (forcehost  forcenet)
 		errx(EXIT_FAILURE, -host and -net conflict);
 	else if (forcehost)



CVS commit: src/sbin/route

2011-12-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec 26 00:20:43 UTC 2011

Modified Files:
src/sbin/route: route.c

Log Message:
Off by one and clarity improvement from Christian Biere


To generate a diff of this commit:
cvs rdiff -u -r1.135 -r1.136 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.135 src/sbin/route/route.c:1.136
--- src/sbin/route/route.c:1.135	Sat Dec 24 18:48:17 2011
+++ src/sbin/route/route.c	Sun Dec 25 19:20:43 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.135 2011/12/24 23:48:17 christos Exp $	*/
+/*	$NetBSD: route.c,v 1.136 2011/12/26 00:20:43 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)route.c	8.6 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: route.c,v 1.135 2011/12/24 23:48:17 christos Exp $);
+__RCSID($NetBSD: route.c,v 1.136 2011/12/26 00:20:43 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -598,7 +598,7 @@ routename(const struct sockaddr *sa, str
 		ms.s_addr = ntohl(ms.s_addr);
 
 		len = snprintf(line, sizeof(line), %u, ms.shim.label);
-		if (len  sizeof(line))
+		if (len = sizeof(line))
 			errx(1, snprintf);
 		pms = ((const struct sockaddr_mpls*)sa)-smpls_addr;
 		while (psize  sa-sa_len) {
@@ -607,7 +607,7 @@ routename(const struct sockaddr *sa, str
 			ms.s_addr = ntohl(pms-s_addr);
 			alen = snprintf(line + len, sizeof(line) - len,  %u,
 			ms.shim.label);
-			if (alen + len  sizeof(line))
+			if (alen = sizeof(line) - len)
 errx(1, snprintf);
 			len += alen;
 			psize += sizeof(ms);



CVS commit: src/sbin/route

2011-12-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Dec 24 23:48:17 UTC 2011

Modified Files:
src/sbin/route: route.c

Log Message:
PR/45661: Henning Petersen: Overlapping buffer in route.c.


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.134 src/sbin/route/route.c:1.135
--- src/sbin/route/route.c:1.134	Fri Nov 11 10:09:32 2011
+++ src/sbin/route/route.c	Sat Dec 24 18:48:17 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.134 2011/11/11 15:09:32 gdt Exp $	*/
+/*	$NetBSD: route.c,v 1.135 2011/12/24 23:48:17 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)route.c	8.6 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: route.c,v 1.134 2011/11/11 15:09:32 gdt Exp $);
+__RCSID($NetBSD: route.c,v 1.135 2011/12/24 23:48:17 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -592,18 +592,24 @@ routename(const struct sockaddr *sa, str
 		{
 		union mpls_shim ms;
 		const union mpls_shim *pms;
-		int psize = sizeof(struct sockaddr_mpls);
+		size_t psize = sizeof(struct sockaddr_mpls), len;
 
 		ms.s_addr =((const struct sockaddr_mpls*)sa)-smpls_addr.s_addr;
 		ms.s_addr = ntohl(ms.s_addr);
 
-		snprintf(line, sizeof(line), %u, ms.shim.label);
+		len = snprintf(line, sizeof(line), %u, ms.shim.label);
+		if (len  sizeof(line))
+			errx(1, snprintf);
 		pms = ((const struct sockaddr_mpls*)sa)-smpls_addr;
-		while(psize  sa-sa_len) {
+		while (psize  sa-sa_len) {
+			size_t alen;
 			pms++;
 			ms.s_addr = ntohl(pms-s_addr);
-			snprintf(line, sizeof(line), %s %u, line,
+			alen = snprintf(line + len, sizeof(line) - len,  %u,
 			ms.shim.label);
+			if (alen + len  sizeof(line))
+errx(1, snprintf);
+			len += alen;
 			psize += sizeof(ms);
 		}
 		break;



CVS commit: src/sbin/route

2011-10-07 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Oct  7 09:56:16 UTC 2011

Modified Files:
src/sbin/route: route.c

Log Message:
Simplify.


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.132 src/sbin/route/route.c:1.133
--- src/sbin/route/route.c:1.132	Mon Aug 29 14:35:03 2011
+++ src/sbin/route/route.c	Fri Oct  7 09:56:15 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.132 2011/08/29 14:35:03 joerg Exp $	*/
+/*	$NetBSD: route.c,v 1.133 2011/10/07 09:56:15 joerg Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)route.c	8.6 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: route.c,v 1.132 2011/08/29 14:35:03 joerg Exp $);
+__RCSID($NetBSD: route.c,v 1.133 2011/10/07 09:56:15 joerg Exp $);
 #endif
 #endif /* not lint */
 
@@ -1392,11 +1392,10 @@ readtag(sup su, const char *s)
 	int mplssize = 0;
 	sup retsu = su;
 
-	n = (char*)malloc(strlen(s) + 1);
+	n = strdup(s);
 	if (n == NULL)
 		errx(EXIT_FAILURE, %s: Cannot allocate memory, s);
 	norig = n;
-	strlcpy(n, s, strlen(s) + 1);
 	for (uint i = 0; i  strlen(n); i++)
 		if(n[i] == ',')
 			mplssize++;



CVS commit: src/sbin/route

2011-07-17 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Jul 17 23:46:54 UTC 2011

Modified Files:
src/sbin/route: route.8

Log Message:
prune stray commas


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sbin/route/route.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.8
diff -u src/sbin/route/route.8:1.44 src/sbin/route/route.8:1.45
--- src/sbin/route/route.8:1.44	Sun Jul  3 09:15:20 2011
+++ src/sbin/route/route.8	Sun Jul 17 23:46:53 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: route.8,v 1.44 2011/07/03 09:15:20 wiz Exp $
+.\	$NetBSD: route.8,v 1.45 2011/07/17 23:46:53 dholland Exp $
 .\
 .\ Copyright (c) 1983, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -246,14 +246,14 @@
 symbolic names.
 .Pp
 The optional modifiers
-.Fl mpls ,
+.Fl mpls
 and
 .Fl tag
 specify that all subsequent addresses are in the
 .Tn MPLS
 address family.
 See
-.Xr mpls 4 ,
+.Xr mpls 4
 for examples about setting routes involving MPLS.
 .Pp
 The optional



CVS commit: src/sbin/route

2011-07-03 Thread Mihai Chelaru
Module Name:src
Committed By:   kefren
Date:   Sun Jul  3 07:20:37 UTC 2011

Modified Files:
src/sbin/route: route.8

Log Message:
Mention -mpls and -tag and xref mpls(4)
bin/45071


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sbin/route/route.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.8
diff -u src/sbin/route/route.8:1.42 src/sbin/route/route.8:1.43
--- src/sbin/route/route.8:1.42	Thu Jun 16 23:35:35 2011
+++ src/sbin/route/route.8	Sun Jul  3 07:20:37 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: route.8,v 1.42 2011/06/16 23:35:35 yamt Exp $
+.\	$NetBSD: route.8,v 1.43 2011/07/03 07:20:37 kefren Exp $
 .\
 .\ Copyright (c) 1983, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -152,8 +152,9 @@
 .Fl xns ,
 .Fl atalk ,
 .Fl inet ,
+.Fl inet6,
 or
-.Fl inet6
+.Fl mpls
 modifiers, only routes having destinations with addresses in the
 delineated family will be manipulated.
 .Pp
@@ -244,6 +245,17 @@
 and the names must be numeric specifications rather than
 symbolic names.
 .Pp
+The optional modifiers
+.Fl mpls ,
+and
+.Fl tag
+specify that all subsequent addresses are in the
+.Tn MPLS
+address family.
+See
+.Xr mpls 4 ,
+for examples about setting routes involving MPLS.
+.Pp
 The optional
 .Fl netmask
 qualifier is intended
@@ -391,6 +403,7 @@
 .El
 .Sh SEE ALSO
 .Xr esis 4 ,
+.Xr mpls 4 ,
 .Xr netintro 4 ,
 .Xr route 4 ,
 .Xr routed 8 ,



CVS commit: src/sbin/route

2011-07-03 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Jul  3 09:15:20 UTC 2011

Modified Files:
src/sbin/route: route.8

Log Message:
Whitespace nit.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sbin/route/route.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.8
diff -u src/sbin/route/route.8:1.43 src/sbin/route/route.8:1.44
--- src/sbin/route/route.8:1.43	Sun Jul  3 07:20:37 2011
+++ src/sbin/route/route.8	Sun Jul  3 09:15:20 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: route.8,v 1.43 2011/07/03 07:20:37 kefren Exp $
+.\	$NetBSD: route.8,v 1.44 2011/07/03 09:15:20 wiz Exp $
 .\
 .\ Copyright (c) 1983, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -152,7 +152,7 @@
 .Fl xns ,
 .Fl atalk ,
 .Fl inet ,
-.Fl inet6,
+.Fl inet6 ,
 or
 .Fl mpls
 modifiers, only routes having destinations with addresses in the



CVS commit: src/sbin/route

2011-06-30 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Jul  1 02:54:51 UTC 2011

Modified Files:
src/sbin/route: route.c

Log Message:
Fix memset usage.


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.130 src/sbin/route/route.c:1.131
--- src/sbin/route/route.c:1.130	Wed Jun 22 04:57:28 2011
+++ src/sbin/route/route.c	Fri Jul  1 02:54:51 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.130 2011/06/22 04:57:28 kefren Exp $	*/
+/*	$NetBSD: route.c,v 1.131 2011/07/01 02:54:51 joerg Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = @(#)route.c	8.6 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: route.c,v 1.130 2011/06/22 04:57:28 kefren Exp $);
+__RCSID($NetBSD: route.c,v 1.131 2011/07/01 02:54:51 joerg Exp $);
 #endif
 #endif /* not lint */
 
@@ -1464,7 +1464,7 @@
 	r = len  7;
 	switch (af) {
 	case AF_INET:
-		memset(soup-so_mask, 0, sizeof(soup-so_mask));
+		memset(soup-so_mask, 0, sizeof(*soup-so_mask));
 		soup-so_mask-sin.sin_family = AF_INET;
 		soup-so_mask-sin.sin_len = sizeof(struct sockaddr_in);
 		soup-so_mask-sin.sin_addr.s_addr = (len == 0 ? 0



CVS commit: src/sbin/route

2011-06-21 Thread Mihai Chelaru
Module Name:src
Committed By:   kefren
Date:   Wed Jun 22 04:57:28 UTC 2011

Modified Files:
src/sbin/route: route.c

Log Message:
don't compile tag functions if SMALL is defined. Should fix the build


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.129 src/sbin/route/route.c:1.130
--- src/sbin/route/route.c:1.129	Tue Jun 21 14:33:14 2011
+++ src/sbin/route/route.c	Wed Jun 22 04:57:28 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.129 2011/06/21 14:33:14 kefren Exp $	*/
+/*	$NetBSD: route.c,v 1.130 2011/06/22 04:57:28 kefren Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = @(#)route.c	8.6 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: route.c,v 1.129 2011/06/21 14:33:14 kefren Exp $);
+__RCSID($NetBSD: route.c,v 1.130 2011/06/22 04:57:28 kefren Exp $);
 #endif
 #endif /* not lint */
 
@@ -1384,6 +1384,7 @@
 	/*NOTREACHED*/
 }
 
+#ifndef SMALL
 static sup
 readtag(sup su, const char *s)
 {
@@ -1433,6 +1434,7 @@
 	ms[where].shim.label = atoi(s);
 	ms[where].s_addr = htonl(ms[where].s_addr);
 }
+#endif	/* SMALL */
 
 int
 prefixlen(const char *s, struct sou *soup)



CVS commit: src/sbin/route

2011-06-16 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Thu Jun 16 23:35:35 UTC 2011

Modified Files:
src/sbin/route: route.8

Log Message:
xref link_addr for -link.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sbin/route/route.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.8
diff -u src/sbin/route/route.8:1.41 src/sbin/route/route.8:1.42
--- src/sbin/route/route.8:1.41	Wed May 12 17:56:13 2010
+++ src/sbin/route/route.8	Thu Jun 16 23:35:35 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: route.8,v 1.41 2010/05/12 17:56:13 christos Exp $
+.\	$NetBSD: route.8,v 1.42 2011/06/16 23:35:35 yamt Exp $
 .\
 .\ Copyright (c) 1983, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -239,7 +239,8 @@
 or
 .Tn AppleTalk
 address families,
-or are specified as link-level addresses,
+or are specified as link-level addresses in the form described in
+.Xr link_addr 3 ,
 and the names must be numeric specifications rather than
 symbolic names.
 .Pp



CVS commit: src/sbin/route

2010-12-13 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Dec 13 17:39:47 UTC 2010

Modified Files:
src/sbin/route: Makefile route.c show.c
Added Files:
src/sbin/route: prog_ops.h route_hostops.c route_rumpops.c

Log Message:
Convert from RUMP_ACTION to RUMPPRG.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sbin/route/Makefile
cvs rdiff -u -r0 -r1.1 src/sbin/route/prog_ops.h \
src/sbin/route/route_hostops.c src/sbin/route/route_rumpops.c
cvs rdiff -u -r1.126 -r1.127 src/sbin/route/route.c
cvs rdiff -u -r1.41 -r1.42 src/sbin/route/show.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/Makefile
diff -u src/sbin/route/Makefile:1.24 src/sbin/route/Makefile:1.25
--- src/sbin/route/Makefile:1.24	Thu Nov  4 23:36:10 2010
+++ src/sbin/route/Makefile	Mon Dec 13 17:39:47 2010
@@ -1,9 +1,9 @@
-#	$NetBSD: Makefile,v 1.24 2010/11/04 23:36:10 pooka Exp $
+#	$NetBSD: Makefile,v 1.25 2010/12/13 17:39:47 pooka Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/5/93
 
 .include bsd.own.mk
 
-PROG=	route
+RUMPPRG=route
 MAN=	route.8
 SRCS=	route.c show.c keywords.c
 
@@ -20,15 +20,4 @@
 # keywords.c keywords.h : keywords.sh
 # 	${HOST_SH} keywords.sh
 
-#
-# Compile-time debug flag.  If compiled with make RUMP_ACTION=1,
-# make rump system calls.
-#
-.ifdef RUMP_ACTION
-CPPFLAGS+=  -DRUMP_SYS_NETWORKING -DRUMP_SYS_READWRITE -DRUMP_SYS_CLOSE
-CPPFLAGS+=  -DRUMP_ACTION -DSMALL -Dsysctl=rump_sys___sysctl
-LDADD+= -lrumpclient
-DBG=-g
-.endif
-
 .include bsd.prog.mk

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.126 src/sbin/route/route.c:1.127
--- src/sbin/route/route.c:1.126	Fri Nov 12 16:32:18 2010
+++ src/sbin/route/route.c	Mon Dec 13 17:39:47 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.126 2010/11/12 16:32:18 roy Exp $	*/
+/*	$NetBSD: route.c,v 1.127 2010/12/13 17:39:47 pooka Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = @(#)route.c	8.6 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: route.c,v 1.126 2010/11/12 16:32:18 roy Exp $);
+__RCSID($NetBSD: route.c,v 1.127 2010/12/13 17:39:47 pooka Exp $);
 #endif
 #endif /* not lint */
 
@@ -71,14 +71,13 @@
 #include paths.h
 #include err.h
 
-#ifdef RUMP_ACTION
 #include rump/rump.h
 #include rump/rump_syscalls.h
 #include rump/rumpclient.h
-#endif
 
 #include keywords.h
 #include extern.h
+#include prog_ops.h
 
 union sockunion {
 	struct	sockaddr sa;
@@ -162,11 +161,6 @@
 {
 	int ch;
 
-#ifdef RUMP_ACTION
-	if (rumpclient_init() == -1)
-		err(1, rump client init);
-#endif
-
 	if (argc  2)
 		usage(NULL);
 
@@ -204,11 +198,14 @@
 	argc -= optind;
 	argv += optind;
 
-	pid = getpid();
+	if (prog_init  prog_init() == -1)
+		err(1, init failed);
+
+	pid = prog_getpid();
 	if (tflag)
-		sock = open(/dev/null, O_WRONLY, 0);
+		sock = prog_open(/dev/null, O_WRONLY, 0);
 	else
-		sock = socket(PF_ROUTE, SOCK_RAW, 0);
+		sock = prog_socket(PF_ROUTE, SOCK_RAW, 0);
 	if (sock  0)
 		err(EXIT_FAILURE, socket);
 
@@ -269,7 +266,8 @@
 
 	flags = 0;
 	af = AF_UNSPEC;
-	shutdown(sock, SHUT_RD); /* Don't want to read back our messages */
+	/* Don't want to read back our messages */
+	prog_shutdown(sock, SHUT_RD);
 	parse_show_opts(argc, argv, af, flags, afname, false);
 	mib[0] = CTL_NET;
 	mib[1] = PF_ROUTE;
@@ -277,13 +275,13 @@
 	mib[3] = 0;		/* wildcard address family */
 	mib[4] = NET_RT_DUMP;
 	mib[5] = 0;		/* no flags */
-	if (sysctl(mib, 6, NULL, needed, NULL, 0)  0)
+	if (prog_sysctl(mib, 6, NULL, needed, NULL, 0)  0)
 		err(EXIT_FAILURE, route-sysctl-estimate);
 	buf = lim = NULL;
 	if (needed) {
 		if ((buf = malloc(needed)) == NULL)
 			err(EXIT_FAILURE, malloc);
-		if (sysctl(mib, 6, buf, needed, NULL, 0)  0)
+		if (prog_sysctl(mib, 6, buf, needed, NULL, 0)  0)
 			err(EXIT_FAILURE, actual retrieval of routing table);
 		lim = buf + needed;
 	}
@@ -311,7 +309,8 @@
 			continue;
 		rtm-rtm_type = RTM_DELETE;
 		rtm-rtm_seq = seqno;
-		if ((rlen = write(sock, next, rtm-rtm_msglen))  0) {
+		if ((rlen = prog_write(sock, next,
+		rtm-rtm_msglen))  0) {
 			warnx(writing to routing socket: %s,
 			route_strerror(errno));
 			return 1;
@@ -801,8 +800,10 @@
 
 	cmd = argv[0];
 	af = AF_UNSPEC;
-	if (*cmd != 'g')
-		shutdown(sock, SHUT_RD); /* Don't want to read back our messages */
+	if (*cmd != 'g') {
+		/* Don't want to read back our messages */
+		prog_shutdown(sock, SHUT_RD);
+	}
 	while (--argc  0) {
 		if (**(++argv)== '-') {
 			switch (key = keyword(1 + *argv)) {
@@ -1419,12 +1420,12 @@
 	mib[3] = 0;		/* wildcard address family */
 	mib[4] = NET_RT_IFLIST;
 	mib[5] = 0;		/* no flags */
-	if (sysctl(mib, 6, NULL, needed, NULL, 0)  0)
+	if (prog_sysctl(mib, 6, NULL, needed, NULL, 0)  0)
 		err(EXIT_FAILURE, route-sysctl-estimate);
 	if (needed) {
 		if ((buf = malloc(needed)) == NULL)
 			err(EXIT_FAILURE, malloc);
-		if (sysctl(mib, 6, 

CVS commit: src/sbin/route

2010-11-12 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Nov 12 16:32:19 UTC 2010

Modified Files:
src/sbin/route: route.c

Log Message:
Support the new RTM_IFINFO and RTM_CHGADDR messages.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.125 src/sbin/route/route.c:1.126
--- src/sbin/route/route.c:1.125	Fri Nov  5 13:52:41 2010
+++ src/sbin/route/route.c	Fri Nov 12 16:32:18 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.125 2010/11/05 13:52:41 pooka Exp $	*/
+/*	$NetBSD: route.c,v 1.126 2010/11/12 16:32:18 roy Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = @(#)route.c	8.6 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: route.c,v 1.125 2010/11/05 13:52:41 pooka Exp $);
+__RCSID($NetBSD: route.c,v 1.126 2010/11/12 16:32:18 roy Exp $);
 #endif
 #endif /* not lint */
 
@@ -1613,10 +1613,14 @@
 	RTM_RESOLVE: Route created by cloning,
 	RTM_NEWADDR: address being added to iface,
 	RTM_DELADDR: address being removed from iface,
-	RTM_OIFINFO: iface status change (pre-1.5),
-	RTM_IFINFO: iface status change,
+	RTM_OOIFINFO: iface status change (pre-1.5),
+	RTM_OIFINFO: iface status change (pre-6.0),
 	RTM_IFANNOUNCE: iface arrival/departure,
 	RTM_IEEE80211: IEEE80211 wireless event,
+	,
+	,
+	RTM_IFINFO: iface status change,
+	RTM_CHGADDR: address being changed on iface,
 	0,
 };
 
@@ -1692,6 +1696,7 @@
 		break;
 	case RTM_NEWADDR:
 	case RTM_DELADDR:
+	case RTM_CHGADDR:
 		ifam = (struct ifa_msghdr *)rtm;
 		(void)printf(metric %d, flags: , ifam-ifam_metric);
 		bprintf(stdout, ifam-ifam_flags, routeflags);



CVS commit: src/sbin/route

2010-11-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Nov  4 23:36:10 UTC 2010

Modified Files:
src/sbin/route: Makefile route.c

Log Message:
Support RUMP_ACTION to compile a rump kernel client.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sbin/route/Makefile
cvs rdiff -u -r1.121 -r1.122 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/Makefile
diff -u src/sbin/route/Makefile:1.23 src/sbin/route/Makefile:1.24
--- src/sbin/route/Makefile:1.23	Sat Aug 26 15:26:02 2006
+++ src/sbin/route/Makefile	Thu Nov  4 23:36:10 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.23 2006/08/26 15:26:02 matt Exp $
+#	$NetBSD: Makefile,v 1.24 2010/11/04 23:36:10 pooka Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/5/93
 
 .include bsd.own.mk
@@ -20,4 +20,15 @@
 # keywords.c keywords.h : keywords.sh
 # 	${HOST_SH} keywords.sh
 
+#
+# Compile-time debug flag.  If compiled with make RUMP_ACTION=1,
+# make rump system calls.
+#
+.ifdef RUMP_ACTION
+CPPFLAGS+=  -DRUMP_SYS_NETWORKING -DRUMP_SYS_READWRITE -DRUMP_SYS_CLOSE
+CPPFLAGS+=  -DRUMP_ACTION -DSMALL -Dsysctl=rump_sys___sysctl
+LDADD+= -lrumpclient
+DBG=-g
+.endif
+
 .include bsd.prog.mk

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.121 src/sbin/route/route.c:1.122
--- src/sbin/route/route.c:1.121	Sat Jun 26 14:29:36 2010
+++ src/sbin/route/route.c	Thu Nov  4 23:36:10 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.121 2010/06/26 14:29:36 kefren Exp $	*/
+/*	$NetBSD: route.c,v 1.122 2010/11/04 23:36:10 pooka Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = @(#)route.c	8.6 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: route.c,v 1.121 2010/06/26 14:29:36 kefren Exp $);
+__RCSID($NetBSD: route.c,v 1.122 2010/11/04 23:36:10 pooka Exp $);
 #endif
 #endif /* not lint */
 
@@ -71,6 +71,12 @@
 #include paths.h
 #include err.h
 
+#ifdef RUMP_ACTION
+#include rump/rump.h
+#include rump/rump_syscalls.h
+#include rump/rumpclient.h
+#endif
+
 #include keywords.h
 #include extern.h
 
@@ -154,7 +160,12 @@
 int
 main(int argc, char * const *argv)
 {
-	int ch;
+	int ch, error;
+
+#ifdef RUMP_ACTION
+	if ((error = rumpclient_init()) != 0)
+		errx(1, rump client init: %s, strerror(error));
+#endif
 
 	if (argc  2)
 		usage(NULL);



CVS commit: src/sbin/route

2010-11-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Nov  4 23:37:27 UTC 2010

Modified Files:
src/sbin/route: route.c

Log Message:
be consistent in what to leave outside of SMALL


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.122 src/sbin/route/route.c:1.123
--- src/sbin/route/route.c:1.122	Thu Nov  4 23:36:10 2010
+++ src/sbin/route/route.c	Thu Nov  4 23:37:27 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.122 2010/11/04 23:36:10 pooka Exp $	*/
+/*	$NetBSD: route.c,v 1.123 2010/11/04 23:37:27 pooka Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = @(#)route.c	8.6 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: route.c,v 1.122 2010/11/04 23:36:10 pooka Exp $);
+__RCSID($NetBSD: route.c,v 1.123 2010/11/04 23:37:27 pooka Exp $);
 #endif
 #endif /* not lint */
 
@@ -1173,10 +1173,12 @@
 		su = soup-so_ifa;
 		su-sa.sa_family = af;
 		break;
+#ifndef SMALL
 	case RTA_TAG:
 		su = soup-so_mpls;
 		afamily = AF_MPLS;
 		break;
+#endif
 	default:
 		su = NULL;
 		usage(Internal Error);
@@ -1516,7 +1518,9 @@
 	NEXTADDR(RTA_GENMASK, soup-so_genmask);
 	NEXTADDR(RTA_IFP, soup-so_ifp);
 	NEXTADDR(RTA_IFA, soup-so_ifa);
+#ifndef SMALL
 	NEXTADDR(RTA_TAG, soup-so_mpls);
+#endif
 	rtm.rtm_msglen = l = cp - (char *)m_rtmsg;
 	if (verbose  ! shortoutput) {
 		if (rtm_addrs)



CVS commit: src/sbin/route

2010-11-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Nov  4 23:38:18 UTC 2010

Modified Files:
src/sbin/route: route.c

Log Message:
#ifdef variable correctly


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.123 src/sbin/route/route.c:1.124
--- src/sbin/route/route.c:1.123	Thu Nov  4 23:37:27 2010
+++ src/sbin/route/route.c	Thu Nov  4 23:38:18 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.123 2010/11/04 23:37:27 pooka Exp $	*/
+/*	$NetBSD: route.c,v 1.124 2010/11/04 23:38:18 pooka Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = @(#)route.c	8.6 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: route.c,v 1.123 2010/11/04 23:37:27 pooka Exp $);
+__RCSID($NetBSD: route.c,v 1.124 2010/11/04 23:38:18 pooka Exp $);
 #endif
 #endif /* not lint */
 
@@ -160,9 +160,10 @@
 int
 main(int argc, char * const *argv)
 {
-	int ch, error;
+	int ch;
 
 #ifdef RUMP_ACTION
+	int error;
 	if ((error = rumpclient_init()) != 0)
 		errx(1, rump client init: %s, strerror(error));
 #endif



CVS commit: src/sbin/route

2010-06-26 Thread Mihai Chelaru
Module Name:src
Committed By:   kefren
Date:   Sat Jun 26 14:29:36 UTC 2010

Modified Files:
src/sbin/route: keywords.c keywords.h keywords.sh route.c show.c

Log Message:
add MPLS clue - mpls and tag keywords


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sbin/route/keywords.c
cvs rdiff -u -r1.10 -r1.11 src/sbin/route/keywords.h
cvs rdiff -u -r1.8 -r1.9 src/sbin/route/keywords.sh
cvs rdiff -u -r1.120 -r1.121 src/sbin/route/route.c
cvs rdiff -u -r1.40 -r1.41 src/sbin/route/show.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/keywords.c
diff -u src/sbin/route/keywords.c:1.7 src/sbin/route/keywords.c:1.8
--- src/sbin/route/keywords.c:1.7	Wed May 12 17:56:13 2010
+++ src/sbin/route/keywords.c	Sat Jun 26 14:29:36 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: keywords.c,v 1.7 2010/05/12 17:56:13 christos Exp $ */
+/* $NetBSD: keywords.c,v 1.8 2010/06/26 14:29:36 kefren Exp $ */
 
 /* WARNING!  This file was generated by keywords.sh  */
 
@@ -12,8 +12,6 @@
 	{change, K_CHANGE},
 	{cloned, K_CLONED},
 	{cloning, K_CLONING},
-	{nocloned, K_NOCLONED},
-	{nocloning, K_NOCLONING},
 	{delete, K_DELETE},
 	{dst, K_DST},
 	{expire, K_EXPIRE},
@@ -57,8 +55,12 @@
 	{xns, K_XNS},
 	{xresolve, K_XRESOLVE},
 	{flushall, K_FLUSHALL},
+	{nocloned, K_NOCLONED},
+	{nocloning, K_NOCLONING},
 	{noblackhole, K_NOBLACKHOLE},
 	{noreject, K_NOREJECT},
+	{mpls, K_MPLS},
+	{tag, K_TAG},
 	{0, 0}
 };
 

Index: src/sbin/route/keywords.h
diff -u src/sbin/route/keywords.h:1.10 src/sbin/route/keywords.h:1.11
--- src/sbin/route/keywords.h:1.10	Wed May 12 17:56:13 2010
+++ src/sbin/route/keywords.h	Sat Jun 26 14:29:36 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: keywords.h,v 1.10 2010/05/12 17:56:13 christos Exp $ */
+/* $NetBSD: keywords.h,v 1.11 2010/06/26 14:29:36 kefren Exp $ */
 
 /* WARNING!  This file was generated by keywords.sh  */
 
@@ -61,3 +61,5 @@
 #define	K_NOCLONING	51
 #define	K_NOBLACKHOLE	52
 #define	K_NOREJECT	53
+#define	K_MPLS	54
+#define	K_TAG	55

Index: src/sbin/route/keywords.sh
diff -u src/sbin/route/keywords.sh:1.8 src/sbin/route/keywords.sh:1.9
--- src/sbin/route/keywords.sh:1.8	Wed May 12 19:26:33 2010
+++ src/sbin/route/keywords.sh	Sat Jun 26 14:29:36 2010
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $NetBSD: keywords.sh,v 1.8 2010/05/12 19:26:33 kefren Exp $
+# $NetBSD: keywords.sh,v 1.9 2010/06/26 14:29:36 kefren Exp $
 # @(#)keywords	8.2 (Berkeley) 3/19/94
 #
 # WARNING!  If you change this file, re-run it!
@@ -61,6 +61,8 @@
 nocloning
 noblackhole
 noreject
+mpls
+tag
 _EOF_
 
 

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.120 src/sbin/route/route.c:1.121
--- src/sbin/route/route.c:1.120	Wed May 12 17:56:13 2010
+++ src/sbin/route/route.c	Sat Jun 26 14:29:36 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.120 2010/05/12 17:56:13 christos Exp $	*/
+/*	$NetBSD: route.c,v 1.121 2010/06/26 14:29:36 kefren Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = @(#)route.c	8.6 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: route.c,v 1.120 2010/05/12 17:56:13 christos Exp $);
+__RCSID($NetBSD: route.c,v 1.121 2010/06/26 14:29:36 kefren Exp $);
 #endif
 #endif /* not lint */
 
@@ -57,6 +57,7 @@
 #include netinet/in.h
 #include netatalk/at.h
 #include netiso/iso.h
+#include netmpls/mpls.h
 #include arpa/inet.h
 #include netdb.h
 
@@ -83,13 +84,14 @@
 	struct	sockaddr_dl sdl;
 #ifndef SMALL
 	struct	sockaddr_iso siso;
+	struct	sockaddr_mpls smpls;
 #endif /* SMALL */
 };
 
 typedef union sockunion *sup;
 
 struct sou {
-	union sockunion so_dst, so_gate, so_mask, so_genmask, so_ifa, so_ifp;
+	union sockunion so_dst, so_gate, so_mask, so_genmask, so_ifa, so_ifp, so_mpls;
 };
 
 static char *any_ntoa(const struct sockaddr *);
@@ -121,7 +123,7 @@
 int	pid, rtm_addrs;
 int	sock;
 int	forcehost, forcenet, doflush, nflag, af, qflag, tflag, Sflag;
-int	iflag, verbose, aflen = sizeof(struct sockaddr_in);
+int	iflag, verbose, aflen = sizeof(struct sockaddr_in), rtag;
 int	locking, lockrest, debugonly, shortoutput;
 struct	rt_metrics rt_metrics;
 u_int32_t  rtm_inits;
@@ -575,6 +577,16 @@
 		((const struct sockaddr_at *)sa)-sat_addr.s_net,
 		((const struct sockaddr_at *)sa)-sat_addr.s_node);
 		break;
+	case AF_MPLS:
+		{
+		union mpls_shim ms;
+
+		ms.s_addr =((const struct sockaddr_mpls*)sa)-smpls_addr.s_addr;
+		ms.s_addr = ntohl(ms.s_addr);
+
+		snprintf(line, sizeof(line), %u, ms.shim.label);
+		break;
+		}
 #endif /* SMALL */
 
 	default:
@@ -819,6 +831,16 @@
 af = AF_ISO;
 aflen = sizeof(struct sockaddr_iso);
 break;
+			case K_MPLS:
+af = AF_MPLS;
+aflen = sizeof(struct sockaddr_mpls);
+break;
+			case K_TAG:
+if (!--argc)
+	usage(1+*argv);
+aflen = sizeof(struct sockaddr_mpls);
+(void)getaddr(RTA_TAG, *++argv, 0, soup);
+break;
 #endif /* SMALL */
 
 			case K_IFACE:
@@ -1140,6 +1162,10 @@
 		su = 

CVS commit: src/sbin/route

2010-05-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May 12 17:56:13 UTC 2010

Modified Files:
src/sbin/route: keywords.c keywords.h route.8 route.c

Log Message:
PR/40455: Mihai Chelaru: Add noreject noblackhole options


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sbin/route/keywords.c
cvs rdiff -u -r1.9 -r1.10 src/sbin/route/keywords.h
cvs rdiff -u -r1.40 -r1.41 src/sbin/route/route.8
cvs rdiff -u -r1.119 -r1.120 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/keywords.c
diff -u src/sbin/route/keywords.c:1.6 src/sbin/route/keywords.c:1.7
--- src/sbin/route/keywords.c:1.6	Sun Aug  6 13:44:56 2006
+++ src/sbin/route/keywords.c	Wed May 12 13:56:13 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: keywords.c,v 1.6 2006/08/06 17:44:56 dyoung Exp $ */
+/* $NetBSD: keywords.c,v 1.7 2010/05/12 17:56:13 christos Exp $ */
 
 /* WARNING!  This file was generated by keywords.sh  */
 
@@ -57,6 +57,8 @@
 	{xns, K_XNS},
 	{xresolve, K_XRESOLVE},
 	{flushall, K_FLUSHALL},
+	{noblackhole, K_NOBLACKHOLE},
+	{noreject, K_NOREJECT},
 	{0, 0}
 };
 

Index: src/sbin/route/keywords.h
diff -u src/sbin/route/keywords.h:1.9 src/sbin/route/keywords.h:1.10
--- src/sbin/route/keywords.h:1.9	Sun Aug  6 13:44:56 2006
+++ src/sbin/route/keywords.h	Wed May 12 13:56:13 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: keywords.h,v 1.9 2006/08/06 17:44:56 dyoung Exp $ */
+/* $NetBSD: keywords.h,v 1.10 2010/05/12 17:56:13 christos Exp $ */
 
 /* WARNING!  This file was generated by keywords.sh  */
 
@@ -59,3 +59,5 @@
 #define	K_FLUSHALL	49
 #define	K_NOCLONED	50
 #define	K_NOCLONING	51
+#define	K_NOBLACKHOLE	52
+#define	K_NOREJECT	53

Index: src/sbin/route/route.8
diff -u src/sbin/route/route.8:1.40 src/sbin/route/route.8:1.41
--- src/sbin/route/route.8:1.40	Sun Aug  6 19:38:13 2006
+++ src/sbin/route/route.8	Wed May 12 13:56:13 2010
@@ -1,4 +1,4 @@
-.\	$NetBSD: route.8,v 1.40 2006/08/06 23:38:13 wiz Exp $
+.\	$NetBSD: route.8,v 1.41 2010/05/12 17:56:13 christos Exp $
 .\
 .\ Copyright (c) 1983, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -267,19 +267,21 @@
 These flags may be set (or sometimes cleared)
 by indicating the following corresponding modifiers:
 .Bd -literal
--cloningRTF_CLONING- generates a new route on use
--nocloning ~RTF_CLONING- stop generating new routes on use
--cloned RTF_CLONED - cloned route generated by RTF_CLONING
--nocloned  ~RTF_CLONED - prevent removal with RTF_CLONING parent
--xresolve   RTF_XRESOLVE   - emit mesg on use (for external lookup)
--iface ~RTF_GATEWAY- destination is directly reachable
--static RTF_STATIC - manually added route
--nostatic  ~RTF_STATIC - pretend route added by kernel or daemon
--reject RTF_REJECT - emit an ICMP unreachable when matched
--blackhole  RTF_BLACKHOLE  - silently discard pkts (during updates)
--proto1 RTF_PROTO1 - set protocol specific routing flag #1
--proto2 RTF_PROTO2 - set protocol specific routing flag #2
--llinfo RTF_LLINFO - validly translates proto addr to link addr
+-cloning  RTF_CLONING- generates a new route on use
+-nocloning   ~RTF_CLONING- stop generating new routes on use
+-cloned   RTF_CLONED - cloned route generated by RTF_CLONING
+-nocloned~RTF_CLONED - prevent removal with RTF_CLONING parent
+-xresolve RTF_XRESOLVE   - emit mesg on use (for external lookup)
+-iface   ~RTF_GATEWAY- destination is directly reachable
+-static   RTF_STATIC - manually added route
+-nostatic~RTF_STATIC - pretend route added by kernel or daemon
+-reject   RTF_REJECT - emit an ICMP unreachable when matched
+-noreject~RTF_REJECT - clear reject flag
+-blackholeRTF_BLACKHOLE  - silently discard pkts (during updates)
+-noblackhole ~RTF_BLACKHOLE  - clear blackhole flag
+-proto1   RTF_PROTO1 - set protocol specific routing flag #1
+-proto2   RTF_PROTO2 - set protocol specific routing flag #2
+-llinfo   RTF_LLINFO - validly translates proto addr to link addr
 .Ed
 .Pp
 The optional modifiers

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.119 src/sbin/route/route.c:1.120
--- src/sbin/route/route.c:1.119	Sun Dec 28 15:12:31 2008
+++ src/sbin/route/route.c	Wed May 12 13:56:13 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.119 2008/12/28 20:12:31 christos Exp $	*/
+/*	$NetBSD: route.c,v 1.120 2010/05/12 17:56:13 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1991, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = @(#)route.c	8.6 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: route.c,v 1.119 2008/12/28 20:12:31 christos Exp $);
+__RCSID($NetBSD: route.c,v 1.120 2010/05/12 17:56:13 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -843,9 +843,15 @@
 			case K_REJECT:
 flags |= RTF_REJECT;
 break;
+			case 

CVS commit: src/sbin/route

2010-05-12 Thread Mihai Chelaru
Module Name:src
Committed By:   kefren
Date:   Wed May 12 19:26:33 UTC 2010

Modified Files:
src/sbin/route: keywords.sh

Log Message:
Update also keywords.{c,h} generator in order to reflect latest changes.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sbin/route/keywords.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/keywords.sh
diff -u src/sbin/route/keywords.sh:1.7 src/sbin/route/keywords.sh:1.8
--- src/sbin/route/keywords.sh:1.7	Sat Jul 19 01:36:47 2003
+++ src/sbin/route/keywords.sh	Wed May 12 19:26:33 2010
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $NetBSD: keywords.sh,v 1.7 2003/07/19 01:36:47 jrf Exp $
+# $NetBSD: keywords.sh,v 1.8 2010/05/12 19:26:33 kefren Exp $
 # @(#)keywords	8.2 (Berkeley) 3/19/94
 #
 # WARNING!  If you change this file, re-run it!
@@ -57,6 +57,10 @@
 xns
 xresolve
 flushall
+nocloned
+nocloning
+noblackhole
+noreject
 _EOF_
 
 
@@ -81,7 +85,7 @@
 /* WARNING!  This file was generated by keywords.sh  */
 
 extern struct keytab {
-	char	*kt_cp;
+	const char *kt_cp;
 	int	kt_i;
 } keywords[];