diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1999-09-22 05:10:05 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1999-09-22 05:10:05 +0000 |
commit | cf644adbbdf952cbefaa4db9c57d480b33677e6e (patch) | |
tree | d3c29dd82dc6a8d4c93788056e549473b7c39a54 | |
parent | e94fcd12aabf6dc0d04ab06d4b144275cda837a7 (diff) |
routing interface sends aligned to long word boundaries; itojun
-rw-r--r-- | sbin/route/route.c | 8 | ||||
-rw-r--r-- | sbin/route/show.c | 12 | ||||
-rw-r--r-- | usr.bin/netstat/route.c | 14 |
3 files changed, 20 insertions, 14 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c index a680825229c..be75771aaa5 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.33 1999/08/17 09:13:15 millert Exp $ */ +/* $OpenBSD: route.c,v 1.34 1999/09/22 05:10:04 deraadt Exp $ */ /* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)route.c 8.3 (Berkeley) 3/19/94"; #else -static char rcsid[] = "$OpenBSD: route.c,v 1.33 1999/08/17 09:13:15 millert Exp $"; +static char rcsid[] = "$OpenBSD: route.c,v 1.34 1999/09/22 05:10:04 deraadt Exp $"; #endif #endif /* not lint */ @@ -144,7 +144,7 @@ quit(s) } #define ROUNDUP(a) \ - ((a) > 0 ? (1 + (((a) - 1) | (sizeof(in_addr_t) - 1))) : sizeof(in_addr_t)) + ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) #define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len)) int @@ -332,7 +332,7 @@ bad: usage(*argv); struct sockaddr *sa = (struct sockaddr *)(rtm + 1); (void) printf("%-20.20s ", rtm->rtm_flags & RTF_HOST ? routename(sa) : netname(sa)); - sa = (struct sockaddr *)(sa->sa_len + (char *)sa); + sa = (struct sockaddr *)(ROUNDUP(sa->sa_len) + (char *)sa); (void) printf("%-20.20s ", routename(sa)); (void) printf("done\n"); } diff --git a/sbin/route/show.c b/sbin/route/show.c index 40fa2419db2..237a10ecd36 100644 --- a/sbin/route/show.c +++ b/sbin/route/show.c @@ -1,4 +1,4 @@ -/* $OpenBSD: show.c,v 1.8 1999/02/24 22:56:02 angelos Exp $ */ +/* $OpenBSD: show.c,v 1.9 1999/09/22 05:10:04 deraadt Exp $ */ /* $NetBSD: show.c,v 1.1 1996/11/15 18:01:41 gwr Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "from: @(#)route.c 8.3 (Berkeley) 3/9/94"; #else -static char *rcsid = "$OpenBSD: show.c,v 1.8 1999/02/24 22:56:02 angelos Exp $"; +static char *rcsid = "$OpenBSD: show.c,v 1.9 1999/09/22 05:10:04 deraadt Exp $"; #endif #endif /* not lint */ @@ -70,6 +70,10 @@ extern char *netname __P((struct sockaddr *)); extern char *ns_print __P((struct sockaddr_ns *)); extern int nflag; +#define ROUNDUP(a) \ + ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) +#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len)) + /* * Definitions for showing gateway flags. */ @@ -209,9 +213,7 @@ p_rtentry(rtm) p_sockaddr(sa, 0, 36); else { p_sockaddr(sa, rtm->rtm_flags, 16); - if (sa->sa_len == 0) - sa->sa_len = sizeof(in_addr_t); - sa = (struct sockaddr *)(sa->sa_len + (char *)sa); + sa = (struct sockaddr *)(ROUNDUP(sa->sa_len) + (char *)sa); p_sockaddr(sa, 0, 18); } p_flags(rtm->rtm_flags & interesting, "%-6.6s "); diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c index 47f0b329fae..9b747220843 100644 --- a/usr.bin/netstat/route.c +++ b/usr.bin/netstat/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.28 1999/06/26 21:21:46 ho Exp $ */ +/* $OpenBSD: route.c,v 1.29 1999/09/22 05:10:04 deraadt Exp $ */ /* $NetBSD: route.c,v 1.15 1996/05/07 02:55:06 thorpej Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "from: @(#)route.c 8.3 (Berkeley) 3/9/94"; #else -static char *rcsid = "$OpenBSD: route.c,v 1.28 1999/06/26 21:21:46 ho Exp $"; +static char *rcsid = "$OpenBSD: route.c,v 1.29 1999/09/22 05:10:04 deraadt Exp $"; #endif #endif /* not lint */ @@ -81,6 +81,11 @@ static char *rcsid = "$OpenBSD: route.c,v 1.28 1999/06/26 21:21:46 ho Exp $"; #define kget(p, d) (kread((u_long)(p), (char *)&(d), sizeof (d))) +/* alignment constraint 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)) + /* * Definitions for showing gateway flags. */ @@ -108,6 +113,7 @@ struct bits { static union { struct sockaddr u_sa; u_int32_t u_data[64]; + int u_dummy; /* force word-alignment */ } pt_u; int do_rtent = 0; @@ -389,9 +395,7 @@ np_rtentry(rtm) p_sockaddr(sa, 0, 0, 36); else { p_sockaddr(sa, 0, rtm->rtm_flags, 16); - if (sa->sa_len == 0) - sa->sa_len = sizeof(in_addr_t); - sa = (struct sockaddr *)(sa->sa_len + (char *)sa); + sa = (struct sockaddr *)(ROUNDUP(sa->sa_len) + (char *)sa); p_sockaddr(sa, 0, 0, 18); } p_flags(rtm->rtm_flags & interesting, "%-6.6s "); |