Commit Graph

30591 Commits

Author SHA1 Message Date
Donald Sharp
ef03888333 zebra: Convert time to uint64_t for zclient data structures
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-24 08:29:50 -04:00
Donald Sharp
bce18b18fe pimd: Intentionally downcast to a uint32_t value
When calling time(NULL), FRR is intentionally throwing
away the upper 32 bits of value returned.  Let's explicitly
call it out so that coverity understands this is intentional
and ok.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-24 08:28:51 -04:00
Donald Sharp
98b7e9754c bgpd: Replace rfapi_time() with monotime()
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-24 08:28:51 -04:00
Donald Sharp
083ec940ab bgpd: Convert from bgp_clock() to monotime()
Let's convert to our actual library call instead
of using yet another abstraction that makes it fun
for people to switch daemons.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-24 08:23:40 -04:00
Carmine Scarpitta
877682e328 sharpd: Fix memory leaks related to SRv6 nexthops
Running the `zebra_seg6local_route` topotest with `--valgrind-memleaks`
gives several memory leak errors. This is due to the way SRv6 routes
(seg6 and seg6local routes) are handled: when the user executes the CLI
command `sharp install seg6-routes` or `sharp install seg6local-routes`
to create a seg6 or seg6local route, sharpd calls
`nexthop_add_srv6_seg6` or `nexthop_add_srv6_seg6local` to create an
SRv6 nexthop. A pointer to the SRv6 nexthop is stored in the global data
structure `sg.r.nhop`. If you call `sharp install routes`,
`sharp install seg6-routes` or `sharp install seg6local-routes` to create
more routes, `sg.r.nhop` is set to zero and the
pointer to the SRv6 nexthop contained in `sg.r.nhop` is definitely lost
and the allocated memory is never freed.

This patch adds calls to `nexthop_del_srv6_seg6()` and
`nexthop_del_srv6_seg6local()` to free the memory allocated for the SRv6
nexthop before clearing the `sg.r.nhop` data structure.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-08-24 14:22:04 +02:00
Carmine Scarpitta
6dece5ac29 sharpd: Fix memory leak in release-locator-chunk
Running the `zebra_seg6local_route` topotest with `--valgrind-memleaks`
gives several memory leak errors. This is due to the way SRv6 chunks are
released: when the user executes the CLI command
`sharp srv6-manager release-locator-chunk` to release the chunks of an
SRv6 locator, the `list_delete()` function is called to delete the
chunks list (`loc->chunks`), but the memory allocated for the chunks is
not freed.

This patch defines a new callback `sharp_srv6_locator_chunk_free()`.
This callback takes care of freeing the memory allocated for a given
chunk. When `list_delete()` is called to remove the chunk list
`loc->chunks`, it automatically calls `sharp_srv6_locator_chunk_free()`
on each element of the list to free the allocated memory before
deleting the list.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-08-24 14:22:04 +02:00
Carmine Scarpitta
a0c47583a4 sharpd: Fix memory leak in release-locator-chunk
Running the `zebra_seg6local_route` topotest with `--valgrind-memleaks`
gives several memory leak errors. This is due to the way SRv6 chunks are
released: when the user executes the CLI command
`sharp srv6-manager release-locator-chunk` to release the chunks of an
SRv6 locator, all the chunks are removed from the list `loc->chunks`.
Also, the locator is removed from the SRv6 locators list
`sg.srv6_locators`, but the memory allocated for the locator is not
freed.

This patch adds a call to `XFREE()` to properly free the allocated
memory when all the chunks of an SRv6 locator are removed and the
locator is removed as well.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-08-24 14:22:04 +02:00
Carmine Scarpitta
f8e9c702a1 bgpd: Fix memory leak in SRv6 locator delete
Running `bgp_srv6l3vpn_to_bgp_vrf` and `bgp_srv6l3vpn_to_bgp_vrf2`
topotests with `--valgrind-memleaks` gives several memory leak errors.
This is due to the way SRv6 locators are removed/unset in bgpd: when
an SRv6 locator is deleted or unset, the memory allocated for the
locator prefix (`tovpn_sid_locator`) is not freed.

This patch adds a `for` loop that iterates over the list of BGP
instances. For each BGP instance using the SRv6 locator to be
removed/unset, we use `XFREE()` to properly free the memory allocated
for `tovpn_sid_locator` after the SRv6 locator is removed or unset.

The memory allocated for `tovpn_sid_locator` cannot be freed before
calling `vpn_leak_postchange_all()`. This is because
after deleting an SRv6 locator, we call `vpn_leak_postchange_all()`
to handle the SRv6 locator deletion and send a BGP Prefix SID withdraw
message. `tovpn_sid_locator` is required to properly build the BGP
Prefix SID withdraw message. After calling `vpn_leak_postchange_all()`
we can safely remove the `tovpn_sid_locator` and free the allocated
memory.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-08-24 14:22:04 +02:00
Donald Sharp
1a6c318d64 gdb: Add a macro to walk memory allocations
Add a macro to walk all memory allocations in a core file.

load the file in gdb:
source /path/to/frr/gdb/lib.txt
mg_walk mg_first
(gdb) mq_walk mg_first
showing active allocations in memory group libfrr
memstats: BFD info:0
memstats: Buffer:5
memstats: Buffer data:0
memstats: Host config:6
memstats: Completion item:0
memstats: Command Tokens:2585
memstats: Command Token Text:1951
memstats: Command Token Help:1951
memstats: Command Argument:0
memstats: Command Argument Name:575
memstats: Command Match Stack:0
memstats: Lexer token (temporary):0
memstats: Path Computation Algorithms:0
memstats: Distribute ctx:0
memstats: Distribute list:0
memstats: Dist-list ifname:0
memstats: Dist-list name:0
memstats: error information:0
memstats: Access List:0
memstats: Access List Str:0
memstats: Access Filter:0
memstats: RCU thread:0
<snip>

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-24 07:13:29 -04:00
Donatas Abraitis
9e7103f6b7
Merge pull request #11848 from rgirada/ospf_gr_nbr
ospfd: Adding per neighbour json details to GR helper detail command
2022-08-24 12:39:13 +03:00
Carmine Scarpitta
bda15542f4 bgpd: Fix memory leak when an SRv6 SID is removed
Running `bgp_srv6l3vpn_to_bgp_vrf` and `bgp_srv6l3vpn_to_bgp_vrf2`
topotests with `--valgrind-memleaks` gives several memory leak errors.
This is due to the way SRv6 SIDs are removed in bgpd: when
an SRv6 locator is deleted/unset, all the SIDs allocated from that
locator are removed from the SRv6 functions list
(`bgp->srv6_functions`),but the memory allocated for the SIDs is not
freed.

This patch adds a call to `XFREE()` to properly free the allocated
memory when an SRv6 SID is removed.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-08-24 08:56:46 +02:00
Carmine Scarpitta
03852f673b bgpd: Fix memory leak in SRv6 locator delete/unset
Running `bgp_srv6l3vpn_to_bgp_vrf` and `bgp_srv6l3vpn_to_bgp_vrf2`
topotests with `--valgrind-memleaks` gives several memory leak errors.
This is due to the way SRv6 locators are deleted/unset in bgpd: when
an SRv6 locator is deleted/unset, all the chunks of the locator are
removed from the SRv6 locator chunks list (`bgp->srv6_locator_chunks`).
However, the memory allocated for the chunks is not freed.

This patch adds a call to the `srv6_locator_chunk_free()` function to
properly free the allocated memory when an SRv6 locator is removed or
unset.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-08-24 08:53:08 +02:00
Carmine Scarpitta
d0c775e3eb lib: Fix memory leak in zclient_send_localsid()
Running `bgp_srv6l3vpn_to_bgp_vrf` and `bgp_srv6l3vpn_to_bgp_vrf2`
topotests with `--valgrind-memleaks` gives several memory leak errors.
This is due to the way FRR daemons pass local SIDs to zebra: to send a
local SID to zebra, FRR daemons call the `zclient_send_localsid()`
function.

The `zclient_send_localsid()` function performs the following sequence
of operations:
* create a temporary `struct nexthop`;
* call `nexthop_add_srv6_seg6local()` to fill the `struct nexthop` with
the proper local SID information;
* create a `struct zapi_route` and call `zapi_nexthop_from_nexthop()` to
copy the information from the `struct nexthop` to the
`struct zapi_route`;
* send the `struct zapi_route` to zebra through the ZAPI.

The `nexthop_add_srv6_seg6local()` function uses `XCALLOC()` to allocate
memory for the SRv6 nexthop. This memory is never freed.

Creating a temporary `struct nexthop` is unnecessary, as the local SID
information can be pushed directly to the `struct zapi_route`. This
patch simplifies the implementation of `zclient_send_localsid()` by
avoiding using the temporary `struct nexthop`. This eliminates the need
to use `nexthop_add_srv6_seg6local()` to fill the `struct nexthop` and
consequently fixes the memory leak.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-08-24 08:41:45 +02:00
Carmine Scarpitta
0a58467251 zebra: Fix memory leak in SRv6 locator delete
Running `srv6_locator` topotest with `--valgrind-memleaks` gives several
memory leak errors. This is due to the way SRv6 locators are deleted:
when an SRv6 locator is deleted, it is removed from the SRv6 locators
list (`srv6->locators`), but the memory allocated for the SRv6 locator
is not freed.

This patch adds a call to the `srv6_locator_free()` function to properly
free the allocated memory when an SRv6 locator is removed.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-08-24 08:38:22 +02:00
Donatas Abraitis
e02865fe34
Merge pull request #11853 from sri-mohan1/sri-ospf-dbg1
ospfd: changes for code maintainability
2022-08-24 09:19:51 +03:00
Donatas Abraitis
ff8f74b68e doc: Define internet BGP community
Overall, rfc1997 states:

The community attribute values ranging from 0x0000000 through
   0x0000FFFF and 0xFFFF0000 through 0xFFFFFFFF are hereby reserved.

But we have a special handling here, like Cisco IOS XR.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-08-24 08:59:25 +03:00
Donatas Abraitis
b6dbdee5ad Revert "bgpd: Drop internet community check from community_list_match()"
Seems that, `internet` community is used to match ANY community.

This reverts commit e605d0cfae.
2022-08-24 08:46:56 +03:00
Donatas Abraitis
e317aea23f Revert "tests: Check if BGP community-list filtering works correctly"
This reverts commit b087842814.
2022-08-24 08:46:47 +03:00
rgirada
7b71c1e3f7 ospfd: Adding per neighbour json details to GR helper detail command
Description:
	Per neighbor GR enabled information is  missing from json
	output in "show ip ospf gr helper details json" command.

      Example config:

	frr(config-router)# graceful-restart helper enable 2.2.2.2
	frr(config-router)#
	frr(config-router)# do show ip ospf  graceful-restart helper  detail

       OSPF Router with ID (10.112.156.220)

	Graceful restart helper support disabled.
	Strict LSA check is enabled.
	Helper supported for Planned and Unplanned Restarts.
	Supported Graceful restart interval: 1800(in seconds).
	Enable Router list:
		2.2.2.2,

	frr(config-router)# do show ip ospf  graceful-restart helper  detail json
	{
	 "routerId":"10.112.156.220",
	 "helperSupport":"Disabled",
	 "strictLsaCheck":"Enabled",
	 "restartSupoort":"Planned and Unplanned Restarts",
	 "supportedGracePeriod":1800,
	}
	frr(config-router)#

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2022-08-23 21:15:12 -07:00
sri-mohan1
921b959602 ospfd: changes for code maintainability
these changes are for improving the code maintainability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2022-08-23 22:18:33 +05:30
Stephen Worley
a5d7012ca0 bgpd: use DEFPY for new vrf rt auto commands
Switch to using DEFPY for new vrf rt auto commands.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-08-23 12:41:25 -04:00
Stephen Worley
5ad4fc6ce9 lib: use evpn type enum for prefix conversion
Use the evpn type enum for the evpn_prefix2prefix conversion.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-08-23 12:41:25 -04:00
Stephen Worley
133c000cc2 doc: fix typo in route-target
Fix small typo in route-target doc.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-08-23 12:41:25 -04:00
Stephen Worley
a33b4d3f4c lib: handle type2/5 routes in optimized route-map
Handle matching type2/5 evpn routes via lookup in the optimized
route-maps used by plists.

Convert the evpn_prefix to ipv4/v6 prefix to perform longest
matching on in the tree.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-08-23 12:41:25 -04:00
Stephen Worley
0f33e6dfca doc: add doc for EVPN L3 Route-Targets
Add doc for EVPN L3 Route-Targets.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-08-23 12:41:25 -04:00
Stephen Worley
6eb8350586 bgpd,lib: route-map/plist matching via type-2/5 routes
Implement the ability to match type-2 and type-5 routes
via a route-map and a prefix-list.

Add some library code to convert an evpn prefix into
a general ipv4/ipv6 prefix for type-2 and type-5 routes.
evpn prefix is really just another subtype of prefix so all
the info needed can be extracted right there.

Add a special handler to bgp_routemap for evpn type routes
when applying the outbound route-map. This calls the library
code to convert the evpn_prefix to a ipv4/ipv6 prefix and
run it through the plist code. In this we assume type-2 routes
are a /32.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-08-23 12:41:25 -04:00
Stephen Worley
24df337988 bgpd: add route-map to no advertise ipvX * cmd
Add route-map as a possible word for the `no` form
of `advertise ipvX *** [route-map WORD] cmd.

Before this patch the cmd was only accepted if `no` form
was given without route-map WORD. So if you just copypaste
the original version of the cmd, it would fail.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-08-23 12:41:25 -04:00
Stephen Worley
58d8948cf4 bgpd: evpn L3 RT auto config and wildcard implementation
Implement forcing L3 auto derivation via configs even when
manually RTs are set. This will allow both to coexist in
BGP RTs. Without using auto config command, it will remove
auto derived RTs when you manually configure your own. To allow
both, use the auto command ond import/export/both.

Implement '*' wildcard import L3 RTs so we can import a route into any AS.
This is necessary to avoid a user from having to configure an L3 RT for
every AS they care to import evpn route from.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-08-23 12:41:25 -04:00
Stephen Worley
ca337b4641 bgpd: abstract ecom into struct for l3 route targets
Abstract the ecommunity into a container struct for L3
route targets so that we can add some additional info
via flags to go along with RT configs without modifying
the used elsewhere ecommunity struct. This functions as a
wrapper everywhere its used including the import/export lists.
The flags will be used in later commits to change behavior
when importing/exporting routes.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-08-23 12:41:25 -04:00
Russ White
c143b87519
Merge pull request #11851 from sri-mohan1/sri-ospf-dbg1
ospfd: changes for code maintainability
2022-08-23 11:07:29 -04:00
Russ White
abeb15e9cf
Merge pull request #11820 from opensourcerouting/fix/clist_match
bgpd: Fix community-list handling
2022-08-23 11:06:15 -04:00
Philippe Guibert
04931fa90a
Merge pull request #11836 from ak503/nhrp_nbma
nhrpd: Use nhrp_interface_update_nbma when source vrf was changed
2022-08-23 17:06:02 +02:00
Russ White
37f88e58bf
Merge pull request #11840 from xdxu/master
ospf6d: Don't remove summary route if it is a range
2022-08-23 10:58:57 -04:00
Russ White
7a15a3d2fc
Merge pull request #11842 from opensourcerouting/fix/topotests_platform_check
tests: Log as error if some of the daemons are missing
2022-08-23 10:58:01 -04:00
Russ White
f3b1f6fe59
Merge pull request #11843 from ARShreenidhi/ecmp_testcase
tests : bgp-default-originate ecmp scenerio is added
2022-08-23 10:57:13 -04:00
sri-mohan1
f96ec6a674 ospfd: changes for code maintainability
these changes are for improving the code maintainability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2022-08-23 16:50:54 +05:30
Mobashshera Rasool
e23b5d868a pim6d: mroute stuck in register state, multicast traffic getting drops
IPv4 and IPv6 behaves a little bit differently with the socket
options.
IPPROTO_RAW socket option is only for IPv4.
Therefore the register packet was not properly getting encapculated
for PIMv6 and was working fine for PIMv4.

So have used IPPROTO_PIM for PIMv6.

Fixes: #11846

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2022-08-23 00:09:20 -07:00
mobash-rasool
c480bc4358
Merge pull request #11847 from sri-mohan1/sri-ospf-dbg1
ospfd: changes for code maintainability
2022-08-23 10:27:13 +05:30
Stephen Worley
7022da35c2 bgpd: evpn L3 RTs list config and auto boilerplate
Add functionality to allow EVPN L3 RTs to be configured via
a list rather than one at a time.

Also add boilerplate config for forcing auto derivation of RTs
via config.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-08-22 14:10:37 -04:00
sri-mohan1
2944807553 ospfd: changes for code maintainability
these changes are for improving the code maintainability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2022-08-22 23:16:28 +05:30
Donald Sharp
d69d7a615a
Merge pull request #11845 from sri-mohan1/sri-ospf-dbg1
ospfd: changes for code maintainability
2022-08-22 12:46:49 -04:00
Dmitrii Turlupov
8d1d3fdf7b nhrpd: Use nhrp_interface_update_nbma when source vrf was changed
1. Run frr:
interface enp0s8
 ip address 193.168.1.2/24
exit
!
interface gre1
 ip address 10.8.1.2/32
 ip nhrp network-id 1
 ip nhrp nhs dynamic nbma 193.168.1.1
 tunnel source enp0s8
exit

Log:

NHS: Register 10.8.1.2 -> 10.8.1.2 (timeout 2)
Send Registration-Request(3) 10.8.1.2 -> 10.8.1.2
Recv Registration-Reply(4) 10.8.1.1 -> 10.8.1.2

2. Create VRF and move enp0s8 to VRF
 ip link set enp0s8 master vrf1

Before patch:
NHS: Waiting link for 193.168.1.1

After patch:
NHS: Register 10.8.1.2 -> 10.8.1.2 (timeout 2)

Signed-off-by: Dmitrii Turlupov <dturlupov@factor-ts.ru>
2022-08-22 15:54:18 +03:00
sri-mohan1
0faaabfb0b ospfd: changes for code maintainability
these changes are for improving the code maintainability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2022-08-22 18:23:04 +05:30
Donatas Abraitis
8475465d98
Merge pull request #11841 from sri-mohan1/sri-ospf-dbg1
ospfd: changes for code maintainability
2022-08-22 13:11:51 +03:00
sri-mohan1
4adc415e99 ospfd: changes for code maintainability
these changes are for improving the code maintainability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2022-08-22 12:48:35 +05:30
ARShreenidhi
2620f3f1bb tests : bgp-default-originate ecmp scenerio is added
Signed-off-by: ARShreenidhi <rshreenidhi@vmware.com>
2022-08-22 05:03:26 +00:00
Donatas Abraitis
e40b713015 tests: Log as error if some of the daemons are missing
Also print runtime directory for topotests if the error occurs.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-08-20 21:45:06 +03:00
Donatas Abraitis
01da2d2691 bgpd: Add neighbor soo command
BGP SoO is a tag that is appended on BGP updates to allow a peer to mark
a particular peer as belonging to a particular site. In certain MPLS L3 VPN
configurations, the BGP AS-Path may not provide the granularity needed
prevent a loop in the control-plane. With this in mind, BGP SoO is designed
to fill this gap and prevent a routing loop that may occur.

If we configure for example, `neighbor soo 65000:1` at PEs, routes won't be
announced between CPEs if soo matches. This is especially needed when using
as-override or allowas-in.

Also, this is the automated way of the same behavior as configuring route-maps
for each peer like:

```
bgp extcommunity-list cpe permit soo 65000:1
!
route-map cpe permit 10
 set extcommunity soo 65000:1
...
route-map cpe deny 10
 match extcommunity cpe
route-map cpe permit 20
...
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-08-20 21:22:45 +03:00
Donatas Abraitis
ed2c427f83
Merge pull request #11835 from crosser/fix-lua-build
debian: add lua _binary_ to build dependencies
2022-08-20 16:45:28 +03:00
Xiaodong Xu
4ef96a7015 ospf6d: Don't remove summary route if it is a range
Fix issue #11839.

When the user defines a range in an area other than the backbone area, the
summary route will be announced to the backbone area as an inter-area LSA.
However, if the prefix defined in the range is the same prefix as a connected
route in that area, the LSA won't be announced to the backbone area.

This is because when ospf6d is originating the summary route for the
intra-area route, it finds the range configured by the user and tries to
suppress the route by deleting the existing summary route, which happens to be
the one created by the range.

Although the range definition is not necessary in this case, it should not
fail this use case. So let's just keep the summary route there if it is
created from the user defined range.

Signed-off-by: Xiaodong Xu <stid.smth@gmail.com>
2022-08-19 23:26:06 -07:00