summaryrefslogtreecommitdiff
path: root/lib/nexthop_group.c
AgeCommit message (Collapse)Author
2022-06-21*: Replace sockunion2str => %pSUDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2021-11-18*: Remove unused variablesDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-18lib: Replace inet_ntop to %pI4/6 for JSON outputsDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-10-15lib: remove wrong setting of interface configured flagIgor Ryzhov
The fact that the interface name is used in some nexthop config doesn't mean that the interface is configured. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-23*: explicitly print "exit" at the end of every node configIgor Ryzhov
There is a possibility that the same line can be matched as a command in some node and its parent node. In this case, when reading the config, this line is always executed as a command of the child node. For example, with the following config: ``` router ospf network 193.168.0.0/16 area 0 ! mpls ldp discovery hello interval 111 ! ``` Line `mpls ldp` is processed as command `mpls ldp-sync` inside the `router ospf` node. This leads to a complete loss of `mpls ldp` node configuration. To eliminate this issue and all possible similar issues, let's print an explicit "exit" at the end of every node config. This commit also changes indentation for a couple of existing exit commands so that all existing commands are on the same level as their corresponding node-entering commands. Fixes #9206. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-17*: require semicolon after DEFINE_QOBJ & co.David Lamparter
Again, see previous commits. Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17*: require semicolon after DEFINE_MTYPE & coDavid Lamparter
Back when I put this together in 2015, ISO C11 was still reasonably new and we couldn't require it just yet. Without ISO C11, there is no "good" way (only bad hacks) to require a semicolon after a macro that ends with a function definition. And if you added one anyway, you'd get "spurious semicolon" warnings on some compilers... With C11, `_Static_assert()` at the end of a macro will make it so that the semicolon is properly required, consumed, and not warned about. Consistently requiring semicolons after "file-level" macros matches Linux kernel coding style and helps some editors against mis-syntax'ing these macros. Signed-off-by: David Lamparter <equinox@diac24.net>
2020-10-22lib: Convert inet_ntoa to %pI4Donatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-10-02lib: remove nexthop_same_firsthop() apiStephen Worley
Remove the nexthop_same_firsthop() api and just call nexthop_same(). Not entirely sure why we were using this function in the first place, but now we are just marking dupes with it so lets just call a common function and avoid issues. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28Revert "lib,sharpd,pbrd: `set installable` nhg command"Stephen Worley
This reverts commit 1844f45e30913b27cfd875036f865a0edadcf244.
2020-09-28lib,sharpd,pbrd: `set installable` nhg commandStephen Worley
Add a command `set installable` that allows configured nexthop groups to be treated as separate/installable objects in the RIB. A callback needs to be implemented per daemon to handle installing the NHG into the rib via zapi when this command is set. This patch includes the implementation for sharpd. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28lib,doc: add `onlink` flag to nexthop group configStephen Worley
Add an `onlink` flag to nexthop group configuration. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-08-28lib: Note old ifindex on shutdownDonald Sharp
If we have an interface configured in a daemon on shutdown store the old ifindex value for retrieval on when it is possibly recreated. This is especially important for nexthop groups as that we had at one point in time the ability to restore the configuration but it was lost when we started deleting all deleted interfaces. We need the nexthop group subsystem to also mark that it has configured an interface. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-28lib: Allow nexthop simple display to take an alternate ifp nameDonald Sharp
The nexthop_group_write_nexthop_simple function outputs the interface name, because we've stored the ifindex. The problem is that there are ephermeal interfaces in linux that can be destroyed/recreated. Allow us to keep that data and do something a bit smarter to allow show run's and other show commands to continue to work when the interface is deleted. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-27lib: break up show nexthop API a bit for reuseStephen Worley
Not everything cares about the vrf and backup info. Break up the API to add a simple version to just write gateway/interface info. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-08-18lib: fix crash in show nexthop when vrf deletedStephen Worley
Fix a crash where if we issue a show run after a vrf has been deleted we would crash here due to not null checking. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-07-17lib: support multiple backup nexthops in nexthop group cliMark Stapp
Revise the nexthop-group cli to support multiple backups for a single primary nexthop. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-07-17lib,sharpd,zebra: initial support for multiple backup nexthopsMark Stapp
Initial changes to support a nexthop with multiple backups. Lib changes to hold a small array in each primary, zapi message changes to support sending multiple backups, and daemon changes to show commands to support multiple backups. The config input for multiple backup indices is not present here. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-07-01pbrd, lib: remember to free alloc'd qobj on deleteWesley Coakley
Signed-off-by: Wesley Coakley <wcoakley@nvidia.com>
2020-05-27pbrd, lib, doc: fix new `show` json key semanticsWesley Coakley
Revise new `show pbr` keys to be consistent with existing json in other daemons target->nexthop id->tableId (where relevant) isValid->valid isInstalled->installed Signed-off-by: Wesley Coakley <wcoakley@cumulusnetworks.com>
2020-05-27pbrd, lib: verbosity++ for json `show` directivesWesley Coakley
Increased the verbosity of the json keys and flattened the returned structure by removing superfluous keys. Signed-off-by: Wesley Coakley <wcoakley@cumulusnetworks.com>
2020-05-27pbrd, lib: opt. json for `show pbr nexthop-group`Wesley Coakley
Signed-off-by: Wesley Coakley <wcoakley@cumulusnetworks.com>
2020-04-16*: move CLI node names to cmd_node->nameDavid Lamparter
And again for the name. Why on earth would we centralize this, just so people can forget to update it? Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16*: move CLI parent data to cmd_node->parent_nodeDavid Lamparter
Same as before, instead of shoving this into a big central list we can just put the parent node in cmd_node. Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16*: remove second parameter on install_node()David Lamparter
There is really no reason to not put this in the cmd_node. And while we're add it, rename from pointless ".func" to ".config_write". [v2: fix forgotten ldpd config_write] Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16*: remove cmd_node->vtyshDavid Lamparter
The only nodes that have this as 0 don't have a "->func" anyway, so the entire thing is really just pointless. Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16*: clean up cmd_node initializersDavid Lamparter
... and use named assignments everywhere (so I can change the struct.) Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-07lib: support replacement in the nexthop-group cliMark Stapp
Use more limited matching logic so that nexthops within a nexthop-group are unique based only on vrf, type, and gateway. Treat configuration of a nexthop that matches an existing nexthop as a replace operation. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-27lib: support backup nexthops in nexthop-groups and zapiMark Stapp
Add vty support for backup nexthops in nexthop groups. Capture backup nexthop info in zapi route messages. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-27zebra,lib: use const in more apisMark Stapp
Use const with some args to ipaddr, zebra vxlan, mpls lsp, and nexthop apis; add some extra checks to some nexthop-related apis. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-02-25lib: use const in nexthop_group copy apiMark Stapp
Add some const to the nhg copy api. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-01-15Merge pull request #5600 from sworleys/NHG-Depend-CrashMark Stapp
zebra: can't improve efficiency for recursive depends
2020-01-15lib: assert if someone adds to nexthop list to nhgStephen Worley
If someone tries to add a nexthop with a list of nexthops already attached to it, let's just assert. This standardizes the API to say we assume this is an individual nexthop you are appending to a group. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-01-15lib,zebra: tighten up the nexthop_copy/nexthop_dup APIsStephen Worley
Make the nexthop_copy/nexthop_dup APIs more consistent by adding a secondary, non-recursive, version of them. Before, it was inconsistent whether the APIs were expected to copy recursive info or not. Make it clear now that the default is recursive info is copied unless the _no_recurse() version is called. These APIs are not heavily used so it is fine to change them for now. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
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>