From owner-freebsd-net@FreeBSD.ORG Tue Apr 13 01:47:21 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 3C90E16A4CE for ; Tue, 13 Apr 2004 01:47:21 -0700 (PDT) Received: from xorpc.icir.org (xorpc.icir.org [192.150.187.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2E86F43D2D for ; Tue, 13 Apr 2004 01:47:21 -0700 (PDT) (envelope-from rizzo@icir.org) Received: from xorpc.icir.org (localhost [127.0.0.1]) by xorpc.icir.org (8.12.9p1/8.12.8) with ESMTP id i3D8lKgd060667; Tue, 13 Apr 2004 01:47:20 -0700 (PDT) (envelope-from rizzo@xorpc.icir.org) Received: (from rizzo@localhost) by xorpc.icir.org (8.12.9p1/8.12.3/Submit) id i3D8lKEg060666; Tue, 13 Apr 2004 01:47:20 -0700 (PDT) (envelope-from rizzo) Date: Tue, 13 Apr 2004 01:47:20 -0700 From: Luigi Rizzo To: net@freebsd.org Message-ID: <20040413014720.A57543@xorpc.icir.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i Subject: 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 08:47:21 -0000 The ROUNDUP macro, used to account for the space occupied by a sockaddr when passed through a routing socket, is defined in a zillion places: 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) | (sizeof(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) | (sizeof(lonsrc/sys/net/rtsock.c:#define ROUNDUP(a) \ A similar macro, ADVANCE, has similar problems. This is confusing at best, and a likely source of trouble. 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. BTW, i notice that the rounding is to multiples of "sizeof(long)", and i wonder if this is intentional, especially on 64-bit architectures. cheers luigi