summaryrefslogtreecommitdiffstats
path: root/sys/net/route.c
diff options
context:
space:
mode:
authorluigi <luigi@FreeBSD.org>2004-04-13 11:22:22 +0000
committerluigi <luigi@FreeBSD.org>2004-04-13 11:22:22 +0000
commitf83ca5e62d50a0c97e6da783970932ec1865b591 (patch)
treef81cadb2baf9d439843a5c8123c911c7980bb872 /sys/net/route.c
parentc3b6d70103e7aa78831dc2504b16900173fbc234 (diff)
downloadFreeBSD-src-f83ca5e62d50a0c97e6da783970932ec1865b591.zip
FreeBSD-src-f83ca5e62d50a0c97e6da783970932ec1865b591.tar.gz
route.h: introduce a macro, SA_SIZE(struct sockaddr *) which returns
the space occupied by a struct sockaddr when passed through a routing socket. Use it to replace the macro ROUNDUP(int), that does the same but is redefined by every file which uses it, courtesy of the School of Cut'n'Paste Programming(TM). (partial) userland changes to follow.
Diffstat (limited to 'sys/net/route.c')
-rw-r--r--sys/net/route.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/sys/net/route.c b/sys/net/route.c
index 5a083ca..60b2c1b 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1001,15 +1001,13 @@ rt_fixchange(struct radix_node *rn, void *vp)
rt_mask(rt), rt->rt_flags, (struct rtentry **)0);
}
-#define ROUNDUP(a) (a>0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
-
int
rt_setgate(struct rtentry *rt, struct sockaddr *dst, struct sockaddr *gate)
{
/* XXX dst may be overwritten, can we move this to below */
struct radix_node_head *rnh = rt_tables[dst->sa_family];
caddr_t new, old;
- int dlen = ROUNDUP(dst->sa_len), glen = ROUNDUP(gate->sa_len);
+ int dlen = SA_SIZE(dst), glen = SA_SIZE(gate);
RT_LOCK_ASSERT(rt);
@@ -1037,7 +1035,7 @@ rt_setgate(struct rtentry *rt, struct sockaddr *dst, struct sockaddr *gate)
* if we need to malloc a new chunk, then keep the old one around
* till we don't need it any more.
*/
- if (rt->rt_gateway == 0 || glen > ROUNDUP(rt->rt_gateway->sa_len)) {
+ if (rt->rt_gateway == 0 || glen > SA_SIZE(rt->rt_gateway)) {
old = (caddr_t)rt_key(rt);
R_Malloc(new, caddr_t, dlen + glen);
if (new == 0)
OpenPOWER on IntegriCloud