From owner-freebsd-alpha Fri Aug 3 19:26: 6 2001 Delivered-To: freebsd-alpha@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id F0E5937B403; Fri, 3 Aug 2001 19:25:59 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id MAA18601; Sat, 4 Aug 2001 12:25:30 +1000 Date: Sat, 4 Aug 2001 12:23:04 +1000 (EST) From: Bruce Evans X-X-Sender: To: Brian Somers Cc: Julian Elischer , Thomas Pornin , , , Brian Somers , , Brian Somers Subject: Re: kern/27767: (was: PPPoE + Alpha + 32/64 bits) In-Reply-To: <200108022338.f72Nc6u09427@hak.lan.Awfulhak.org> Message-ID: <20010804121134.G16179-100000@besplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-alpha@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On Fri, 3 Aug 2001, Brian Somers wrote: > > [bde wrote] > > Here I don't see how packing the struct helps on alphas. Doesn't it > > cause traps by misaligning uniqtag.data.pointer? I think you need > > something like: > > It doesn't cause a trap as the compiler is (now) smart enough to > handle it properly. Note where we have the alignment problem here: I guess it knows how to handle this in packed structs and not in many other cases. > > struct { > > struct pppoe_tag hdr; > > char data[sizeof(void *)]; > > } uniqtag; > > void *pointer; > > ... > > pointer = sp; > > memcpy(uniqtag.data, &pointer, sizeof(uniqtag.data)); > > That's probably better. I went with the __attribute((packed)) stuff > because it was already done that way in the rest of the code. I think the packed attributes in ng_pppoe.h are no-ops on most machines. > In this specific case however, it may be best to just send the variable > plus the alignment padding as the tag: > > struct { > struct pppoe_tag hdr; > union uniq data; > } uniqtag; > > ...... > uniqtag.hdr.tag_type = PTT_HOST_UNIQ; > uniqtag.hdr.tag_len = htons((u_int16_t)(sizeof(uniqtag) - sizeof(uniqtag.hdr)); > uniqtag.data.pointer = sp; You might also have to zero everything to ensure that there is no stack garbage in the message. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-alpha" in the body of the message