Commit Graph

34795 Commits

Author SHA1 Message Date
Igor Ryzhov
f9960582ee lib: fix access-list entry update
When an access-list entry is updated, current NB code calls notification
hooks for each updated field. It means that when multiple fields of an
entry are changed in a single commit, the hooks are run with an interim
state of an access-list instead of a final one. To fix the issue, we
should call the hooks once, after all fields of an entry are updated.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
(cherry picked from commit a9460ae713)
2024-02-27 11:40:00 +00:00
Donatas Abraitis
1d64549c3d
Merge pull request #15435 from FRRouting/mergify/bp/dev/10.0/pr-15387
bgpd: fix no bgp as-path access-list issue  (backport #15387)
2024-02-27 13:36:01 +02:00
Francois Dumontet
8acb85bd5b bgpd: fix no bgp as-path access-list issue
router bgp 65001
 no bgp ebgp-requires-policy
 neighbor 192.168.1.2 remote-as external
 neighbor 192.168.1.2 timers 3 10
 address-family ipv4 unicast
  neighbor 192.168.1.2 route-map r2 in
 exit-address-family
!
ip prefix-list p1 seq 5 permit 172.16.255.31/32
!
route-map r2 permit 10
 match ip address prefix-list p1
 set as-path exclude 65003
route-map r2 permit 20
 set as-path exclude all
!

we make the following commands

bgp as-path access-list FIRST permit ^65
bgp as-path access-list SECOND permit 2
 route-map r2 permit 6
  set as-path exclude as-path-access-list SECOND

and then

no bgp as-path access-list SECOND permit 2
clear bgp *

we have the following crash in bgp

               Stack trace of thread 536083:
                #0  0x00007f87f8aacfe1 raise (libpthread.so.0 + 0x12fe1)
                #1  0x00007f87f8cf6870 core_handler (libfrr.so.0 +
		    0xf6870)
                #2  0x00007f87f8aad140 __restore_rt (libpthread.so.0 +
		    0x13140)
                #3  0x00007f87f89a5122 __GI___regexec (libc.so.6 +
		    0xdf122)
                #4  0x000055d7f198b4a7 aspath_filter_exclude_acl (bgpd +
		    0x2054a7)
                #5  0x000055d7f1902187 route_set_aspath_exclude (bgpd +
		    0x17c187)
                #6  0x00007f87f8ce54b0 route_map_apply_ext (libfrr.so.0
		    + 0xe54b0)
                #7  0x000055d7f18da925 bgp_input_modifier (bgpd +
		    0x154925)
                #8  0x000055d7f18e0647 bgp_update (bgpd + 0x15a647)
                #9  0x000055d7f18e4772 bgp_nlri_parse_ip (bgpd +
		    0x15e772)
                #10 0x000055d7f18c38ae bgp_nlri_parse (bgpd + 0x13d8ae)
                #11 0x000055d7f18c6b7a bgp_update_receive (bgpd +
		    0x140b7a)
                #12 0x000055d7f18c8ff3 bgp_process_packet (bgpd +
		    0x142ff3)
                #13 0x00007f87f8d0dce0 thread_call (libfrr.so.0 +
		    0x10dce0)
                #14 0x00007f87f8cacb28 frr_run (libfrr.so.0 + 0xacb28)
                #15 0x000055d7f18435da main (bgpd + 0xbd5da)
                #16 0x00007f87f88e9d0a __libc_start_main (libc.so.6 +
		    0x23d0a)
                #17 0x000055d7f18415fa _start (bgpd + 0xbb5fa)

analysis

crash is due to the fact that there were always a pointer from
as-path exclude to deleted as-path access list.

fix
we add a backpointer mechanism to manage the dependency beetween
as-path access-list  and aspath exclude.

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
(cherry picked from commit 100ef15262)
2024-02-27 07:53:25 +00:00
Francois Dumontet
8273b61ef0 tests: extend tests for aspath exclude
adding a tests about:
"no bgp as-path access-list" command.

the folloxing "clear bgp *" command leads to the
crash exhibited above.

a sleep had been added to capture the crash befor the end of scenario.

50	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
[Current thread is 1 (Thread 0x7f5f05cbb9c0 (LWP 1371086))]
(gdb) bt
    context=0x7ffcf2c216c0) at lib/sigevent.c:248
    acl_list=0x55c976ec03c0) at bgpd/bgp_aspath.c:1688
    dummy=0x7ffcf2c22340, object=0x7ffcf2c21e70) at bgpd/bgp_routemap.c:2401
    match_object=0x7ffcf2c21e70, set_object=0x7ffcf2c21e70, pref=0x0)
    at lib/routemap.c:2687
    attr=0x7ffcf2c220b0, afi=AFI_IP, safi=SAFI_UNICAST, rmap_name=0x0, label=0x0,
    num_labels=0, dest=0x55c976ebeaf0) at bgpd/bgp_route.c:1807
    addpath_id=0, attr=0x7ffcf2c22450, afi=AFI_IP, safi=SAFI_UNICAST, type=10,
    sub_type=0, prd=0x0, label=0x0, num_labels=0, soft_reconfig=0, evpn=0x0)
    at bgpd/bgp_route.c:4424
    packet=0x7ffcf2c22410) at bgpd/bgp_route.c:6266
    packet=0x7ffcf2c22410, mp_withdraw=false) at bgpd/bgp_packet.c:341
    peer=0x55c976e89ed0, size=43) at bgpd/bgp_packet.c:2414
    at bgpd/bgp_packet.c:3899

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
(cherry picked from commit 324fa21015)
2024-02-27 07:53:24 +00:00
Donatas Abraitis
3497d85dcc
Merge pull request #15433 from FRRouting/mergify/bp/dev/10.0/pr-15430
lib: fix setting temporary log options for libyang (backport #15430)
2024-02-27 09:48:15 +02:00
Igor Ryzhov
0b2d943811 lib: fix setting temporary log options for libyang
By calling `ly_log_options` with `LY_LOSTORE`, the current code
effectively disables libyang logging and never enables it back. The call
is done to get the current logging options, but we don't really need
that. When looking for a schema node, we don't want neither to log nor
to store the error, so simply set the temporary options to 0.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
(cherry picked from commit 3cd6ddaec6)
2024-02-26 15:27:27 +00:00
Igor Ryzhov
493c991315
Merge pull request #15428 from FRRouting/mergify/bp/dev/10.0/pr-15426
bgpd, yang: fix missing mandatory/default statements on some leafs (backport #15426)
2024-02-26 13:52:38 +02:00
Igor Ryzhov
7dd059f6f3 bgpd, yang: fix missing mandatory/default statements on some leafs
The code expects these leafs to always exist. If they are not set, the
daemon would crash. CLI always sets them, but we should properly mark
them as mandatory/default to prevent them from being missed when using
the API.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
(cherry picked from commit 83a3b0f10f)
2024-02-26 07:44:44 +00:00
Donatas Abraitis
3496e9b205
Merge pull request #15425 from FRRouting/mergify/bp/dev/10.0/pr-15423
lib: fix processing of choices in northbound (backport #15423)
2024-02-26 08:06:57 +02:00
Christian Hopps
6a921b2fc0 tests: add test for required choice/np-container callbacks
Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit e5acf6797c)
2024-02-25 21:55:03 +00:00
Christian Hopps
5b499a6bf7 tests: add test for northbound ordering fix
Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit a37f5f9153)
2024-02-25 21:55:03 +00:00
Igor Ryzhov
2ca3dc7701 lib: fix nb callbacks for containers inside choice case
Containers inside a choice's case must be treated as presence containers
as they can be explicitly created and deleted. They must have `create`
and `destroy` callbacks, otherwise the internal data they represent may
never be deleted.

The issue can be reproduced with the following steps:
- create an access-list with destination-network params
  ```
  # access-list test seq 1 permit ip any 10.10.10.0 0.0.0.255
  ```
- delete the `destination-network` container
  ```
  # mgmt delete-config /frr-filter:lib/access-list[name='test'][type='ipv4']/entry[sequence='1']/destination-network
  # mgmt commit apply
  MGMTD: No changes found to be committed!
  ```

As the `destination-network` container is non-presence, and all its
leafs are mandatory, mgmtd doesn't see any changes to be commited and
simply updates its YANG data tree without passing any updates to backend
daemons.

This commit fixes the issue by requiring `create` and `destroy`
callbacks for containers inside choice's cases.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
(cherry picked from commit 0b905f7404)
2024-02-25 21:55:03 +00:00
Igor Ryzhov
f9b30889e3 lib: fix order of northbound operations
When ordering operations, destroys must always come before other
operations, to correctly cover the change of a "case" in a "choice".

The problem can be reproduced with the following commands:
```
access-list test seq 1 permit 10.0.0.0/8
access-list test seq 1 permit host 10.0.0.1
access-list test seq 1 permit 10.0.0.0/8
```

Before this commit, the order of changes would be the following:
- `access-list test seq 1 permit 10.0.0.0/8`
  - `modify` for `ipv4-prefix`
- `access-list test seq 1 permit host 10.0.0.1`
  - `destroy` for `ipv4-prefix`
  - `modify` for `host`
- `access-list test seq 1 permit 10.0.0.0/8`
  - `modify` for `ipv4-prefix`
  - `destroy` for `host`

As `destroy` for `host` is called last, it rewrites the fields that were
filled by `modify` callback of `ipv4-prefix`. This commit fixes this
problem by always calling `destroy` callbacks first.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
(cherry picked from commit 38b85e0c2b)
2024-02-25 21:55:03 +00:00
Igor Ryzhov
0caa1711e1
Merge pull request #15422 from FRRouting/mergify/bp/dev/10.0/pr-15421
lib: fix processing of notifications on mgmt fe client (backport #15421)
2024-02-24 17:51:16 +02:00
Igor Ryzhov
fc114b168d lib: fix processing of notifications on mgmt fe client
Notifications are sent by mgmtd for each session of a client, so they
should be processed once per each session.

Also, add session_id parameter to an async_notification callback as all
other callbacks have this parameter.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
(cherry picked from commit 13359c5cc9)
2024-02-23 21:30:46 +00:00
Igor Ryzhov
9a3284c2b5
Merge pull request #15403 from FRRouting/mergify/bp/dev/10.0/pr-15401
Fix order of NB callbacks (and a crash) (backport #15401)
2024-02-21 15:28:28 +02:00
Igor Ryzhov
424d607932 lib: fix order of northbound callbacks
When ordering the NB callbacks according to their priorities, if the
operation is "destroy" we should reverse the order, to destroy the
dependants before the dependencies.

This fixes the crash, that can be reproduced with the following steps:
```
frr# conf term file-lock
frr(config)# affinity-map map bit-position 10
frr(config)# interface test
frr(config-if)# link-params
frr(config-link-params)# affinity map
frr(config-link-params)# exit
frr(config-if)# exit
frr(config)# mgmt commit apply
frr(config)# no affinity-map map
frr(config)# interface test
frr(config-if)# link-params
frr(config-link-params)# no affinity map
frr(config-link-params)# exit
frr(config-if)# exit
frr(config)# mgmt commit apply
```

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
(cherry picked from commit 01f371a677)
2024-02-21 08:02:18 +00:00
Igor Ryzhov
21af614945 lib: add missing priority for affinity map callbacks
Other objects depend on affinity-maps being created before them by using
leafref with require-instance true. Set the priority to ensure that.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
(cherry picked from commit 323caf1d70)
2024-02-21 08:02:18 +00:00
Igor Ryzhov
4d1affb4e7
Merge pull request #15398 from FRRouting/mergify/bp/dev/10.0/pr-15381
lib: mgmtd: add xpath arg to YANG notification message (backport #15381)
2024-02-20 23:28:08 +02:00
Christian Hopps
06ccaac51b lib: mgmtd: add xpath arg to notification message
Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit 4a93d171c2)
2024-02-20 17:14:55 +00:00
Christian Hopps
2a9d407cc5 lib: always call new notification hooks too
- call the new notification hooks when backends call the old notification
posting API.

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit 1d4ea437e4)
2024-02-20 17:14:54 +00:00
Igor Ryzhov
d331c7fb6a
Merge pull request #15380 from FRRouting/mergify/bp/dev/10.0/pr-15371
Fixes for the northbound/mgmtd (backport #15371)
2024-02-16 00:10:18 +02:00
Christian Hopps
2d3b40dce6 lib: actually create the tree for the conversion
Before this fix would always return empty results b/c there was no
libyang tree to print to output format.

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit dff28248c3)
2024-02-15 18:03:50 +00:00
Christian Hopps
ca30662b7f lib: fix memleak on success
Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit b8e07049a8)
2024-02-15 18:03:50 +00:00
Donatas Abraitis
6c86e3a59c tools: Change the major version from 9 to 10
It was decided to keep it 10, not 9 as planned initially.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-02-13 21:20:41 +02:00
Donald Sharp
9fd7bf4cbb
Merge pull request #15234 from opensourcerouting/snmp-topotest-fixes
topotests: fix snmptrap log OID parsing
2024-02-13 10:59:30 -05:00
Russ White
e74c3b0746
Merge pull request #15320 from donaldsharp/vtysh_limit_fds
lib, ospfclient, vtysh: Allow for a minimum fd poll size
2024-02-13 09:50:00 -05:00
Russ White
17a0a625f0
Merge pull request #15284 from opensourcerouting/feature/bgpd_announce_rpki_state_knob
bgpd: Add neighbor X send-community extended rpki command
2024-02-13 09:35:10 -05:00
Christian Hopps
7b94a923ae
Merge pull request #15042 from Orange-OpenSource/ospf-te
ospfd: Add Opaque LSA decoder for json output
2024-02-13 05:37:29 -05:00
Christian Hopps
60cb834ead
Merge pull request #15361 from idryzhov/fix-be-interested
mgmtd: fix be_is_client_interested
2024-02-12 20:11:20 -05:00
Donatas Abraitis
26faf341ef
Merge pull request #15352 from louis-6wind/fix-leak-recursive
bgpd: fix route recursion on leaked routes
2024-02-12 21:42:03 +02:00
Igor Ryzhov
745a2bd8b3 mgmtd: fix be_is_client_interested
Backend "subscribe" API allows daemons to dynamically register xpaths
they are interested in. Such xpaths are not stored in hardcoded
config/oper xpath arrays so this function fails to understand that a
backend daemon is interested in them. Fix by using dynamic xpath maps
instead which store both hardcoded and dynamic xpaths.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-12 20:55:34 +02:00
Igor Ryzhov
24ca4f408b
Merge pull request #15358 from LabNConsulting/chopps/doc-update
update doc with new more strict protobuf requirements
2024-02-12 19:52:35 +02:00
Olivier Dugeon
b46a1fe826 tests: adapt ospfapiclient test to new json output
Following new json decoder for Opaque LSA, this patch adapts the ospfapiclient
test to the new json output.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2024-02-12 17:52:00 +01:00
Olivier Dugeon
6fcc86d37a ospfd: Decode Extended Link & Prefix TLVs for json
When dumping ospf database with json output, decode Extended Link and Extended
Prefix TLVs and sub-TLVs.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2024-02-12 17:52:00 +01:00
Olivier Dugeon
b27d9e4d3b ospfd: Decode Router Info. TLVs for json output
When dumping ospf database with json output, decode Router Information TLVs
and sub-TLVs.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2024-02-12 17:52:00 +01:00
Olivier Dugeon
95c9cb9aa9 ospfd: Decode TE TLVs for json output
When dumping ospf database with json output, decode Traffic Engineering TLVs
and sub-TLVs.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2024-02-12 17:52:00 +01:00
Olivier Dugeon
aa2b539bf5 ospfd: Prepare Opaque LSA for json output
Instead of output bulk of data with json output, prepare json context to decode
opaque TLVs and sub-TLVs.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2024-02-12 17:52:00 +01:00
Christian Hopps
8d6e7a350f tests: fix grpc test
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-02-12 07:48:50 -05:00
Christian Hopps
6374970cb8 doc: docker: update with new more strict protobuf requirements
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-02-12 06:48:12 -05:00
Christian Hopps
d71710a910
Merge pull request #15355 from idryzhov/fix-mgmtd-notif
Fix and rework YANG notifications
2024-02-12 06:17:38 -05:00
Donald Sharp
9800590ccc
Merge pull request #15346 from opensourcerouting/fix/memory_optimizations
Some more memory optimizations
2024-02-11 21:33:44 -05:00
Donald Sharp
6d3f9bf605
Merge pull request #15356 from idryzhov/configure-sysconfdir
build: fix configure output
2024-02-11 21:33:00 -05:00
Donatas Abraitis
400fe8db63
Merge pull request #15347 from askorichenko/test-bgp-ttl
bgpd: fix minttl copying during peer reset
2024-02-11 22:12:32 +02:00
Igor Ryzhov
e9d41d1441 build: fix configure output
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-11 13:34:59 +02:00
Igor Ryzhov
3ac3a6605d lib, mgmtd: rework processing of yang notifications
Currently, YANG notification processing is done using a special type of
callbacks registered in backend clients. In this commit, we start using
regular northbound infrastructure instead, because it already has a
convenient way of registering xpath-specific callbacks without the need
for creating additional structures for each necessary notification. We
also now pass a notification data to the callback, instead of a plain
JSON. This allows to use regular YANG library functions for inspecting
notification fields, instead of manually parsing the JSON.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-11 13:26:52 +02:00
Donald Sharp
8aeb63634d
Merge pull request #15354 from cscarpitta/fix/fpm-pb-add-missing-include
qpb: Add missing `#include nexthop.h`
2024-02-10 20:52:47 -05:00
Carmine Scarpitta
6d1c04f4d0 qpb: Add missing #include nexthop.h
In `qpb.h` we have a bunch of functions that make use of
`union g_addr`. `union g_addr` is defined in `nexthop.h`, which
actually is NOT included in `qpb.h`.

Let's add the missing `#include nexthop.h`.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-02-10 00:44:50 +01:00
Igor Ryzhov
7d8064c6d4
Merge pull request #15353 from vjardin/yang_converted
mgmtd: ripng, libs fully converted
2024-02-10 01:27:23 +02:00
Igor Ryzhov
d94f80fbc4 lib, mgmtd: fix processing of yang notifications
Current code assumes that notification is always sent in stripped JSON
format and therefore notification xpath starts at the third symbol of
notification data. Assuming JSON is more or less fine, because this
representation is internal to FRR, but the assumption about the xpath is
wrong, because it won't work for not top-level notifications. YANG
allows to define notification as a child for some data node deep into
the tree and in this case notification data contains not only the
notification node itself, but also all its parents.

To fix the issue, parse the notification data and get its xpath from its
schema node.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-10 01:00:24 +02:00