NetBSD Problem Report #11098

Received: (qmail 1963 invoked by uid 1155); 29 Sep 2000 03:18:58 -0000
Message-Id: <20000929031858.1962.qmail@mail.netbsd.org>
Date: 29 Sep 2000 03:18:58 -0000
From: erh@netbsd.org
Reply-To: erh@netbsd.org
To: gnats-bugs@gnats.netbsd.org
Subject: ROUNDUP is inconsistently used when ALIGN would be better.
X-Send-Pr-Version: 3.95

>Number:         11098
>Category:       kern
>Synopsis:       ROUNDUP is inconsistently used when ALIGN would be better.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Sep 29 03:19:01 +0000 2000
>Closed-Date:    
>Last-Modified:  Fri Sep 29 16:52:01 +0000 2000
>Originator:     Eric Haszlakiewicz
>Release:        Current as of Sep 28, 2000.
>Organization:
>Environment:
>Description:
	There are several places in the kernel and in userland code
that use the ROUNDUP macro when passing addresses into and out of the
kernel.  The apparant reason for this in most cases is to make sure
that each address is aligned correctly.
	The problem is that the ROUNDUP macro is defined differently
in several different places.  With the slight (and unused) feature
that at least one definition has where a length of 0 gets rounded up,
these all act in a similar fashion as the ALIGN macro.  Furthermore,
there exists what might be considered a general ROUNDUP macro in
the sys/gmon.h header file with 2 arguments instead of 1.
>How-To-Repeat:
>Fix:
	Proposed fix is to replace all custom occurances of ROUNDUP
with ALIGN after verifying the correctness of each change.
>Release-Note:
>Audit-Trail:

From: Jun-ichiro itojun Hagino <itojun@iijlab.net>
To: erh@netbsd.org
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: kern/11098: ROUNDUP is inconsistently used when ALIGN would be better. 
Date: Fri, 29 Sep 2000 14:10:20 +0900

 >>Synopsis:       ROUNDUP is inconsistently used when ALIGN would be better.

 	is it about routing socket?  it has been there forever and i don't
 	think we can fix it in reasonable amount of time, due to existing
 	third-party source code (fixing kernel is easy but by doing that
 	we become incompatible with others.

 itojun

From: Eric Haszlakiewicz <erh@nimenees.com>
To: Jun-ichiro itojun Hagino <itojun@iijlab.net>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: kern/11098: ROUNDUP is inconsistently used when ALIGN would be better.
Date: Fri, 29 Sep 2000 11:00:39 -0500

 On Fri, Sep 29, 2000 at 02:10:20PM +0900, Jun-ichiro itojun Hagino wrote:
 > 
 > >>Synopsis:       ROUNDUP is inconsistently used when ALIGN would be better.
 > 
 > 	is it about routing socket?  it has been there forever and i don't
 > 	think we can fix it in reasonable amount of time, due to existing
 > 	third-party source code (fixing kernel is easy but by doing that
 > 	we become incompatible with others.
 	Unless I'm reading it wrong, the ROUNDUP macro as used there does
 the exact same thing as the ALIGN macro except that the ROUNDUP macro
 rounds 0 up to sizeof(long).  Since passing a zero length address doesn't
 make any sense (length=0 doesn't even include the length field itself) ,
 and since other parts of the kernel assume non-zero length fields, I think
 it's best to remove that "feature".

 eric

From: itojun@iijlab.net
To: Eric Haszlakiewicz <erh@nimenees.com>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: kern/11098: ROUNDUP is inconsistently used when ALIGN would be better.
Date: Sat, 30 Sep 2000 01:03:32 +0900

 >> >>Synopsis:       ROUNDUP is inconsistently used when ALIGN would be better.
 >> 	is it about routing socket?  it has been there forever and i don't
 >> 	think we can fix it in reasonable amount of time, due to existing
 >> 	third-party source code (fixing kernel is easy but by doing that
 >> 	we become incompatible with others.
 >	Unless I'm reading it wrong, the ROUNDUP macro as used there does
 >the exact same thing as the ALIGN macro except that the ROUNDUP macro
 >rounds 0 up to sizeof(long).  Since passing a zero length address doesn't
 >make any sense (length=0 doesn't even include the length field itself) ,
 >and since other parts of the kernel assume non-zero length fields, I think
 >it's best to remove that "feature".

 	my question was not the macro itself, but more on deployment and
 	transition.

 	how can you repair all the existing third party software?
 	(pkgsrc looks good but takes time)
 	how these existing software differentiate a kernel with
 	ROUNDUP and a kernel with ALIGN? (they emit data in different
 	alignment, i'm 100% sure)  we need to provide some mechanism at least.

 itojun

From: Andrei Petrov <and@genesyslab.com>
To: erh@netbsd.org
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: kern/11098: ROUNDUP is inconsistently used when ALIGN would be
 better.
Date: Fri, 29 Sep 2000 09:49:21 -0700 (PDT)

 ROUNDUP is defined mupltiple times(!) in various .c files(!),
 and what is proposed is
 to remove those definitions and replace it's usage by another
 which already exists. That's 'code clean-up'. I definitely support
 this move. Shouldn't take long.

 The interface to 'routing socket' is very fragile and depends on
 platform alignment requirements which in reality are inforced by kernel.
 I don't know how important to keep this interface and how many 
 third-party applications depend on this but if all those
 sockaddr_.. could be moved inside rt_msghdr as it was done for metrics
 it will simplify both application writing and make interface more
 strict etc.

 --
 	Andrey

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.