summaryrefslogtreecommitdiff
path: root/lib/nexthop_group.c
AgeCommit message (Collapse)Author
2019-12-16Merge pull request #5535 from opensourcerouting/santa-elfDonald Sharp
*: cleanup elves were here
2019-12-13Merge pull request #5452 from mjstapp/fix_notify_nhgDonald Sharp
zebra: align dplane notify processing with nhg work
2019-12-13lib: make some variables staticDavid Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-12-09lib,zebra: add api to enforce nexthop sort order when copyingMark Stapp
Add an api that creates a copy of a list of nexthops and enforces the canonical sort ordering; consolidate some nhg code to avoid copy-and-paste. The zebra dplane uses that api when a plugin sets up a list of nexthops, ensuring that the plugin's list is ordered when it's processed in zebra. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-12-09lib: Add weight to nexthop for nexthop-group nexthopsDonald Sharp
Add the ability to read in the weight of a nexthop and store/handle it appropriately nexthop-group BLUE nexthop 192.168.201.44 weight 33 nexthop 192.168.201.45 weight 66 nexthop 192.168.201.46 weight 99 Is appropriately read in and handled as appropriate. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-12-06Merge pull request #5439 from mjstapp/nhg_add_labelsRenato Westphal
lib: support labelled nexthops in nexthop_groups
2019-12-04lib,zebra: use nhg_hash_entry pointer in route_entryMark Stapp
Replace the existing list of nexthops (via a nexthop_group struct) in the route_entry with a direct pointer to zebra's new shared group (from zebra_nhg.h). This allows more direct access to that shared group and the info it carries. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-12-03lib: support labelled nexthops in nexthop_groupsMark Stapp
Add support for labelled nexthops in nexthop-group vtysh configuration. Also update the PBR doc where the cli is described. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-10-25lib,pbrd,zebra: Use one api to delete nexthops/groupStephen Worley
Reduce the api for deleting nexthops and the containing group to just one call rather than having a special case and handling it separately. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25lib: Add common handler for nexthop_group_equal*()Stephen Worley
Add a common handler function for the different nexthop_group_equal*() comparison functions. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25lib: Add NULL check in nexthop_group_equal*() iterStephen Worley
Add NULL checks in `nexthop_group_equal*()` iteration before calling `nexthop_same()` to make Clang SA happy. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25lib: Fix nexthop_group_equal*() NULL checkStephen Worley
Logic error on the second null check for nexthop groups passed to the `nexthop_group_equal*() functions. This fixes it. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25lib: Separate nexthop_group_equal() into recursiveStephen Worley
Separate nexthop_group_equal() into two versions. One that compares verses recurisvely resolved nexthops and one that doesn't. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25lib,zebra: Move nexthop dup marking into creationStephen Worley
We were waiting until install time to mark nexthops as duplicate. Since they are immutable now and re-used, move this marking into when they are actually created to save a bunch of cycles. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25lib: nexthop_group_equal() assume orderedStephen Worley
Speed up nexthop_group_equal() by making it assume the groups it has been passed are ordered. This should always be the case. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25lib: Hash on resolved nexthops by defaultStephen Worley
Include resolved nexthops when hashing a nexthop group but provide an API that allows you to non-recursively hash as well. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Add recursive functionality to NHE'sStephen Worley
Add the ability to recursively resolve nexthop group hash entries and resolve them when sending to the kernel. When copying over nexthops into an NHE, copy resolved info as well. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25lib: Add equals function for nexthop groupsStephen Worley
Add a function to check whether nexthop groups are equivalent. It does not care about ordering. Also, set any functions that it relies on to take const vars as well. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra,lib: Refactor depends to RB treeStephen Worley
Refactor the depends to use an RB tree instead of a list. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-09-24*: fix missing VRF autocompletionsIgor Ryzhov
Current autocompletion works only for simple "vrf NAME" case. This commit expands it also for the following cases: - "nexthop-vrf NAME" in staticd - usage of $varname in many daemons All daemons are updated to use single varname "$vrf_name". Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2019-08-19lib: Add tail check before nexthop insertionStephen Worley
Add a tail check to see if we can just put the nexthop at the end of the already sorted list before iteration. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-06-25lib: Private api for nexthop_group manipulationStephen Worley
Add a file that exposes functions which modify nexthop groups. Nexthop groups are techincally immutable but there are a few special cases where we need direct access to add/remove nexthops after the group has been made. This file provides a way to expose those functions in a way that makes it clear this is a private/hidden api. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-06-25lib: Add a nexthop_dup() that allocates and copiesStephen Worley
Add a nexthop_dup() api that both allocates and copies a new nexthop from an old one. Still retain the old exposed function nexthop_copy() so we can copy without allocation. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-06-25lib: Put single nexthop copy into its own functionStephen Worley
Put the code to copy a single nexthop into a function of its own. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-06-25lib: Add a couple functions to nexthop_group.cDonald Sharp
Add nexthop_group_copy and nexthop_group_add_sorted functions. nexthop_group_copy -> Copy src nexthop_group into dst nexthop_group nexthop_group_add_sorted -> Adds a new nexthop to the nexthop group in a sorted manner. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-05lib, pbrd, sharpd, vtysh: Add autocompletion for 'nexthop-group'Donald Sharp
Add some auto-completion for the nexthop-group command Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-18lib: Add a counter for number of nexthopsDonald Sharp
Add a ability to count the number of nexthops in a nexthop_group. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-05lib: Add hash function for nexthop groupsStephen Worley
Add a hash function to turn a nexthop group into a 32 bit unsigned hash key with jhash. We do not care to hash any recursively resolved nexthops, just the group. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-04-04libs: use const in copy_nexthops apiMark Stapp
Use const for the source arg to copy_nexthops(). Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-04-03lib: reduce exported var symbolsQuentin Young
Don't need these in our DSO tables Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-03-22Merge pull request #3776 from opensourcerouting/pbrd-interface-nexthopsDonald Sharp
pbrd: add support for interface nexthops
2019-02-25*: remove null check before XFREEQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-02-14lib, pbrd: fix indentation of a few commandsRenato Westphal
When displaying the running configuration, we should use a single space to indent commands when necessary (and not two spaces). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-02-14lib: add support for interface nexthops on nexthop groupsRenato Westphal
This patch adds support to nexthops of type NEXTHOP_TYPE_IFINDEX to nexthop-groups. This should be especially useful when dealing with p2p interfaces like tunnels that don't have IP addresses assigned to them. NOTE: nh->addr can be NULL now, so we should always perform a null check before dereferencing this pointer. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-02-14lib: change how nexthop groups store nexthop addressesRenato Westphal
Use a pointer to a sockunion instead of a full sockunion in the nexthop_hold structure. This prepares the ground for the next commit, which will make nexthop addresses optional (in this commit we assume nh->addr will never be NULL, but this will change). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-02-14lib: consolidate nexthop-group deletion in a single placeRenato Westphal
Reuse the nhgl_delete() function to avoid code duplication. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-02*: list_delete_and_null() -> list_delete()David Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-04-23lib: Fix SA warningDonald Sharp
The addr value will never be null because of the way we do the cli, but the SA system doesn't understand this. Add an assert to make it happy. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-17lib: Handle if up/down and vrf enable/disable eventsDonald Sharp
Properly notice when we get if up/down and vrf enable/disable events and attempt to properly install nexthops as they come in. Ticket: CM20489 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-17lib: Store nexthop information independentlyDonald Sharp
Store Nexthop's as the incoming raw data. This will allow us to separate the act of inputting the cli from the act of instantiating the cli. Ticket: CM-20489 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-17lib: Clean up delete of a nexthop from a nexthop groupDonald Sharp
The delete was not properly deleting the nexthop from the nexthop group and it was not properly setting the nexthop's pointers to NULL. Ticket: CM-20261 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-17lib, pbrd: Do not allow v6 LL nexthops to be specified without an interface.Donald Sharp
Prevent the creation of a v6 LL nexthop that does not include an interface for proper resolution. Ticket: CM-20276 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-06lib: dont break display of nexthop-groups themselvesQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-06lib, pbrd: rm extra space when displaying nexthopQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-14lib: Add the ability for other people to call a nexthop write lineDonald Sharp
Add code to allow nexthops to be written by people who are interested in writing their own nexthop line. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-14lib: Expose nhgc_find commandDonald Sharp
Expose to the world the nhgc_find command so that interested parties can find a stored nexthop group. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-14lib: Add nexthop-group cliDonald Sharp
Add a nexthop-group cli: nexthop-group NAME nexthop A nexthop B nexthop C ! This will allow interested parties to hook into the cli for nexthops. Users can add callback functions for add/delete of a nexthop group as well as add/delete of each individual nexthop. Future work( PBR and static routes ) will take advantage of this. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-09lib, vtysh: Start cli for nexthop-groupDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-03-09lib: Isolate nexthop_group functions to nexthop_group.cDonald Sharp
Also modify `struct route_entry` to use nexthop_groups. Move ALL_NEXTHOPS loop to nexthop_group.h Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>