I think the most efficient technique is to make the per-address lookup table an mmap'd array of pointers to entries in the existing route table.
That makes it effectively addrtable[2][2**24], right?
Yes. Of course a single pointer would be 8 bytes when it is compiled for 64 bits, but it would not need to be. When your existing route table is an array rather than a collection of malloc'ed objects linked by pointers, the "pointer" from the address lookup table into the route table could be the smaller index into the route table (that would easily fit in an unsigned short integer, allowing for 65535 gateways). Or, in 32 bit mode a simple pointer can be used (4 bytes per entry).
Rob
The existing routing table is an array of structs. Storing the index+1 into the into the addrs table array requires some index arithmetic, but that is relatively cheap. Yes, u_short would save considerable memory. - Brian
On Mon, May 01, 2017 at 09:11:17PM +0200, Rob Janssen wrote:
Yes. Of course a single pointer would be 8 bytes when it is compiled for 64 bits, but it would not need to be. When your existing route table is an array rather than a collection of malloc'ed objects linked by pointers, the "pointer" from the address lookup table into the route table could be the smaller index into the route table (that would easily fit in an unsigned short integer, allowing for 65535 gateways). Or, in 32 bit mode a simple pointer can be used (4 bytes per entry).
Using a simple global array to be the list of addresses and pointers, full load time went from about 3ms to 15ms. But it works just fine and the lookups are so fast the microsecond timer registers zero. - Brian
On Mon, May 01, 2017 at 09:11:17PM +0200, Rob Janssen wrote:
Yes. Of course a single pointer would be 8 bytes when it is compiled for 64 bits, but it would not need to be. When your existing route table is an array rather than a collection of malloc'ed objects linked by pointers, the "pointer" from the address lookup table into the route table could be the smaller index into the route table (that would easily fit in an unsigned short integer, allowing for 65535 gateways). Or, in 32 bit mode a simple pointer can be used (4 bytes per entry).
Rob
44Net mailing list 44Net@hamradio.ucsd.edu http://hamradio.ucsd.edu/mailman/listinfo/44net