From owner-freebsd-hackers@FreeBSD.ORG Mon Sep 20 03:40:54 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 784C016A4CE; Mon, 20 Sep 2004 03:40:54 +0000 (GMT) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.185]) by mx1.FreeBSD.org (Postfix) with ESMTP id AE95643D54; Mon, 20 Sep 2004 03:40:53 +0000 (GMT) (envelope-from max@love2party.net) Received: from [212.227.126.179] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1C9F2o-0002Lr-00; Mon, 20 Sep 2004 05:40:50 +0200 Received: from [217.227.156.246] (helo=donor.laier.local) by mrelayng.kundenserver.de with asmtp (TLSv1:RC4-MD5:128) (Exim 3.35 #1) id 1C9F2n-0007vz-00; Mon, 20 Sep 2004 05:40:50 +0200 From: Max Laier To: Brooks Davis Date: Mon, 20 Sep 2004 05:39:38 +0200 User-Agent: KMail/1.7 References: <200409200250.49518.max@love2party.net> <20040920022852.GA21281@odin.ac.hmc.edu> In-Reply-To: <20040920022852.GA21281@odin.ac.hmc.edu> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart3010729.AUYAN69HKC"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200409200539.48073.max@love2party.net> X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:61c499deaeeba3ba5be80f48ecc83056 cc: freebsd-hackers@freebsd.org cc: freebsd-net@freebsd.org cc: freebsd-standards@freebsd.org cc: freebsd-arch@freebsd.org Subject: Re: Global (non _KERNEL) place for sockaddr_union? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Sep 2004 03:40:54 -0000 --nextPart3010729.AUYAN69HKC Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Monday 20 September 2004 04:28, Brooks Davis wrote: > On Mon, Sep 20, 2004 at 02:50:40AM +0200, Max Laier wrote: > > Hi, > > > > http://www.freebsd.org/cgi/query-pr.cgi?pr=3Dkern/71836 is the symptom.= Now > > I am looking for a clean solution to it. What is needed is an include > > file that defines union sockaddr_union in a way that is useable from > > kernel and userland. Historically it seems that this union first apeared > > in context of ipsec within the kernel. pf has adopted it, but uses it in > > the userland as well. I am sure that it can be usefull in a lot of plac= es > > that have to deal with/store different address formats. > > > > My question now is, what would be a good place to define this? Are there > > any fromal standarts that might define it already? (Couldn't find > > anything) Is there anything else that I must consider? > > > > At some point I though netinet/in.h might be a good place, but that'd > > require inclusion of sys/socket.h, which certainly is not a good > > solution. > > > > Opinions? Ideas? > > > > > #include > > > #include > > > > > > union sockaddr_union { > > > struct sockaddr sa; > > > struct sockaddr_in sin; > > > struct sockaddr_in6 sin6; > > > struct sockaddr_storage __su_pad; /* maybe not a bad idea */ > > > }; > > I don't see an elegant solution. Stuffing it off in its own file may > be the best thing if you're going to use it. Overall, I'd say it's bad > idea that PF be better off without. It appears to save a few casts, > but nothing worth the pain of generalizing the declaration. > > -- Brooks =46irst of all, the padding is bogus as sin6 is big enough. Especially sinc= e one=20 point here is to save space. I was a bit confused there, sorry. Especially= =20 since this is an important point: In pf this union is uses to - for example= -=20 store address information in tables. It allows to store IPv4 and IPv6=20 addresses in the same table without creating overhead in the memory footpri= nt=20 or having to deal with different objects for every address type. The fewer= =20 casts are just an additional benefit. Maybe you are right and a new header is the easiest way out. Moving this ou= t=20 of under _KERNEL would require all includer of netipsec/keydb.h to include= =20 sys/socket.h and netinet/in.h. As I was saying, I don't have a good idea=20 either. The only thing that came to my mind just now is to add a protecting= =20 define and #ifdef around the two places that define it. But I have no idea= =20 how clean (in terms of style) such a solution is. =2D-=20 /"\ Best regards, | mlaier@freebsd.org \ / Max Laier | ICQ #67774661 X http://pf4freebsd.love2party.net/ | mlaier@EFnet / \ ASCII Ribbon Campaign | Against HTML Mail and News --nextPart3010729.AUYAN69HKC Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (FreeBSD) iD8DBQBBTlEEXyyEoT62BG0RAr9TAJ42DYbnMVi2Cgj9TICFk7YXCo0YFgCfQdyg ORVq+9JZZUGaOxLFYXMf82U= =cYA3 -----END PGP SIGNATURE----- --nextPart3010729.AUYAN69HKC--