Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Sep 2007 14:59:38 -0700
From:      Alfred Perlstein <alfred@freebsd.org>
To:        net@freebsd.org
Subject:   take II: Allocating AF constants for vendors.
Message-ID:  <20070906215938.GL87451@elvis.mu.org>

next in thread | raw e-mail | index | archive | help
* Alfred Perlstein <alfred@freebsd.org> [070821 14:13] wrote:
> Hello all,
> 
> I would like to reserve about 64 entries for VENDOR specific address
> families in sys/socket.h.
> 
> I think this will allow vendors to comfortably use the array of
> address families without worrying about overlap with FreeBSD
> protocols.
> 
> If no one objects I plan to commit this in the next few days.
> 
> The format will be along the lines of:
> 
> AF_VENDOR0 -> AF_VENDOR63
> 
> Suggestions?

Sam asked that I provide some numbers for this proposal, I have
them, however in the meanwhile another proposal I've floated
was implementing a reservation system where FreeBSD would allocate
every even number in the AF_ set of constants and leave the
odd numbers for vendors.

Q: "What if a vendor wants to then contribute code to FreeBSD?"
A: They should have asked FreeBSD to reserve a number, now they
   can allocate a FreeBSD one.

The numbers are specifically meant for internal address families.

Here's the numbers for simply bumping AF_MAX:

Here's what I have for sizing it up 59 entries.                                 


===========================================================================
GDB commands to get sizes of structures related to AF_MAX:

printf "AF_MAX: %d\n", sizeof(((struct ifnet *)0)->if_afdata) / sizeof(void*)
printf "struct netexport: %d\n", sizeof(struct netexport)
printf "struct ifnet: %d\n", sizeof(struct ifnet)
printf "route.c:rt_tables: %d\n", sizeof(rt_tables)

===========================================================================
Data from AF_MAX = 37 (FreeBSD-stable)

AF_MAX: 37
Kernel size:
/usr/src/sys/i386/compile/JUNIPER_6_2_SMP % size kernel.debugSMALLMAX
   text    data     bss     dec     hex filename
5964450  791752  367916 7124118  6cb496 kernel.debugSMALLMAX

/usr/src/sys/i386/compile/JUNIPER_6_2_SMP % gdb kernel.debugSMALLMAX 
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...
(gdb) printf "AF_MAX: %d\n", sizeof(((struct ifnet *)0)->if_afdata) / sizeof(void*)
AF_MAX: 37
(gdb) printf "struct netexport: %d\n", sizeof(struct netexport)
struct netexport: 316
(gdb) printf "struct ifnet: %d\n", sizeof(struct ifnet)
struct ifnet: 644
(gdb) printf "route.c:rt_tables: %d\n", sizeof(rt_tables)
route.c:rt_tables: 152
(gdb) 


===========================================================================
Data from AF_MAX = 96 (FreeBSD-stable + 59 entries)

AF_MAX: 96
/usr/src/sys/i386/compile/JUNIPER_6_2_SMP % size kernel.debug        
   text    data     bss     dec     hex filename
5964450  791752  368140 7124342  6cb576 kernel.debug

.(14:22:56)(alfred@pants.juniper.net) !!! SANDBOX UNSET!!! 
/usr/src/sys/i386/compile/JUNIPER_6_2_SMP % gdb kernel.debug        
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...
(gdb) printf "AF_MAX: %d\n", sizeof(((struct ifnet *)0)->if_afdata) / sizeof(void*)
AF_MAX: 96
(gdb) printf "struct netexport: %d\n", sizeof(struct netexport)
struct netexport: 552
(gdb) printf "struct ifnet: %d\n", sizeof(struct ifnet)
struct ifnet: 880
(gdb) printf "route.c:rt_tables: %d\n", sizeof(rt_tables)
route.c:rt_tables: 388
(gdb) %


===========================================================================
Summary of differences:

size:
   text    data     bss     dec     hex filename
5964450  791752  367916 7124118  6cb496 kernel.debugSMALLMAX
5964450  791752  368140 7124342  6cb576 kernel.debug

AF_MAX: 37
struct netexport: 316
struct ifnet: 644
route.c:rt_tables: 152

AF_MAX: 96
struct netexport: 552
struct ifnet: 880
route.c:rt_tables: 388

bss diff: bytes: 224 percent: 1%
dec diff: bytes: 224 percent: 1%
AF_MAX: difference: 59 percent: 62%
struct netexport: bytes: 236 percent: 43%
struct ifnet: bytes: 236 percent: 27%
route.c:rt_tables: bytes: 236 percent: 61%

===========================================================================
Unknown:  (I don't know how to get a static variable from gdb)

unknown: netatm/atm_if.c: -> atm_ifouttbl

===========================================================================
Source inpection reveals the following iterations over AF_MAX:

vfs_free_addrlist: iterates whenever a filesystem exports are changed.
net/if.c: when deleting an interface, the rt_tables are walked to delete
all routes.

===========================================================================
Misc information:

Both PF_MAX and NET_MAXID are influenced by AF_MAX, but they do not appear
to influence the size of anything in the kernel.

===========================================================================
Summary:

bss diff: bytes: 224 percent: 1%
dec diff: bytes: 224 percent: 1%
AF_MAX: difference: 59 percent: 62%
struct netexport: bytes: 236 percent: 43%
struct ifnet: bytes: 236 percent: 27%
route.c:rt_tables: bytes: 236 percent: 61%



-- 
- Alfred Perlstein



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