bgpd: optimize bgp_nexthop_self()
This function scores 2nd, profiling a full internet table load. It's called
for every prefix received.
Instead of looping in the interface lists comparing addresses use a hash
to mantain them.
* bgpd.c: Init the own address hash.
* bgp_nexthop.c: Introduce methods to maintain an own address hash.
(bgp_connected_add) add addresses to the hash.
(bgp_connected_delete) delete addresses from the hash.
(bgp_nexthop_self) lookup addresses in the hash. Removed the unused afi_t
parameter.
* bgp_route.c: (bgp_update_main) Micro-optimization, rearranged condition to
not lookup the hash for bogus nexthops (0.0.0.0 or a class D/E address)
Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
diff --git a/bgpd/bgp_nexthop.h b/bgpd/bgp_nexthop.h
index 874f3bb..6e5350e 100644
--- a/bgpd/bgp_nexthop.h
+++ b/bgpd/bgp_nexthop.h
@@ -55,6 +55,7 @@
extern int bgp_multiaccess_check_v4 (struct in_addr, char *);
extern int bgp_config_write_scan_time (struct vty *);
extern int bgp_nexthop_onlink (afi_t, struct attr *);
-extern int bgp_nexthop_self (afi_t, struct attr *);
+extern int bgp_nexthop_self (struct attr *);
+extern void bgp_address_init (void);
#endif /* _QUAGGA_BGP_NEXTHOP_H */