Commit Graph

37380 Commits

Author SHA1 Message Date
Enke Chen
cb5e415c2a tests: adjust topotest after bgp_redistribute_add() fix
In ospf_multi_vrf_bgp_route_leak, the admin distance for the
redistributed ospf route should be 110, and should remain as 110 after
it's imported into another vrf, and then downloaded to zebra.

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
2024-09-19 11:57:20 -07:00
Enke Chen
3c433ae558 bgpd: fix misplaced arguments in bgp_redistribute_add()
Fix the misplaced arguments "bhtype" and "api.distance" in
bgp_redistribute_add().

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
2024-09-19 08:52:35 -07:00
Donald Sharp
ccbfb46d28 zebra: Remove nl_addraw_l
This function is never used.  So let's remove it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-19 08:28:48 -04:00
Donatas Abraitis
cc7d3afdd5
Merge pull request #16848 from enkechen-panw/ecomm-val
bgpd: define val in ecommunity_val as uint8_t
2024-09-19 11:33:58 +02:00
Donatas Abraitis
4d18e4a8b3
Merge pull request #16868 from sri-mohan1/srib-24-frr-a
bgpd: changes for code maintainability
2024-09-19 11:33:36 +02:00
Louis Scalbert
6dc83f6a9a yang: use relative path for route-map
f1ea52bee9 ("yang: use relative path instead of absolute one for
route-map") has introduced a route-map optimization but some paths
were not changed.

Use relative path instead absolute one everywhere.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-09-19 11:26:57 +02:00
zhou-run
556a1138af isisd: Fix NHLFE entry memory leaks
Before adding an NHLFE entry, zebra calls nhlfe_nexthop_active_ipv4()/nhlfe_nexthop_active_ipv6() to check if there is a corresponding directly connected route for the next hop prefix of the NHLFE. If such a route exists, it directly overwrites the output interface of the NHLFE's next hop with the output interface of the directly connected route. If the output interface of the directly connected route is different from the output interface of the NHLFE's next hop, deleting the NHLFE entry later will fail because nhlfe_nhop_match() cannot find the same next hop address and output interface, leading to an NHLFE entry leak.

Establishing neighbors in ISIS only requires the existence of the neighbor's IP address and does not need the neighbor's IP address to be in the same subnet as the local IP address. When zebra creates an adjacency label entry, it uses the neighbor's IP address as the next hop. If the neighbor's IP address is not in the same subnet as the local IP address and there is a local directly connected route with the neighbor's IP address prefix, it will result in an issue where the corresponding adjacency label entry in zebra cannot be deleted.

We cannot enforce that ISIS must establish neighbors using IPv4 and IPv6 addresses in the same subnet, but we can ensure that IPv4 or IPv6 addresses in different subnets do not create adjacency labels.

Signed-off-by: zhou-run <zhou.run@h3c.com>
2024-09-19 14:07:35 +08:00
sri-mohan1
8b590cf759 bgpd: changes for code maintainability
these changes are for improving the code maintainability and readability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2024-09-19 09:18:06 +05:30
Jafar Al-Gharaibeh
9a009e1274
Merge pull request #16860 from LabNConsulting/aceelindem/ospf-sr-algo-vulnerability
ospfd: Fix heap corruption vulnerability when parsing SR-Algorithm TLV
2024-09-18 18:55:47 -05:00
Enke Chen
4b138bdd00 bgpd: define val in ecommunity_val as uint8_t
The type of the val field in ecommunity_val is used inconsistently
in a number of places. It should be defined as uint8_t.

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
2024-09-18 12:28:03 -07:00
Mark Stapp
f07579254a
Merge pull request #16857 from donaldsharp/logger_warning
tests: use logger.warning not logger.warn
2024-09-18 14:52:41 -04:00
Acee Lindem
0dc969185f ospfd: Fix heap corruption vulnerability when parsing SR-Algorithm TLV
When parsing the SR-Algorithm TLV in the OSPF Router Information Opaque
LSA, assure that not more than the maximum number of supported
algorithms are copied from the TLV.

Signed-off-by: Acee Lindem <acee@lindem.com>
2024-09-18 18:09:19 +00:00
Jafar Al-Gharaibeh
31c015195d
Merge pull request #16846 from donaldsharp/zebra_evpn_mac_cleanup
Zebra evpn mac cleanup
2024-09-18 13:04:01 -05:00
Mark Stapp
05481607a1 bgpd: cancel events once in peer_free()
Don't need to cancel scheduled events twice in a row - just
once.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2024-09-18 13:38:00 -04:00
Jafar Al-Gharaibeh
5ae0b26220
Merge pull request #16856 from donaldsharp/ospf_vrf_debugs
ospfd: Add vrf name to debug functions in ospf_zebra.c
2024-09-18 11:26:50 -05:00
Donald Sharp
5634307f3a
Merge pull request #16841 from mjstapp/fix_bgp_script
bgpd: remove bgpd.h from bgp script header
2024-09-18 12:00:06 -04:00
Donald Sharp
8b25888ce8
Merge pull request #16816 from opensourcerouting/feature/bgp_dual_as
bgpd: Implement BGP dual-as feature
2024-09-18 11:59:16 -04:00
Donald Sharp
3d3c0e35eb tests: use logger.warning not logger.warn
Apparently logger.warn is being deprecated.  So let's
switch over to logger.warning.  Clearly it's better

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-18 11:56:42 -04:00
Donald Sharp
ffa0fd5c43 bgpd: Fixup crash when leaking from default vrf for mpls vpn's
When we get a update on a route that we already have information on
from another router and that route has been leaked ensure that
we do not crash when trying to releak the code when we may want
to modify the as path.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-18 18:03:10 +03:00
Don Slice
dc4440bdb2 bgpd: copy asn for prefixes imported as type5 from a vrf
When a prefix in a vrf is imported into evpn as a type5,
copy the asn of the source to make sure it is reflected
in the target vrf.

Ticket: cumuluslinux-2554562
Signed-off-by: Don Slice <dslice@nvidia.com>
2024-09-18 18:03:10 +03:00
Don Slice
d4426b62d2 bgpd: copy source vrf ASN to leaked route and block loops
When we leak routes and are using a different ASN in the
source vrf from the target vrf, it's possible we could
create loops because of an incomplete as-path (missing
the source vrf ASN). This fix adds the source vrf ASN and
stops the importing of a BGP prefix that has the target
ASN in the as-path in the source vrf.

Signed-off-by: Don Slice <dslice@nvidia.com>
2024-09-18 18:03:10 +03:00
Don Slice
091abc6b28 bgpd: do not allow override ASN unless hidden or auto-created
While it's okay to allow overwriting the ASN of a bgp vrf/instance
that is either hidden or automatically created, it's dangerous to
allow it on explicitly defined instances.  If that were allowed,
a typo entering the bgp config could take down existing peering,
which would be a bad thing.

Signed-off-by: Don Slice <dslice@nvidia.com>
2024-09-18 18:03:10 +03:00
Don Slice
4d0e7a49cf bgpd: VRF-Lite fix default bgp delete
1. bgp coredump is observed when we delete default bgp instance
   when we have multi-vrf; and route-leaking is enabled between
   default, non-default vrfs.
Removing default router bgp when routes leaked between non-default vrfs.
- Routes are leaked from VRF-A to VRF-B
- VPN table is created with auto RD/RT in default instance.
- Default instance is deleted, we try to unimport the routes from all VRFs
- non-default VRF schedules a work-queue to process deleted routes.
- Meanwhile default bgp instance clears VPN tables and free the route
  entries as well, which are still referenced by non-default VRFs which
  have imported routes.
- When work queue process starts to delete imported route in VRF-A it cores
  as it accesses freed memory.

- Whenever we delete bgp in default vrf, we skip deleting routes in the vpn
  table, import and export lists.
- The default hidden bgp instance will not be listed in any of the show
  commands.
- Whenever we create new default instance, handle it with AS number change
  i.e. old hidden default bgp's AS number is updated and also changing
  local_as for all peers.

2. A default instance is created with ASN of the vrf with the import
  statement.
  This may not be the ASN desired for the default table
- First problem with current behavior.
  Define two vrfs with different ASNs and then add import between.
  starting without any bgp config (no default instance)
  A default instance is created with ASN of the vrf with the import
  statement.
  This may not be the ASN desired for the default table
- Second related problem.  Start with a default instance and a vrf in a
  different ASN. Do an import statement in the vrf for a bgp vrf instance
  not yet defined and it auto-creates that bgp/vrf instance and it inherits
  the ASN of the importing vrf
- Handle bgp instances with different ASNs and handle ASN for auto created
  BGP instance

Signed-off-by: Kantesh Mundaragi <kmundaragi@vmware.com>
2024-09-18 18:03:10 +03:00
Russ White
6109043c54
Merge pull request #16720 from opensourcerouting/fix/default_originate_not_needed_if_not_enabled
bgpd: Do not scan update-groups if default-originate timer is set to 0
2024-09-18 10:11:23 -04:00
Donald Sharp
9f149fabd4 ospfd: Add vrf name to debug functions in ospf_zebra.c
This file had a bunch of debugs that were operating on
specific vrf's but not telling you which vrf this was
happening in.  Add code to allow operator debugging
to understand what vrf is being worked on.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-18 09:52:49 -04:00
Donald Sharp
1af0a67401 zebra: In zebra_evpn_mac.c remove bad comments
Adding comments that tell what a variable is doing in
the middle of a function call makes it extremely hard
to read the formatting.  Remove.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-18 07:35:54 -04:00
Donald Sharp
03a7ab10fe zebra: Reindent some badly formatted functions in zebra_evpn_mac.c
Fix some badly formatted code to fit better on the screen.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-18 07:33:17 -04:00
Donald Sharp
390406973c zebra: Reframe zebra_evpn_mac.c to be properly formatted
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-18 07:33:17 -04:00
Donald Sharp
d1af3910b6
Merge pull request #16849 from opensourcerouting/fix/remove_rpki_cmd
bgpd: Remove deprecated RPKI command
2024-09-18 07:27:18 -04:00
Donald Sharp
04a6f2d900
Merge pull request #16840 from LabNConsulting/chopps/yang-lib
add ietf-yang-library support
2024-09-18 07:25:20 -04:00
Donald Sharp
174d46d7fc
Merge pull request #16852 from sri-mohan1/srib-24-frr-a
bgpd: changes for code maintainability
2024-09-18 07:23:56 -04:00
Shbinging
be32e8afba ospfd: fix no ip ospf dead-interval minimal hello-multiplier syntax
Signed-off-by: Shbinging <bingshui@smail.nju.edu.cn>
2024-09-18 15:39:55 +08:00
Donatas Abraitis
7a7ae8879f
Merge pull request #16850 from enkechen-panw/show-stat
bgpd: add counters for redistributed and aggregated routes
2024-09-18 08:57:03 +02:00
sri-mohan1
80c8b988b0 bgpd: changes for code maintainability
these changes are for improving the code maintainability and readability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2024-09-18 11:24:19 +05:30
Christian Hopps
d5e4e2dfa5 tests: add test for new ietf-yang-library support
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-09-17 22:27:36 -04:00
Christian Hopps
c5df98aece mgmtd: add ietf-yang-library support
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-09-17 22:27:36 -04:00
Enke Chen
25c290a17d bgpd: add counters for redistributed and aggregated routes
Add counters for redistributed routes, and local aggregates to the
output of "show ip bgp statistics".

Signed-off-by: Enke Chen <enchen@paloaltonetworks.com>
2024-09-17 15:13:49 -07:00
Donatas Abraitis
6a7a83c718 bgpd: Remove deprecated RPKI command
`rpki cache <A.B.C.D|WORD> ...`

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-09-17 23:04:30 +03:00
Joshua Muthii
97a03685e8 nhrpd: Implement retrying resolution request
In the event that a resolution request is sent and
and resolution reply is never received, resolution
requests will continue to be sent until either the
newly created shortcut has been purged or a resolution
reply is finally received.

NHRPD_DEFAULT_PURGE_TIME and NHRPD_PURGE_EXPIRE are values
that were previously hardcoded and  moved into macros for
the sake of readability.

Signed-off-by: Joshua Muthii <jmuthii@labn.net>
2024-09-17 12:44:41 -04:00
Russ White
da96ad08cd
Merge pull request #16774 from donaldsharp/bgp_give_some_ordering_increases
Bgp give some ordering increases
2024-09-17 11:01:34 -04:00
Donald Sharp
ade993b629
Merge pull request #16809 from louis-6wind/fix-rcap-double-free
isisd: fix rcap tlv double-free crash
2024-09-17 08:33:43 -04:00
Donald Sharp
f436b8668b
Merge pull request #16839 from LabNConsulting/chopps/edit-reply
Add `created` and `changed` booleans to `edit-reply` message
2024-09-17 08:30:35 -04:00
Mark Stapp
754d027e7e bgpd: remove bgpd.h from bgp script header
Use forward references instead of including the main bgpd.h
header in the bgp scripting header to reduce external impact
of changes.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2024-09-17 08:26:04 -04:00
Christian Hopps
b097a966cb lib: mgmtd: add changed and created to edit-reply msg
- This is used for various return values in RESTCONF

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-09-17 05:31:00 -04:00
Christian Hopps
96db155acd lib: mgmtd: cleanup error value for native messaging
- Now if positive it's libyang LY_ERR, otherwise it's `-errno` value.

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-09-17 03:04:59 -04:00
Christian Hopps
d57a6f761e mgmtd: allow dest DS "running" if implicit lock+commit
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-09-17 03:04:59 -04:00
Christian Hopps
0913d9fc0e lib: constify yang_resolve_snode_xpath results
Signed-off-by: Christian Hopps <chopps@labn.net>

ang
2024-09-17 03:04:59 -04:00
Donald Sharp
f02d76f0fd zebra: Attempt to reuse NHG after interface up and route reinstall
The previous commit modified zebra to reinstall the singleton
nexthops for a nexthop group when a interface event comes up.
Now let's modify zebra to attempt to reuse the nexthop group
when this happens and the upper level protocol resends the
route down with that.  Only match if the protocol is the same
as well as the instance and the nexthop groups would match.

Here is the new behavior:
eva(config)# do show ip route 9.9.9.9/32
Routing entry for 9.9.9.9/32
  Known via "static", distance 1, metric 0, best
  Last update 00:00:08 ago
  * 192.168.99.33, via dummy1, weight 1
  * 192.168.100.33, via dummy2, weight 1
  * 192.168.101.33, via dummy3, weight 1
  * 192.168.102.33, via dummy4, weight 1

eva(config)# do show ip route nexthop-group 9.9.9.9/32
% Unknown command: do show ip route nexthop-group 9.9.9.9/32
eva(config)# do show ip route 9.9.9.9/32 nexthop-group
Routing entry for 9.9.9.9/32
  Known via "static", distance 1, metric 0, best
  Last update 00:00:54 ago
  Nexthop Group ID: 57
  * 192.168.99.33, via dummy1, weight 1
  * 192.168.100.33, via dummy2, weight 1
  * 192.168.101.33, via dummy3, weight 1
  * 192.168.102.33, via dummy4, weight 1

eva(config)# exit
eva# conf
eva(config)# int dummy3
eva(config-if)# shut
eva(config-if)# no shut
eva(config-if)# do show ip route 9.9.9.9/32 nexthop-group
Routing entry for 9.9.9.9/32
  Known via "static", distance 1, metric 0, best
  Last update 00:00:08 ago
  Nexthop Group ID: 57
  * 192.168.99.33, via dummy1, weight 1
  * 192.168.100.33, via dummy2, weight 1
  * 192.168.101.33, via dummy3, weight 1
  * 192.168.102.33, via dummy4, weight 1

eva(config-if)# exit
eva(config)# exit
eva# exit
sharpd@eva ~/frr1 (master) [255]> ip nexthop show id 57
id 57 group 37/43/50/58 proto zebra
sharpd@eva ~/frr1 (master)> ip route show 9.9.9.9/32
9.9.9.9 nhid 57 proto 196 metric 20
	nexthop via 192.168.99.33 dev dummy1 weight 1
	nexthop via 192.168.100.33 dev dummy2 weight 1
	nexthop via 192.168.101.33 dev dummy3 weight 1
	nexthop via 192.168.102.33 dev dummy4 weight 1
sharpd@eva ~/frr1 (master)>

Notice that we now no longer are creating a bunch of new
nexthop groups.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-16 09:34:05 -04:00
Donald Sharp
3be8b48e6b zebra: Reinstall nexthop when interface comes back up
If a interface down event caused a nexthop group to remove
one of the entries in the kernel, have it be reinstalled
when the interface comes back up.  Mark the nexthop as
usable.

new behavior:
eva# show nexthop-group rib 181818168
ID: 181818168 (sharp)
     RefCnt: 1
     Uptime: 00:00:23
     VRF: default(bad-value)
     Valid, Installed
     Depends: (35) (38) (44) (51)
           via 192.168.99.33, dummy1 (vrf default), weight 1
           via 192.168.100.33, dummy2 (vrf default), weight 1
           via 192.168.101.33, dummy3 (vrf default), weight 1
           via 192.168.102.33, dummy4 (vrf default), weight 1
eva# conf
eva(config)# int dummy3
eva(config-if)# shut
eva(config-if)# do show nexthop-group rib 181818168
ID: 181818168 (sharp)
     RefCnt: 1
     Uptime: 00:00:44
     VRF: default(bad-value)
     Depends: (35) (38) (44) (51)
           via 192.168.99.33, dummy1 (vrf default), weight 1
           via 192.168.100.33, dummy2 (vrf default), weight 1
           via 192.168.101.33, dummy3 (vrf default) inactive, weight 1
           via 192.168.102.33, dummy4 (vrf default), weight 1
eva(config-if)# no shut
eva(config-if)# do show nexthop-group rib 181818168
ID: 181818168 (sharp)
     RefCnt: 1
     Uptime: 00:00:53
     VRF: default(bad-value)
     Valid, Installed
     Depends: (35) (38) (44) (51)
           via 192.168.99.33, dummy1 (vrf default), weight 1
           via 192.168.100.33, dummy2 (vrf default), weight 1
           via 192.168.101.33, dummy3 (vrf default), weight 1
           via 192.168.102.33, dummy4 (vrf default), weight 1
eva(config-if)# exit
eva(config)# exit
eva# exit
sharpd@eva ~/frr1 (master) [255]> ip nexthop show id 181818168
id 181818168 group 35/38/44/51 proto 194
sharpd@eva ~/frr1 (master)>

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-16 09:34:05 -04:00
Donald Sharp
ce166ca789 zebra: Expose _route_entry_dump_nh so it can be used.
Expose this helper function so it can be used in zebra_nhg.c

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-16 09:34:05 -04:00