Commit Graph

6021 Commits

Author SHA1 Message Date
Donald Sharp
466efab870
Merge pull request #17136 from opensourcerouting/clang-sa-19
*: fix clang-19 SA
2024-10-17 07:38:28 -04:00
Russ White
75e34c032b
Merge pull request #16452 from louis-6wind/fix-ipv4-mapped-ipv6-display
lib, test: fix display ipv4 mapped ipv6 addresses
2024-10-16 13:01:52 -04:00
Donatas Abraitis
1ce225d7e4
Merge pull request #17076 from donaldsharp/rnh_and_redistribution_nexthop_num_fix
*: Fix up improper handling of nexthops for nexthop tracking
2024-10-16 16:34:08 +03:00
Russ White
80dc863d92
Merge pull request #16946 from opensourcerouting/fix/match_src-peer
bgpd: Implement match src-peer ... command
2024-10-16 07:51:20 -04:00
Louis Scalbert
84ab0213fc lib, test: fix display ipv4 mapped ipv6 addresses
Display ipv4 mapped ipv6 addresses in the format ::ffff:A.B.C.D.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-10-16 13:45:46 +02:00
David Lamparter
17f512c10d lib: fix invalid use of errno in PTM
errno is only valid if there was an actual error.  A zero return value
isn't an error, it's either EOF or an empty datagram depending on
context.  Fix the logic.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16 13:30:25 +02:00
David Lamparter
a67df2a17f lib: guard close() in netns code
clang-SA complains that ns->fd could be invalid.  Add a guard.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16 13:30:25 +02:00
David Lamparter
40d4a47c0e lib: make clang-SA not choke on defun_lex.l
The flex-generated code is disabled for clang-SA builds already, but
that means that function prototypes are missing too.  Just add dummy
function prototypes so clang-SA can process the file.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16 13:30:25 +02:00
David Lamparter
c071b4370d *: clang-SA switch-enum initializer workarounds
In these cases the value assigned by the switch block is used directly
rather than returned.  Mark the initial/default value as used so
clang-SA doesn't complain about it.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16 13:30:25 +02:00
David Lamparter
49cf311d46 *: clang-SA friendly switch-enum-return-string
clang-19's SA complains about unused initializers for this kind of
"switch (enum) { return string }" kind of code.  Use direct string
return values to avoid the issue.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16 13:00:11 +02:00
Russ White
de02471a8d
Merge pull request #17038 from opensourcerouting/feature/bgp_set_metric_internal
bgpd: Derive and set MED from IGP or AIGP
2024-10-15 17:58:05 -04:00
Donald Sharp
645a9e4f83 *: Fix up improper handling of nexthops for nexthop tracking
Currently FRR needs to send a uint16_t value for the number
of nexthops as well it needs the ability to properly decode
all of this.  Find and handle all the places that this happens.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-15 11:57:23 -04:00
Russ White
884e183f4a
Merge pull request #17058 from opensourcerouting/fix/apply_route_maps_earlier
lib: Apply and generate route-map commands earlier before any other protocol
2024-10-15 11:15:41 -04:00
Donatas Abraitis
e94f48498d bgpd: Implement set metric aigp command
Same as `set metric igp`, but in this case accumulated IGP metric is being
sent as MED attribute.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-10-15 17:42:52 +03:00
Donatas Abraitis
f677fc8db3 bgpd: Implement set metric igp command
Set metric automatically from the path info (IGP protocol).

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-10-15 17:36:51 +03:00
Donatas Abraitis
b9a9be492e bgpd: Move some non BGP-specific route-map functions to lib
They are managed under `frr-route-map`, not under `frr-bgp-route-map`.

Fixes: https://github.com/FRRouting/frr/issues/17055

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-10-10 16:52:57 +03:00
Donatas Abraitis
310ca4f33d lib: Apply and generate route-map commands earlier before any other protocol
If e.g. BGP neighbor is using a route-map at the boot, that is not yet created,
then the log is spammed with `The route-map 'X' does not exist`.

Processing earlier, should do the trick.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-10-10 16:24:24 +03:00
Igor Ryzhov
c10e4d336b
Merge pull request #17015 from LabNConsulting/chopps/load-internal-ietf-yang-library
lib: add flag to have libyang load internal ietf-yang-library module
2024-10-07 20:33:23 +03:00
Christian Hopps
e8648a0c72 lib: add flag to have libyang load internal ietf-yang-library module
Mgmtd makes use of libyang's internal ietf-yang-library module to add
support for said module to FRR management. Previously, mgmtd was loading
this module explicitly; however, that required that libyang's
`ietf-yang-library.yang` module definition file be co-located with FRR's
yang files so that it (and ietf-datastore.yang) would be found when
searched for by libyang using FRRs search path. This isn't always the
case depending on how the user compiles and installs libyang so mgmtd
was failing to run in some cases.

Instead of doing it the above way we simply tell libyang to load it's
internal version of ietf-yang-library when we initialize the libyang
context.

This required adding a boolean to a couple of the init functions which
is why so many files are touched (although all the changes are minimal).

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-10-07 03:32:44 +00:00
Donna Sharp
f62dfc5d53 lib,zebra: remove unused ZEBRA_VRF_UNREGISTER
Signed-off-by: Donna Sharp <dksharp5@gmail.com>
2024-10-06 19:40:49 -04:00
Louis Scalbert
db7b9a5a70 lib: remove unused bfd defines
Remove unused bfd defines

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-10-03 13:37:55 +02:00
Donald Sharp
0bc79f5e51 lib: nexthop code should use uint16_t for nexthop counting
It's possible to specify via the cli and configure how many
nexthops that are allowed on the system.  If you happen to
have > 255 then things are about to get interesting otherwise.

Let's allow up to 65k nexthops (ha!)

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-01 15:38:14 -04:00
Rafael Zalamena
660146b57a lib: fix calloc warning on recent compiler
Fix the following compiler warning:
```
lib/elf_py.c: In function _elffile_load_:
lib/elf_py.c:1310:34: warning: _calloc_ sizes specified with _sizeof_ in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
 1310 |         w->sects = calloc(sizeof(PyObject *), w->ehdr->e_shnum);
      |                                  ^~~~~~~~
lib/elf_py.c:1310:34: note: earlier argument should specify number of elements, later size of each element
```

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2024-09-30 11:31:56 -03:00
Donatas Abraitis
5d3da70ba3 bgpd: Implement match src-peer ... command
To match source peer on the outgoing direction.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-09-27 23:01:06 +03:00
Jafar Al-Gharaibeh
2203dc4777
Merge pull request #16909 from donaldsharp/help
lib: Help text correction
2024-09-24 21:23:03 -05:00
Donald Sharp
d722e99075 lib: Removed unused RFP_DEFAULTS_NODE
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-24 16:11:43 -04:00
Donald Sharp
e54261e20d lib, zebra: TABLE_NODE is not used
No-one is using this, remove

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-24 16:05:54 -04:00
Donald Sharp
4e12ba08c4 lib: Help text correction
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-24 15:25:49 -04:00
Donatas Abraitis
4b0f4f96ac lib: Load built-in Lua functions
We can't use even `string()` function because built-in functions are not
loaded.

Testing with:

```
$ cat /etc/frr/scripts/zebra.lua
function on_rib_process_dplane_results(ctx)
	log.warn(string.upper("testas"))
	return {}
end
```

This results to "TESTAS" in the logs.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-09-24 13:13:50 +03:00
Donatas Abraitis
74f12853c6
Merge pull request #16738 from odivlad/fix-stdout-fork
lib: Attach stdout to child only if --log=stdout and stdout FD is a tty
2024-09-19 22:24:19 +02:00
Christian Hopps
c5df98aece mgmtd: add ietf-yang-library support
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-09-17 22:27:36 -04:00
Christian Hopps
b097a966cb lib: mgmtd: add changed and created to edit-reply msg
- This is used for various return values in RESTCONF

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

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-09-17 03:04:59 -04:00
Christian Hopps
0913d9fc0e lib: constify yang_resolve_snode_xpath results
Signed-off-by: Christian Hopps <chopps@labn.net>

ang
2024-09-17 03:04:59 -04:00
Carmine Scarpitta
04025514ed lib: Include SID structure in seg6local nexthop
Include SID structure information in seg6local nexthop data structure.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-09-15 17:23:34 +02:00
Vladislav Odintsov
0e3c5e8e59 lib: Attach stdout to child only if --log=stdout and stdout FD is a tty
Prior to this commit stdout of a process started in a daemon mode was
attached to a calling process.
As a result a calling process hung for infinity.

Signed-off-by: Vladislav Odintsov <vlodintsov@k2.cloud>
2024-09-10 19:06:13 +03:00
Russ White
add56c61dd
Merge pull request #15259 from dmytroshytyi-6WIND/nexthop_resolution
zebra: add LSP entry to nexthop via recursive (part 2)
2024-09-10 10:04:08 -04:00
Christian Hopps
035843705b lib: fix clang SA warnings
Also, cleanup some unreachable code in `nb_op_sib_next()`.

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-09-07 22:12:03 -04:00
Donald Sharp
d97c535c1e *: Create termtable specific temp memory
When trying to track down a MTYPE_TMP memory leak
it's harder to search for it when you happen to
have some usage of ttable_dump.  Let's just give
it it's own memory type so that we can avoid
confusion in the future.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-01 13:07:46 -04:00
Jafar Al-Gharaibeh
77e1a26faa
Merge pull request #16664 from mjstapp/igor_debug_simplify
*: simplify frrlib debug
2024-08-29 11:51:53 -04:00
Mark Stapp
79e0c6a2e0
Merge pull request #16672 from raja-rajasekar/vty_out_mem_spike_srujana
lib: Memory spike reduction for sh cmds at scale
2024-08-28 15:29:23 -04:00
Donatas Abraitis
a0a2a35ed3 lib: Add a helper function to dump Lua stack
Very handy for debugging.

In Lua script just use "log.trace(table)":

```
function on_rib_process_dplane_results(ctx)
	log.trace(ctx.rinfo.zd_ng)
end
```

You will get something like:

```
Aug 28 17:04:36 donatas-laptop zebra[3782199]: [GCZ7N-MM9D9] {
                                                 1: {
                                                   type: 2
                                                   weight: 1
                                                   flags: 5
                                                   backup_idx: 0
                                                   vrf_id: 0
                                                   nh_encap_type: 0
                                                   gate: {
                                                     value: 5.87967e+08
                                                     string: "192.168.11.35"
                                                   }
                                                   nh_label_type: 0
                                                   srte_color: 0
                                                   ifindex: 0
                                                   backup_num: 0
                                                 }
                                                 2: {
                                                   type: 3
                                                   weight: 1
                                                   flags: 3
                                                   backup_idx: 0
                                                   vrf_id: 0
                                                   nh_encap_type: 0
                                                   nh_label_type: 0
                                                   srte_color: 0
                                                   ifindex: 4
                                                   backup_num: 0
                                                 }
                                               }
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-08-28 17:08:45 +03:00
Donatas Abraitis
b1012b693f lib: Start from 1, not 0 when creating Lua tables for nexthops
Lua technically enumerates arrays from 1, not 0.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-08-28 15:31:47 +03:00
Srujana
9112fb367b lib: Memory spike reduction for sh cmds at scale
The output buffer vty->obuf is a linked list where
each element is of 4KB.
Currently, when a huge sh command  like <show ip route json>
is executed on a large scale, all the vty_outs are
processed and the entire data is accumulated.
After the entire vty execution, vtysh_flush proceeses
and puts this data in the socket (131KB at a time).

Problem here is the memory spike for such heavy duty
show commands.

The fix here is to chunkify the output on VTY shell by
flushing it intermediately for every 128 KB of output
accumulated and free the memory allocated for the buffer data.

This way, we achieve ~25-30% reduction in the memory spike.

Fixes: #16498
Note: This is a continuation of MR #16498

Signed-off-by: Srujana <skanchisamud@nvidia.com>

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2024-08-27 12:47:00 -07:00
Igor Ryzhov
830972cab2 lib: common debug status output
Implement common code for debug status output and remove daemon-specific
code that is duplicated everywhere.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-08-27 09:53:02 -04:00
Igor Ryzhov
82e52e0f21 lib: common debug config output
Implement common code for debug config output and remove daemon-specific
code that is duplicated everywhere.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-08-27 09:53:02 -04:00
Igor Ryzhov
5dac696154 lib: rework debug init
The debug library allows to register a `debug_set_all` callback which
should enable all debugs in a daemon. This callback is implemented
exactly the same in each daemon. Instead of duplicating the code, rework
the lib to allow registration of each debug type, and implement the
common code only once in the lib.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-08-27 09:53:02 -04:00
Mark Stapp
b4dae97381
Merge pull request #16609 from donaldsharp/singleton_no_weight
Reduce the number of Singleton objects when using weight for NHG's
2024-08-23 16:19:29 -04:00
Donald Sharp
a04cca6f74
Merge pull request #16633 from Jafaral/fix-version-build
config: fix missing case when reporting version 'configured with'
2024-08-23 14:45:33 -04:00
Jafar Al-Gharaibeh
4b050cb080 config: fix missing case when reporting version 'configured with'
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2024-08-22 14:28:49 -05:00