From owner-freebsd-net@FreeBSD.ORG Tue Apr 13 03:29:39 2004 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 38B8216A4CE for ; Tue, 13 Apr 2004 03:29:39 -0700 (PDT) Received: from tigra.ip.net.ua (tigra.ip.net.ua [82.193.96.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 71CF343D5D for ; Tue, 13 Apr 2004 03:29:38 -0700 (PDT) (envelope-from ru@ip.net.ua) Received: from heffalump.ip.net.ua (heffalump.ip.net.ua [82.193.96.213]) by tigra.ip.net.ua (8.12.11/8.12.11) with ESMTP id i3DAYQtm067207 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 13 Apr 2004 13:34:27 +0300 (EEST) (envelope-from ru@ip.net.ua) Received: (from ru@localhost) by heffalump.ip.net.ua (8.12.11/8.12.11) id i3DATUqj043257; Tue, 13 Apr 2004 13:29:30 +0300 (EEST) (envelope-from ru) Date: Tue, 13 Apr 2004 13:29:30 +0300 From: Ruslan Ermilov To: Luigi Rizzo Message-ID: <20040413102930.GJ35262@ip.net.ua> References: <20040413014720.A57543@xorpc.icir.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="r4QXMf6/kyF/FvJJ" Content-Disposition: inline In-Reply-To: <20040413014720.A57543@xorpc.icir.org> User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp) cc: net@freebsd.org Subject: Re: multiple definitions of ROUNDUP macro X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Apr 2004 10:29:39 -0000 --r4QXMf6/kyF/FvJJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 13, 2004 at 01:47:20AM -0700, Luigi Rizzo wrote: > The ROUNDUP macro, used to account for the space occupied by a sockaddr = =20 > when passed through a routing socket, is defined in a zillion places: >=20 > src/usr.sbin/IPXrouted/startup.c:#define ROUNDUP(a) \ > src/usr.sbin/arp/arp.c:#define ROUNDUP(a) \ > src/usr.sbin/ndp/ndp.c:#define ROUNDUP(a) \ > src/usr.sbin/ppp/defs.h:#define ROUNDUP(x) ((x) ? (1 + (((x) - 1) | (size= of(longsrc/usr.sbin/route6d/route6d.c:#define ROUNDUP(a) \ > src/usr.sbin/rwhod/rwhod.c:#define ROUNDUP(a) \ > src/sys/net/route.c.orig:#define ROUNDUP(a) (a>0 ? (1 + (((a) - 1) | (siz= eof(lonsrc/sys/net/rtsock.c:#define ROUNDUP(a) \ >=20 You forgot ifconfig(8) and route(8), my favourite reference utils, when it comes to routing. ;) > A similar macro, ADVANCE, has similar problems. > This is confusing at best, and a likely source of trouble. >=20 > If there are no objections I would like to replace it with a > centralised macro (possibly with a suitable name) which takes > a sockaddr * as argument and returns the rounded-up size of the > object as a result. >=20 Yes, please! I wanted to do it long ago, but couldn't come up with good names for them. > BTW, i notice that the rounding is to multiples of "sizeof(long)", > and i wonder if this is intentional, especially on 64-bit > architectures. >=20 It would probably be OK to round-up to an int, but it's too late to change it now -- many off-tree tools that work with routing sockets would break on machines with sizeof(int) !=3D sizeof(long). Cheers, --=20 Ruslan Ermilov ru@FreeBSD.org FreeBSD committer --r4QXMf6/kyF/FvJJ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) iD8DBQFAe8EKUkv4P6juNwoRAtyUAJ4v3BmVGmctlk7sk5w0UeIXRTl2DwCfTRnd Xz/PRVq67FZz1FR+BwKwg1Y= =4uxg -----END PGP SIGNATURE----- --r4QXMf6/kyF/FvJJ--