summaryrefslogtreecommitdiffstats
path: root/lib/prefix.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* lib: move SG prefix2str APIs from pimd to libAnuradha Karuppiah2019-04-201-0/+29
| | | | | | This is to allow zebra to use these APIs instead of re-defining. Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
* Merge pull request #3869 from qlyoung/cocci-fixesDavid Lamparter2019-03-061-6/+3
|\ | | | | Assorted Coccinelle fixes
| * *: remove casts of XMALLOC / XCALLOCQuentin Young2019-02-261-4/+2
| | | | | | | | | | | | No cast necessary for void * Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
| * *: remove null check before XFREEQuentin Young2019-02-261-2/+1
| | | | | | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* | lib: strncpy -> strlcpy | memcpyQuentin Young2019-02-261-3/+3
|/ | | | | | strncpy is a byte copy function not a string copy function Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* lib: MTYPE_PREFIX_FLOWSPEC should not be exposed by memory.hDonald Sharp2019-02-071-0/+1
| | | | | | This MTYPE should be owned by prefix.c as a STATIC for the file. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* Treewide: use ANSI function definitionsRuben Kerkhof2019-01-241-2/+2
| | | | Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
* Merge pull request #3180 from qlyoung/prefixlen-u8-to-u16Renato Westphal2019-01-151-11/+9
|\ | | | | lib: convert prefixlen to 16-bit integer
| * bgpd, lib: few more prefixlen updatedQuentin Young2018-10-251-0/+4
| | | | | | | | | | | | | | | | * Cast when assigning should be to uint16_t * Restored comment documenting strange behavior * Further increased PREFIX_STRLEN to 80 chars Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
| * lib: convert prefixlen to 16-bit integerQuentin Young2018-10-151-11/+5
| | | | | | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* | lib: do not convert ip prefixes without '.'Philippe Guibert2018-11-281-1/+1
|/ | | | | | | | | | | | | | There are cases where the passed parameter for a vty command is either an interface name or an ip address. Because the interface name can be a number, and because the user may want to use a number to define an IP ( for instance 'ping 0' is valid from shell purpose), there is a choice that needs to be done at frr level. either from the application point of view, the interface name will be priorized, or each number will be considered as an ip address. In that commit, the inet_aton procedure is replaced with the inet_pton procedure that ignores ips with just a number. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* *: style for EC replacementsQuentin Young2018-09-131-2/+2
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: LIB_[ERR|WARN] -> EC_LIBQuentin Young2018-09-131-1/+1
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: rename zlog_fer -> flog_errQuentin Young2018-08-141-1/+1
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* lib: Add LIB_ERR_DEVELOPMENTDonald Sharp2018-08-141-2/+4
| | | | | | | | | Sometimes a error state is detected when we have added new code to FRR, but not updated all the places that we should have. Consider this a developmental escape that needs to be fixed. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* bgpd, lib, ospfd, zebra: all_digit moved to frrstrpaco2018-06-191-11/+0
| | | | | | This solves a pending FIXME Signed-off-by: F. Aragon <paco@voltanet.io>
* bgpd: null chk (Coverity 1433544 1433543 1433542)paco2018-06-181-0/+3
| | | | Signed-off-by: F. Aragon <paco@voltanet.io>
* lib: OoB access (Coverity 1448806, 1448810)paco2018-06-121-8/+8
| | | | Signed-off-by: F. Aragon <paco@voltanet.io>
* bgpd, lib: Cleanup CI warnings from systemDonald Sharp2018-05-301-0/+1
| | | | | | Make the CI system happy. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* *: support for evpn type-4 routemitesh2018-05-301-1/+67
| | | | Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
* *: change struct evpn_addr to include a union of all evpn route typesmitesh2018-05-031-39/+89
| | | | | | | | | | EVPN prefix depends on the EVPN route type. Currently, in FRR we have a prefix_evpn/evpn_addr which relates to a evpn prefix. We need to convert this to encompass an union of various EVPN route-types. This diff handles the necessary code changes to adopt the new struct evpn_addr. Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
* lib/prefix.[ch]: add family2str()G. Paul Ziemba2018-04-041-0/+15
| | | | Signed-off-by: G. Paul Ziemba <paulz@labn.net>
* bgpd: add flowspec featurejaydom2018-03-301-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* lib: prefix support for flowspecPhilippe Guibert2018-03-301-4/+82
| | | | | | | | | | | prefix structure is used to handle flowspec prefixes. A new AFI is introduced: AF_FLOWSPEC. A sub structure named flowspec_prefix is used in prefix to host the flowspec entry. Reason to introduce that new kind is that prefixlen from prefix structure is too short to all the flowspec needs, since NLRI can go over 0xff bytes. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* *: use C99 standard fixed-width integer typesQuentin Young2018-03-271-27/+27
| | | | | | | | | | | | | | | | | | | | | | 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>
* *: conform with COMMUNITY.md formatting rules, via 'make indent'Lou Berger2018-03-061-262/+390
| | | | Signed-off-by: Lou Berger <lberger@labn.net>
* bgpd: advertise/withdraw type-5 routes upon user configmitesh2017-12-141-1/+2
| | | | | | | | | | | | | CLI config for enabling/disabling type-5 routes router bgp <as> vrf <vrf> address-family l2vpn evpn [no] advertise <ipv4|ipv6|both> loop through all the routes in VRF instance and advertise/withdraw all ip routes as type-5 routes in default instance. Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
* zebra, lib: zebra changes for symmetric routing supportMitesh Kanjariya2017-12-141-1/+1
| | | | Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
* lib: prefix: try harder to not hash garbageDavid Lamparter2017-08-241-1/+2
| | | | | | | With prefix_ptr or prefix_ls, there can still be stuff in a struct prefix that we shouldn't hash. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: optimize IPV4_ADDR_[SAME|COPY]()Jorge Boncompte2017-08-171-2/+1
| | | | | | | | | Change all callers of IPV4_ADDR_SAME() to pass a pointer to a struct in_addr Use assignment and comparison instead of memcpy() and memcmp(). Avoids function calls. Faster. Signed-off-by: Jorge Boncompte <jbonor@gmail.com>
* lib: some final MAC access-list fixesDavid Lamparter2017-08-091-1/+7
| | | | | | | | | | | - couldn't load back written configs because it was trying to parse "any" as MAC address - don't need special-casing in filter_match_zebra(), exact is going to be 0 for AF_ETHERNET anyway - some vty formatting was slightly different - is_zero_mac now static to prefix.c Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib, bgpd: Use 'struct prefix *' for filter matchingDonald Sharp2017-08-081-19/+12
| | | | | | | | There is no need for special casing of mac addresses, since the mac address is it's own type integrated into `struct prefix` now. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* lib, bgpd: Distinguish between AF_EVPN and AF_ETHERNETDonald Sharp2017-08-081-9/+26
| | | | | | Create AF_EVPN for internal use and start using it. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
* lib: changes needed for mac access-list any commandMitesh Kanjariya2017-08-081-0/+12
| | | | | | | | Ticket: CM-17074 Review: CCR-6453 Unit-test: Manual Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
* bgpd, lib, vtysh: Added support for mac filtering in route-mapsMitesh Kanjariya2017-08-081-384/+274
| | | | | | | | | | | | 1. Added support to create mac filters 2. Enabled route-map commands for EVPN address family 3. Provision to add mac filters under match clause in route-maps Ticket: CM-16349 Review: CCR-6190 Unit-test: Manual (logs attached to ticket) Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
* lib: Add ETH_ALEN to prefix.h and deprecate ETHER_ADDR_LENDonald Sharp2017-08-041-1/+1
| | | | | | | | From discussion we decided that we should use ETH_ALEN instead of ETHER_ADDR_LEN. Add ETH_ALEN to prefix.h and make ETHER_ADDR_LEN generate a warning when used( but still work ). Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* lib: move prefix hash key to prefix.c to allow global useChristian Franke2017-08-031-0/+13
| | | | Signed-off-by: Christian Franke <chris@opensourcerouting.org>
* lib/bgpd: introduce the iana_safi_t enumRenato Westphal2017-08-011-1/+2
| | | | | | | 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>
* Revert "*: reindent pt. 2"David Lamparter2017-07-221-3/+2
| | | | | | | | | 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>
* *: reindent pt. 2whitespace / reindent2017-07-171-2/+3
| | | | | | | | w/ clang 5 * reflow comments * struct members go 1 per line * binpack algo was adjusted
* *: reindentreindent-master-afterwhitespace / reindent2017-07-171-872/+1063
| | | | | | indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* Merge commit '3d22338f04d9554fa' into evpn-prepDavid Lamparter2017-07-101-21/+62
|\ | | | | | | | | | | | | Conflicts: lib/Makefile.am Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
| * lib: Refine EVPN prefix definitionvivek2017-05-251-21/+62
| | | | | | | | | | | | | | | | | | Modify EVPN prefix to use the generic IP address structure. Add support for EVPN type-2 and type-3 prefix dump. Fix references to modified fields as needed. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
* | lib/ospf/eigrp: enable ospf and eigrp to use more specific network statementsDon Slice2017-06-281-0/+25
|/ | | | | | | | | | | | | Issue reported that a configuration commonly used on other routing implementations fails in frr. If under ospf, "network 172.16.1.1/32 area 0" or under eigrp, "network 172.16.1.1/32" is entered, the appropriate interfaces are not included in the routing protocol. This was because the code was calling prefix_match, which did not match if the network statement had a longer mask than the interface being matched. This fix takes away that restriction by creating a "lib/prefix_match_network_statement" function which doesn't care about the mask of the interface. Manual testing shows both ospf and eigrp now can be defined with more specific network statements. Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
* *: make consistent & update GPLv2 file headersDavid Lamparter2017-05-151-4/+3
| | | | | | | | | | | 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>
* lib: add labeled-unicast in safi2str()Renato Westphal2017-05-121-2/+4
| | | | | | | While here, move SAFI_ENCAP above SAFI_MPLS_VPN to keep the ordering consistent. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* *: get rid of zlog(*, LOG_LEVEL, ...)David Lamparter2017-03-081-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Result of running the following Coccinelle patch + fixups: <<EOF /* long-forms: zlog(NULL, <level>, ...) * => zlog_level(...) */ @@ expression list args; @@ - zlog(NULL, LOG_DEBUG, args) + zlog_debug(args) @@ expression list args; @@ - zlog(NULL, LOG_NOTICE, args) + zlog_notice(args) @@ expression list args; @@ - zlog(NULL, LOG_INFO, args) + zlog_info(args) @@ expression list args; @@ - zlog(NULL, LOG_WARNING, args) + zlog_warn(args) @@ expression list args; @@ - zlog(NULL, LOG_ERR, args) + zlog_err(args) /* long-forms: zlog(base->log, <level>, ...) * => zlog_level(...) */ @@ expression base; expression list args; @@ - zlog(base->log, LOG_DEBUG, args) + zlog_debug(args) @@ expression base; expression list args; @@ - zlog(base->log, LOG_NOTICE, args) + zlog_notice(args) @@ expression base; expression list args; @@ - zlog(base->log, LOG_INFO, args) + zlog_info(args) @@ expression base; expression list args; @@ - zlog(base->log, LOG_WARNING, args) + zlog_warn(args) @@ expression base; expression list args; @@ - zlog(base->log, LOG_ERR, args) + zlog_err(args) EOF Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: restore pre-evpn output behaviorPhilippe Guibert2017-02-161-0/+5
| | | | | | | If an EVPN entry is detected, and type is not route type 5, displays the Ethernet MAC configured, as it was before evpn is introduced. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* lib: prefix2str initialises incoming buffer in case erroneous EVPN pfxPhilippe Guibert2017-02-141-0/+4
| | | | | | | | In the case, evpn prefix is requested to be transformed into string, and if the evpn prefix is not an evpn route type 5 entry, then the prefix is returning an initialised string that mentions the vpn prefix is unknown. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* lib: simplify str2mac and use struct ethaddr structurePhilippe Guibert2017-02-141-87/+17
| | | | | | | | | | This commit simplified the string to mac conversion, since it uses sscanf, instead of depicting each incoming character one by one, and doing self analysis. Also,this commit changes the internal usage of the mac address representation in mac handling function. Signed-off-by: Lou Berger <lberger@labn.net> Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>