Commit graph

854 commits

Author SHA1 Message Date
Donald Sharp fff267e4ee
Merge pull request #14968 from opensourcerouting/fix/missing_whitespace
zebra: Add missing whitespace when printing route entry status
2023-12-10 14:30:27 -05:00
Donatas Abraitis 162433cb2a zebra: Add missing whitespace when printing route entry status
Before:

```
status: Removed ReplacingInstalled
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-12-08 13:57:56 +02:00
Philippe Guibert 4d60d9e2b4 zebra: enqueue NHG_DEL in rib_nhg meta queue
The NHG_DEL operation is done directly from ZAPI call, whereas
the NHG_ADD operation is done in the rib_nhg meta queue.

This may be problematic when ADD is followed by DEL. Imagine a
scenarion with two protocol NHIDs. <NH1> depends of <NH2> and
<NH3>. The deletion of <NH3> at the protocol level will trigger
2 messages to ZEBRA: NHG_ADD(<NH1>) and NHG_DEL(<NH3>).

Those operations are properly enqueued in ZAPI, but in the end,
the NHG_DEL is executed first. This causes NHG_ADD to unlink an
already freed NHG.

Fix this by consistently enqueuing NHG_DEL and NHG_ADD operations.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-12-07 17:20:20 +01:00
Mark Stapp 2648661ed5
Merge pull request #14795 from donaldsharp/zebra_notify_admin_lost
zebra: Fix non-notification of better admin won
2023-12-07 08:30:00 -05:00
Russ White 0a79e117d6
Merge pull request #12600 from donaldsharp/local_routes
*: Introduce Local Host Routes to FRR
2023-12-05 11:00:44 -05:00
Donald Sharp 2d3005068c zebra: Fix non-notification of better admin won
If there happens to be a entry in the zebra rib
that has a lower admin distance then a newly received
re, zebra would not notify the upper level protocol
about this happening.  Imagine a case where there
is a connected route for say a /32 and bgp receives
a route from a peer that is the same route as the
connected.  Since BGP has no network statement and
perceives the route as being `good` bgp will install
the route into zebra.  Zebra will look at the new
bgp re and correctly identify that the re is not
something that it will use and do nothing.  This
change notices this and sends up a BETTER_ADMIN_WON
route notification.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-29 13:47:48 -05:00
Donald Sharp a1c1b9d9c5 zebra: On shutdown, ensure ctx's in rib_dplane_q are freed
a) Rename rib_init to zebra_rib_init() to better follow how
things are named

b) on shutdown cycle through the rib_dplane_q and free
up any contexts sitting in it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-21 12:41:18 -05:00
Mark Stapp bb3faf1b95 zebra: reduce number of switch statements with dplane opcodes
Replace several switch blocks that contain every dplane opcode
with simpler sets of if()s. In these cases the code only
uses a couple of opcodes.

Signed-off-by: Mark Stapp <mjs@labn.net>
2023-11-17 08:40:58 -05:00
Donald Sharp 6de9f7fbf5 *: Move distance related defines into their own header
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-07 06:47:51 -05:00
Donald Sharp 315aa6cde4 *: Remove netlink headers from lib/zebra.h
The headers associated with netlink code
really only belong in those that need it.
Move these headers out of lib/zebra.h and
into more appropriate places.  bgp's usage
of the RT_TABLE_XXX defines are probably not
appropriate and will be cleaned up in future
commits.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-07 06:46:19 -05:00
Donald Sharp d4aa24ba7d *: Introduce Local Host Routes to FRR
Create Local routes in FRR:

S   0.0.0.0/0 [1/0] via 192.168.119.1, enp39s0, weight 1, 00:03:46
K>* 0.0.0.0/0 [0/100] via 192.168.119.1, enp39s0, 00:03:51
O   192.168.119.0/24 [110/100] is directly connected, enp39s0, weight 1, 00:03:46
C>* 192.168.119.0/24 is directly connected, enp39s0, 00:03:51
L>* 192.168.119.224/32 is directly connected, enp39s0, 00:03:51
O   192.168.119.229/32 [110/100] via 0.0.0.0, enp39s0 inactive, weight 1, 00:03:46
C>* 192.168.119.229/32 is directly connected, enp39s0, 00:03:46

Create ability to redistribute local routes.

Modify tests to support this change.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-01 17:13:06 -04:00
Philippe Guibert daad19071c zebra: add redistribute table-direct support
Redistributing routes from a specific routing table to a particular routing
protocol necessitates copying route entries to the main routing table using the
"ip import-table" command. Once copied, these routes are assigned a distinct
"table" route type, which the "redistribute table" command of the routing
protocol then picks up.

For illustration, here is a configuration that showcases the use of
"import-table" and "redistribute":

> # show running-config
> [..]
> ip route 172.31.0.10/32 172.31.1.10 table 100
> router bgp 65500
>  address-family ipv4 unicast
>   redistribute table 100
>  exit-address-family
> exit
> ip import-table 100
>
> # show ip route vrf default
> [..]
> T[100]>* 172.31.0.10/32 [15/0] via 172.31.1.10, r2-eth1, weight 1, 00:00:05

However, this method has inherent constraints:

- The 'import-table' parameter only handles route table id up to 252. The
253/254/255 table ids are reserved in the linux system, and adding other table
IDs above 255 leads to a design issue, where the size of some tables is directly
related to the maximum number of table ids to support.
- Duplicated route entries might interfere with original default table routes,
leading to potential conflicts. There is no guarantee that the zebra RIB will
favor these duplicated entries during redistribution.
- There are cases where the table ID can be checked independently of the default
routing table, as seen in Linux where the "ip rule" command is able to divert
traffic to that routing table. In that case, there is no need to duplicate route
entries in the default routing table.

To overcome these issues, a new redistribution type is proposed to redistribute
route entries directly from a specified routing table, eliminating the need for
an initial import into the default table.

Add a 'ZEBRA_ROUTE_TABLE_DIRECT' type to the 'REDISTRIBUTE' ZAPI messages. It
allows sending routes from a given non default table ID from zebra to a routing
daemon. The destination routing protocol table must be the default table.
The redistributed route inherit from the default distance value of 14: this is
the distance value reserved for routes redistributed via ROUTE_TABLE_DIRECT.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-10-20 13:28:52 +02:00
Donald Sharp 02cbd97801
Merge pull request #14561 from idryzhov/implicit-fallthrough
build: add -Wimplicit-fallthrough
2023-10-13 11:51:11 -04:00
Donald Sharp 4f7dc7709f
Merge pull request #13340 from leonshaw/fix/rib-del-connected
zebra: Fix connected route deletion when multiple entry exists
2023-10-13 08:53:43 -04:00
Igor Ryzhov 7d67b9ff28 build: add -Wimplicit-fallthrough
Also:
- replace all /* fallthrough */ comments with portable fallthrough;
pseudo keyword to accomodate both gcc and clang
- add missing break; statements as required by older versions of gcc
- cleanup some code to remove unnecessary fallthrough

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-10-12 21:23:18 +03:00
Rajasekar Raja 27ccfd9aa6 zebra: Fix zebra crash when replacing NHE during shutdown
During replace of a NHE from upper proto in zebra_nhg_proto_add(),
 - rib_handle_nhg_replace() is invoked with old NHE where we walk all
   RNs/REs & replace the re->nhe whose address points to old NHE.
 - In this walk, if prev re->nhe refcnt is decremented to 0, we free up
   the memory which the old NHE is pointing to.
Later in zebra_nhg_proto_add(), we end up accessing this freed memory
and crash.

Logs:
1380766 2023/08/16 22:34:11.994671 ZEBRA: [WDEB1-93HCZ] zebra_nhg_decrement_ref: nhe 0x56091d890840 (70312519[2756/2762/2810]) 2 => 1
1380773 2023/08/16 22:34:11.994678 ZEBRA: [WDEB1-93HCZ] zebra_nhg_decrement_ref: nhe 0x56091d890840 (70312519[2756/2762/2810]) 1 => 0
1380777 2023/08/16 22:34:11.994844 ZEBRA: [JE46R-G2NEE] zebra_nhg_release: nhe 0x56091d890840 (70312519[2756/2762/2810])
1380778 2023/08/16 22:34:11.994849 ZEBRA: [SCDBM-4H062] zebra_nhg_free: nhe 0x56091d890840 (70312519[2756/2762/2810]), refcnt 0
1380782 2023/08/16 22:34:11.995000 ZEBRA: [SCDBM-4H062] zebra_nhg_free: nhe 0x56091d890840 (0[]), refcnt 0
1380783 2023/08/16 22:34:11.995011 ZEBRA: lib/memory.c:84: mt_count_free(): assertion (mt->n_alloc) failed

Backtrace:
0  0x00007f833f5f48eb in raise () from /lib/x86_64-linux-gnu/libc.so.6
1  0x00007f833f5df535 in abort () from /lib/x86_64-linux-gnu/libc.so.6
2  0x00007f833f636648 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
3  0x00007f833f63cd6a in ?? () from /lib/x86_64-linux-gnu/libc.so.6
4  0x00007f833f63cfb4 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
5  0x00007f833f63fbc8 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
6  0x00007f833f64172a in malloc () from /lib/x86_64-linux-gnu/libc.so.6
7  0x00007f833f6c3fd2 in backtrace_symbols () from /lib/x86_64-linux-gnu/libc.so.6
8  0x00007f833f9013fc in zlog_backtrace_sigsafe (priority=priority@entry=2, program_counter=program_counter@entry=0x7f833f5f48eb <raise+267>) at lib/log.c:222
9  0x00007f833f901593 in zlog_signal (signo=signo@entry=6, action=action@entry=0x7f833f988ee8 "aborting...", siginfo_v=siginfo_v@entry=0x7ffee1ce4a30,
    program_counter=program_counter@entry=0x7f833f5f48eb <raise+267>) at lib/log.c:154
10 0x00007f833f92dbd1 in core_handler (signo=6, siginfo=0x7ffee1ce4a30, context=<optimized out>) at lib/sigevent.c:254
11 <signal handler called>
12 0x00007f833f5f48eb in raise () from /lib/x86_64-linux-gnu/libc.so.6
13 0x00007f833f5df535 in abort () from /lib/x86_64-linux-gnu/libc.so.6
14 0x00007f833f958f96 in _zlog_assert_failed (xref=xref@entry=0x7f833f9e4080 <_xref.10705>, extra=extra@entry=0x0) at lib/zlog.c:680
15 0x00007f833f905400 in mt_count_free (mt=0x7f833fa02800 <MTYPE_NH_LABEL>, ptr=0x51) at lib/memory.c:84
16 mt_count_free (ptr=0x51, mt=0x7f833fa02800 <MTYPE_NH_LABEL>) at lib/memory.c:80
17 qfree (mt=0x7f833fa02800 <MTYPE_NH_LABEL>, ptr=0x51) at lib/memory.c:140
18 0x00007f833f90799c in nexthop_del_labels (nexthop=nexthop@entry=0x56091d776640) at lib/nexthop.c:563
19 0x00007f833f907b91 in nexthop_free (nexthop=0x56091d776640) at lib/nexthop.c:393
20 0x00007f833f907be8 in nexthops_free (nexthop=<optimized out>) at lib/nexthop.c:408
21 0x000056091c21aa76 in zebra_nhg_free_members (nhe=0x56091d890840) at zebra/zebra_nhg.c:1628
22 zebra_nhg_free (nhe=0x56091d890840) at zebra/zebra_nhg.c:1628
23 0x000056091c21bab2 in zebra_nhg_proto_add (id=<optimized out>, type=9, instance=<optimized out>, session=0, nhg=nhg@entry=0x56091d7da028, afi=afi@entry=AFI_UNSPEC)
    at zebra/zebra_nhg.c:3532
24 0x000056091c22bc4e in process_subq_nhg (lnode=0x56091d88c540) at zebra/zebra_rib.c:2689
25 process_subq (qindex=META_QUEUE_NHG, subq=0x56091d24cea0) at zebra/zebra_rib.c:3290
26 meta_queue_process (dummy=<optimized out>, data=0x56091d24d4c0) at zebra/zebra_rib.c:3343
27 0x00007f833f9492c8 in work_queue_run (thread=0x7ffee1ce55a0) at lib/workqueue.c:285
28 0x00007f833f93f60d in thread_call (thread=thread@entry=0x7ffee1ce55a0) at lib/thread.c:2008
29 0x00007f833f8f9888 in frr_run (master=0x56091d068660) at lib/libfrr.c:1223
30 0x000056091c1b8366 in main (argc=12, argv=0x7ffee1ce5988) at zebra/main.c:551

Issue: 3492162

Ticket# 3492162

Signed-off-by: Chirag Shah <chirag@nvidia.com>

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2023-08-31 05:40:34 +00:00
Donald Sharp 4d22b41321
Merge pull request #14256 from rodecker/rt-table-id
zebra: Make main routing table (RT_TABLE_MAIN) configurable
2023-08-25 17:33:52 -04:00
Martin Pels 4d96ce1b4d zebra: Make main routing table (RT_TABLE_MAIN) configurable
Signed-off-by: Martin Pels <mpels@ripe.net>
2023-08-22 15:29:07 +02:00
Pavel Ivashchenko 69906fdbd6 zebra: fix assert in process_subq_route
Bug is reporoduced in case of switching interfaces betwean VRFs.
 ospf6d is enabled and configured in each VRF.

 'dest' can be removed from the route node in the time when the same
 route node waiting processing in another sub-queue.

 A route node must only be in one sub-queue at a time.

 Details:

 1. Config:

    interface if0
     ipv6 address 2001:db8:cafe:2::2/64
     ipv6 nat inside
     ipv6 ospf6 area 0.0.0.51
     ipv6 ospf6 cost 10
     vrf test2
    exit
    !
    interface if1
     ipv6 address 2001:db8:cafe:4::1/64
     ipv6 nat outside
     ipv6 ospf6 area 0.0.0.0
     ipv6 ospf6 cost 10
     vrf test2
    exit
    !
    router ospf6
     ospf6 router-id 2.2.2.2
    exit
    !
    router ospf6 vrf test1
     ospf6 router-id 2.2.2.2
    exit
    !
    router ospf6 vrf test2
     ospf6 router-id 2.2.2.2
    exit

  I just quickly switched interfaces between different VRFs (default/test1/test2).

 2. Log messages:

  Aug 02 16:51:56 ubuntu zebra[386985]: [MFYWV-KH3MC] process_subq_early_route_add: (0:?):2001:db8:cafe:2::/64: Inserting route rn 0x56267593de90, re 0x56267595ae40 (connected) existing 0x0, same_count 0
  Aug 02 16:51:56 ubuntu zebra[386985]: [Q4T2G-E2SQF] process_subq_early_route_add: dumping RE entry 0x56267595ae40 for 2001:db8:cafe:2::/64 vrf default(0)
  Aug 02 16:51:56 ubuntu zebra[386985]: [GCGMT-SQR82] rib_link: (0:?):2001:db8:cafe:2::/64: rn 0x56267593de90 adding dest
  Aug 02 16:51:56 ubuntu zebra[386985]: [JF0K0-DVHWH] rib_meta_queue_add: (0:254):2001:db8:cafe:2::/64: queued rn 0x56267593de90 into sub-queue Connected Routes
  Aug 02 16:51:56 ubuntu zebra[386985]: [QE6V0-J8BG5] rib_delnode: (0:254):2001:db8:cafe:2::/64: rn 0x56267593de90, re 0x56267595ae40, removing
  Aug 02 16:51:56 ubuntu zebra[386985]: [KMPGN-JBRKW] rib_meta_queue_add: (0:254):2001:db8:cafe:2::/64: rn 0x56267593de90 is already queued in sub-queue Connected Routes
  Aug 02 16:51:56 ubuntu zebra[386985]: [MFYWV-KH3MC] process_subq_early_route_add: (0:254):2001:db8:cafe:2::/64: Inserting route rn 0x56267593de90, re 0x56267595abf0 (ospf6) existing 0x0, same_count 1
  Aug 02 16:51:56 ubuntu zebra[386985]: [Q4T2G-E2SQF] process_subq_early_route_add: dumping RE entry 0x56267595abf0 for 2001:db8:cafe:2::/64 vrf default(0)
  Aug 02 16:51:56 ubuntu zebra[386985]: [KMPGN-JBRKW] rib_meta_queue_add: (0:254):2001:db8:cafe:2::/64: rn 0x56267593de90 is already queued in sub-queue Connected Routes
  Aug 02 16:51:56 ubuntu zebra[386985]: [YEYFX-TDSC2] process_subq_early_route_add: (0:254):2001:db8:cafe:2::/64: rn 0x56267593de90, removing unneeded re 0x56267595ae40
  Aug 02 16:51:56 ubuntu zebra[386985]: [Y53JX-CBC5H] rib_unlink: (0:254):2001:db8:cafe:2::/64: rn 0x56267593de90, re 0x56267595ae40
  Aug 02 16:51:56 ubuntu zebra[386985]: [QE6V0-J8BG5] rib_delnode: (0:254):2001:db8:cafe:2::/64: rn 0x56267593de90, re 0x56267595abf0, removing
  Aug 02 16:51:56 ubuntu zebra[386985]: [JF0K0-DVHWH] rib_meta_queue_add: (0:254):2001:db8:cafe:2::/64: queued rn 0x56267593de90 into sub-queue RIP/OSPF/ISIS/EIGRP/NHRP Routes
  Aug 02 16:51:56 ubuntu zebra[386985]: [NZNZ4-7P54Y] default(0:254):2001:db8:cafe:2::/64: Processing rn 0x56267593de90
  Aug 02 16:51:56 ubuntu zebra[386985]: [ZJVZ4-XEGPF] default(0:254):2001:db8:cafe:2::/64: Examine re 0x56267595abf0 (ospf6) status: Removed Changed flags: None dist 110 metric 10
  Aug 02 16:51:56 ubuntu zebra[386985]: [NM15X-X83N9] rib_process: (0:254):2001:db8:cafe:2::/64: rn 0x56267593de90, removing re 0x56267595abf0
  Aug 02 16:51:56 ubuntu zebra[386985]: [Y53JX-CBC5H] rib_unlink: (0:254):2001:db8:cafe:2::/64: rn 0x56267593de90, re 0x56267595abf0
  Aug 02 16:51:56 ubuntu zebra[386985]: [KT8QQ-45WQ0] rib_gc_dest: (0:?):2001:db8:cafe:2::/64: removing dest from table
  Aug 02 16:51:56 ubuntu zebra[386985]: [HH6N2-PDCJS] default(0:0):2001:db8:cafe:2::/64 rn 0x56267593de90 dequeued from sub-queue Connected Routes

 3. ...and then assert:

  (gdb) bt
  #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=140662163115136) at ./nptl/pthread_kill.c:44
  #1  __pthread_kill_internal (signo=6, threadid=140662163115136) at ./nptl/pthread_kill.c:78
  #2  __GI___pthread_kill (threadid=140662163115136, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
  #3  0x00007fee76753476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
  #4  0x00007fee767397f3 in __GI_abort () at ./stdlib/abort.c:79
  #5  0x00007fee76a420fd in _zlog_assert_failed () from target:/usr/lib/x86_64-linux-gnu/frr/libfrr.so.0
  #6  0x0000562674efe0f0 in process_subq_route (qindex=7 '\a', lnode=0x562675940c60) at zebra/zebra_rib.c:2540
  #7  process_subq (qindex=META_QUEUE_NOTBGP, subq=0x562675574580) at zebra/zebra_rib.c:3055
  #8  meta_queue_process (dummy=<optimized out>, data=0x56267556d430) at zebra/zebra_rib.c:3091
  #9  0x00007fee76a386e8 in work_queue_run () from target:/usr/lib/x86_64-linux-gnu/frr/libfrr.so.0
  #10 0x00007fee76a31c91 in thread_call () from target:/usr/lib/x86_64-linux-gnu/frr/libfrr.so.0
  #11 0x00007fee769ee528 in frr_run () from target:/usr/lib/x86_64-linux-gnu/frr/libfrr.so.0
  #12 0x0000562674e97ec5 in main (argc=5, argv=0x7ffd1e275958) at zebra/main.c:478

  (gdb) print lnode->data
  $10 = (void *) 0x56267593de90
  (gdb) p/x *(struct route_node *)0x56267593de90
  $11 = {
    p = {
      family = 0xa,
      prefixlen = 0x40,
      u = {
        prefix = 0x20,
        prefix4 = {
          s_addr = 0xb80d0120
        },
        prefix6 = {
          __in6_u = {
            __u6_addr8 = {0x20, 0x1, 0xd, 0xb8, 0xca, 0xfe, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
            __u6_addr16 = {0x120, 0xb80d, 0xfeca, 0x200, 0x0, 0x0, 0x0, 0x0},
            __u6_addr32 = {0xb80d0120, 0x200feca, 0x0, 0x0}
          }
        },
   ...
    table = 0x5626755ae010,
    parent = 0x5626755ae070,
    link = {0x0, 0x0},
    lock = 0x4,
    nodehash = {
      hi = {
        next = 0x5626755ae0d0,
        hashval = 0xebe8bdbf
      }
    },
    info = 0x0

 3. What's happen:

   We removed unneeded re 0x56267595ae40 while adding re 0x56267595abf0. It was the last connected re,
   but rn 0x56267593de90 is still in the connected sub-queue.

   Then rib_delnode was called for 0x56267595abf0. (rn 0x56267593de90 is still in the connected sub-queue).
   rib_delnode have called rib_meta_queue_add which have checked, that rn is absent in sub-queue RIP/OSPF/ISIS/EIGRP/NHRP
   and have added rn in the second sub-queue.

 Fixes: d7ac4c4d88 ("zebra: Introduce early route processing on the MetaQ")

Signed-off-by: Pavel Ivashchenko <pivashchenko@nfware.com>
2023-08-09 21:25:33 +00:00
Xiao Liang cea3f7f25a lib, zebra: Fix EVPN nexthop config order
Delay EVPN route addition to synchronize with rib_delete(), which now
uses early route queue.

Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
2023-07-27 15:07:42 +08:00
anlan_cs 90bc24408b zebra: add several fields for debug
Two changes for debug:
1. Add a field to indicate its vrf for nexthop.  When the interface changes
vrf, we can't easily know the vrf of this nexthop according to current log.
2. Add a field to indicate operation type.  We can't know whether to add or
remove route according to current log.

Before:
```
zebra_nhg_increment_ref: nhe 0x555623eb82c0 (76[if 6]) 0 => 1
zebra_interface_nhg_reinstall install nhe 75[77.75.1.75 if 6] nh type 3 flags 0x1
Route 77.75.1.0/24(8) queued for processing into sub-queue Early Route Processing
Route 77.75.1.0/24(8) queued for processing into sub-queue Early Route Processing
```

After:
```
zebra_nhg_increment_ref: nhe 0x555623eb82c0 (76[if 6 vrfid 9]) 0 => 1
zebra_interface_nhg_reinstall install nhe 75[77.75.1.75 if 6 vrfid 8] nh type 3 flags 0x1
Route 77.75.1.0/24(8) (add) queued for processing into sub-queue Early Route Processing
Route 77.75.1.0/24(8) (delete) queued for processing into sub-queue Early Route Processing
```

Signed-off-by: anlan_cs <anlan_cs@tom.com>
2023-07-25 14:23:35 +08:00
Donald Sharp af80201876 zebra: Further handle route replace semantics
When an upper level protocol is installing a route X that needs to be
route replaced and at the same time the same or another protocol installs a
different route that depends on route X for nexthop resolution can leave
us with a state where the route is not accepted because zebra is still
really early in the route replace semantics ( route X is still on the work
Queue to be processed ) then the dependent route would not be installed.
This came up in the bgp_default_originate test cases frequently.

Further extendd the ROUTE_ENTR_ROUTE_REPLACING flag to cover this case
as well.  This has come up because the early route processing queueing
that was implemented late last year.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-07-17 10:00:32 -04:00
Donald Sharp 605df8d44f zebra: Use zebra dplane for RTM link and addr
a) Move the reads of link and address information
into the dplane
b) Move the startup read of data into the dplane
as well.
c) Break up startup reading of the linux kernel data
into multiple phases.  As that we have implied ordering
of data that must be read first and if the dplane has
taken over some data reading then we must delay initial
read-in of other data.

Fixes: #13288
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-07-05 13:03:14 -04:00
Donald Sharp a014450441 zebra: Add code to get/set interface to pass up from dplane
1) Add a bunch of get/set functions and associated data
structure in zebra_dplane to allow the setting and retrieval
of interface netlink data up into the master pthread.

2) Add a bit of code to breakup startup into stages.  This is
because FRR currently has a mix of dplane and non dplane interactions
and the code needs to be paused before continuing on.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-07-05 13:03:14 -04:00
Mark Stapp d6caf0dbd7
Merge pull request #13875 from donaldsharp/static_dplane_issues
zebra: Static routes async notification do not need this test
2023-07-05 08:27:23 -04:00
Donatas Abraitis 64510b9467 zebra: Dump route details when deleting a route
Just more details what's going on when deleting a route.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-06-29 17:39:45 +03:00
Donald Sharp d0123a9012 zebra: Static routes async notification do not need this test
When using asic_offload with an asynchronous notification the
rib_route_match_ctx function is testing for distance and tag
being correct against the re.

Normal route notification for static routes is this(well really all routes):
a) zebra dplane generates a ctx to send to the dplane for route install
b) dplane installs it in the kernel
c) if the dplane_fpm_nl.c module is being used it installs it.
d) The context's success code is set to it worked and passes the context
back up to zebra for processing.
e) Zebra master receives this and checks the distance and tag are correct
for static routes and accepts the route and marks it installed.

If the operator is using a wait for install mechansim where the dplane
is asynchronously sending the result back up at a future time *and*
it is using the dplane_fpm_nl.c code where it uses the rt_netlink.c
route parsing code, then there is no way to set distance as that we
do not pass distance to the kernel.

As such static routes were never being properly handled since the re and
context would not match and the route would still be marked as queued.

Modify the code such that the asynchronous path notification for static
routes ignores the distance and tag's as that there is no way to test
for this data from that path at this point in time.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-06-29 09:35:00 -04:00
Donald Sharp d8be139972 zebra: Reduce creation and fix memory leak of frrscripting pointers
There are two issues being addressed:

a) The ZEBRA_ON_RIB_PROCESS_HOOK_CALL script point
was creating a fs pointer per dplane ctx in
rib_process_dplane_results().

b) The fs pointer was not being deleted and directly
leaked.

For (a) Move the creation of the fs to outside
the do while loop.

For (b) At function end ensure that the pointer
is actually deleted.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-05-05 12:24:02 -04:00
Xiao Liang a35ba7ba60 zebra: Fix connected route deletion when multiple entry exists
When multiple interfaces have addresses in the same network, deleting
one of them may cause the wrong connected route being deleted.
For example:

    ip link add veth1 type veth peer veth2
    ip link set veth1 up
    ip link set veth2 up
    ip addr add dev veth1 192.168.0.1/24
    ip addr add dev veth2 192.168.0.2/24
    ip addr flush dev veth1

Zebra deletes the route of interface veth2 rather than veth1.

Should match nexthop against ere->re_nhe instead of ere->re->nhe.

Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
2023-04-20 12:13:18 +08:00
Donald Sharp 1b192d88e4 zebra: Actually free up memory associated with the mq list
Free up the link list data structures as well as properly
account for data sizes.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-04-12 10:41:42 -04:00
Jafar Al-Gharaibeh 92c4494ce5
Merge pull request #13145 from donaldsharp/do_delete
Improve and fix zebra GR
2023-04-04 21:10:54 -05:00
Donald Sharp 3cd0accb50 zebra: Cleanup ctx leak on shutdown and turn off event
two things:

On shutdown cleanup any events associated with the update walker.
Also do not allow new events to be created.

Fixes this mem-leak:

./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790:Direct leak of 8 byte(s) in 1 object(s) allocated from:
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-    #0 0x7f0dd0b08037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-    #1 0x7f0dd06c19f9 in qcalloc lib/memory.c:105
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-    #2 0x55b42fb605bc in rib_update_ctx_init zebra/zebra_rib.c:4383
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-    #3 0x55b42fb6088f in rib_update zebra/zebra_rib.c:4421
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-    #4 0x55b42fa00344 in netlink_link_change zebra/if_netlink.c:2221
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-    #5 0x55b42fa24622 in netlink_information_fetch zebra/kernel_netlink.c:399
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-    #6 0x55b42fa28c02 in netlink_parse_info zebra/kernel_netlink.c:1183
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-    #7 0x55b42fa24951 in kernel_read zebra/kernel_netlink.c:493
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-    #8 0x7f0dd0797f0c in event_call lib/event.c:1995
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-    #9 0x7f0dd0684fd9 in frr_run lib/libfrr.c:1185
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-    #10 0x55b42fa30caa in main zebra/main.c:465
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-    #11 0x7f0dd01b5d09 in __libc_start_main ../csu/libc-start.c:308
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-SUMMARY: AddressSanitizer: 8 byte(s) leaked in 1 allocation(s).

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-31 09:09:21 -04:00
Donald Sharp 81322b96b0 zebra: Ensure gr events run after Meta Queue has run
BGP signals to zebra that a afi has converged immediately
after it has finished processing all routes for a given
afi/safi.  This generates events in zebra in this order

a) Routes received from BGP, placed on early-rib Meta-Q
b) Signal GR for the afi.

Now imagine that zebra reads GR code and immediately
processes routes that are in the actual rib and
removes some routes.  This generates a

c) route deletion to the kernel for some number of
routes that may be in the the early-rib Meta-Q
d) Process the Meta-Q, and re-install the routes

This is undesirable behavior in zebra.  In that
while we may end up in a correct state, there
will be a blip for some number of routes that
happen to be in the early rib Meta-Q.

Modify the GR code to have it's own processing
entry at the end of the Meta-Q.  This will
allow all routes to be processed and ready
for handling by the Graceful Restart code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-29 20:25:51 -04:00
Donald Sharp 9a7d1e7427 zebra: Use zebra_vrf_lookup_by_id when we can
Let's make this as consistent as is possible.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-28 15:49:50 -04:00
Donald Sharp 24a58196dd *: Convert event.h to frrevent.h
We should probably prevent any type of namespace collision
with something else.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp e16d030c65 *: Convert THREAD_XXX macros to EVENT_XXX macros
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp 5f6eaa9b96 *: Convert a bunch of thread_XX to event_XX
Convert these functions:

thread_getrusage
thread_cmd_init
thread_consumed_time
thread_timer_to_hhmmss
thread_is_scheduled
thread_ignore_late_timer

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp 907a2395f4 *: Convert thread_add_XXX functions to event_add_XXX
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp e6685141aa *: Rename struct thread to struct event
Effectively a massive search and replace of
`struct thread` to `struct event`.  Using the
term `thread` gives people the thought that
this event system is a pthread when it is not

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp cb37cb336a *: Rename thread.[ch] to event.[ch]
This is a first in a series of commits, whose goal is to rename
the thread system in FRR to an event system.  There is a continual
problem where people are confusing `struct thread` with a true
pthread.  In reality, our entire thread.c is an event system.

In this commit rename the thread.[ch] files to event.[ch].

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:16 -04:00
Russ White 12906cb1c8
Merge pull request #12798 from donaldsharp/rib_match_multicast
Rib match multicast
2023-02-21 11:40:36 -05:00
Donald Sharp 64269ccae1
Merge pull request #12818 from imzyxwvu/fix/other-table-inactive
zebra: Fix other table inactive when ip import-table is on
2023-02-21 11:37:31 -05:00
Donald Sharp 8383d53e43
Merge pull request #12780 from opensourcerouting/spdx-license-id
*: convert to SPDX License identifiers
2023-02-17 09:43:05 -05:00
Donald Sharp 312e29b060 zebra: Remove code duplication for v4 and v6 versions of rib_match_multicast
a) Consolidate v4 and v6 versions of rib_match_multicast
b) Improve debug to show what we matched against as well.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-16 07:52:35 -05:00
zyxwvu Shi 207207c0c0 zebra: Fix other table inactive when ip import-table is on
In `rib_link`, if is_zebra_import_table_enabled returns
true, `rib_queue_add` will not called, resulting in other
table route node never processed. This actually should not
be dependent on whether the route is imported.

In `rib_delnode`, if is_zebra_import_table_enabled returns
true, it will use `rib_unlink` instead of enqueuing the
route node for process. There is no reason that imported
route nodes should not be reprocessed. Long ago, the
behaviour was dependent on whether the route_entry comes
from a table other than main.

Signed-off-by: zyxwvu Shi <i@shiyc.cn>
2023-02-15 23:55:30 +08:00
David Lamparter a836a6cf8c
Merge pull request #12789 from donaldsharp/version_cleanup 2023-02-14 17:19:07 +01:00
Stephen Worley 4645cb6bc2 lib,zebra,bgpd,staticd: use label code to store VNI info
Use the already existing mpls label code to store VNI
info for vxlan. VNI's are defined as labels just like mpls,
we should be using the same code for both.

This patch is the first part of that. Next we will need to
abstract the label code to not be so mpls specific. Currently
in this, we are just treating VXLAN as a label type and storing
it that way.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2023-02-13 18:12:05 -05:00
Donald Sharp 8b6a9cca67 lib, zebra: Consolidate ZEBRA_TABLE_MAX_DISTANCE values
Currently `ip import-table 33` imports routes with
a distance of 15, as defined by zebra.h.  zebra_rib.c
on the other hand believes the default value for the table
is 150.  Let's make them agree with each other.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-10 09:07:47 -05:00
Donald Sharp 3d55a4ef29 lib, zebra: Use defines for distance
Use the defines for distance that are in zebra.h.  We could
easily have a cluster where we don't agree with ourselves.  So
let's convert zebra to use the defines in zebra.h

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-10 09:07:47 -05:00
David Lamparter acddc0ed3c *: auto-convert to SPDX License IDs
Done with a combination of regex'ing and banging my head against a wall.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:11 +01:00
Donald Sharp a98701f053 zebra: Add missing enums to switch statements
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-31 15:15:42 -05:00
Donald Sharp 8ce0e517ed zebra: Send nht resolved entry up to concerned protocols in all cases
There existed the idea, from Volta, that a nexthop group would not have
the same nexthops installed -vs- what FRR actually sent down.  The
dplane would notify you.

With the addition of 06525c4f99
the code was put behind a bit of a wall controlled the usage
of it.

The flag ROUTE_ENTRY_USE_FIB_NHG flag was being used
to control which set was being sent up to concerned parties
in nexthop tracking.  Put this flag behind the wall and
do not necessarily set it when we receive a data plane
notification about a route being installed or not.

Fixes: #12706
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-31 07:28:19 -05:00
Donald Sharp d2a174233b zebra: Remove impossible to use function
The rib_update_handle_vrf function is no longer being used.
Cleanup it's usage from zebra.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-25 15:27:41 -05:00
Mark Stapp ac96497ccc zebra: use typesafe lib lists in zebra dplane
Replace some of the old queue/DLIST macros with typesafe
dlists.

Signed-off-by: Mark Stapp <mjs@labn.net>
2023-01-23 08:55:44 -05:00
Russ White bb1d52b3c0
Merge pull request #12604 from donaldsharp/distance_metric_offload_fixes
Distance/metric offload fixes
2023-01-18 15:57:48 -05:00
Rafael Zalamena e96817f877 zebra: fix use after free on RIB processing
After calling `rib_unlink` the variable `re` will point to `free()`d
memory, so don't attempt to use it after this point.

Found by Coverity Scan (Coverity ID 1519784)

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-01-16 17:40:54 -03:00
Donald Sharp 68ff69fa27 zebra: Set metric appropriately on route offload to asic
When FRR receives a route from the kernel about the route
offload success/failure.  The metric being reported is not
going to be correct since we may not know it appropriately
at this point in time.  If we can set the metric to something
appropriate.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-05 14:31:36 -05:00
Donald Sharp 1cd8bd054c zebra: Fix distance being set incorrectly on kernel offload update
When we are notified about the kernel about a route being offloaded
or not correctly set the distance.

Ticket: CM-33097
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-05 14:31:36 -05:00
Donald Sharp 739bc9fd72 zebra: When freeing the early route queue, actually free it right
The early route queue has a series of `struct zebra_early_route *`
entries.  Zebra is treating this memory as just a `struct route entry`.
This is wrong.  Correct this to free the memory correctly.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-15 11:15:33 -05:00
Donald Sharp 074c80b705 lib, tests, zebra: Remove unused workqueue error function
The wq->spec.errorfunc is never used in the code.
It's been in the code base since 2005 and I also
do not remember ever seeing it being called.  No
workqueue process function ever returns error.
Since it's not used let's just remove it from the
code base.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-15 11:15:33 -05:00
Donald Sharp a0e1173678 zebra: Read from the dplane_fpm_nl a route update
Read from the fpm dplane a route update that will
include status about whether or not the asic was
successfull in offloading the route.

Have this data passed up to zebra for processing and disseminate
this data as appropriate.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-13 15:34:05 -05:00
Donald Sharp 06525c4f99 zebra: Add zrouter.asic_notification_nexthop_control
Volta submitted notification changes for the dplane that had a
special use case for their system.  Volta is no more, the code
is not being actively developed and from talking with ex-Volta
employees there is no current plans to even maintain this code.
Wrap the special handling of nexthops that their asic-dataplane
did in a bit of code to isolate it and allow for future removal,
as that I do not actually believe anyone else is using this code.
Add a CPP_NOTICE several years into the future that will tell us
to remove the code.  If someone starts using it then they will
have to notice this variable to set it and hopefully they will
see my CPP_NOTICE to come talk to us.  If this is being used then
we can just remove this wrapper.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-12 10:44:57 -05:00
Donald Sharp 871a16cd7e zebra: Return statements do not use paranthesis
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-12 10:44:57 -05:00
Siger Yang c317d3f246
zebra: traffic control state management
This allows Zebra to manage QDISC, TCLASS, TFILTER in kernel and do cleaning
jobs when it starts up.

Signed-off-by: Siger Yang <siger.yang@outlook.com>
2022-11-22 22:35:35 +08:00
Donald Sharp 8d4665aabf zebra: Fix handling of recursive routes when processing closely in time
When zebra receives routes from upper level protocols it decodes the
zapi message and places the routes on the metaQ for processing.  Suppose
we have a route A that is already installed by some routing protocol.
And there is a route B that has a nexthop that will be recursively
resolved through A.  Imagine if a route replace operation for A is
going to happen from an upper level protocol at about the same time
the route B is going to be installed into zebra.  If these routes
are received, and decoded, at about the same time there exists a
chance that the metaQ will contain both of them at the same time.
If the order of installation is [ B, A ].  B will be resolved
correctly through A and installed, A will be processed and
re-installed into the FIB.  If the nexthops have changed for
A then the owner of B should be notified about the change( and B
can do the correct action here and decide to withdraw or re-install ).
Now imagine if the order of routes received for processing on the
metaQ is [ A, B ].  A will be received, processed and sent to the
dataplane for reinstall.  B will then be pulled off the metaQ and
fail the install since A is in a `not Installed` state.

Let's loosen the restriction in nexthop resolution for B such
that if the route we are dependent on is a route replace operation
allow the resolution to suceed.  This requires zebra to track a new
route state( ROUTE_ENTRY_ROUTE_REPLACING ) that can be looked at
during nexthop resolution.  I believe this is ok because A is
a route replace operation, which could result in this:
-route install failed, in which case B should be nht'ing and
will receive the nht failure and the upper level protocol should
remove B.
-route install succeeded, no nexthop changes.  In this case
allowing the resolution for B is ok, NHT will not notify the upper
level protocol so no action is needed.
-route install succeeded, nexthops changes.  In this case
allowing the resolution for B is ok, NHT will notify the upper
level protocol and it can decide to reinstall B or not based
upon it's own algorithm.

This set of events was found by the bgp_distance_change topotest(s).
Effectively the tests were looking for the bug ( A, B order in the metaQ )
as the `correct` state.  When under very heavy load, the A, B ordering
caused A to just be installed and fully resolved in the dataplane before
B is gotten to( which is entirely possible ).

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-10-26 15:06:23 -04:00
anlan_cs 0d0f516c76 zebra: fix fpm crash
Fix issue#11996.

When removing VRF ( all routes of this VRF), zebra mistakenly forgot to check
whether its routes are in update queue of FPM.  So FPM module will crash during
its dealing with these routes, which are already freed.

Add a new HOOK `rib_shutdown()`, `zebra_rtable_node_cleanup()` will use it
to remove these routes from update queue of FPM module before freeing them.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-09-24 19:39:58 -04:00
Donald Sharp b0385873fa zebra: Create a zebra_rib_route_entry_new function and use it
Abstract the creation of the route_entry and use it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-17 16:04:50 -04:00
Donald Sharp d7ac4c4d88 zebra: Introduce early route processing on the MetaQ
Currently if an operator does this operation:

sharpd@eva ~/frr8> sudo ip nexthop add id 5000 via 192.168.119.44 dev enp39s0 ; sudo ip route add 10.0.0.1 nhid 5000
2022/06/30 08:52:40 ZEBRA: [ZHQK5-J9M1R] proto2zebra: Please add this protocol(0) to proper rt_netlink.c handling
2022/06/30 08:52:40 ZEBRA: [PS16P-365FK][EC 4043309076] Zebra failed to find the nexthop hash entry for id=5000 in a route entry
sharpd@eva ~/frr8> vtysh -c "show ip route 10.0.0.1"
Routing entry for 0.0.0.0/0
  Known via "kernel", distance 0, metric 100, best
  Last update 00:01:58 ago
  * 192.168.119.1, via enp39s0

The route is dropped by zebra with no warnings.  This is not good,
but unlikely to happen at this point in time.  In order to fix
this issue route processing from inputs needs to happen after nexthop
group processing from inputs.  This was not possible because
nexthop groups are placed on the metaQ.  As such the above
nexthop group creation is placed on the metaQ for processing
in META_QUEUE_NHG.  Then the route is read in and processed
immediately.  The nexthop group is not found ( not processed yet!)
and the route is dropped in zebra.

Modify the code to have early route processing of validity
on the MetaQ.  This preserves the order of operations.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-17 16:04:50 -04:00
Donald Sharp 53216dff6e zebra: Convert label processing to Meta-Q
Convert label processing that comes from zapi messages
into being handled by the meta-Q.  This is because early
route processing is going to be moved to the meta-Q as
well and we will have a chicken and egg problem without
moving this code to be processed by the meta-Q.

Ordering of messages from ospf as an example:
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:48] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:48] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:48] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:48] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:62] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:43] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:47] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:47] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:47] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:47] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:61] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:47] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:47] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_MPLS_LABELS_REPLACE:0:47] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_MPLS_LABELS_REPLACE:0:66] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_MPLS_LABELS_REPLACE:0:47] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_MPLS_LABELS_REPLACE:0:47] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_MPLS_LABELS_REPLACE:0:47] comes from socket [36]

The ZEBRA_MPLS_LABELS_REPLACE immediately turn around and attempt to replace nexthop labels on routes that
were added.  If the route add is placed on the metaQ, it will not exist yet and as such the label replace
will fail.

Modify the zebra code to take the label operations and place them on the metaQ as well.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-17 10:44:33 -04:00
Siger Yang 449a30edf6
zebra: add tc netlink and dplane ops
This commit implements necessary netlink encoders for traffic control
including QDISC, TCLASS and TFILTER, and adds basic dplane operations.

Co-authored-by: Stephen Worley <sworley@nvidia.com>
Signed-off-by: Siger Yang <siger.yang@outlook.com>
2022-08-11 02:32:43 +08:00
Donald Sharp a310ebc114 zebra: Combine meta_queue_free and meta_queue_vrf_free functions
These functions essentially do the same thing.  Combine them
for the goodness of mankind.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-10 07:14:43 -04:00
Donald Sharp 57a5524578 zebra: System routes should be processed the same time as kernel
For whatever reason.  ZEBRA_ROUTE_SYSTEM routes were being processed
last.  Since a system route is just another kernel route type.  Let's
just switch it to be processed the same time as kernel routes.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-10 07:14:43 -04:00
Donald Sharp 014e732d3e zebra: Let's use enum for META Queue indexes
Convert the meta queue values to an enum and use
them.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-10 07:14:43 -04:00
Donald Sharp 4bbbd1f6b3 zebra: Explicitly call out the correct queue name
There were more than a few places where the NHG meta
queue was not being explicitly called out.  Let's
be consistent and use the same nomenclature as much
as possible when talking about metaQ's.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-10 07:14:43 -04:00
Donald Sharp cb1991af8c *: frr_with_mutex change to follow our standard
convert:
	frr_with_mutex(..)

to:
	frr_with_mutex (..)

To make all our code agree with what clang-format is going to produce

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-20 15:50:32 -04:00
Russ White 1dc900fe27
Merge pull request #11502 from donaldsharp/zebra_dplane_fini
zebra: make rib_process_dplane_results own ctx freeing
2022-07-05 09:49:02 -04:00
Donatas Abraitis 484cc1bd97
Merge pull request #11514 from donaldsharp/zebra_odds_and_ends
Zebra odds and ends
2022-07-04 08:11:29 +03:00
Donald Sharp 7a96ccc7b4 zebra: Add a subqueue2str function to give more useful data in debugs
New output example:

2022-07-03 09:40:29.310 [DEBG] zebra: [JF0K0-DVHWH] rib_meta_queue_add: (0:254):4.5.6.8/32: queued rn 0x55937f586ee0 into sub-queue Kernel Routes
2022-07-03 09:40:29.321 [DEBG] zebra: [HH6N2-PDCJS] default(0:254):4.5.6.8/32 rn 0x55937f586ee0 dequeued from sub-queue Kernel Routes

Let's make it a bit more human readable.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-03 09:41:31 -04:00
Donald Sharp 88b0baa648 zebra: move allow_delete to zrouter.allow_delete
Instead of having global allow_delete move it to
where it belongs in the zrouter data structure.

Additionally show this data in `show zebra`

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-01 07:59:53 -04:00
Donald Sharp f00b37e710 zebra: make rib_process_dplane_results own ctx freeing
The rib_process_dplane_results function was having each
sub function handler process the results and then
free the ctx.  Lot's of functionality that needs to remember
to free the context.  Let's just free it in the main loop.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-29 15:24:20 -04:00
Russ White 98b3ab772e
Merge pull request #10629 from leonshaw/fix/mp-evpn-nh
lib, zebra, bgpd: Move route EVPN flag to nexthop
2022-06-23 07:00:33 -04:00
anlan_cs f1f4a65288 zebra: remove redundant calling hook for fpm
Since the calling hook for old fpm is done in `rib_uninstall_kernel()`
inside, this calling place outside should be redundant. Just remove it.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-06-17 17:42:12 -04:00
Xiao Liang 5609e70fb8 lib, zebra, bgpd: Move route EVPN flag to nexthop
Multipath route may have mixed nexthops of EVPN and IP unicast. Move
EVPN flag to nexthop to support such cases.

Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
2022-06-10 17:12:48 +08:00
Donald Sharp 20ceb5475d zebra: Remove unused function route_entry_copy_nexthops
This function is no longer used.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-13 16:11:09 -04:00
Donatas Abraitis 6006b807b1 *: Properly use memset() when zeroing
Wrong: memset(&a, 0, sizeof(struct ...));
    Good:  memset(&a, 0, sizeof(a));

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-11 14:08:47 +03:00
David Lamparter 425fd200c9 zebra: add rib_match_ipv6_multicast variant
... for IPv6, analogous to v4.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-26 16:15:00 +02:00
Stephen Worley 5d41413833 zebra: add support for protodown reason code
Add support for setting the protodown reason code.

829eb208e8

These patches handle all our netlink code for setting the reason.

For protodown reason we only set `frr` as the reason externally
but internally we have more descriptive reasoning available via
`show interface IFNAME`. The kernel only provides a bitwidth of 32
that all userspace programs have to share so this makes the most sense.

Since this is new functionality, it needs to be added to the dplane
pthread instead. So these patches, also move the protodown setting we
were doing before into the dplane pthread. For this, we abstract it a
bit more to make it a general interface LINK update dplane API. This
API can be expanded to support gernal link creation/updating when/if
someone ever adds that code.

We also move a more common entrypoint for evpn-mh and from zapi clients
like vrrpd. They both call common code now to set our internal flags
for protodown and protodown reason.

Also add debugging code for dumping netlink packets with
protodown/protodown_reason.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-03-09 17:52:44 -05:00
Donald Sharp 16d91fce15 zebra: Prevent crash if ZEBRA_ROUTE_ALL is used for a route type
FRR will crash when the re->type is a ZEBRA_ROUTE_ALL and it
is inserted into the meta-queue.  Let's just put some basic
code in place to prevent a crash from happening.  No routing
protocol should be using ZEBRA_ROUTE_ALL as a value but
bugs do happen.  Let's just accept the weird route type
gracefully and move on.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-28 09:50:35 -05:00
Mark Stapp cd787a8a45 zebra: use dataplane to read interface NETCONF info
Use the dataplane to query and read interface NETCONF data;
add netconf-oriented data to the dplane context object, and
add accessors for it. Add handler for incoming update
processing.

Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2022-02-25 10:18:32 -05:00
Mark Stapp 728f2017ae zebra: add dplane type for NETCONF data
Add a new dplane op for interface NETCONF data; add the new
enum value to several switch statements.

Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2022-02-25 09:53:02 -05:00
Donald Sharp cc9f21da22 *: Change thread->func to return void instead of int
The int return value is never used.  Modify the code
base to just return a void instead.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-23 19:56:04 -05:00
Donald Sharp ce649b9d11 zebra: Abstract nhg deletion to reduce code duplication
Reduce code duplication when we are cleaning up nexthop
groups.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-07 16:10:36 -05:00
Donald Sharp c6eee91f66 zebra: Fix ships in the night issue
When using wait for install there exists situations where
zebra will issue several route change operations to the kernel
but end up in a state where we shouldn't be at the end
due to extra data being received.  Example:

a) zebra receives from bgp a route change, installs sends the
route to the kernel.
b) zebra receives a route deletion from bgp, removes the
struct route entry and then sends to the kernel a deletion.
c) zebra receives an asynchronous notification that (a) succeeded
but we treat this as a new route.

This is the ships in the night problem.  In this case if we receive
notification from the kernel about a route that we know nothing
about and we are not in startup and we are doing asic offload
then we can ignore this update.

Ticket: #2563300
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-07 16:10:03 -05:00
Mark Stapp 3d1ff4bfdb
Merge pull request #10409 from idryzhov/zebra-mq-clean-crash
zebra: fix cleanup of meta queues on vrf disable
2022-02-02 08:35:00 -05:00
Igor Ryzhov 0ef6eacc95 zebra: fix cleanup of meta queues on vrf disable
Current code treats all metaqueues as lists of route_node structures.
However, some queues contain other structures that need to be cleaned up
differently. Casting the elements of those queues to struct route_node
and dereferencing them leads to a crash. The crash may be seen when
executing bgp_multi_vrf_topo2.

Fix the code by using the proper list element types.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2022-02-01 18:20:30 +03:00
Mark Stapp b86c1f4fcc zebra: name the route_entry opaque struct more specifically
The name 'opaque' is a little general - call the route_entry
struct 're_opaque' to make it more specific.

Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2022-01-31 08:50:50 -05:00
Donald Sharp 5ef3568f22 zebra: Use %pRN instead of %pFX whenver possible
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-01-18 08:39:41 -05:00
Donald Sharp a7704e1b98 zebra: Modify route_notify_internal to use a route_node
Pass in the route_node that is under consideration
into route_notify_internal to allow calling functions
to reduce stack size as well as looking up data.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-01-18 08:39:41 -05:00
Donald Sharp 69a2d597d2 zebra: Cleanup %pFX to %pRN in rib_process_result
The dest_pfx was pretty much only ever used for
debug output and FRR already knows the rn.  So
use that instead.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-01-18 08:39:41 -05:00
Donald Sharp 085e8f8f6b zebra: Reduce unneeded lookup in rib_process
the lookup of the src_p and dest_p is not needed
since the values are never used.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-01-18 08:39:40 -05:00