]> git.proxmox.com Git - mirror_frr.git/commit - lib/hash.c
bgpd: peer hash expands until we are out of memory
authorDaniel Walton <dwalton@cumulusnetworks.com>
Mon, 31 Jul 2017 21:22:23 +0000 (21:22 +0000)
committerDaniel Walton <dwalton@cumulusnetworks.com>
Mon, 31 Jul 2017 21:22:23 +0000 (21:22 +0000)
commit40520c3649dc9d556b3a11f1d60e84130cebf487
tree22a1ee7b22142e9fe49caec66da2bcfa7bce6aa4
parent8726d93baefc7a5dda4eab09d66a71cd78660d35
bgpd: peer hash expands until we are out of memory

Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
swpX peers all start out with the same sockunion so initially they all
go into the same hash bucket. Once IPv6 ND has worked its magic they
will have different sockunions and will go in different buckets...life
is good.

Until then though, we are in a phase where all swpX peers have the same
socknunion. Once we have HASH_THRESHOLD (10) swpX peers and call
hash_get for a new swpX peer the hash code calls hash_expand(). This
happens because there are more than HASH_THRESHOLD entries in a single
bucket so the logic is "expand the hash to spread things out"...in our
case expanding doesn't spread out the swpX peers because all of their
sockunions are the same.

I looked at having peer_hash_make and peer_hash_same consider the ifname
of the swpX peer but that is a large change that we don't want to make
at the moment. So the fix is to put a cap on how large we are
willing to let the hash table get. By default there is no limit but if
max_size is set we will not allow the hash to expand above that.
bgpd/bgpd.c
bgpd/bgpd.h
lib/hash.c
lib/hash.h