Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/ndp fix routing socket alignment issue on alpha.
details: https://anonhg.NetBSD.org/src/rev/eb62e959caca
branches: trunk
changeset: 476002:eb62e959caca
user: itojun <itojun%NetBSD.org@localhost>
date: Fri Sep 03 03:54:47 1999 +0000
description:
fix routing socket alignment issue on alpha.
sync with more recent KAME code.
PR: 8305
diffstat:
usr.sbin/ndp/ndp.8 | 4 ++--
usr.sbin/ndp/ndp.c | 41 ++++++++++++++++++++---------------------
2 files changed, 22 insertions(+), 23 deletions(-)
diffs (116 lines):
diff -r c7e43f06da1b -r eb62e959caca usr.sbin/ndp/ndp.8
--- a/usr.sbin/ndp/ndp.8 Fri Sep 03 03:47:39 1999 +0000
+++ b/usr.sbin/ndp/ndp.8 Fri Sep 03 03:54:47 1999 +0000
@@ -25,8 +25,8 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $NetBSD: ndp.8,v 1.2 1999/07/06 13:20:04 itojun Exp $
-.\" KAME Id: ndp.8,v 1.1.2.8.2.7.4.1 1999/03/23 01:26:42 itojun Exp
+.\" $NetBSD: ndp.8,v 1.3 1999/09/03 03:54:47 itojun Exp $
+.\" KAME Id: ndp.8,v 1.1.1.1 1999/08/08 23:30:48 itojun Exp
.\"
.Dd May 17, 1998
.Dt NDP 8
diff -r c7e43f06da1b -r eb62e959caca usr.sbin/ndp/ndp.c
--- a/usr.sbin/ndp/ndp.c Fri Sep 03 03:47:39 1999 +0000
+++ b/usr.sbin/ndp/ndp.c Fri Sep 03 03:54:47 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ndp.c,v 1.2 1999/07/06 13:20:04 itojun Exp $ */
+/* $NetBSD: ndp.c,v 1.3 1999/09/03 03:54:47 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
@@ -115,6 +115,11 @@
#include <unistd.h>
#include "gmt2local.h"
+/* packing rule for routing socket */
+#define ROUNDUP(a) \
+ ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
+#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len))
+
extern int errno;
static int pid;
static int fflag;
@@ -145,7 +150,6 @@
void pfx_flush __P((void));
void rtr_flush __P((void));
void harmonize_rtr __P((void));
-void quit __P((char *));
static char *sec2str __P((time_t t));
static char *ether_str __P((struct sockaddr_dl *sdl));
static void ts_print __P((const struct timeval *));
@@ -369,7 +373,7 @@
return (1);
}
sin = (struct sockaddr_in6 *)(rtm + 1);
- sdl = (struct sockaddr_dl *)(sin->sin6_len + (char *)sin);
+ sdl = (struct sockaddr_dl *)(ROUNDUP(sin->sin6_len) + (char *)sin);
if (IN6_ARE_ADDR_EQUAL(&sin->sin6_addr, &sin_m.sin6_addr)) {
if (sdl->sdl_family == AF_LINK &&
(rtm->rtm_flags & RTF_LLINFO) &&
@@ -451,7 +455,7 @@
return (1);
}
sin = (struct sockaddr_in6 *)(rtm + 1);
- sdl = (struct sockaddr_dl *)(sin->sin6_len + (char *)sin);
+ sdl = (struct sockaddr_dl *)(ROUNDUP(sin->sin6_len) + (char *)sin);
if (IN6_ARE_ADDR_EQUAL(&sin->sin6_addr, &sin_m.sin6_addr)) {
if (sdl->sdl_family == AF_LINK &&
(rtm->rtm_flags & RTF_LLINFO) &&
@@ -505,19 +509,22 @@
mib[4] = NET_RT_FLAGS;
mib[5] = RTF_LLINFO;
if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
- quit("route-sysctl-estimate");
- if ((buf = malloc(needed)) == NULL)
- quit("malloc");
- if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0)
- quit("actual retrieval of routing table");
- lim = buf + needed;
+ err(1, "sysctl(PF_ROUTE estimate)");
+ if (needed > 0) {
+ if ((buf = malloc(needed)) == NULL)
+ errx(1, "malloc");
+ if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0)
+ err(1, "sysctl(PF_ROUTE, NET_RT_FLAGS)");
+ lim = buf + needed;
+ } else
+ buf = lim = NULL;
- for (next = buf; next < lim; next += rtm->rtm_msglen) {
+ for (next = buf; next && next < lim; next += rtm->rtm_msglen) {
int isrouter = 0, prbs = 0;
rtm = (struct rt_msghdr *)next;
sin = (struct sockaddr_in6 *)(rtm + 1);
- sdl = (struct sockaddr_dl *)(sin + 1);
+ sdl = (struct sockaddr_dl *)((char *)sin + ROUNDUP(sin->sin6_len));
if (addr) {
if (!IN6_ARE_ADDR_EQUAL(addr, &sin->sin6_addr))
continue;
@@ -610,7 +617,7 @@
if (rtm->rtm_addrs & RTA_NETMASK) {
sin = (struct sockaddr_in6 *)
(sdl->sdl_len + (char *)sdl);
- if (!IN6_IS_ADDR_ANY(&sin->sin6_addr))
+ if (!IN6_IS_ADDR_UNSPECIFIED(&sin->sin6_addr))
p += sprintf((char *)p, "P");
if (sin->sin6_len != sizeof(struct sockaddr_in6))
p += sprintf((char *)p, "W");
@@ -942,14 +949,6 @@
}
}
-void
-quit(msg)
- char *msg;
-{
- fprintf(stderr, "%s\n", msg);
- exit(1);
-}
-
static char *
sec2str(total)
time_t total;
Home |
Main Index |
Thread Index |
Old Index