Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Jul 2002 01:18:10 -0700
From:      Luigi Rizzo <luigi@freebsd.org>
To:        current@freebsd.org
Subject:   different packing of structs in kernel vs. userland ?
Message-ID:  <20020714011810.A72236@iguana.icir.org>

next in thread | raw e-mail | index | archive | help
Hi,
the following message seems to suggest that the compiler
(the way it is invoked) packs structures differently
when building the kernel and userland.

The stize of the structure in question is computed
by both kernel and userland app using sizeof(),
so there is no assumption on the size of its members,
so i believe the only possibility of a mismatch is
the one above.

Any ideas ?

	cheers
	luigi

----- Forwarded message from Mike Barcroft <mike@FreeBSD.org> -----

Date: Sat, 13 Jul 2002 00:38:29 -0400
From: Mike Barcroft <mike@FreeBSD.org>
Subject: New ipfw isn't 64-bit clean
To: luigi@FreeBSD.org
Cc: current@FreeBSD.org

In struct ip_fw, the member timespace becomes padded with 32-bits
because a pointer follows it.  This causes the RULESIZE() macro to
miscalculate the size of the rule by 4 bytes.  Resulting in EINVAL
and kernel warnings:

%%%
bowie# ipfw add allow all from me to 192.168.3.1
00000 allow ip from me to 192.168.3.1
ipfw: size mismatch (have 64 want 68)
ipfw: getsockopt(IP_FW_ADD): Invalid argument
%%%

(Shouldn't 00000 be 00100?)

I worked around the breakage by moving next_rule to the second
position in the struct.  I imagine the real solution involves not
jamming kernel pointers into public interfaces.

Also, ipfw(8) has lots of warnings as a result of printf()s with
deprecated quad_t's.  This should be easily fixed by using intmax_t's.

Best regards,
Mike Barcroft

----- End forwarded message -----

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020714011810.A72236>