summaryrefslogtreecommitdiff
path: root/bgpd/bgp_open.c
AgeCommit message (Collapse)Author
2019-08-27bgpd: Eliminate all incorrect formulations of afi/safi in JSONDinesh G Dutt
In a number of places, the JSON output had invalid key names for AFI/SAFI. For example, the key name in JSON was "IPv4 Unicast" which is invalid as a JSON Key name. Many JSON tools such as those used in Ansible, jq etc. all fail to parse the output in these scenarios. The valid name is ipv4Unicast. There's already a routine afi_safi_json() defined to handle this change, but it was not consistently called. The non-JSON version was called afi_safi_print() and it merely returned the CLI version of the string, didn't print anything. This patch deals with this issue by: - Renaming afi_safi_print to get_afi_safi_str() - get_afi_safi_str takes an additional param, for_json which if true will return the JSON-valid string - Renaming afi_safi_json to get_afi_safi_json_str() - Creating a new routine get_afi_safi_vty_str() for printing to vty - Consistently using get_afi_safi_str() with the appropriate for_json value Signed-off-by: Dinesh G Dutt <5016467+ddutt@users.noreply.github.com>
2019-06-02bgpd, lib: Add iana_afi2str and iana_safi2str for eye pleasing stringsDonald Sharp
Modify the code such that we can auto turn the iana values of afi and safi to pleasant to read strings. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-02-27bgpd: capabiltyQuentin Young
capabilty Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-11-10bgpd: Re-use TX Addpath IDs where possibleMitch Skiba
The motivation for this patch is to address a concerning behavior of tx-addpath-bestpath-per-AS. Prior to this patch, all paths' TX ID was pre-determined as the path was received from a peer. However, this meant that any time the path selected as best from an AS changed, bgpd had no choice but to withdraw the previous best path, and advertise the new best-path under a new TX ID. This could cause significant network disruption, especially for the subset of prefixes coming from only one AS that were also communicated over a bestpath-per-AS session. The patch's general approach is best illustrated by txaddpath_update_ids. After a bestpath run (required for best-per-AS to know what will and will not be sent as addpaths) ID numbers will be stripped from paths that no longer need to be sent, and held in a pool. Then, paths that will be sent as addpaths and do not already have ID numbers will allocate new ID numbers, pulling first from that pool. Finally, anything left in the pool will be returned to the allocator. In order for this to work, ID numbers had to be split by strategy. The tx-addpath-All strategy would keep every ID number "in use" constantly, preventing IDs from being transferred to different paths. Rather than create two variables for ID, this patch create a more generic array that will easily enable more addpath strategies to be implemented. The previously described ID manipulations will happen per addpath strategy, and will only be run for strategies that are enabled on at least one peer. Finally, the ID numbers are allocated from an allocator that tracks per AFI/SAFI/Addpath Strategy which IDs are in use. Though it would be very improbable, there was the possibility with the free-running counter approach for rollover to cause two paths on the same prefix to get assigned the same TX ID. As remote as the possibility is, we prefer to not leave it to chance. This ID re-use method is not perfect. In some cases you could still get withdraw-then-add behaviors where not strictly necessary. In the case of bestpath-per-AS this requires one AS to advertise a prefix for the first time, then a second AS withdraws that prefix, all within the space of an already pending MRAI timer. In those situations a withdraw-then-add is more forgivable, and fixing it would probably require a much more significant effort, as IDs would need to be moved to ADVs instead of paths. Signed-off-by Mitchell Skiba <mskiba@amazon.com>
2018-09-18bgpd: Extend RFC 5549 metaphor a bit moreDonald Sharp
Currently we only support RFC 5549 in bgp via using the `neighbor swp1 interface remote-as ...` command. This causes the extended capability data to be traded as part of the open message. Additionally at that point in time we notify zebra to turn on the RA code for that interface so that the zebra trick of turning the v6 nexthop into a 169.254.0.1 nexthop and adding a neighbor entry works. This code change does 2 things: 1) Modify bgp to pass the extended capability if we are attempting to establish a v4/unicast session over a v6 peer. In the past we limited this to just the LL based peer. 2) Modify the nexthop tracking code to notice when it receives nexthop data about the global v6 peer to turn on RA code on those interfaces we will be using. This will allow the v4 route with a v6 nexthop received in zebra to auto translate this correctly. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-13*: style for EC replacementsQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13bgpd: BGP_[WARN|ERR] -> EC_BGPQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-06bgpd: Convert bgp_open.c to use flog_warnDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-30bgpd/ospfd: make bgp and ospf json response a bit more consistentDon Slice
Problem reported that some bgp and ospf json commands did not return any json output at all if the bgp/ospf instance did not exist. Additionally, some bgp and ospf json commands did not return any json output if the instance existed but no neighbors were defined. This fix makes these commands more consistent in returning empty braces for json output and issue a message if not using json output. Additionally, made the flag "use_json" a bool to make it consistent since previously, it had been defined as an int, char, u_char, and bool at various places. Ticket: CM-21040 Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2018-08-14*: rename zlog_fer -> flog_errQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14bgpd: implement zlog_ferr facility for enhance error messages in bgpDon Slice
Signed-off-by: Don Slice <dslice@cumulusnetworks.com<
2018-06-28bgpd: return value (Coverity 1399203)paco
The return value can be ignored because in case of error both the 'afi' and 'safi' variables are set to the invalid values (AFI_MAX, SAFI_MAX), and the invalid values are handled properly afterwards in the 'default' blocks. Signed-off-by: F. Aragon <paco@voltanet.io>
2018-03-30bgpd: add flowspec featurejaydom
This work is derived from a work done by China-Telecom. That initial work can be found in [0]. As the gap between frr and quagga is important, a reworks has been done in the meantime. The initial work consists of bringing the following: - Bringing the client side of flowspec. - the enhancement of address-family ipv4/ipv6 flowspec - partial data path handling at reception has been prepared - the support for ipv4 flowspec or ipv6 flowspec in BGP open messages, and the internals of BGP has been done. - the memory contexts necessary for flowspec has been provisioned In addition to this work, the following has been done: - the complement of adaptation for FS safi in bgp code - the code checkstyle has been reworked so as to match frr checkstyle - the processing of IPv6 FS NLRI is prevented - the processing of FS NLRI is stopped ( temporary) [0] https://github.com/chinatelecom-sdn-group/quagga_flowspec/ Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com> Signed-off-by: jaydom <chinatelecom-sdn-group@github.com>
2018-03-27*: use C99 standard fixed-width integer typesQuentin Young
The following types are nonstandard: - u_char - u_short - u_int - u_long - u_int8_t - u_int16_t - u_int32_t Replace them with the C99 standard types: - uint8_t - unsigned short - unsigned int - unsigned long - uint8_t - uint16_t - uint32_t Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-11-21bgpd: use FOREACH_AFI_SAFI where possibleQuentin Young
Improves consistency and readability. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-28lib: new APIs for get/set system hostname/domainnameMitesh Kanjariya
1. Change hostname_get to cmd_hostname_get 2. Change domainname_get to cmd_domainname_get 3. New API to set domainname 3. Provide a CLI command to set domainname Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-08-24lib/bgpd: provide/use API to get hostname/domainnameMitesh Kanjariya
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-08-04bgpd: Fix safi_t confusion wition iana_safi_tDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-31lib/bgpd: introduce the iana_safi_t enumRenato Westphal
We had afi_t/iana_afi_t for AFIs but only safi_t for SAFIs. Fix this inconsistency. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-07-22Revert "*: reindent pt. 2"David Lamparter
This reverts commit c14777c6bfd0a446c85243d3a9835054a259c276. clang 5 is not widely available enough for people to indent with. This is particularly problematic when rebasing/adjusting branches. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-17*: reindent pt. 2whitespace / reindent
w/ clang 5 * reflow comments * struct members go 1 per line * binpack algo was adjusted
2017-07-17*: reindentreindent-master-afterwhitespace / reindent
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14*: remove VTYNL, part 1 of 6David Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-06-29*: vty_outln (vty, "") --> vty_out (vty, VTYNL)Quentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29*: use vty_outlnQuentin Young
Saves 400 lines Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-21*: simplify log message lookupQuentin Young
log.c provides functionality for associating a constant (typically a protocol constant) with a string and finding the string given the constant. However this is highly delicate code that is extremely prone to stack overflows and off-by-one's due to requiring the developer to always remember to update the array size constant and to do so correctly which, as shown by example, is never a good idea.b The original goal of this code was to try to implement lookups in O(1) time without a linear search through the message array. Since this code is used 99% of the time for debugs, it's worth the 5-6 additional cmp's worst case if it means we avoid explitable bugs due to oversights... Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-05-26bgpd: remove struct capability_orf_entryQuentin Young
virtually unused Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-05-15*: make consistent & update GPLv2 file headersDavid Lamparter
The FSF's address changed, and we had a mixture of comment styles for the GPL file header. (The style with * at the beginning won out with 580 to 141 in existing files.) Note: I've intentionally left intact other "variations" of the copyright header, e.g. whether it says "Zebra", "Quagga", "FRR", or nothing. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-10bgpd: add ENHE support for "address-family ipv4 labeled-unicast"Daniel Walton
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2017-04-06bgpd: labeled unicast processingDon Slice
Implement support for negotiating IPv4 or IPv6 labeled-unicast address family, exchanging prefixes and installing them in the routing table, as well as interactions with Zebra for FEC registration. This is the implementation of RFC 3107. Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2017-02-14bgpd: basic support for EVPNPhilippe Guibert
To handle BGP NLRI EVPN messages, bgp is modified to handle AFI_L2VPN and SAFI_EVPN values. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2017-01-17Merge remote-tracking branch 'origin/master' into pim_lib_work2Donald Sharp
2017-01-12Quagga: AFI/SAFI mappings IANA to/from internal valuesvivek
Introduce internal and IANA defintions for AFI/SAFI and mapping functions and modify code to use these. This refactoring will facilitate adding support for other AFI/SAFI whose IANA values won't be suitable for internal data structure definitions (e.g., they are not contiguous). The commit adds some fixes related to afi/safi testing with 'make check ' command. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com> Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com> Ticket: CM-11416 Reviewed By: CCR-3594 (mpls branch) Testing Done: Not tested now, tested earlier on mpls branch
2017-01-06bgpd: enable send of Graceful Restart Preserve State F bitJulien Courtat
Enhance struct bgp to add a new flag BGP_FLAG_GR_PRESERVE_FWD, which allow to set the Preserve State F bit of Graceful Restart capability in OPEN messages. Signed-off-by: Julien Courtat <julien.courtat@6wind.com>
2017-01-04bgpd: set Graceful Restart R bit for vpnv4 address familyJulien Courtat
Signed-off-by: Julien Courtat <julien.courtat@6wind.com>
2016-09-19*: split & distribute memtypes and stop (re|ab)using lib/ MTYPEsDavid Lamparter
This is a rather large mechanical commit that splits up the memory types defined in lib/memtypes.c and distributes them into *_memory.[ch] files in the individual daemons. The zebra change is slightly annoying because there is no nice place to put the #include "zebra_memory.h" statement. bgpd, ospf6d, isisd and some tests were reusing MTYPEs defined in the library for its own use. This is bad practice and would break when the memtype are made static. Acked-by: Vincent JARDIN <vincent.jardin@6wind.com> Acked-by: Donald Sharp <sharpd@cumulusnetworks.com> [CF: rebased for cmaster-next] Signed-off-by: David Lamparter <equinox@opensourcerouting.org> Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2016-09-03lib: add AF_ETHERNET/AFI_ETHERLou Berger
2016-08-16lib, bgpd, tests: Refactor FILTER_X in zebra.hDonald Sharp
lib/zebra.h has FILTER_X #define's. These do not belong there. Put them in lib/filter.h where they belong. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> (cherry picked from commit 0490729cc033a3483fc6b0ed45085ee249cac779)
2016-08-07bgpd: use utsname.domainname only when availableRenato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-06-11bgpd: encap: add encap SAFI (RFC5512)Lou Berger
Adds RFC5512 and Encapsulation Attribute. Signed-off-by: Lou Berger <lberger@labn.net> (cherry picked from commit 298cc2f688dbadf0a447fcd06ae8e20fa5006ce4) Conflicts: bgpd/Makefile.am bgpd/bgp_attr.c bgpd/bgp_open.c bgpd/bgp_packet.c bgpd/bgp_route.c bgpd/bgp_vty.c bgpd/bgpd.c
2016-06-07bgpd: Fix Missing capability codes in data structureDonald Sharp
Forward port of a fix from upstream introduced the need to have data on the new capability codes that have been introduced. This commit adds in the missing capabilities. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-06-06bgpd: wire up VPNv6 protocol processingLou Berger
There wasn't much missing for VPNv6 to begin with; just a few bits of de- & encoding and a few lists to be updated. Signed-off-by: Lou Berger <lberger@labn.net> Signed-off-by: David Lamparter <equinox@opensourcerouting.org> [Editorial note: Signed-off-by may imply an authorship claim, but need not] Edited-by: Paul Jakma <paul.jakma@hpe.com> / <paul@jakma.org> (cherry picked from commit 9da04bca0e994ec92b9242159bf27d89c6743354) Conflicts: bgpd/bgp_attr.c bgpd/bgp_mplsvpn.c bgpd/bgpd.c
2016-06-06bgpd: Fix graceful restart capability minsizeLou Berger
* bgp_open.c: cap_minsize should be CAPABILITY_CODE_RESTART_LEN for RESTART not 6. (cherry picked from commit 7748fdc757a2181649dd4956f2767545673ef28d)
2016-06-06lib, bgpd: Fixup afi_t to be an enum and cleanup zebra.hDonald Sharp
This code change does two things: 1) Removes ZEBRA_AFI_XXX #defines since they were redundant information 2) Switches afi_t to an enumerated type so that the compiler can do a bit more compile time checking. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> (cherry picked from commit f3cfc46450cccc5ac035a5a97c5a1a5484205705) Conflicts: bgpd/bgp_open.c bgpd/bgp_open.h bgpd/bgp_routemap.c
2016-06-06bgpd: Update error subcode for OPEN messagevivek
Updates: 695ef95fd7d5d8e48e2406092a2f52c8c9c784f3
2016-06-06bgpd: Check capability falls on right multiple of size, where possible.Paul Jakma
* bgp_open.c: (cap_modsizes) Table of multiple a capability's data size should fall on, if applicable. (bgp_capability_parse) Check the header lengthcap_modsizes should fall on. Inspiration from Cumulus bgpd-capability-cleanup.patch patch, with a slightly different approach. Acked-by: Donald Sharp <sharpd@cumulusnetworks.com> (cherry picked from commit 4078f2eb7a3a94ddb30cfd8b76b054e790aab524)
2016-05-26bgpd: trivial, remove unneeded extra variable in bgp_capability_restartPaul Jakma
(cherry picked from commit ec98d90767b341877fb7f1547f025b946955899a)
2016-05-19bgpd: Clean up some static analysis warningsDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Don Slice <dslice@cumulusnetworks.com> Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-03-10BGP memory leak in peer hostnameDaniel Walton
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com> Ticket: CM-9786
2016-01-07BGP: Ignore unexpected values in ENHE capabilityvivek
Silently ignore (without sending a Notification) unexpected values of AFI, SAFI or Nexthop AFI received in the Extended Next Hop Encoding capability (defined in RFC 5549). While this RFC only defines certain values as allowed, that may be changed by a future spec. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com> Ticket: CM-5975 Reviewed By: CCR-3947 Testing Done: test_fuzz 1.11, 1.12 and 1.13