summaryrefslogtreecommitdiffstats
path: root/zebra (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* | Merge pull request #16681 from donaldsharp/zebra_re_after_rnJafar Al-Gharaibeh2024-08-291-4/+3
|\ \ | | | | | | zebra: Move prefix lookup to outside re loop
| * | zebra: Move prefix lookup to outside re loopDonald Sharp2024-08-281-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | Move the prefix lookup/comparison to outside the re loop and into the rn loop, since that is where the code should actually be. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* | | Merge pull request #16300 from donaldsharp/local_connectedMark Stapp2024-08-284-19/+105
|\ \ \ | |/ / |/| | Local connected
| * | zebra: Prevent accidental re memory leak in odd caseDonald Sharp2024-08-271-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | There exists a path in rib_add_multipath where if a decision is made to not use the passed in re, we just drop the memory instead of freeing it. Let's free it. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
| * | zebra: Handle kernel routes appropriatelyDonald Sharp2024-08-274-14/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current code intentionally ignores kernel routes. Modify zebra to allow these routes to be read in on linux. Also modify zebra to look to see if a route should be treated as a connected and mark it as such. Additionally this should properly handle some of the issues being seen with NOPREFIXROUTE. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
| * | zebra: Expose rib_update_handle_vrf_allDonald Sharp2024-08-272-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | This function will be used on interface down events to allow for kernel routes to be cleaned up. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
| * | zebra: Make p and src_p const for rib_deleteDonald Sharp2024-08-272-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | The prefix'es p and src_p are not const. Let's make them so. Useful to signal that we will not change this data. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* | | Merge pull request #16103 from mjstapp/fix_5549_nhg_typeRuss White2024-08-271-7/+0
|\ \ \ | |/ / |/| | zebra: be consistent about v6 nexthops for v4 routes
| * | zebra: be consistent about v6 nexthops for v4 routesMark Stapp2024-08-061-7/+0
| | | | | | | | | | | | | | | | | | | | | Treat TYPE_IPV6 and TYPE_IPV6_IFINDEX nexthops the same way when processing v4 (RFC 5549) routes. Signed-off-by: Mark Stapp <mjs@cisco.com>
* | | Merge pull request #16609 from donaldsharp/singleton_no_weightMark Stapp2024-08-231-5/+43
|\ \ \ | | | | | | | | Reduce the number of Singleton objects when using weight for NHG's
| * | | zebra: Create Singleton nhg's without weightsDonald Sharp2024-08-221-5/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently FRR when it has two nexthop groups: A nexthop 1 weight 5 nexthop 2 weight 6 nexthop 3 weight 7 B nexthop 1 weight 3 nexthop 2 weight 4 nexthop 3 weight 5 We end up with 5 singleton nexthops and two groups: ID: 181818168 (sharp) RefCnt: 1 Uptime: 00:04:52 VRF: default Valid, Installed Depends: (69) (70) (71) via 192.168.119.1, enp13s0 (vrf default), weight 182 via 192.168.119.2, enp13s0 (vrf default), weight 218 via 192.168.119.3, enp13s0 (vrf default), weight 255 ID: 181818169 (sharp) RefCnt: 1 Uptime: 00:02:08 VRF: default Valid, Installed Depends: (71) (127) (128) via 192.168.119.1, enp13s0 (vrf default), weight 127 via 192.168.119.2, enp13s0 (vrf default), weight 170 via 192.168.119.3, enp13s0 (vrf default), weight 255 id 69 via 192.168.119.1 dev enp13s0 scope link proto 194 id 70 via 192.168.119.2 dev enp13s0 scope link proto 194 id 71 via 192.168.119.3 dev enp13s0 scope link proto 194 id 127 via 192.168.119.1 dev enp13s0 scope link proto 194 id 128 via 192.168.119.2 dev enp13s0 scope link proto 194 id 181818168 group 69,182/70,218/71,255 proto 194 id 181818169 group 71,255/127,127/128,170 proto 194 This is not a desirable state to be in. If you have a link flapping in the network and weights are changing rapidly you end up with a large number of singleton nexthops that are being used by the nexthop groups. This fills up asic space and clutters the table. Additionally singleton nexthops cannot have any weight and the fact that you attempt to create a singleton nexthop with different weights means nothing to the linux kernel( or any asic dplane ). Let's modify the code to always create the singleton nexthops without a weight and then just creating the NHG's that use the singletons with the appropriate weight. ID: 181818168 (sharp) RefCnt: 1 Uptime: 00:00:32 VRF: default Valid, Installed Depends: (22) (24) (28) via 192.168.119.1, enp13s0 (vrf default), weight 182 via 192.168.119.2, enp13s0 (vrf default), weight 218 via 192.168.119.3, enp13s0 (vrf default), weight 255 ID: 181818169 (sharp) RefCnt: 1 Uptime: 00:00:14 VRF: default Valid, Installed Depends: (22) (24) (28) via 192.168.119.1, enp13s0 (vrf default), weight 153 via 192.168.119.2, enp13s0 (vrf default), weight 204 via 192.168.119.3, enp13s0 (vrf default), weight 255 id 22 via 192.168.119.1 dev enp13s0 scope link proto 194 id 24 via 192.168.119.2 dev enp13s0 scope link proto 194 id 28 via 192.168.119.3 dev enp13s0 scope link proto 194 id 181818168 group 22,182/24,218/28,255 proto 194 id 181818169 group 22,153/24,204/28,255 proto 194 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* | | | zebra: Mimic GNU basename() API for non-glibc library e.g. muslKhem Raj2024-08-221-0/+4
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | musl only provides POSIX version of basename and it has also removed providing it via string.h header [1] which now results in compile errors with newer compilers e.g. clang-18 [1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7 Signed-off-by: Khem Raj <raj.khem@gmail.com>
* | | zebra, tests: Connected and Local routes should have a weight of 1Donald Sharp2024-08-212-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | All routes received by zebra from upper level protocols have a weight of 1. Let's just make everything extremely consistent in our code. Lot's of tests needed to be fixed up to make this work. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* | | zebra: Ensure we cannot send invalid range to kernelDonald Sharp2024-08-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The linux kernel adds 1 upon receipt of a weight, if you send a 255 it gets unhappy. Let's Limit range to 254 as that kernel does not like sending of 255. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* | | Merge pull request #16597 from kprovost/masterJafar Al-Gharaibeh2024-08-193-0/+6
|\ \ \ | | | | | | | | zebra: fix loading kernel routes without netlink
| * | | zebra: fix loading kernel routs without netlinkKristof Provost2024-08-163-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 605df8d44 zebra: Use zebra dplane for RTM link and addr broke loading of kernel routes at startup for configurations without netlink. It rearranged the startup sequence in zebra_ns_enable() to pass via zebra_ns_startup_continue(), triggered through zebra_dplane_startup_stage() calls. However, it neglected to make these calls in the non-netlink code path. As a result zebra failed to load kernel routes at startup on platforms such as FreeBSD. Insert these calls so we run through all of the expected startup stages. Signed-off-by: Kristof Provost <kprovost@netgate.com>
* | | | zebra: Do not assign time and then never use itDonald Sharp2024-08-181-1/+1
| | | | | | | | | | | | | | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* | | | zebra: Fix compilation warningCarmine Scarpitta2024-08-181-1/+1
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make sure the variable `srv6` is not NULL before dereferencing it. Fixes the following compilation warnings: ``` error 15-Aug-2024 14:20:01 zebra/zebra_srv6_vty.c:974:8: warning: Access to field 'locators' results in a dereference of a null pointer (loaded from variable 'srv6') [core.NullDereference] error 15-Aug-2024 14:20:01 for (ALL_LIST_ELEMENTS_RO(srv6->locators, node, locator)) { error 15-Aug-2024 14:20:01 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error 15-Aug-2024 14:20:01 ./lib/linklist.h:345:11: note: expanded from macro 'ALL_LIST_ELEMENTS_RO' error 15-Aug-2024 14:20:01 (node) = listhead(list), ((data) = NULL); \ error 15-Aug-2024 14:20:01 ^~~~~~~~~~~~~~ error 15-Aug-2024 14:20:01 ./lib/linklist.h:63:22: note: expanded from macro 'listhead' error 15-Aug-2024 14:20:01 #define listhead(X) ((X) ? ((X)->head) : NULL) error 15-Aug-2024 14:20:01 ^ ``` Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
* | | *: Fix spelling errors foundDonald Sharp2024-08-151-1/+1
| | | | | | | | | | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* | | Merge pull request #16576 from ↵Donald Sharp2024-08-135-19/+15
|\ \ \ | | | | | | | | | | | | | | | | opensourcerouting/fix/free_opaque_data_of_route_entry zebra: Do not forget to free opaque data for route entry
| * | | zebra: Do not forget to free opaque data for route entryDonatas Abraitis2024-08-135-19/+15
| |/ / | | | | | | | | | Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
* / / zebra: Ensure non-equal id's are not same nhg'sDonald Sharp2024-08-111-3/+12
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function zebra_nhg_hash_equal is only used as a hash function for storage of NHG's and retrieval. If you have say two nhg's: 31 (25/26) 32 (25/26) This function would return them as being equal. Which of course leads to the problem when you attempt to hash_release 32 but release 31 from the hash. Then later when you attempt to do hash comparisons 32 has actually been freed leaving to use after free situations and shit goes down hill fast. This hash is only used as part of the hash comparison function for nexthop group storage. Since this is so let's always return the 31/32 nhg's are not equal at all. We possibly have a different problem where we are creating 31 and 32 ( when 31 should have just been used instead of 32 ) but we need to prevent any type of hash release problem at all. This supercedes any other issue( that should be tracked down on it's own ). Since you can have use after free situation that leads to a crash -vs- some possible nexthop group duplication which is very minor in comparison. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* | bgpd: Show which AFI is affected when prefix-list is not foundDonatas Abraitis2024-07-311-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the prefix-list is not found, show which AFI is the real one we are looking for. E.g.: looking at this output is not clear: ``` [RYF1Z-ZKDRS] route_match_address_prefix_list: Prefix List p1 specified does not exist defaulting to NO_MATCH ``` route_match_address_prefix_list() is called by route_match_ipv6_address_prefix_list(), and route_match_ip_address_prefix_list(). Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
* | zebra: Fix removal of routes on MetaQ when client goes downDonald Sharp2024-07-301-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | It is possible that right before an upper level protocol dies or is killed routes would be installed into zebra. These routes could be on the Meta-Q for early route-processing. Leaving us with a situation where the client is removed, and all it's routes that are in the rib at that time, and then after that the MetaQ is run and the routes are reprocessed leaving routes from an upper level daemon post daemon going away from zebra's perspective. These routes will be abandoned. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* | Merge pull request #16041 from sri-mohan1/srib-24-zebra-dmobash-rasool2024-07-251-12/+13
|\ \ | | | | | | zebra: changes for code maintainability
| * | zebra: changes for code maintainabilitysri-mohan12024-07-151-12/+13
| | | | | | | | | | | | | | | | | | these changes are for improving the code maintainability and readability Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
* | | zebra: Remove duplicate `#include "zebra/interface.h"`Carmine Scarpitta2024-07-241-1/+0
| | | | | | | | | | | | Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
* | | zebra: Remove duplicate `#include "zebra/interface.h"`Carmine Scarpitta2024-07-241-1/+0
| | | | | | | | | | | | Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
* | | zebra: Remove duplicate `#include "zebra/debug.h"`Carmine Scarpitta2024-07-241-1/+0
| | | | | | | | | | | | Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
* | | zebra: Remove duplicate `#include <stdio.h>`Carmine Scarpitta2024-07-241-1/+0
| | | | | | | | | | | | Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
* | | zebra: Remove duplicate `#include <string.h>`Carmine Scarpitta2024-07-241-1/+0
| | | | | | | | | | | | Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
* | | zebra: Remove duplicate `#include <stdlib.h>`Carmine Scarpitta2024-07-241-1/+0
| | | | | | | | | | | | Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
* | | zebra: Remove duplicate `#include <arpa/inet.h>`Carmine Scarpitta2024-07-241-1/+0
| | | | | | | | | | | | Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
* | | zebra: Remove duplicate `#include <netinet/in.h>`Carmine Scarpitta2024-07-241-1/+0
| | | | | | | | | | | | Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
* | | Merge pull request #16410 from pguibert6WIND/show_zebra_dplane_nexthopRuss White2024-07-231-0/+8
|\ \ \ | | | | | | | | zebra: add nexthop counter to 'show zebra dplane' command
| * | | zebra: add nexthop counter to 'show zebra dplane' commandPhilippe Guibert2024-07-171-0/+8
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The nexthop updates counter value was never displayed. Add it. > # show zebra dplane > Zebra dataplane: > Route updates: 7673010 > Route update errors: 0 > Nexthop updates: 1100 > Nexthop update errors: 0 > [..] Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* | | Merge pull request #16330 from donaldsharp/nhg_going_downRuss White2024-07-232-2/+28
|\ \ \ | | | | | | | | zebra: Properly note that a nhg's nexthop has gone down
| * | | zebra: Properly note that a nhg's nexthop has gone downDonald Sharp2024-07-032-2/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current code when a link is set down is to just mark the nexthop group as not properly setup. Leaving situations where when an interface goes down and show output is entered we see incorrect state. This is true for anything that would be checking those flags at that point in time. Modify the interface down nexthop group code to notice the nexthops appropriately ( and I mean set the appropriate flags ) and to allow a `show ip route` command to actually display what is going on with the nexthops. eva# show ip route 1.0.0.0 Routing entry for 1.0.0.0/32 Known via "sharp", distance 150, metric 0, best Last update 00:00:06 ago * 192.168.44.33, via dummy1, weight 1 * 192.168.45.33, via dummy2, weight 1 sharpd@eva:~/frr1$ sudo ip link set dummy2 down eva# show ip route 1.0.0.0 Routing entry for 1.0.0.0/32 Known via "sharp", distance 150, metric 0, best Last update 00:00:12 ago * 192.168.44.33, via dummy1, weight 1 192.168.45.33, via dummy2 inactive, weight 1 Notice now that the 1.0.0.0/32 route now correctly displays the route for the nexthop group entry. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* | | | Merge pull request #16341 from crosser/preserve-needed-rmacsDonatas Abraitis2024-07-221-44/+34
|\ \ \ \ | |_|/ / |/| | | zebra: evpn: not coerce VTEP IP to IPv4 in nh_list
| * | | zebra: evpn: not coerce VTEP IP to IPv4 in nh_listEugene Crosser2024-07-081-44/+34
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In L3 BGP-EVPN, if there are both IPv4 and IPv6 routes in the VPN, zebra maintains two instances of `struct zebra_neigh` object: one with IPv4 address of the nexthop, and another with IPv6 address that is an IPv4 mapped to IPv6, but only one intance of `struct zebra_mac` object, that contains a list of nexthop addresses that use this mac. The code in `zebra_vxlan` module uses the fact that the list is empty as the indication that the `zebra_mac` object is unused, and needs to be dropped. However, preexisting code used nexthop address converted to IPv4 notation for the element of this list. As a result, when two `zebra_neigh` objects, one IPv4 and one IPv6-mapped-IPv4 were linked to the `zebra_mac` object, only one element was added to the list. Consequently, when one of the two `zebra_neigh` objects was dropped, the only element in the list was removed, making it empty, and `zebra_mac` object was dropped, and neigbrour cache elements uninstalled from the kernel. As a result, after the last route in _one_ family was removed from a remote vtep, all remaining routes in the _other_ family became unreachable, because RMAC of the vtep was removed. This commit makes `zebra_mac` use uncoerced IP address of the `zebra_neigh` object for the entries in the `nh_list`. This way, `zebra_mac` object no longer loses track of `zebra_neigh` objects that need it. Bug-URL: https://github.com/FRRouting/frr/issues/16340 Signed-off-by: Eugene Crosser <crosser@average.org>
* | | Merge pull request #16350 from ↵Donatas Abraitis2024-07-141-16/+20
|\ \ \ | | | | | | | | | | | | | | | | raja-rajasekar/rajasekarr/table_id_for_2vrf_3970414 zebra: Fix to avoid two Vrfs with same table ids
| * | | zebra: Fix to avoid two Vrfs with same table idsRajasekar Raja2024-07-121-16/+20
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During internal testing, when the following sequence is followed, two non default vrfs end up pointing to the same table-id - Initially vrf201 has table id 1002 - ip link add dev vrf202 type vrf table 1002 - ip link set dev vrf202 up - ip link set dev <intrerface> master vrf202 This will ideally lead to zebra exit since this is a misconfiguration as expected. However if we perform a restart frr.service at this point, we end up having two vrfs pointing to same table-id and bad things can happen. This is because in the interface_vrf_change, we incorrectly check for vrf_lookup_by_id() to evaluate if there is a misconfig. This works well for a non restart case but not for the startup case. root@mlx-3700-20:mgmt:/var/log/frr# sudo vtysh -c "sh vrf" vrf mgmt id 37 table 1001 vrf vrf201 id 46 table 1002 vrf vrf202 id 59 table 1002 >>>> Fix: in all cases of misconfiguration, exit zebra as expected. Ticket :#3970414 Signed-off-by: Donald Sharp <sharpd@nvidia.com> Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
* / / zebra, topotests: do not set nexthop's FIB flag when DUPLICATE presentPhilippe Guibert2024-07-082-0/+7
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bgp_duplicate_nexthop test installs routes with nexthop's flags set to both DUPLICATE and FIB: this should not happen. The DUPLICATE flag of a nexthop indicates this nexthop is already used in the same nexthop-group, and there is no need to install it twice in the system; having the FIB flag set indicates that the nexthop is installed in the system. This is why both flags should not be set on the same nexthop. This case happens at installation time, but can also happen at update time. - Fix this by not setting the FIB flag value when the DUPLICATE flag is present. - Modify the bgp_duplicate_test to check that the FIB flag is not present on duplicated nexthops. - Modify the bgp_peer_type_multipath_relax test. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* | *: Add and use option for graceful (re)startvivek2024-07-0110-46/+152
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new start option "-K" to libfrr to denote a graceful start, and use it in zebra and bgpd. zebra will use this option to denote a planned FRR graceful restart (supporting only bgpd currently) to wait for a route sync completion from bgpd before cleaning up old stale routes from the FIB. An optional timer provides an upper-bounds for this cleanup. bgpd will use this option to denote either a planned FRR graceful restart or a bgpd-only graceful restart, and this will drive the BGP GR restarting router procedures. Signed-off-by: Vivek Venkatraman <vivek@nvidia.com>
* | Merge pull request #16270 from cscarpitta/fix/fix-coverity-issuesDonatas Abraitis2024-06-251-17/+5
|\ \ | | | | | | zebra: Fix coverity issues
| * | zebra: Fix NULL pointer dereferenceCarmine Scarpitta2024-06-241-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `locator` pointer is dereferenced before ensuring it is not NULL. Fix the issue by checking that the pointer is not NULL before dereferencing it. Fixes 1594013 ** CID 1594013: Null pointer dereferences (REVERSE_INULL) /zebra/zebra_srv6.c: 961 in zebra_srv6_sid_compose() ________________________________________________________________________________________________________ *** CID 1594013: Null pointer dereferences (REVERSE_INULL) /zebra/zebra_srv6.c: 961 in zebra_srv6_sid_compose() 955 struct srv6_locator *locator, 956 uint32_t sid_func) 957 { 958 uint8_t offset, func_len; 959 struct srv6_sid_format *format = locator->sid_format; 960 CID 1594013: Null pointer dereferences (REVERSE_INULL) Null-checking "locator" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 961 if (!sid_value || !locator) 962 return false; 963 964 if (format) { 965 offset = format->block_len + format->node_len; 966 func_len = format->function_len; Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
| * | zebra: Fix wrong variable used in `for` loopCarmine Scarpitta2024-06-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `for` loop starting at line 1848 searches the `func_allocated` array for a pointer that points to a specific `sid_wide_func` element. The loop should iterate over all the elements of the `func_allocated` array and dereference each element to see if it is the one we are looking for. Currently, the loop is using the wrong variable to iterate over the array. Let's fix this issue by using the correct variable in the loop. Fixes CID 1594014 Fixes CID 1594016 ** CID 1594014: Null pointer dereferences (FORWARD_NULL) /zebra/zebra_srv6.c: 1860 in release_srv6_sid_func_explicit() ________________________________________________________________________________________________________ *** CID 1594014: Null pointer dereferences (FORWARD_NULL) /zebra/zebra_srv6.c: 1860 in release_srv6_sid_func_explicit() 1854 1855 /* Lookup SID function in the functions allocated list of EWLIB range */ 1856 for (ALL_LIST_ELEMENTS_RO(block->u.usid 1857 .wide_lib[sid_func] 1858 .func_allocated, 1859 node, sid_func_ptr)) CID 1594014: Null pointer dereferences (FORWARD_NULL) Dereferencing null pointer "sid_wide_func_ptr". 1860 if (*sid_wide_func_ptr == sid_wide_func) 1861 break; 1862 1863 /* Ensure that the SID function is allocated */ 1864 if (!sid_wide_func_ptr) { 1865 zlog_warn("%s: failed to release wide SID function %u, function is not allocated", ** CID 1594016: Possible Control flow issues (DEADCODE) /zebra/zebra_srv6.c: 1871 in release_srv6_sid_func_explicit() ________________________________________________________________________________________________________ *** CID 1594016: Possible Control flow issues (DEADCODE) /zebra/zebra_srv6.c: 1871 in release_srv6_sid_func_explicit() 1865 zlog_warn("%s: failed to release wide SID function %u, function is not allocated", 1866 __func__, sid_wide_func); 1867 return -1; 1868 } 1869 1870 /* Release the SID function from the EWLIB range */ CID 1594016: Possible Control flow issues (DEADCODE) Execution cannot reach this statement: "listnode_delete(block->u.us...". 1871 listnode_delete(block->u.usid.wide_lib[sid_func] 1872 .func_allocated, 1873 sid_wide_func_ptr); 1874 zebra_srv6_sid_func_free(sid_wide_func_ptr); 1875 } else { 1876 zlog_warn("%s: function %u is outside ELIB [%u/%u] and EWLIB alloc ranges [%u/%u]", Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
| * | zebra: Remove dead SRv6 codeCarmine Scarpitta2024-06-241-15/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At line 1736, `alloc_mode` is set to `SRV6_SID_ALLOC_MODE_EXPLICIT` or `SRV6_SID_ALLOC_MODE_DYNAMIC` depending on the `sid_value` variable. There will never be a case where alloc_mode will be `SRV6_SID_ALLOC_MODE_MAX` or `SRV6_SID_ALLOC_MODE_UNSPEC`. Let's replace the `switch(alloc_mode) {...}` with an if-else. Fixes CID 1594015. ** CID 1594015: (DEADCODE) /zebra/zebra_srv6.c: 1782 in get_srv6_sid() /zebra/zebra_srv6.c: 1781 in get_srv6_sid() ________________________________________________________________________________________________________ *** CID 1594015: (DEADCODE) /zebra/zebra_srv6.c: 1782 in get_srv6_sid() 1776 } 1777 1778 ret = get_srv6_sid_dynamic(sid, ctx, locator); 1779 1780 break; 1781 case SRV6_SID_ALLOC_MODE_MAX: CID 1594015: (DEADCODE) Execution cannot reach this statement: "case SRV6_SID_ALLOC_MODE_UN...". 1782 case SRV6_SID_ALLOC_MODE_UNSPEC: 1783 default: 1784 flog_err(EC_ZEBRA_SM_CANNOT_ASSIGN_SID, 1785 "%s: SRv6 Manager: Unrecognized alloc mode %u", 1786 __func__, alloc_mode); 1787 /* We should never arrive here */ /zebra/zebra_srv6.c: 1781 in get_srv6_sid() 1775 return -1; 1776 } 1777 1778 ret = get_srv6_sid_dynamic(sid, ctx, locator); 1779 1780 break; CID 1594015: (DEADCODE) Execution cannot reach this statement: "case SRV6_SID_ALLOC_MODE_MAX:". 1781 case SRV6_SID_ALLOC_MODE_MAX: 1782 case SRV6_SID_ALLOC_MODE_UNSPEC: 1783 default: 1784 flog_err(EC_ZEBRA_SM_CANNOT_ASSIGN_SID, 1785 "%s: SRv6 Manager: Unrecognized alloc mode %u", 1786 __func__, alloc_mode); Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
* | | Merge pull request #16261 from chiragshah6/evpn_dev4Donatas Abraitis2024-06-251-0/+13
|\ \ \ | |/ / |/| | zebra: clear evpn dup-addr return error-msg when there is no vni
| * | zebra: clear evpn dup-addr return error-msg when there is no vniSindhu Parvathi Gopinathan2024-06-211-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | clear evpn dup-addr cli returns error-msg for below conditions, - If evpn is not enabled & - If there is no VNI exists. supported command: ``` clear evpn dup-addr vni <vni-id> ``` Ticket: #3495573 Testing: bharat# clear evpn dup-addr vni all Error type: validation Error description: % EVPN not enabled bharat# clear evpn dup-addr vni 20 Error type: validation Error description: % VNI 20 does not exist Signed-off-by: Sindhu Parvathi Gopinathan's <sgopinathan@nvidia.com> Signed-off-by: Chirag Shah <chirag@nvidia.com>