summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_route.c
Commit message (Collapse)AuthorAgeFilesLines
* bgpd: Fix crash reported by NetDEF CILou Berger2016-03-081-0/+3
| | | | | | | | | | | | This patch is part of the previously submitted patch set on VPN and Encap SAFIs. It fixes an issue identified by NetDEF CI. Ensure temp stack structures are initialized Add protection against double frees / post free access to bgp_attr_flush Signed-off-by: Lou Berger <lberger@labn.net>
* bgpd: Remove the double-pass parsing of NLRIsPaul Jakma2016-03-081-105/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * bgpd parses NLRIs twice, a first pass "sanity check" and then a second pass that changes actual state. For most AFI/SAFIs this is done by bgp_nlri_sanity_check and bgp_nlri_parse, which are almost identical. As the required action on a syntactic error in an NLRI is to NOTIFY and shut down the session, it should be acceptable to just do a one pass parse. There is no need to atomically handle the NLRIs. * bgp_route.h: (bgp_nlri_sanity_check) Delete * bgp_route.c: (bgp_nlri_parse) Make the prefixlen size check more general and don't hard-code AFI/SAFI details, e.g. use prefix_blen library function. Add error logs consistent with bgp_nlri_sanity_check as much as possible. Add a "defense in depth" type check of the prefixlen against the sizeof the (struct prefix) storage - ala bgp_nlri_parse_vpn. Update standards text from draft RFC4271 to the actual RFC4271 text. Extend the semantic consistency test of IPv6. E.g. it should skip mcast NLRIs for unicast safi as v4 does. * bgp_mplsvpn.{c,h}: Delete bgp_nlri_sanity_check_vpn and make bgp_nlri_parse_vpn_body the bgp_nlri_parse_vpn function again. (bgp_nlri_parse_vpn) Remove the notifies. The sanity checks were responsible for this, but bgp_update_receive handles sending NOTIFY generically for bgp_nlri_parse. * bgp_attr.c: (bgp_mp_reach_parse,bgp_mp_unreach_parse) Delete sanity check. NLRI parsing done after attr parsing by bgp_update_receive. Arising out of discussions on the need for two-pass NLRI parse with: Lou Berger <lberger@labn.net> Donald Sharp <sharpd@cumulusnetworks.com>
* bgpd: Regularise bgp_update_receive, add missing notifies and checksPaul Jakma2016-03-081-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * bgp_packet.c: (bgp_update_receive) Lots of repeated code, doing same thing for each AFI/SAFI. Except when it doesn't, e.g. the IPv4/VPN case was missing the EoR bgp_clear_stale_route call - the only action really needed for EoR. Make this function a lot more regular, using common, AFI/SAFI independent blocks so far as possible. Replace the 4 separate bgp_nlris with an array, indexed by an enum. The distinct blocks that handle calling bgp_nlri_parse for each different AFI/SAFI can now be replaced with a loop. Transmogrify the nlri SAFI from the SAFI_MPLS_LABELED_VPN code-point used on the wire, to the SAFI_MPLS_VPN safi_t enum we use internally as early as possible. The existing code was not necessarily sending a NOTIFY for NLRI parsing errors, if they arose via bgp_nlri_sanity_check. Send the correct NOTIFY - INVAL_NETWORK for the classic NLRIs and OPT_ATTR_ERR for the MP ones. EoR can now be handled in one block. The existing code seemed broken for EoR recognition in a number of ways: 1. A v4/unicast EoR should be an empty UPDATE. However, it seemed to be treating an UPDATE with attributes, inc. MP REACH/UNREACH, but no classic NLRIs, as a v4/uni EoR. 2. For other AFI/SAFIs, it was treating UPDATEs with no classic withraw and with a zero-length MP withdraw as EoRs. However, that would mean an UPDATE packet _with_ update NLRIs and a 0-len MP withdraw could be classed as an EoR. This seems to be loose coding leading to ambiguous protocol situations and likely incorrect behaviour, rather than simply being liberal. Be more strict about checking that an UPDATE really is an EoR and definitely is not trying to update any NLRIs. This same loose EoR parsing was noted by Chris Hall previously on list. (bgp_nlri_parse) Front end NLRI parse function, to fan-out to the correct parser for the AFI/SAFI. * bgp_route.c: (bgp_nlri_sanity_check) We try convert NLRI safi to internal code-point ASAP, adjust switch for that. Leave the wire code point in for defensive coding. (bgp_nlri_parse) rename to bgp_nlri_parse_ip. * tests/bgp_mp_attr_test.c: Can just use bgp_nlri_parse frontend.
* bgpd: Regularise BGP NLRI sanity checks a bitPaul Jakma2016-03-081-6/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * bgp_route.h: (bgp_nlri_sanity_check) The bulk of the args are equivalent to a (struct bgp_nlri), consolidate. * bgp_route.c: (bgp_nlri_sanity_check) Make this a frontend for all afi/safis. Including SAFI_MPLS_LABELED_VPN. (bgp_nlri_sanity_check_ip) Regular IP NLRI sanity check based on the existing code, and adjusted for (struct bgp_nlri *) arg. * bgp_attr.c: (bgp_mp_reach_parse) Adjust for passing (struct bgp_nlri *) to bgp_nlri_sanity_check. Get rid of special-casing to not sanity check VPN. (bgp_mp_unreach_parse) Ditto. * bgp_mplsvpn.c: Use the same VPN parsing code for both the sanity check and the actual parse. (bgp_nlri_parse_vpn) renamed to bgp_nlri_parse_vpn_body and made internal. (bgp_nlri_parse_vpn_body) Added (bool) argument to control whether it is sanity checking or whether it should update routing state for each NLRI. Send a NOTIFY and reset the session, if there's a parsing error, as bgp_nlri_sanity_check_ip does, and as is required by the RFC. (bgp_nlri_parse_vpn) now a wrapper to call _body with update. (bgp_nlri_sanity_check_vpn) wrapper to call parser without updating. * bgp_mplsvpn.h: (bgp_nlri_sanity_check_vpn) export for bgp_nlri_sanity_check. * bgp_packet.c: (bgp_update_receive) Adjust for bgp_nlri_sanity_check argument changes. * test/bgp_mp_attr_test.c: Extend to also test the NLRI parsing functions, if the initial MP-attr parsing has succeeded. Fix the NLRI in the VPN cases. Add further VPN tests. * tests/bgpd.tests/testbgpmpattr.exp: Add the new test cases. This commit a joint effort of: Lou Berger <lberger@labn.net> Donald Sharp <sharpd@cumulusnetworks.com> Paul Jakma <paul.jakma@hpe.com> / <paul@jakma.org>
* bgpd: remove HAVE_IPV6 conditionalsLou Berger2016-02-261-198/+15
| | | | | Signed-off-by: Lou Berger <lberger@labn.net> Tested-by: NetDEF CI System <cisystem@netdef.org>
* bgpd: Add back old forms of 'show <afi> <safi>' for compatibilityLou Berger2016-02-261-201/+3898
| | | | Signed-off-by: Lou Berger <lberger@labn.net>
* bgpd: drop machineparse / random "show" improvementsLou Berger2016-02-261-15/+26
| | | | Signed-off-by: Lou Berger <lberger@labn.net>
* bgpd: encap show commandsLou Berger2016-02-261-2023/+1819
| | | | Signed-off-by: Lou Berger <lberger@labn.net>
* bgpd: VPNv6 show commandsLou Berger2016-02-261-216/+105
| | | | Signed-off-by: Lou Berger <lberger@labn.net>
* bgpd: encap: add encap SAFI (RFC5512)Lou Berger2016-02-261-85/+170
| | | | | | Adds RFC5512 and Encapsulation Attribute. Signed-off-by: Lou Berger <lberger@labn.net>
* bgpd: general MP/SAFI improvementsLou Berger2016-02-261-9/+26
| | | | | | | | This fixes some minor mixups particularly in MPLS-related SAFIs, as well as doing some stylistic changes & adding comments. Signed-off-by: Lou Berger <lberger@labn.net> Reviewed-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: improve cleanup in bgp_delete()Lou Berger2016-02-261-18/+87
| | | | Signed-off-by: Lou Berger <lberger@labn.net>
* bgpd: make _vpnv4 static handling SAFI-agnosticLou Berger2016-02-261-49/+163
| | | | | | | | | | This changes the existing _vpnv4 functions for MPLS-VPN into SAFI-agnostic functions, renaming them from *_vpnv4 to *_safi. Also adds route-map support while at it. Signed-off-by: Lou Berger <lberger@labn.net> Reviewed-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: make bgp_info_cmp and multiple-path decision logic more regularPaul Jakma2016-02-181-88/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * bgp_route.c: (bgp_info_cmp) This function is supposed to return a preference between the given paths, and does so as binary either or. When mpath was added, the binary return value was left as is and instead an out parameter 'paths_eq' was added to indicate the mpath-equality case. It's a bit odd, as is the resulting logic in the caller. Regularise things again by making the function return a strcmp like trinary return value of -1,0,1. Get rid of the mpath specific arguments, but pass in afi/safi as part of the general context - that plus the (struct bgp *) is enough to access configuration. Update the return values. The mpath check was testing the IGP metric for equality, even though previous to the mpath changes (and consistent with the behaviour of all the other tests bar the end), equality results in continuing through to the next comparison. Just go back to the previous way - each test finds a preference to return, or continues on to let further tests have a go. (bgp_best_selection) Get rid of the (struct bgp_maxpaths_cfg *) arg, we can't add state for every optional feature to the argument list - they have to look it up as needed. Do pass through the very general afi/safi context though (saves several lookups through the route_node). Adjust for the new trinary bgp_info_cmp return value and updated args. Do the mpath clearing/accumulation in one place, in each loop. Call to bgp_info_mpath_update similarly gets updated, as there's no cfg to pass. (bgp_process_{rsclient,main}) match bgp_best_selection changes. * bgp_mpath.c: (bgp_mpath_is_configured_sort) Helper for whether mpath is enabled by peer sort. (bgp_mpath_is_configured) ditto, generally. (bgp_info_mpath_update) caller no longer has the cfg to pass in, look it up. * bgp_mpath.h: Export the above and Match .c changes. Requires commit: "bgpd: bgp_scan shouldn't queue up route_nodes with no routes for processing" Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* bgpd: bgp_scan shouldn't queue up route_nodes with no routes for processingPaul Jakma2016-02-181-2/+25
| | | | | | | | * bgp_nexthop.c: (bgp_scan) There is little point queueing an rn with no routing information for processing. * bgp_route.c: (bgp_process) Do nothing on rn's with no routes. Add an assert for now, to try catch any other cases, but prob should be removed. (bgp_best_selection) rn with no routes == finish early.
* bgpd: If route-map does not exist DENY for redistribute statementsDaniel Walton2015-09-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upon usage of a route-map statement in bgp, if the route-map does not exist it turns into a implicit ALLOW, this causes issues in a wide variety of scenarios. Without this fix: ! router bgp 100 bgp router-id 10.0.2.15 redistribute static route-map FOOEY ! ip route 33.33.33.33/32 eth1 ip route 44.44.44.44/32 eth1 ! Now look at show ip bgp: show ip bgp: Network Next Hop Metric LocPrf Weight Path *> 33.33.33.33/32 0.0.0.0 0 32768 ? *> 44.44.44.44/32 0.0.0.0 0 32768 ? With this fix: show ip bgp: Network Next Hop Metric LocPrf Weight Path Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com
* bgpd: Fix memory leak in bgpd/bgp_route.cDenil Vira2015-09-241-0/+7
| | | | | | | | In function bgp_aggregate_add, variables 'aspath' and 'community' are malloced but not guaranteed to be freed before the function returns. Signed-off-by: Denil Vira <denil@cumulusnetworks.com>
* bgpd: Addition of "show ip bgp dampening" command treeBalaji2015-09-241-0/+136
| | | | | | | | | | This patch addresses David's comments and contains: 1.Addition of show ip bgp dampening command tree 2.Addition of show ip bgp dampening parameters to display BGP dampening parameters. Signed-off-by: Balaji.G <balajig81@gmail.com>
* bgpd: Make bgp_info_cmp robust to paths that do not have su_remote infoTimo Teräs2015-09-241-1/+6
| | | | | | | | | My original su_remote == NULL check is not correct. It seems that * bgp_route.c: (bgp_info_cmp) Some bgp_info is compared with su_remote=NULL and it's supposed to be perfectly legal. E.g. configured subnet announces ("network a.b.c.d/n"). Ensure bgp_info_cmp is robust if such a path gets as far as the neighbour address comparison step.
* bgpd: Fix race in clearing completionDonald Sharp2015-09-241-22/+10
| | | | | | | | | | | | | | | | | | When a peer that is Established goes down, it is moved into the Clearing state to facilitate clearing of the routes received from the peer - remove from the RIB, reselect best path, update/delete from Zebra and to other peers etc. At the end of this, a Clearing_Completed event is generated to the FSM which will allow the peer to move out of Clearing to Idle. The issue in the code is that there is a possibility of multiple Clearing Completed events being generated for a peer, one per AFI/SAFI. Upon the first such event, the peer would move to Idle. If other events happened (e.g., new connection got established) before the last Clearing_Completed event is received, bad things can happen. Fix to ensure only one Clearing_Completed event is generated. Signed-off-by: Vivek Venkataraman <vivek@cumulusnetworks.com>
* bgpd: Only use routes from Established peers for best path selectionDinesh G Dutt2015-09-241-0/+14
| | | | | | | | | | | | | | Ensure that routes from a peer are not considered for best path comparison if the peer is not in an Established state. There can be a window between a peer being deleted and the background thread that actually clears the routes (marks them as "removed") runs during which best path may run. If this path selection compared two prefixes all the way down to peer IP addresses and one of these two peers had just been deleted, that peer would not have its sockunion structures, especially su_remote, resulting in a BGPD exception. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
* bgpd: Ignore stale entry candidates during bestpath selection.vivek2015-09-241-1/+13
| | | | | | | | | | During best path selection, if one of the candidates is a stale entry, do not perform the neighbor address comparison as that information is invalid for the stale entry. Attempting to perform the comparison results in a bgpd exception. Signed-off-by: Vivek Venkataraman <vivek@cumulusnetworks.com> Reviewed-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
* bgpd: speed up "no-hit" withdraws for routeserversDavid Lamparter2015-05-051-9/+21
| | | | | | | | | | | | | | | | | | | | | | This accelerates handling of incoming Withdraw messages for routes that don't exist in the table to begin with. Cisco IOS 12.4(24)T4 has a bug in this regard - it sends withdraws instead of doing nothing for prefixes that are filtered. Pulling up the adj_in removal in Quagga should have no ill effect, but we can avoid the costly iteration over all rsclients if there was no adj_in entry. Performance impact of this change on routeserver with 3 buggy peers, startup/sync time: before patch: 143.12 seconds (user cpu) after patch: 7.01 seconds (user cpu) Many thanks to Nick Hilliard & INEX for providing real-world test data! Signed-off-by: David Lamparter <equinox@opensourcerouting.org> Acked-by: Paul Jakma <paul@jakma.org>
* Merge branch 'volatile/fix_warnings'David Lamparter2015-04-231-60/+4
|\ | | | | | | | | | | Thanks to Donald Sharp and Greg Troxel for providing feedback! Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
| * bgpd: don't use #ifdef inside macro argsDavid Lamparter2015-04-211-58/+1
| | | | | | | | | | | | | | | | Using #ifdef inside preprocessor macro argument lists is not guaranteed to work. In reality it mostly does, but we don't need these ifdefs for HAVE_IPV6 anymore, so let's get rid of the warning nonetheless. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
| * bgpd, zebra: fix struct/pointer sizeof mixupsDavid Lamparter2015-04-211-2/+3
| | | | | | | | | | | | | | | | | | | | Two places were taking sizeof(pointer) instead of the sizeof(struct), while performing operations on the struct. Both are initialisation functions; I guess we haven't seen fallout since they weren't critical. Fix anyway. [v2: fix mistake that actually broke bgpd RS workqueue init] Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* | bgpd: Configured suppress value cannot be less than the reuse value in bgp ↵Balaji2015-04-141-0/+8
|/ | | | | | | | | dampening RFC 2439, Section 4.2; the values pair up for hysteresis. Signed-off-by: Balaji.G <balajig81@gmail.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* Fix most compiler warnings in default GCC build.Paul Jakma2014-09-231-15/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix lots of warnings. Some const and type-pun breaks strict-aliasing warnings left but much reduced. * bgp_advertise.h: (struct bgp_advertise_fifo) is functionally identical to (struct fifo), so just use that. Makes it clearer the beginning of (struct bgp_advertise) is compatible with with (struct fifo), which seems to be enough for gcc. Add a BGP_ADV_FIFO_HEAD macro to contain the right cast to try shut up type-punning breaks strict aliasing warnings. * bgp_packet.c: Use BGP_ADV_FIFO_HEAD. (bgp_route_refresh_receive) fix an interesting logic error in (!ok || (ret != BLAH)) where ret is only well-defined if ok. * bgp_vty.c: Peer commands should use bgp_vty_return to set their return. * jhash.{c,h}: Can take const on * args without adding issues & fix warnings. * libospf.h: LSA sequence numbers use the unsigned range of values, and constants need to be set to unsigned, or it causes warnings in ospf6d. * md5.h: signedness of caddr_t is implementation specific, change to an explicit (uint_8 *), fix sign/unsigned comparison warnings. * vty.c: (vty_log_fixed) const on level is well-intentioned, but not going to fly given iov_base. * workqueue.c: ALL_LIST_ELEMENTS_RO tests for null pointer, which is always true for address of static variable. Correct but pointless warning in this case, but use a 2nd pointer to shut it up. * ospf6_route.h: Add a comment about the use of (struct prefix) to stuff 2 different 32 bit IDs into in (struct ospf6_route), and the resulting type-pun strict-alias breakage warnings this causes. Need to use 2 different fields to fix that warning? general: * remove unused variables, other than a few cases where they serve a sufficiently useful documentary purpose (e.g. for code that needs fixing), or they're required dummies. In those cases, try mark them as unused. * Remove dead code that can't be reached. * Quite a few 'no ...' forms of vty commands take arguments, but do not check the argument matches the command being negated. E.g., should 'distance X <prefix>' succeed if previously 'distance Y <prefix>' was set? Or should it be required that the distance match the previously configured distance for the prefix? Ultimately, probably better to be strict about this. However, changing from slack to strict might expose problems in command aliases and tools. * Fix uninitialised use of variables. * Fix sign/unsigned comparison warnings by making signedness of types consistent. * Mark functions as static where their use is restricted to the same compilation unit. * Add required headers * Move constants defined in headers into code. * remove dead, unused functions that have no debug purpose.
* *: merge branch stable/0.99.23David Lamparter2014-06-291-6/+9
|\ | | | | | | | | | | bgp extcommunity fixes from stable branch Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
| * bgpd: fix some bgp_update_main() attribute leaksDavid Lamparter2014-06-291-6/+9
| | | | | | | | | | | | | | | | | | | | | | bgp_update_main() wasn't doing anything to release attribute values set from route maps for two of its error paths. To fix, pull up the appropriate cleanup from further down and apply it here. bgp_update_rsclient() doesn't have the issue since it immediately does bgp_attr_intern() on the results from bgp_{export,import}_modifier. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* | bgpd: implement "next-hop-self all"Timo Teräs2014-06-251-1/+2
|/ | | | | | | | | | | | | As specified in: http://www.cisco.com/c/en/us/td/docs/ios-xml/ios/iproute_bgp/command/irg-cr-book/bgp-m1.html#wp4972925610 This allows overriding next-hop for ibgp learned routes on an RR for reflected routes. Especially useful for using iBGP in DMVPN setups. See: http://blog.ipspace.net/2014/04/changes-in-ibgp-next-hop-processing.html Signed-off-by: Timo Teräs <timo.teras@iki.fi>
* *: nuke ^L (page feed)David Lamparter2014-06-041-34/+34
| | | | | | | | | | | | | | Quagga sources have inherited a slew of Page Feed (^L, \xC) characters from ancient history. Among other things, these break patchwork's XML-RPC API because \xC is not a valid character in XML documents. Nuke them from high orbit. Patches can be adapted simply by: sed -e 's%^L%%' -i filename.patch (you can type page feeds in some environments with Ctrl-V Ctrl-L) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: don't compare next-hop to router-idPradosh Mohapatra2014-06-031-10/+0
| | | | | | | | | | | | | | | | While announcing a path to a peer, the code currently compares the path's next-hop with the peer's router-id. This can lead to problems as the router IDs are unique only within an AS. Suppose AS 1 sends route with next-hop 10.1.1.1. It is possible that the speaker has an established BGP peering with a router in AS 2 with router ID 10.1.1.1. The route will not be advertised to that peer in AS 2. The patch removes this check. Signed-off-by: Pradosh Mohapatra <pmohapat@cumulusnetworks.com> Reviewed-by: Dinesh G Dutt <ddutt@cumulusnetworks.com> Reviewed-by: Shrijeet Mukherjee <shm@cumulusnetworks.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: Fix condition allowas-in in rsclient codeMilan Kocian2014-05-191-1/+1
| | | | | | | | | | | Currently when you set neighbour's 'allowas-in' option on route server side you get redistribution of the prefixes from this neighbour's table into all neighbour's tables which have the same AS number. I think that wanted behaviour is to allow import prefixes from neighbour's tables with the same AS num into neighbour which has 'allowas-in' option set. Signed-off-by: Milan Kocian <milon@wq.cz> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: display multipath status in "show ip bgp"Boian Bonev2014-05-151-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The output of "show ip bg" does not show whether and which routes are installed as multipath routes along the best route: BGP table version is 0, local router ID is 10.10.100.209 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale, R Removed Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *>i1.0.0.0/24 10.10.100.1 1 111 0 15169 i * i 10.10.100.2 1 111 0 15169 i * i 10.10.100.3 1 111 0 65100 15169 i This patch adds a new status code that is showing exactly which routes are used as multipath: BGP table version is 0, local router ID is 10.10.100.209 Status codes: s suppressed, d damped, h history, * valid, > best, = multipath, i internal, r RIB-failure, S Stale, R Removed Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *>i1.0.0.0/24 10.10.100.1 1 111 0 15169 i *=i 10.10.100.2 1 111 0 15169 i * i 10.10.100.3 1 111 0 65100 15169 i The inconsistency in the status code legend ("i - internal" vs. "i internal") inherent from old IOS was fixed. It had to be touched anyways. Signed-off-by: Boian Bonev <bbonev at ipacct.com> [DL: rewrap long line, clean whitespace in same chunk] Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: track correct originator-id in reflected routesPradosh Mohapatra2014-05-151-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | ISSUE: Suppose route1 and route2 received from route-reflector-client1 and client2 respectively have identical attributes. The current logic of creating the adj-rib-out for a peer threads the 'adv' structures for both routes against the same attribute. This results in 'bgp_update_packet()' to pack those routes in the same UPDATE message with one attr structure formatted. The originator-id is thus set according to the first route's received router id. This is incorrect. PATCH: Fix bgp_announce_check() function to set the originator-id in the advertising attr structure. Also, fix the attribute hash function and compare function to consider originator-id. Otherwise attributes where all fields except the originator-id are identical get merged into one memory location. Signed-off-by: Pradosh Mohapatra <pmohapat at cumulusnetworks.com> Reviewed-by: Scott Feldman <sfeldma at cumulusnetworks.com> Reviewed-by: Ken Yin <kyin at cumulusnetworks.com> [DL: whitespace changes dropped] Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: add 'bgp bestpath as-path multipath-relax'Pradosh Mohapatra2014-05-151-1/+14
| | | | | | | | | | Compute multipath in BGP based on AS_PATH hop count match. If the knob is turned on, it is not required to have an exact match of AS_PATHs (provided other multipath conditions are met, of course). Signed-off-by: Pradosh Mohapatra <pmohapat at cumulusnetworks.com> Reviewed-by: Dinesh G Dutt <ddutt at cumulusnetworks.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd, ospfd, zebra: fix some DEFUN definitionsChristian Franke2014-04-011-29/+29
| | | | | | | Fixup some DEFUNS with incorrect command strings or mixed up helpstrings. Signed-off-by: Christian Franke <chris@opensourcerouting.org> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: fix crash in soft-reconfigurationChristian Franke2013-02-011-3/+4
| | | | | | | | | | | | Commit 8692c50652 introduced a bug where bgpd would crash on soft-reconfiguration. This happens e.g. when there are filtered unicast routes because rn->info is NULL in that case, which the code did not account for. Reported-by: Paweł Staszewski <pstaszewski@itcare.pl> Signed-off-by: Christian Franke <chris@opensourcerouting.org> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: conditional default-originate using route-mapChristian Franke2013-01-161-14/+34
| | | | | | | | | | | | | | | | | Incorporate a patch by Svetozar Mihailov which implements default-originate route-maps to behave as expected, i.e. allowing the default route to be advertised conditionally, depending on a criterion given by the route-map. I am aware that the performance attributes of the following implementation are far from optimal. However, this affects only code paths belonging to a feature that is broken without this patch, therefore, it seems reasonable to me to have this in the mainline for now. Cc: Svetozar Mihailov <quagga@j.zarhi.com> Reported-by: Sébastien Cramatte <scramatte@gmail.com> Signed-off-by: Christian Franke <chris@opensourcerouting.org> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: mark route nodes scheduled into work queueStephen Hemminger2013-01-151-0/+1
| | | | | | | The flag bit BGP_NODE_PROCESS_SCHEDULED is checked but never set. This causes route node to be scheduled multiple times under load. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: avoid heap fragmentation in bgp_clear_route_tableJorge Boncompte [DTI2]2013-01-141-15/+15
| | | | | | | | | | | | | In bgp_clear_route_table, moved cleanup code before the allocation of the work queue items. This returns the memory to the system allocator before allocating new and might therefore help avoiding heap fragmentation. * bgp_route.c: (bgp_clear_route_table) moved code blocks. Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net> Reviewed-by: Leonid Rosenboim <Leonid.Rosenboim@windriver.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: fix for leaked struct bgp_adj_[in|out] on peer shutdownJorge Boncompte [DTI2]2013-01-141-3/+0
| | | | | | | | | | | If a peer with soft-reconfiguration configured is cleared, the function bgp_clear_route_table() doesn't free the bgp_adj_in and bgp_adj_out structures of route nodes that for some reason, ej. denied by a filter, don't have routes attached "rn->info == NULL". Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net> Reviewed-by: Leonid Rosenboim <Leonid.Rosenboim@windriver.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: make bgp_table a wrapper around table libraryAvneesh Sachdev2012-09-261-20/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | Make the BGP table code a thin wrapper around the table implementation in libzebra. * bgpd/bgp_table.[ch] - Use the ROUTE_NODE_FIELDS macro to embed the fields of a route_node in the bgp_node structure. - Add a route_table field to the bgp_table structure. Initialize the route_table with a delegate, such that the nodes in the table are bgp_node structures. - Add inline wrappers that call route_table functions underneath, and accept/return the correct BGP types. * bgpd/bgp_route.c Change some code to use inline wrappers instead of accessing fields of nodes/tables directly. The latter does not always work because the types of some fields need to be translated now. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: Partially revert f018db8, fixes BZ#730Jorge Boncompte [DTI2]2012-06-211-6/+2
| | | | | | | | The change from bgp_node_get() to bgp_node_lookup() broke aggregation. Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net> Tested-by: Martin Winter <mwinter@opensourcerouting.org> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: optimize bgp_aggregate_[increment|decrement]()Jorge Boncompte [DTI2]2012-05-221-2/+20
| | | | | | | | | | | | | If there were no aggregates configured this functions were allocating and freeing a struct bgp_node for every call, and it's called for every prefix received. * bgp_route.c: Bail out early if the there are no aggregates configured. Change from bgp_node_get() to bgp_node_lookup() that does not allocate a new struct bgp_node if not found. Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: optimize bgp_update_main() in the soft_reconfig caseJorge Boncompte [DTI2]2012-05-221-2/+2
| | | | | | | Avoids 3 checks per call. Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: Remove useless initializationJorge Boncompte [DTI2]2012-05-221-1/+1
| | | | | | | It's initialized below Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: reduce struct attr_extra allocations/freeingJorge Boncompte [DTI2]2012-05-221-54/+47
| | | | | | | Try to use on stack structs for temporary uses. Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: fix struct attr_extra leak in bgp_default_originate()Jorge Boncompte [DTI2]2012-05-221-6/+2
| | | | | | | | The call to bgp_attr_default_set() above creates the attr_extra struct, but the attr.extra = NULL initialization was leaking it. Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>