summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorChris Cappuccio <chris@cvs.openbsd.org>2009-06-05 22:40:25 +0000
committerChris Cappuccio <chris@cvs.openbsd.org>2009-06-05 22:40:25 +0000
commit4e9d97f9bd4bf6ffea35c2fc1c968806bab268a6 (patch)
tree8dd99e6c5ab1c033916b198c7678a4a083f2aa9e /usr.sbin
parent637897ed02de73e77d8087fcaf4bb06dfca62df0 (diff)
rtm->rtm_hdrlen conversion
ok claudio@, henning@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpd/kroute.c6
-rw-r--r--usr.sbin/ldpd/kroute.c8
-rw-r--r--usr.sbin/ndp/ndp.c8
-rw-r--r--usr.sbin/ospf6d/kroute.c6
-rw-r--r--usr.sbin/ospfd/kroute.c6
-rw-r--r--usr.sbin/ppp/ppp/route.c4
-rw-r--r--usr.sbin/rarpd/arptab.c2
-rw-r--r--usr.sbin/ripd/kroute.c6
-rw-r--r--usr.sbin/route6d/route6d.c8
-rw-r--r--usr.sbin/rtadvd/if.c12
-rw-r--r--usr.sbin/snmpd/kroute.c6
11 files changed, 37 insertions, 35 deletions
diff --git a/usr.sbin/bgpd/kroute.c b/usr.sbin/bgpd/kroute.c
index c0a6f5edaf1..41fb84531f3 100644
--- a/usr.sbin/bgpd/kroute.c
+++ b/usr.sbin/bgpd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.166 2009/05/25 11:49:47 claudio Exp $ */
+/* $OpenBSD: kroute.c,v 1.167 2009/06/05 22:40:24 chris Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -2210,7 +2210,7 @@ fetchtable(u_int rtableid, int connected_only)
lim = buf + len;
for (next = buf; next < lim; next += rtm->rtm_msglen) {
rtm = (struct rt_msghdr *)next;
- sa = (struct sockaddr *)(rtm + 1);
+ sa = (struct sockaddr *)(next + rtm->rtm_hdrlen);
get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
if ((sa = rti_info[RTAX_DST]) == NULL)
@@ -2440,7 +2440,7 @@ dispatch_rtmsg(void)
case RTM_ADD:
case RTM_CHANGE:
case RTM_DELETE:
- sa = (struct sockaddr *)(rtm + 1);
+ sa = (struct sockaddr *)(next + rtm->rtm_hdrlen);
get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
if (rtm->rtm_pid == kr_state.pid) /* cause by us */
diff --git a/usr.sbin/ldpd/kroute.c b/usr.sbin/ldpd/kroute.c
index ab722b76e0c..287958b9724 100644
--- a/usr.sbin/ldpd/kroute.c
+++ b/usr.sbin/ldpd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.1 2009/06/01 20:59:45 michele Exp $ */
+/* $OpenBSD: kroute.c,v 1.2 2009/06/05 22:40:24 chris Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -1089,6 +1089,7 @@ send_rtlabelmsg(int fd, int action, struct kroute *kroute, u_int32_t family)
hdr.rtm_priority = 0;
hdr.rtm_seq = kr_state.rtseq++; /* overflow doesn't matter */
hdr.rtm_msglen = sizeof(hdr);
+ hdr.rtm_hdrlen = sizeof(struct rt_msghdr);
/* adjust iovec */
iov[iovcnt].iov_base = &hdr;
iov[iovcnt++].iov_len = sizeof(hdr);
@@ -1222,6 +1223,7 @@ send_rtmsg(int fd, int action, struct kroute *kroute)
hdr.rtm_fmask = RTF_PROTO2|RTF_PROTO1|RTF_REJECT|RTF_BLACKHOLE;
hdr.rtm_seq = kr_state.rtseq++; /* overflow doesn't matter */
hdr.rtm_msglen = sizeof(hdr);
+ hdr.rtm_hdrlen = sizeof(struct rt_msghdr);
/* adjust iovec */
iov[iovcnt].iov_base = &hdr;
iov[iovcnt++].iov_len = sizeof(hdr);
@@ -1351,7 +1353,7 @@ fetchtable(void)
rtm = (struct rt_msghdr *)next;
if (rtm->rtm_version != RTM_VERSION)
continue;
- sa = (struct sockaddr *)(rtm + 1);
+ sa = (struct sockaddr *)(next + rtm->rtm_hdrlen);
get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
if ((sa = rti_info[RTAX_DST]) == NULL)
@@ -1546,7 +1548,7 @@ dispatch_rtmsg(void)
if (rtm->rtm_type == RTM_ADD || rtm->rtm_type == RTM_CHANGE ||
rtm->rtm_type == RTM_DELETE) {
- sa = (struct sockaddr *)(rtm + 1);
+ sa = (struct sockaddr *)(next + rtm->rtm_hdrlen);
get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
if (rtm->rtm_tableid != 0)
diff --git a/usr.sbin/ndp/ndp.c b/usr.sbin/ndp/ndp.c
index c4f0c00fb54..bbe30506ee4 100644
--- a/usr.sbin/ndp/ndp.c
+++ b/usr.sbin/ndp/ndp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ndp.c,v 1.42 2008/06/09 15:49:31 claudio Exp $ */
+/* $OpenBSD: ndp.c,v 1.43 2009/06/05 22:40:24 chris Exp $ */
/* $KAME: ndp.c,v 1.101 2002/07/17 08:46:33 itojun Exp $ */
/*
@@ -417,7 +417,7 @@ set(int argc, char **argv)
errx(1, "RTM_GET(%s) failed", host);
/* NOTREACHED */
}
- sin = (struct sockaddr_in6 *)(rtm + 1);
+ sin = (struct sockaddr_in6 *)((char *)rtm + rtm->rtm_hdrlen);
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 &&
@@ -516,7 +516,7 @@ delete(char *host)
errx(1, "RTM_GET(%s) failed", host);
/* NOTREACHED */
}
- sin = (struct sockaddr_in6 *)(rtm + 1);
+ sin = (struct sockaddr_in6 *)((char *)rtm + rtm->rtm_hdrlen);
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 &&
@@ -607,7 +607,7 @@ again:;
int isrouter = 0, prbs = 0;
rtm = (struct rt_msghdr *)next;
- sin = (struct sockaddr_in6 *)(rtm + 1);
+ sin = (struct sockaddr_in6 *)(next + rtm->rtm_hdrlen);
sdl = (struct sockaddr_dl *)((char *)sin + ROUNDUP(sin->sin6_len));
/*
diff --git a/usr.sbin/ospf6d/kroute.c b/usr.sbin/ospf6d/kroute.c
index 85fb89578af..28668b861dd 100644
--- a/usr.sbin/ospf6d/kroute.c
+++ b/usr.sbin/ospf6d/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.11 2009/04/09 19:03:10 stsp Exp $ */
+/* $OpenBSD: kroute.c,v 1.12 2009/06/05 22:40:24 chris Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -1070,7 +1070,7 @@ fetchtable(void)
rtm = (struct rt_msghdr *)next;
if (rtm->rtm_version != RTM_VERSION)
continue;
- sa = (struct sockaddr *)(rtm + 1);
+ sa = (struct sockaddr *)(next + rtm->rtm_hdrlen);
get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
if ((sa = rti_info[RTAX_DST]) == NULL)
@@ -1260,7 +1260,7 @@ dispatch_rtmsg(void)
if (rtm->rtm_type == RTM_ADD || rtm->rtm_type == RTM_CHANGE ||
rtm->rtm_type == RTM_DELETE) {
- sa = (struct sockaddr *)(rtm + 1);
+ sa = (struct sockaddr *)(next + rtm->rtm_hdrlen);
get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
if (rtm->rtm_tableid != 0)
diff --git a/usr.sbin/ospfd/kroute.c b/usr.sbin/ospfd/kroute.c
index 4e5776a07d2..f2abe979071 100644
--- a/usr.sbin/ospfd/kroute.c
+++ b/usr.sbin/ospfd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.70 2009/06/05 04:12:52 claudio Exp $ */
+/* $OpenBSD: kroute.c,v 1.71 2009/06/05 22:40:24 chris Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -1179,7 +1179,7 @@ fetchtable(void)
rtm = (struct rt_msghdr *)next;
if (rtm->rtm_version != RTM_VERSION)
continue;
- sa = (struct sockaddr *)(rtm + 1);
+ sa = (struct sockaddr *)(next + rtm->rtm_hdrlen);
get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
if ((sa = rti_info[RTAX_DST]) == NULL)
@@ -1364,7 +1364,7 @@ dispatch_rtmsg(void)
if (rtm->rtm_type == RTM_ADD || rtm->rtm_type == RTM_CHANGE ||
rtm->rtm_type == RTM_DELETE) {
- sa = (struct sockaddr *)(rtm + 1);
+ sa = (struct sockaddr *)(next + rtm->rtm_hdrlen);
get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
if (rtm->rtm_tableid != kr_state.rdomain)
diff --git a/usr.sbin/ppp/ppp/route.c b/usr.sbin/ppp/ppp/route.c
index 703842d0389..f66b6dad2d2 100644
--- a/usr.sbin/ppp/ppp/route.c
+++ b/usr.sbin/ppp/ppp/route.c
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: route.c,v 1.35 2007/09/02 15:19:39 deraadt Exp $
+ * $OpenBSD: route.c,v 1.36 2009/06/05 22:40:24 chris Exp $
*/
#include <sys/param.h>
@@ -317,7 +317,7 @@ route_ParseHdr(struct rt_msghdr *rtm, struct sockaddr *sa[RTAX_MAX])
char *wp;
int rtax;
- wp = (char *)(rtm + 1);
+ wp = (char *)((char *)rtm + rtm->rtm_hdrlen);
for (rtax = 0; rtax < RTAX_MAX; rtax++)
if (rtm->rtm_addrs & (1 << rtax)) {
diff --git a/usr.sbin/rarpd/arptab.c b/usr.sbin/rarpd/arptab.c
index 0bc28f90daa..ae785c17dcc 100644
--- a/usr.sbin/rarpd/arptab.c
+++ b/usr.sbin/rarpd/arptab.c
@@ -125,7 +125,7 @@ tryagain:
s = -1;
return (1);
}
- sin = (struct sockaddr_inarp *)(rtm + 1);
+ sin = (struct sockaddr_inarp *)((char *)rtm + rtm->rtm_hdrlen);
sdl = (struct sockaddr_dl *)(sin->sin_len + (char *)sin);
if (sin->sin_addr.s_addr == sin_m.sin_addr.s_addr) {
if (sdl->sdl_family == AF_LINK &&
diff --git a/usr.sbin/ripd/kroute.c b/usr.sbin/ripd/kroute.c
index 203b38ea97d..6554f17c09e 100644
--- a/usr.sbin/ripd/kroute.c
+++ b/usr.sbin/ripd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.15 2009/06/02 21:43:36 claudio Exp $ */
+/* $OpenBSD: kroute.c,v 1.16 2009/06/05 22:40:24 chris Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -861,7 +861,7 @@ fetchtable(void)
rtm = (struct rt_msghdr *)next;
if (rtm->rtm_version != RTM_VERSION)
continue;
- sa = (struct sockaddr *)(rtm + 1);
+ sa = (struct sockaddr *)(next + rtm->rtm_hdrlen);
get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
if ((sa = rti_info[RTAX_DST]) == NULL)
@@ -1070,7 +1070,7 @@ dispatch_rtmsg(void)
if (rtm->rtm_type == RTM_ADD || rtm->rtm_type == RTM_CHANGE ||
rtm->rtm_type == RTM_DELETE) {
- sa = (struct sockaddr *)(rtm + 1);
+ sa = (struct sockaddr *)(next + rtm->rtm_hdrlen);
get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
if (rtm->rtm_tableid != 0)
diff --git a/usr.sbin/route6d/route6d.c b/usr.sbin/route6d/route6d.c
index 70c16e96cc3..00601a38d8f 100644
--- a/usr.sbin/route6d/route6d.c
+++ b/usr.sbin/route6d/route6d.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route6d.c,v 1.52 2009/05/13 16:14:57 deraadt Exp $ */
+/* $OpenBSD: route6d.c,v 1.53 2009/06/05 22:40:24 chris Exp $ */
/* $KAME: route6d.c,v 1.111 2006/10/25 06:38:13 jinmei Exp $ */
/*
@@ -31,7 +31,7 @@
*/
#if 0
-static char _rcsid[] = "$OpenBSD: route6d.c,v 1.52 2009/05/13 16:14:57 deraadt Exp $";
+static char _rcsid[] = "$OpenBSD: route6d.c,v 1.53 2009/06/05 22:40:24 chris Exp $";
#endif
#include <stdio.h>
@@ -1597,7 +1597,7 @@ rtrecv(void)
default:
rtm = (struct rt_msghdr *)p;
addrs = rtm->rtm_addrs;
- q = (char *)(rtm + 1);
+ q = (char *)(p + rtm->rtm_hdrlen);
if (rtm->rtm_version != RTM_VERSION) {
trace(1, "unexpected rtmsg version %d "
"(should be %d)\n",
@@ -2514,7 +2514,7 @@ rt_entry(struct rt_msghdr *rtm, int again)
*/
if (rtm->rtm_flags & RTF_DYNAMIC)
return;
- rtmp = (char *)(rtm + 1);
+ rtmp = (char *)((char *)rtm + rtm->rtm_hdrlen);
/* Destination */
if ((rtm->rtm_addrs & RTA_DST) == 0)
return; /* ignore routes without destination address */
diff --git a/usr.sbin/rtadvd/if.c b/usr.sbin/rtadvd/if.c
index a388dfec180..c2788da2766 100644
--- a/usr.sbin/rtadvd/if.c
+++ b/usr.sbin/rtadvd/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.18 2008/04/21 20:40:55 rainer Exp $ */
+/* $OpenBSD: if.c,v 1.19 2009/06/05 22:40:24 chris Exp $ */
/* $KAME: if.c,v 1.17 2001/01/21 15:27:30 itojun Exp $ */
/*
@@ -236,7 +236,7 @@ get_next_msg(char *buf, char *lim, int ifindex, size_t *lenp, int filter)
*lenp = 0;
for (rtm = (struct rt_msghdr *)buf;
rtm < (struct rt_msghdr *)lim;
- rtm = (struct rt_msghdr *)(((char *)rtm) + rtm->rtm_msglen)) {
+ rtm = (struct rt_msghdr *)((char *)rtm + rtm->rtm_msglen)) {
/* just for safety */
if (!rtm->rtm_msglen) {
log_warnx("rtm_msglen is 0 (buf=%p lim=%p rtm=%p)",
@@ -255,7 +255,7 @@ get_next_msg(char *buf, char *lim, int ifindex, size_t *lenp, int filter)
continue;
/* address related checks */
- sa = (struct sockaddr *)(rtm + 1);
+ sa = (struct sockaddr *)((char *)rtm + rtm->rtm_hdrlen);
get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
if ((dst = rti_info[RTAX_DST]) == NULL ||
dst->sa_family != AF_INET6)
@@ -320,7 +320,7 @@ get_addr(char *buf)
struct rt_msghdr *rtm = (struct rt_msghdr *)buf;
struct sockaddr *sa, *rti_info[RTAX_MAX];
- sa = (struct sockaddr *)(rtm + 1);
+ sa = (struct sockaddr *)(buf + rtm->rtm_hdrlen);
get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
return(&SIN6(rti_info[RTAX_DST])->sin6_addr);
@@ -332,7 +332,7 @@ get_rtm_ifindex(char *buf)
struct rt_msghdr *rtm = (struct rt_msghdr *)buf;
struct sockaddr *sa, *rti_info[RTAX_MAX];
- sa = (struct sockaddr *)(rtm + 1);
+ sa = (struct sockaddr *)(buf + rtm->rtm_hdrlen);
get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
return(((struct sockaddr_dl *)rti_info[RTAX_GATEWAY])->sdl_index);
@@ -369,7 +369,7 @@ get_prefixlen(char *buf)
struct sockaddr *sa, *rti_info[RTAX_MAX];
u_char *p, *lim;
- sa = (struct sockaddr *)(rtm + 1);
+ sa = (struct sockaddr *)(buf + rtm->rtm_hdrlen);
get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
sa = rti_info[RTAX_NETMASK];
diff --git a/usr.sbin/snmpd/kroute.c b/usr.sbin/snmpd/kroute.c
index 0cb0c337ad1..6772b6f516b 100644
--- a/usr.sbin/snmpd/kroute.c
+++ b/usr.sbin/snmpd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.6 2008/01/16 09:51:15 reyk Exp $ */
+/* $OpenBSD: kroute.c,v 1.7 2009/06/05 22:40:24 chris Exp $ */
/*
* Copyright (c) 2007, 2008 Reyk Floeter <reyk@vantronix.net>
@@ -812,7 +812,7 @@ fetchtable(void)
lim = buf + len;
for (next = buf; next < lim; next += rtm->rtm_msglen) {
rtm = (struct rt_msghdr *)next;
- sa = (struct sockaddr *)(rtm + 1);
+ sa = (struct sockaddr *)(next + rtm->rtm_hdrlen);
get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
if ((sa = rti_info[RTAX_DST]) == NULL)
@@ -995,7 +995,7 @@ dispatch_rtmsg(int fd, short event, void *arg)
if (rtm->rtm_type == RTM_ADD || rtm->rtm_type == RTM_CHANGE ||
rtm->rtm_type == RTM_DELETE) {
- sa = (struct sockaddr *)(rtm + 1);
+ sa = (struct sockaddr *)(next + rtm->rtm_hdrlen);
get_rtaddrs(rtm->rtm_addrs, sa, rti_info);
if (rtm->rtm_tableid != 0)