Commit Graph

5340 Commits

Author SHA1 Message Date
Louis Scalbert
8b8861401a lib: clarify flex-algo mtype
Clarify flex-algo MTYPE by creating a specific MTYPE definition to the
database of flex-algo information.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-04-27 15:35:50 +02:00
Mark Stapp
b38aed324d
Merge pull request #13374 from opensourcerouting/build-fix-rmap-yang
build: fix frr-if-rmap.yang model embedding
2023-04-25 15:26:19 -04:00
Russ White
4855ca5e56
Merge pull request #13310 from opensourcerouting/feature/bgpd_node_target_extended_community
bgpd: Add Node Target Extended Communities support
2023-04-25 11:06:23 -04:00
Christian Hopps
7f6b20074f lib: fix style warns and get rid of "!" for success
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-04-24 11:20:48 -04:00
David Lamparter
edaee5461d build: fix frr-if-rmap.yang model embedding
This was missed somewhere along the line, causing ripd to not start.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-04-24 17:02:34 +02:00
Christian Hopps
9b96394d05
Merge pull request #13149 from pushpasis/mgmt_cleanup_zlog
mgmtd, lib: Cleanup zlog_err()
2023-04-24 11:00:08 -04:00
Donald Sharp
3eefea9249
Merge pull request #13350 from opensourcerouting/typesafe-fixes-20230421
lib: typesafe shenanigans
2023-04-23 15:06:59 -04:00
Olivier Dugeon
30584b6f6a lib: Fix memory leak in in Link State
When using ls_stream2ted() function to parse Opaque Link State message to local
TED, in case of vertex or subnet deletion, the function return a pointer to the
deleted ls_element instead of NULL. This could lead into a potential pointer
corruption when caller try to access to the deleted ls_element.

This patch ensure that the ls_element pointer return by ls_stream2ted()
function is NULL when the message event is a delete operation for vertex and
subnet. Note that edge deletion was correctly handled.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2023-04-21 18:24:51 +02:00
Olivier Dugeon
871b46e7eb lib: Link State memory corruption
In function ls_find_subnet(), prefix argument is directly copied into
subnet.key structure to find corresponding subnet in RB Tree. This could leadr
to a memory corruption. Function prefix_copy() must be used instead.

This patch replaces the direct prefix copy by a call to prefix_copy() function
to avoid this memory issue.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2023-04-21 18:09:28 +02:00
David Lamparter
5523a505f4 lib: fix _hash_member() crash w/ empty hash
The typesafe hash _member() didn't check tabshift/count before
proceeding to look at the hash table, leading it to dereference a NULL
pointer when the hash table is in fact empty.

Test case added to tests/lib/test_typelist.

Note this function is not currently used anywhere.  Only lib/cspf.c uses
_member(), but it does so on a RB-tree rather than a hash.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-04-21 16:30:32 +02:00
David Lamparter
ae19023b8e lib: typesafe hash table breadcrumbs
Looking at the coverity report, it complains that tabshift could be
zero, resulting in a uint32_t shifted by 33 (which is undefined.)

As I was confused by the "+ 1", in addition to the SA assume(), leave
some breadcumbs for next time this comes up.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-04-21 16:27:21 +02:00
Donald Sharp
a7209c2dbc lib: Make coverity happy about close
The error condition handled both failure to open
and a fstat failure.  Just double check that the close
is appropriate to call.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-04-21 09:12:08 -04:00
Philippe Guibert
7b343a9ed5
Merge pull request #12933 from Orange-OpenSource/link_state
lib: Update edge key in link state database
2023-04-20 18:33:21 +02:00
Donatas Abraitis
5db1931962
Merge pull request #13166 from Jafaral/ospf-external-metric
ospfd: use rib metric as the base for set metric +/-
2023-04-19 21:11:25 +03:00
Olivier Dugeon
fd4377d9a5
Merge pull request #11667 from louis-6wind/flexalgo-mpls
isisd: Flex-Algo for SR-MPLS
2023-04-18 14:45:30 +02:00
Eric Kinzie
42bf1afa5a lib: convert termtable to json
Add a function that returns a JSON-C structure containing a representation
of a termtable.  This is intended to be a quick way to implement JSON
output to CLI commands.

Signed-off-by: Eric Kinzie <ekinzie@labn.net>
2023-04-18 11:33:15 +02:00
Louis Scalbert
72eae2c3cb lib: add a frr_each_const macro
Add a frr_each_const macro equivalent to loop on const lists.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-04-18 10:13:59 +02:00
Hiroki Shirokura
46fb37cf67 lib,vtysh,isisd,yang: algo cli/yang/callbacks
Define the IS-IS flex-algo structure in yang, the CLI configuration
commands and the skeletons of frontend and backend functions that are
called by the CLI code.

Signed-off-by: Hiroki Shirokura <hiroki.shirokura@linecorp.com>
Signed-off-by: Eric Kinzie <ekinzie@labn.net>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-04-18 10:13:59 +02:00
Hiroki Shirokura
735fb37db1 lib: add library for igp flexible-algorithm
Add a library to deal with Flexible Algorithm that will be common to
IS-IS and OSPF. The functions enables to deal with:

- Affinity-maps
- Extended Admin Group (RFC7308)
- Flex-Algo structures that contains the flex-algo configurations

Signed-off-by: Hiroki Shirokura <hiroki.shirokura@linecorp.com>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-04-18 10:13:58 +02:00
Hiroki Shirokura
81a067cd92 lib,isisd: refactor igp-agnostic sr misc functions
SR Algorithms are independent of specific IGPs
such as IS-IS. This commit adds lib/sr to
aggregate IGP agnostic functions and constants.

Signed-off-by: Hiroki Shirokura <hiroki.shirokura@linecorp.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-04-18 10:11:43 +02:00
Jafar Al-Gharaibeh
055355e104 lib, ospfd, yang: add route map set for min/max metric
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2023-04-18 00:48:16 -05:00
Donatas Abraitis
89618e7e5e
Merge pull request #13320 from LabNConsulting/fix-show-opdata-command
Fix show opdata command
2023-04-17 14:51:38 +03:00
Donatas Abraitis
e7fd314f06
Merge pull request #12550 from AbhishekNR/mld_join
pim6d: Implementing "ipv6 mld join"
2023-04-17 11:01:21 +03:00
Christian Hopps
e01ecbe194 lib: always check for error, don't count on dnode being NULL
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-04-17 02:15:32 -04:00
Christian Hopps
d249d7e0ab lib: always return valid data format for show yang command.
For JSON return `{}` for XPath return an XML comment `<!-- Not found -->`

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-04-17 02:15:32 -04:00
Christian Hopps
4ac51e2430 lib: fix broken "show yang operational-data" functionality
Previously was using an API that returned the root of the data tree given the
users input xpath value, and then used it like it was the leaf node (last not
first). So basically this CLI command only worked when one requested the root
node of the model.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-04-17 01:43:48 -04:00
Christian Hopps
9e0241c8fb lib: add and use new yang function for finding schema nodes
Add a wrapper around lys_find_xpath which has an unfortunate API
returning an allocated set of schema nodes when we only ever expect and
want one.

Another libyang function `lys_find_path` returns a single node; however,
that function can assert/abort on invalid path values so is unsuitable
for user input.

Replace previous uses of `lys_find_path` with new API when dealing with
possible invalid path values (i.e., from a user).

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-04-17 01:43:48 -04:00
Donatas Abraitis
c9a2561444 bgpd: Implement Node Target Extended Communities
kttps://datatracker.ietf.org/doc/html/draft-ietf-idr-node-target-ext-comm

unet> sh r1 vtysh -c 'sh ip bgp nei 192.168.1.2 adver'
BGP table version is 1, local router ID is 192.168.1.1, vrf id 0
Default local pref 100, local AS 65001
Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

    Network          Next Hop            Metric LocPrf Weight Path
 *> 10.10.10.10/32   0.0.0.0                  0         32768 i

Total number of prefixes 1

unet> sh r1 vtysh -c 'sh ip bgp nei 192.168.1.3 adver'
BGP table version is 1, local router ID is 192.168.1.1, vrf id 0
Default local pref 100, local AS 65001
Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

    Network          Next Hop            Metric LocPrf Weight Path
 *> 10.10.10.10/32   0.0.0.0                  0         32768 i

Total number of prefixes 1

unet> sh r2 vtysh -c 'show ip bgp 10.10.10.10/32'
% Network not in table

unet> sh r3 vtysh -c 'show ip bgp 10.10.10.10/32'
BGP routing table entry for 10.10.10.10/32, version 1
Paths: (1 available, best #1, table default)
  Advertised to non peer-group peers:
  192.168.1.1
  65001
    192.168.1.1 from 192.168.1.1 (192.168.1.1)
      Origin IGP, metric 0, valid, external, best (First path received)
      Extended Community: NT:192.168.1.3 NT:192.168.1.4
      Last update: Tue Apr 11 23:19:33 2023

unet>

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-04-14 21:04:40 +03:00
Philippe Guibert
c37812dd2a lib: fix handle seg6local routes on default vrf
An L3VPN network can be configured on the main BGP instance,
with an SRv6 SID. By declaring a network, a seg6local route
is created but remains invalid.

The below BGP VPN configuration the default VRF has been
used:
> router bgp 1
>  address-family ipv6 unicast
>   sid vpn export auto
>   rd vpn export 1:30
>   rt vpn both 77:77
>   import vpn
>   export vpn
>   network 2001:7::/64
>  exit-address-family

The below seg6local route has been added:

> # show ipv6 route
> [..]
> B   2001:db8:2:2:300::/128 [20/0] is directly connected, unknown inactive, seg6local End.DT6 table 254, seg6 ::, weight 1, 00:00:07
>

When creating the seg6local route, an interface is used as nexthop.
The interface index is obtained from the vrf identifier. This is
true when using VRF interfaces, but is wrong when using the lo
interface which usually has the '1' ifindex whereas the vrf id for
the default VRF is 0.

Get the appropriate index from the vrf identifier.
The below seg6local route is visible:

> # show ipv6 route
> [..]
> B>* 2001:db8:1:1:300::/128 [20/0] is directly connected, lo, seg6local End.DT6 table 254, seg6 ::, weight 1, 00:00:15
>

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-04-14 12:17:10 +02:00
Christian Hopps
2437ddf0b7
Merge pull request #13279 from idryzhov/if-rmap-northbound
lib: convert if_rmap config output to northbound
2023-04-13 03:50:11 -04:00
Jafar Al-Gharaibeh
dde1018745
Merge pull request #13193 from Keelan10/link_state-memory-leak
lib: link state leak fix
2023-04-12 10:57:34 -05:00
Igor Ryzhov
1d1f77b60d lib: convert if_rmap config output to northbound
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-04-12 17:17:03 +03:00
Igor Ryzhov
4150fc5399
Merge pull request #13242 from LabNConsulting/chopps/no_rip_in_lib
Convert if_rmap to use YANG northbound
2023-04-12 16:06:17 +03:00
Pushpasis Sarkar
048e1e7be8 mgmtd, lib: Cleanup zlog_err()
Cleanup all zlog_err() that were meant for debug only.

Signed-off-by: Pushpasis Sarkar <pushpasis@gmail.com>
2023-04-11 22:48:52 -07:00
Jafar Al-Gharaibeh
b4ac6683ac
Merge pull request #13122 from rgirada/mgmtd_codecov
mgmtd: Fixing coverity issues and style warnings in the code
2023-04-12 00:05:56 -05:00
Christian Hopps
efa2ca6ef0 lib: convert if_rmap to YANG northbound
- nice correspondence between new YANG grouping and shared library code.
- fixes bug with RIPNG use, certainly didn't work before.
- removes rip header from shared library code
- still has uses RIP_NODE/RIPNG_NODE as required by CLI foo.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-04-11 15:27:05 -04:00
Christian Hopps
2eb4471114 lib: fix formatting
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-04-11 15:26:09 -04:00
Russ White
f26a87cd24
Merge pull request #12698 from Orange-OpenSource/isisd
Isisd/Lib: Add new printfrr format facility for Intermediate System ID
2023-04-11 09:49:01 -04:00
Donatas Abraitis
bc818f2ff5
Merge pull request #13226 from anlancs/fix/ripd-leak
ripd: Fix memory leak for ripd's route-map
2023-04-11 14:37:40 +03:00
Olivier Dugeon
9a9f0b893e lib: Update Edge Key in link_state
The original uin64_t for the edge key in link state is not always appropriate
with IPv6 addresses. In some cases, 2 different edge with 2 different IPv6
addresses could conduct to the same key. The resulting TED is wrong in this
case.

This patch replace the uint64_t edge key by a dedicated structure. The
resulting key of the edge is:
 - the local IPv4 address of the corresponding link
 - the local IPv6 address if no IPv4 address is configured on the link
 - the local + remote link ID for unnumbered address

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2023-04-07 16:40:25 +02:00
Keelan10
c123d2dee0 lib: Fix link state memory leak
Free link message data when a delete event is recorded.

Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
2023-04-07 11:41:21 +04:00
Donald Sharp
b589466918 *: Use a struct prefix *p instead of a struct prefix in functions
When passing a prefix into a function let's pass by address instead
of pass by value.  Let's save our stack space.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-04-06 18:00:09 -04:00
anlan_cs
d3ec0066e5 ripd: Fix memory leak for ripd's route-map
When cleaning `ripd`, it should free `ctx->name` of `struct if_rmap_ctx`,
not `ctx` itself.  Otherwise, it will lead to memory leak.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2023-04-06 21:30:08 +08:00
rgirada
83b78f43f4 mgmtd: Fixing style warnings
Description:
	Fixing the style warnings in the mgmtd code.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2023-04-05 10:30:24 +00:00
Donatas Abraitis
27a0311fcc
Merge pull request #13194 from Keelan10/sharpd-memory-leak
[WIP] sharpd: fix leak
2023-04-05 10:05:49 +03: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
Russ White
204e450a72
Merge pull request #13192 from anlancs/fix/ripd-wrong-routemap
ripd: Fix malformed route-map
2023-04-04 09:50:02 -04:00
Jafar Al-Gharaibeh
3b28a5ef6b
Merge pull request #13131 from LabNConsulting/chopps/no-startup-file
mgmtd: remove startup config feature for now
2023-04-04 08:42:04 -05:00
Russ White
c0656e9040
Merge pull request #12837 from donaldsharp/unlikely_routemap
Unlikely routemap
2023-04-04 08:20:25 -04:00
Keelan10
5aa36ff77b sharpd: Fix sharpd memory leak
Free path

Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
2023-04-03 17:51:48 +04:00
Abhishek N R
bd2c824a21 pim6d: Impelmenting "ipv6 mld join"
Fixes: #12014

Signed-off-by: Abhishek N R <abnr@vmware.com>
2023-04-03 04:05:17 -07:00
anlan_cs
ff0fa00c7d ripd: Fix malformed route-map
Currently the process of the `route-map` configuration for `per-vrf-rip`
is wrong.

There are two problems:
1. `ctx->name` for `if_rmap_ctx`  is not initialized in `if_rmap_ctx_create()`.
2.  The global `if_rmap_ctx_list` is wrongly used for `per-vrf-rip`.

So, two changes for it:
1. Correctly initializes `ctx->name`.
2. Use specific `if_rmap_ctx` for `per-vrf-rip`, not global one.

Note, this related implementation for `route-map` is only for `ripd`.

Before:
```
anlan(config)# route rip vrf vrf1
anlan(config-router)# route-map aa in lan
anlan(config-router)# do show run
!
router rip
 route-map aa in lan
exit
!
```

After:
```
anlan(config)# route rip vrf vrf1
anlan(config-router)# route-map aa in lan
anlan(config-router)# do show run
!
router rip vrf vrf1
 route-map aa in lan
exit
!
```

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2023-04-03 10:48:33 +08:00
Christian Hopps
8033bf3976 mgmtd: lib: read transitioned daemons split config files in mgmtd
When daemons transition to mgmtd they should stop reading their split config
files, and let mgmtd do that, otherwise things can get out of sync.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-04-01 18:06:43 -04:00
Jafar Al-Gharaibeh
277eb2e580
Merge pull request #13060 from opensourcerouting/feature/allow_peering_with_127.0.0.1
bgpd: Allow peering via 127.0.0.0/8
2023-03-31 00:14:27 -05:00
mobash-rasool
6baf6b184c
Merge pull request #12916 from donaldsharp/clang_15_warnings
freebsd 14, clang 15
2023-03-30 08:41:40 +05:30
Donald Sharp
fbdc605778 lib: Ensure the safi is set to a sensible value
The safi has no 0 value which it is set to as part of the
initialization.  Let's just set it to a sensible value.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-29 07:48:42 -04:00
Donald Sharp
2c38c794a0 lib: Remove getopt.c and getopt1.c
Why do we need getopt code that is standard in everything
that we compile against?

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-28 10:07:38 -04:00
Donald Sharp
38c57f3f65 lib: Remove unneeded asserts in mgmt code
event_add_XXXX functions have no failure path where
if you pass in a double event pointer that it could
return without setting the pointer.  As such these
asserts make no sense and are unnecessary

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-27 08:08:36 -04:00
David Lamparter
be95afe196 lib/clippy: bail out on newline inside string
While C compilers will generally process strings across lines, we really
don't want that.  I rather treat this as the indication of the typo it
probably is warn about it than support this odd C edge case.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-03-25 12:34:35 +09:00
David Lamparter
9e92984f32 lib/clippy: don't SEGV on invalid tokens in DEFPY
The token value can be NULL if we run into something that failed to
parse.  Throw a Python exception rather than SEGV.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-03-25 12:33:14 +09:00
Donald Sharp
02e701e49e *: Fixup formatting issues due to reordering
All the event changes exposed a bunch of places where
we were not properly following our standards.  Just
clean them up in one big fell swoop.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:37:21 -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
cd9d053741 *: Convert struct event_master to struct event_loop
Let's find a better name for it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
ce50d11c4d *: Convert thread_master_XXX functions to event_master_XXX
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
70d4d90c82 lib, zebra: Convert THREAD_TIMER_STRLEN to EVENT_TIMER_STRLEN
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
04ec66797c lib: change cpu_thread_history to cpu_event_history
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
5163a1c560 lib: convert xref_threadsched to xref_eventsched
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
3905fb7393 lib: convert thread internal lists to event internal lists
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
2453d15dbf *: Convert struct thread_master to struct event_master and it's ilk
Convert the `struct thread_master` to `struct event_master`
across the code base.

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
70c35c11f2 *: Convert thread_should_yield and thread_set_yield_time
Convert thread_should_yield and thread_set_yield_time
to event_should_yield and event_set_yield_time

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
4f830a0799 *: Convert thread_timer_remain_XXX to event_timer_remain_XXX
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
8c1186d38e *: Convert thread_execute to event_execute
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
ba7d2705d6 lib: Convert THREAD_YIELD_TIME_SLOT to EVENT_YIELD_TIME_SLOT
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
de2754be3a *: Convert thread_fetch and thread_call to event_fetch and event_call
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
2ccccdf5d0 lib: Convert thread_type to event_type and make an enum
a) Convert thread types to a enum
b) Convert MTYPES to EVENT instead of THREAD

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
332beb64b8 *: Convert thread_cancelXXX to event_cancelXXX
Modify the code base so that thread_cancel becomes event_cancel

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
Donatas Abraitis
6927446645
Merge pull request #13074 from donaldsharp/hash_clean_and_free
*: Add a hash_clean_and_free() function
2023-03-23 14:08:29 +02:00
Donald Sharp
71cb4a57a8 lib: Remove tests for ipv[4|6]_prefix_table
During code inspection, it was noticed that the ipv4_prefix_table
as well as the ipv6_prefix_table are always created on map creation.
There are no paths where they are not created, thus testing for
them adds a bit of code that will always be true.  Let's just
remove these extraneous tests.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-23 08:03:30 -04:00
Donald Sharp
cc09ba4584 bgpd, ospfd, zebra: Use unlikely for DEBUG_ROUTEMAP_DETAIL
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-23 07:54:56 -04:00
Donald Sharp
6a72124df9 babeld, lib, nhrpd: Add likely and unlikely macros
We have 2 competing versions of likely and unlikely
in babeld and nhrpd.  Standardize onto lower case
versions and consolidate in the code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-23 07:54:56 -04:00
Christian Hopps
0b645fd216 lib: mgmtd: fix build warnings (as error)
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-03-22 05:22:56 +00:00
Christian Hopps
39c329bbd1 lib: staticd: vtysh: apply frrbot style requirements
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-03-22 05:22:56 +00:00
Pushpasis Sarkar
1401ee8bf7 lib, mgmtd: Add few fixes for commit-check and rollback
This commit contains fixes for the following issues found
- 'mgmt commit check' issued through 'vtysh -f' was actually commtting the changeset.
- On config validation failure backend, mgmtd was not passing the correct error-reason
  to frontend.
- 'mgmt rollback ...' was reverting the change on backend, but config on mgmtd daemon
  remains intact

Signed-off-by: Pushpasis Sarkar <pushpasis@gmail.com>
2023-03-22 05:22:56 +00:00
Christian Hopps
f82370b47b mgmtd: lib: utilize msglib constructed from the removed code
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-03-22 05:22:56 +00:00
Christian Hopps
c9f0e90b60 lib: new message library for mgmtd client and adapters
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-03-22 05:22:56 +00:00
Christian Hopps
d1e85e3600 mgmtd: Enroll Staticd as a backend client for MGMTD
This commmit introduces Staticd as a backend client for the MGMTd
framework. All the static commands will be diverted to the MGMT
daemon and will use the transactional model to make changes to the
internal state. Similar mechanism can be used by other daemons to use
the MGMT framework in the future.

This commit includes the following functionalities in the changeset:
1. Diverts all the staticd (config only) commands to MGMTd.
2. Enrolls staticd as a backend client to use the MGMT framework.
3. Modify the staticd NB config handlers so that they can be compiled
   into a library and loaded in the MGMTd process context.

Co-authored-by: Pushpasis Sarkar <pushpasis@gmail.com>
Co-authored-by: Abhinay Ramesh <rabhinay@vmware.com>
Co-authored-by: Ujwal P <ujwalp@vmware.com>
Signed-off-by: Yash Ranjan <ranjany@vmware.com>
2023-03-21 22:09:07 -04:00
Yash Ranjan
74335ceb27 mgmtd: Add MGMT Transaction Framework
This commit introduces the MGMT Transaction framework that takes
management requests from one (or more) frontend client sessions,
translates them into transactions and drives them to completion
in co-oridination with one (or more) backend client daemons
involved in the request.

This commit includes the following functionalities in the changeset:
1. Introduces the actual Transaction module. Commands added related to
   transaction are:
   a. show mgmt transaction all
2. Adds support for commit rollback feature which stores upto the 10
   commit buffers. Each commit has a commit-id which can be used to
   rollback to the exact configuration state.
   Commands supported for this feature are:
   a. show mgmt commit-history
   b. mgmt rollback commit-id COMMIT_ID
3. Add hidden commands to enable record various performance metrics:
   a. mgmt performance-measurement
   b. mgmt reset-statistic

Co-authored-by: Pushpasis Sarkar <pushpasis@gmail.com>
Co-authored-by: Abhinay Ramesh <rabhinay@vmware.com>
Co-authored-by: Ujwal P <ujwalp@vmware.com>
Signed-off-by: Yash Ranjan <ranjany@vmware.com>
2023-03-21 22:08:32 -04:00
Christian Hopps
7d65b7b7f4 mgmtd: Add MGMT Backend Interface Framework
This commit introduces the MGMT Backend Interface which can be used
by back-end management client daemons like BGPd, Staticd, Zebra to
connect with new FRR Management daemon (MGMTd) and utilize the new
FRR Management Framework to let any Frontend clients to retrieve any
operational data or manipulate any configuration data owned by the
individual Backend daemon component.

This commit includes the following functionalities in the changeset:
1. Add new Backend server for Backend daemons connect to.
2. Add a C-based Backend client library which can be used by daemons
   to communicate with MGMTd via the Backend interface.
3. Maintain a backend adapter for each connection from an appropriate
   Backend client to facilitate client requests and track one or more
   transactions initiated from Frontend client sessions that involves
   the backend client component.
4. Add the following commands to inspect various Backend client
   related information
	a. show mgmt backend-adapter all
	b. show mgmt backend-yang-xpath-registry
        c. show mgmt yang-xpath-subscription

Co-authored-by: Pushpasis Sarkar <pushpasis@gmail.com>
Co-authored-by: Abhinay Ramesh <rabhinay@vmware.com>
Co-authored-by: Ujwal P <ujwalp@vmware.com>
Signed-off-by: Yash Ranjan <ranjany@vmware.com>
2023-03-21 22:08:32 -04:00
Christian Hopps
ef43a6329b mgmtd: Add MGMT Frontend Interface Framework
This commit introduces the Frontend Interface which can be used
by front-end management clients like Netconf server, Restconf
Server and CLI to interact with new FRR Management daemon (MGMTd)
to access and sometimes modify FRR management data.

This commit includes the following functionalities in the changeset:
1. Add new Frontend server for clients connect to.
2. Add a C-based Frontend client library which can be used by Frontend
   clients to communicate with MGMTd via the Frontend interface.
3. Maintain a frontend adapter for each connection from an appropriate
   Frontend client to facilitate client requests and track one or more
   client sessions across it.
4. Define the protobuf message format for messages to be exchanged
   between MGMTd Frontend module and the Frontend client.
5. This changeset also introduces an instance of MGMT Frontend client
   embedded within the lib/vty module that can be leveraged by any FRR
   daemon to connect to MGMTd's Frontend interface. The same has been
   integrated with and initialized within the MGMTd daemon's process
   context to implement a bunch of 'set-config', 'commit-apply',
   'get-config' and 'get-data' commands via VTYSH

Co-authored-by: Pushpasis Sarkar <pushpasis@gmail.com>
Co-authored-by: Abhinay Ramesh <rabhinay@vmware.com>
Co-authored-by: Ujwal P <ujwalp@vmware.com>
Signed-off-by: Yash Ranjan <ranjany@vmware.com>
2023-03-21 22:08:32 -04:00
Christian Hopps
1c84efe4fa mgmtd: Bringup MGMTD daemon and datastore module support
Features added in this commit:
1. Bringup/shutdown new management daemon 'mgmtd' along with FRR.
2. Support for Startup, Candidate and Running DBs.
3. Lock/Unlock DS feature using pthread lock.
4. Load config from a JSON file onto candidate DS.
5. Save config to a JSON file from running/candidate DS.
6. Dump candidate or running DS contents on the terminal or a file in
   JSON/XML format.
7. Maintaining commit history (Full rollback support to be added in
   future commits).
8. Addition of debug commands.

Co-authored-by: Yash Ranjan <ranjany@vmware.com>
Co-authored-by: Abhinay Ramesh <rabhinay@vmware.com>
Co-authored-by: Ujwal P <ujwalp@vmware.com>
Signed-off-by: Pushpasis Sarkar <pushpasis@gmail.com>
2023-03-21 22:08:32 -04:00
Olivier Dugeon
7f9ab3b0bb lib: Add ISO System & Network format to printfrr
Like for IP addresses, this patch add a new format for printfrr collection to
print ISO System ID and Network address a.k.a IS-IS system ID & Network.
This new format is added to the library instead of isisd because other daemons
and tools need to print ISO System ID & Network Address.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2023-03-21 15:19:09 +01:00
Donald Sharp
d8bc11a592 *: Add a hash_clean_and_free() function
Add a hash_clean_and_free() function as well as convert
the code to use it.  This function also takes a double
pointer to the hash to set it NULL.  Also it cleanly
does nothing if the pointer is NULL( as a bunch of
code tested for ).

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-21 08:54:21 -04:00
Donatas Abraitis
8eb09e64d2 bgpd: Allow peering via 127.0.0.0/8
There are some specific edge-cases when is a need to run FRR and another FRR
and/or another BGP implementation on the same box. Relaxing 127.0.0.0/8 for
this case might be reasonable.

An example below peering via 127.0.0.0/8 between FRR and GoBGP:

```
% ss -ntlp | grep 179
LISTEN   0         4096              127.0.0.1:179              0.0.0.0:*
LISTEN   0         128               127.0.0.2:179              0.0.0.0:*

% grep 127.0.0.2 /etc/frr/daemons
bgpd_options="   -A 127.0.0.1 -l 127.0.0.2"

% grep local /etc/gobgp/config.toml
    local-address-list = ["127.0.0.1"]

donatas-pc# sh ip bgp summary

IPv4 Unicast Summary (VRF default):
BGP router identifier 192.168.10.17, local AS number 65001 vrf-id 0
BGP table version 0
RIB entries 0, using 0 bytes of memory
Peers 1, using 725 KiB of memory

Neighbor        V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt Desc
127.0.0.1       4      65002         7         7        0    0    0 00:02:02            0        0 N/A

Total number of neighbors 1
donatas-pc#
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-03-21 13:19:44 +02:00
Donatas Abraitis
0cc7d2ad58
Merge pull request #13061 from donaldsharp/bfd_use_after_free
lib: on bfd peer shutdown actually stop event
2023-03-21 08:59:45 +02:00
Sindhu Parvathi Gopinathan
463110f733 lib:fix clear route-map cmd using DEFPY
Due to the wrong input argv id, "argv[idx_word]->arg"
fetched in-correctly and it clears all the route-maps instead of
specific one.

Now correct argv id is passed to clear the given route-map counters.

Also, use RMAP_NAME which allows to show list of configured
route-maps in the system.

After Fix:-

Ticket:#3407773
Issue:3407773

Testing: UT done

Before:
TORC11# clear route-map counters
  <cr>
  WORD  route-map name

After:

TORC11# clear route-map counters
  <cr>
  RMAP_NAME  route-map name
     my-as

Signed-off-by: Chirag Shah <chirag@nvidia.com>
Signed-off-by: Sindhu Parvathi Gopinathan's <sgopinathan@nvidia.com>
2023-03-20 19:17:32 -07:00