diff options
author | Jorge Boncompte [DTI2] <jorge@dti2.net> | 2012-05-07 16:52:52 +0000 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2012-05-22 20:25:07 +0200 |
commit | 10f9bf3f2021f874e574e4ebae9413bee982ed2b (patch) | |
tree | 5102a98c91d7d60380c07c08d0aaa32aa19cdbdf /bgpd/bgp_route.c | |
parent | f669f7d25f0f491d5e487897227ff434aef20406 (diff) |
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>
Diffstat (limited to 'bgpd/bgp_route.c')
-rw-r--r-- | bgpd/bgp_route.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 589c0738..12cb693a 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -2147,9 +2147,9 @@ bgp_update_main (struct peer *peer, struct prefix *p, struct attr *attr, /* Next hop must not be 0.0.0.0 nor Class D/E address. Next hop must not be my own address. */ - if (bgp_nexthop_self (afi, &new_attr) - || new_attr.nexthop.s_addr == 0 - || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr))) + if (new_attr.nexthop.s_addr == 0 + || IPV4_CLASS_DE (ntohl (new_attr.nexthop.s_addr)) + || bgp_nexthop_self (&new_attr)) { reason = "martian next-hop;"; goto filtered; |