Christian Hopps [Wed, 2 Jun 2021 22:32:37 +0000 (22:32 +0000)]
tests: timing large config operations
To start we use 10k static route config. This test goes along with
recent batching changes it will fail w/o them (b/c some operations w/o
batching take 100 times as long).
This test should be added to over time for other large config
items (e.g., acl, policy, etc)
Donald Sharp [Mon, 7 Jun 2021 13:39:10 +0000 (09:39 -0400)]
bgpd: Convert to using peer_established(peer) function
We are inconsistently using peer_establiahed(peer) with
sometimes using `peer->status == Established`. Just Convert
over to using the function for consistency.
Rafael Zalamena [Mon, 7 Jun 2021 14:02:16 +0000 (11:02 -0300)]
lib: fix address sanitizer crash on `find`
Fix the following address sanitizer crash when running the command `find`:
ERROR: AddressSanitizer: dynamic-stack-buffer-overflow
WRITE of size 1 at 0x7fff4840fc1d thread T0
0 in print_cmd ../lib/command.c:1541
1 in cmd_find_cmds ../lib/command.c:2364
2 in find ../vtysh/vtysh.c:3732
3 in cmd_execute_command_real ../lib/command.c:995
4 in cmd_execute_command ../lib/command.c:1055
5 in cmd_execute ../lib/command.c:1219
6 in vtysh_execute_func ../vtysh/vtysh.c:486
7 in vtysh_execute ../vtysh/vtysh.c:671
8 in main ../vtysh/vtysh_main.c:721
9 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
10 in _start (/usr/bin/vtysh+0x21f64d)
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Donald Sharp [Sat, 5 Jun 2021 16:57:55 +0000 (12:57 -0400)]
bgpd: bgp_vrf has already been derefed in all paths
Coverity scan found this issue. The bgp_vrf variable in
ensure_vrf_tovpn_sid() has already been derefed in all paths
at this point in time. No need to check for it existing
at this point.
Igor Ryzhov [Wed, 2 Jun 2021 14:27:02 +0000 (17:27 +0300)]
zebra: fix config after exit from vrf
When the VRF node is exited using "exit" or "quit", there's still a VRF
pointer stored in the vty context. If you try to configure some router
related command, it will be applied to the previous VRF instead of the
default VRF. For example:
```
(config)# vrf test
(config-vrf)# ip router-id 1.1.1.1
(config-vrf)# do show run
...
!
vrf test
ip router-id 1.1.1.1
exit-vrf
!
...
(config-vrf)# exit
(config)# ip router-id 2.2.2.2
(config)# do show run
...
!
vrf test
ip router-id 2.2.2.2
exit-vrf
!
...
```
`vrf-exit` works correctly, because it stores a pointer to the default
VRF into the vty context (but weirdly keeping the VRF_NODE instead of
changing it to CONFIG_NODE).
Instead of relying on the behavior of exit function, always use the
default VRF when in CONFIG_NODE.
Another problem is missing `VTY_CHECK_CONTEXT`. If someone deletes the
VRF in which node the user enters the command, then zebra applies the
command to the default VRF instead of throwing an error.
similarly to what was done for IS-IS in commit 01d43141, combine
the SRGB and SRLB commands for OSPF-SR, so that we can replace
overlapping ranges in one sweep change.
Also allow the range configuration to be stored before SR is enabled.
There is no reason why we should not - in fact that constraint meant
that we were always requesting the default label ranges regardless
of what we actually wanted to use.
Finally, update the topotests now that we do not need to refresh
the SRGB/SRLB/MSD after disabling SR. Note that the prefix-sid still
needs to be re-added.
Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
Igor Ryzhov [Tue, 1 Jun 2021 17:30:13 +0000 (20:30 +0300)]
bfdd: fix bfd key structure
There's a padding byte between "mhop" and "peer" fields in this structure.
This structure is sometimes passed by value to functions and used in
assignments. The standard doesn't guarantee that the padding bytes are
copied on assignments. As this structure is used as a hash key, having
this padding byte with unspecified value can lead to unwanted behavior.
Fix the possible issue by making the "mhop" field to be 2 bytes. Also
make the struct packed as a precaution for future changes.
As this comment says. ZEBRA_FLAG_XXX should not have been used.
To communicate SRv6 Route Information. A simple Nexthop Flag would
have been sufficient for SRv6 information. And I fixed the whole
thing that way.
[note]
If both of them have more complex extensions in the future,
I think it will be less confusing to remove the integration
of these functions and make them as separate functions as
before.
Hiroki Shirokura [Sat, 19 Dec 2020 01:14:08 +0000 (10:14 +0900)]
bgpd: cli for checking srv6 information (step4)
This commit add cli to check bgp's srv6 status
which is srv6-locator name and its locator-chunks
for bgpd. And this command also can be used to
check tovpn_sid for each bgp instances.
Hiroki Shirokura [Sat, 19 Dec 2020 02:04:40 +0000 (11:04 +0900)]
bgpd: cli for SRv6 SID alloc to redirect to vrf (step4)
This commit add cil to configure BGP SRv6-VPN sid allocation.
Almost mechanism are based on BGP MPLS-VPN.
User can allocate and export sid with using following config.
Then bgpd try to allocate new SID to redirect vpn to vrf using
SRv6 localsid End.DT4/DT6. Currently linux kernel will regect
End.DT4 route install due to no-implementation.
(at-least today's FRR's ci kernel.)
Hiroki Shirokura [Sat, 19 Dec 2020 01:50:18 +0000 (10:50 +0900)]
bgpd: cli for srv6-locator assignment (step4)
This commit add command to speficy SRv6 locator for BGP SRv6-VPN.
CLI example is follow. CLI block of "segment-routing" is already
implemented by previous commits and it's managed by zebra.
Zebra manage just the ownership of locator's prefix.
Zlient can request to get srv6-locator's prefix chunk using
srv6_manager_get_locator_chunk() which is usuful func to
execute ZEBRA_SRV6_MANAGER_GET_LOCATOR_CHUNK api. This request
is wokring as async, And zebra calls same api to Zclients when
zebra allocate locator prefix chunk.
And then, finally zclient(bgpd) catch the information via
process_srv6_lcoator_chunk callback function.
Hiroki Shirokura [Sat, 19 Dec 2020 08:45:26 +0000 (17:45 +0900)]
bgpd: add srv6 vpn base code (step4)
This commit add base-lines for BGP SRv6 VPN support.
srv6_locator_chunks property of struct bgp is used
to store BGPd's own SRv6 locator chunk getting with
ZEBRA_SRV6_MANAGER_GET_LOCATOR_CHUNK api.
And srv6_functions is used to store BGP's srv6
localsids. It's mainly used when new SID reservation
from locator chunks.
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
base
Hiroki Shirokura [Sat, 19 Dec 2020 01:42:44 +0000 (10:42 +0900)]
bgpd: implement nb-func to im/ex-port vrf-rib to vpn-rib (step4)
This commit implement the contents of following 2 functions.
- bgp_global_afi_safis_afi_safi_ipv6_unicast_vpn_config_import_vpn_modify
- bgp_global_afi_safis_afi_safi_ipv6_unicast_vpn_config_export_vpn_modify
This implementation is based on already implemented function for ipv4.
Hiroki Shirokura [Sat, 19 Dec 2020 00:28:38 +0000 (09:28 +0900)]
lib: add usual func to install SRv6 localsid (step4)
This commit add usuful function to configure SRv6 localsid
which is represented with seg6local lwt route.
Now, it can support only NEXTHOP_TYPE_IFINDEX route.
Actual configurationof SRv6 localsid is performed with
ZEBRA_ROUTE_ADD. So this is just a wrapper function
for route-install.
Hiroki Shirokura [Fri, 18 Dec 2020 23:47:11 +0000 (08:47 +0900)]
*: new cli-nodes for BGP SRv6 VPNv4 (step4)
This commit add just CLI-nodes for MP-BGP VPN configuration
with SRv6 backend rather than MPLS. Actual configuration cli
will be implemented after this commit.
Example Configuration follow.
This cli design is based on Cisco IOS-XR but actual cli
tree design is defferent between FRR and Cisco.
It's just based on cisco.
Hiroki Shirokura [Thu, 24 Dec 2020 04:07:39 +0000 (04:07 +0000)]
bgpd: fix prefix-sid crash bug and add topotest (step4)
This commit fix bgpd's prefix-sid type4,5 feature which has
miss implementation from https://github.com/FRRouting/frr/pull/5653
was merged. Due to some nessesary lines are not presented.
When bgpd receives multi update message with same service-sid on
prefix-sid type-5 attribute, bgpd will crash arround path-attribute's
values object reference count.
And also, this commit add a topotest to check that feature work fine.
With this patch, zclient can intall seg6 rotues when
they set properties "nh_seg6_segs" on struct nexthop
and set ZEBRA_FLAG_SEG6_ROUTE on zapi_route's flag.
Hiroki Shirokura [Thu, 17 Dec 2020 13:45:58 +0000 (22:45 +0900)]
lib: add new nexthop's attributes seg6 (step3)
This commit add new nexthop's addional object for SRv6
routing about seg6 route. Before this commit,
we can add MPLS info as additional object on nexthop.
This commit make it add more support about seg6 routes.
seg6 routes are ones of the LWT routing mechanism,
so configuration of seg6local routes is performed by
ZEBRA_ROUTE_SEND, it's same as MPLS configuration.
Real configuration implementation isn't implemented at
this commit. later commit add that. This commit add
only nexthop additional object and some misc functions.
Hiroki Shirokura [Sun, 23 Feb 2020 05:37:24 +0000 (05:37 +0000)]
topotests: keep srv6-locator feature fine (step2)
This commit is a part of #5853 works.
This commit add new topotest to verify SRv6-manager's functionality.
Following tests are performed on this topotest.
- check that SRv6-locator is set correctly
- check that default SRv6-function locator is set correctly
- check that SRv6-function is installed as ipv6 route correctly
zebra: ZAPI add new api to manipulate srv6-locator (step2)
This commit is a part of #5853 works that add new ZAPI to
configure SRv6 locator which manages chunk prefix for
SRv6 SID IPv6 address for each routing protocol daemons.
Zclient can connect to zebra's srv6-manager with
ZEBRA_SRV6_MANAGER_CONNECT api like a label-manager.
Then zclient uses ZEBRA_SRV6_MANAGER_GET_LOCATOR_CHUNK to
allocated dedicated locator chunk for it's routing protocol.
Zebra works for only prefix reservation and distribute
the ownership of the locator chunks for zcliens.
Then, zclient installs SRv6 function with
ZEBRA_ROUTE_ADD api with nh_seg6local_* fields.
This feature is already implemented by another PR(#7680).
Hiroki Shirokura [Sun, 23 Feb 2020 11:27:15 +0000 (11:27 +0000)]
lib: add new structures for srv6-locator (step2)
This commit is a part of #5853 works that add new structures for
SRv6-locator. This structure will be used by zebra and another
routing daemon and its ZAPI messaging to manage SRv6-locator.
Encoder/decoder for ZAPI stream is also added by this commit.
Real configuration mechanism isn't implemented at this commit.
later commit add real configure implementation. This commit add only
SRv6-locator's structures and misc functions.
This commit is a part of #5853 that add new cmd-node for SRv6 configuration.
This commit just add cmd-node and moving node cli only, acutual SRv6 config
command isn't added. (that is added later commit. of this branch)
new cli nodes:
* SRv6
* SRv6-locators
* SRv6-locator
topotests: for zapi's seg6local route configuration (step1)
This commit checks seg6local route configuration via ZAPI is
working fine.
SRv6 feature is little young feature as kernel feature so netlink
interface may be changed/updated in the future. And this ZAPI extention
is something to support new routing paradigm, so it should be checked by
topotests until srv6 feature of linux kernel will be well stable.
In this patch, we can install seg6local routes from shapd cli. New sub
command "sharp install route $PREFIX nexthop-seg6local" is added to
install seg6local routes via ZEBRA_ROUTE_ADD. This is for the behaviour
test(topotest) to ensure SRv6 ZAPI is working fine.
SRv6 routes are installed as NEXTHOP_IFINDEX routes because of seg6local
specification. seg6local routes depends the output device status instead
of routing-nexthop.
FYI:
In seg6local implementation, kernel don't care RTA_OIF on the nexthop
deeply but some requirement are exist as follow.
(a) DEV isn't loopback interface
(b) DEV's ipv6 status is enabled
(c) DEV's enslaving status is the same with target-route
sharpd: install_routes_helper support ZAPI_ROUTE flags (step1)
current route addition mechanism on shaprd support only ipv4/v6 nexthop
routes simply. so It doesn't need to ensure flags of zapi_routes.
Then when we want to configure more complicated routing feature (like a
srv6), we will want to control flags of zapi_route. In this patch, it
will supports to configure flags of zapi_route when sharpd calls
ZEBRA_ROUTE_ADD.
Hiroki Shirokura [Fri, 18 Dec 2020 13:39:25 +0000 (22:39 +0900)]
zebra: parse non-zebra seg6local configuration via netlink (step1)
FRRouting operator can install seg6local route via ZAPI,
But linux kernel operator also can install seg6local route
via Netlink directry (i.e. iproute2)
This commit make zebra to parse non-frr seg6local
route configuration via netlink and audit Zebra's RIB.
With this patch, zclient can intall seg6local rotues whem
they set properties nh_seg6local_{action,ctx} on struct nexthop
and set ZEBRA_FLAG_SEG6LOCAL_ROUTE on zapi_route's flag.
Hiroki Shirokura [Wed, 19 Aug 2020 00:46:33 +0000 (09:46 +0900)]
lib: add new nexthop's attributes seg6local (step1)
This commit is a part of #5853 works that add new nexthop's addional
object for SRv6 routing about seg6local route. Before this commit,
we can add MPLS info as additional object on nexthop.
This commit make it add more support about seg6local routes.
seg6local routes are ones of the LWT routing mechanism,
so configuration of seg6local routes is performed by
ZEBRA_ROUTE_SEND, it's same as MPLS configuration.
Real configuration implementation isn't implemented at this commit.
later commit add that. This commit add only nexthop additional object
and some misc functions.
Make seg6local_context2str function's prototype better.
This function is added on commit e496b4203, and function
interface's considering wasn't enough.
Christian Hopps [Fri, 28 May 2021 19:16:18 +0000 (19:16 +0000)]
northbound: KISS always batch yang config (file read), it's faster
The backoff code assumed that yang operations always completed quickly.
It checked for > 100 YANG modeled commands happening in under 1 second
to enable batching. If 100 yang modeled commands always take longer than
1 second batching is never enabled. This is the exact opposite of what
we want to happen since batching speeds the operations up.
Here are the results for libyang2 code without and with batching.
(IPv6 numbers are basically the same as iPv4, a couple percent slower)
Clearly we need this. Please note the growth (1K to 2K) w/o batching is
non-linear and 100 times slower than batched.
Notes on code: The use of the new `nb_cli_apply_changes_clear_pending`
is to commit any pending changes (including the current one). This is
done when the code would not correctly handle a single diff that
included the current changes with possible following changes. For
example, a "no" command followed by a new value to replace it would be
merged into a change, and the code would not deal well with that. A good
example of this is BGP neighbor peer-group changing. The other use is
after entering a router level (e.g., "router bgp") where the follow-on
command handlers expect that router object to now exists. The code
eventually needs to be cleaned up to not fail in these cases, but that
is for future NB cleanup.