Commit Graph

5340 Commits

Author SHA1 Message Date
Donatas Abraitis
b9941b3fec lib: Release memory of YANG translation module on error
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-02-09 18:01:17 +02:00
Hiroki Shirokura
c86a325285 lib: add copy function for bitfield_t
Add a function to copy a bitfield_t structure.

Add a ‘void *’ to ‘word_t *’ converstion in bf_init() to avoid the
following error:

> ./lib/bitfield.h: In function ‘bf_copy’:
> ./lib/bitfield.h:75:12: error: request for implicit conversion from ‘void *’ to ‘word_t *’ {aka ‘unsigned int *’} not permitted in C++ [-Werror=c++-compat]
>    (v).data = XCALLOC(MTYPE_BITFIELD, ((v).m * sizeof(word_t)));  \
>             ^
> ./lib/bitfield.h:278:2: note: in expansion of macro ‘bf_init’
>   bf_init(dst, WORD_SIZE * (src.m - 1));
>   ^~~~~~~

Signed-off-by: Hiroki Shirokura <hiroki.shirokura@linecorp.com>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-02-09 15:48:39 +01:00
Louis Scalbert
05a12619dd lib,yang,zebra: add affinity-map support
Add the affinity-map global command to zebra. The syntax is:

> affinity-map NAME bit-position (0-1023)

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-02-09 15:48:21 +01:00
Olivier Dugeon
ad1327b3d4
Merge pull request #12730 from louis-6wind/fix-ext-te-metrics
Fix for Extended TE metrics
2023-02-09 15:12:41 +01:00
David Lamparter
2bc1fe6dca lib: SPDX License ID on skiplist code
The skiplist code has a very "colorful" history.  Use the SPDX
"LicenseRef" syntax/notation to track it.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:11 +01: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
David Lamparter
47a3a82770 *: manual SPDX License ID conversions
The files converted in this commit either had some random misspelling or
formatting weirdness that made them escape automated replacement, or
have a particularly "weird" licensing setup (e.g. dual-licensed.)

This also marks a bunch of "public domain" files as SPDX License "NONE".

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:07 +01:00
Pooja Jagadeesh Doijode
6333c54822 lib: Helper function to print empty JSON
Introduced a helper function to print empty JSON object.

Signed-off-by: Pooja Jagadeesh Doijode <pdoijode@nvidia.com>
2023-02-07 14:29:54 -08:00
Donatas Abraitis
96475dfde9
Merge pull request #12707 from donaldsharp/missed_enums
Missed enums
2023-02-07 22:22:27 +02:00
Donald Sharp
d7c6467ba2 lib, bgpd: Add ability to specify that some json output should not be pretty
Initial commit: 23b2a7ef52
changed the json output of `show bgp <afi> <safi> json` to
not have pretty print because when under a situation where
there are a bunch of routes with a large scale ecmp show
output was taking forever and this commit cut 2 minutes out
of vtysh run time.

Subusequent commit: f4ec52f7cc
changed this back.

When upgrading to latest version the long run time was noticed
due to testing.  Let's add back this functionality such that
FRR can have reduced run times with vtysh when it's really
needed.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-02 10:28:19 -05:00
Louis Scalbert
81e7bb3dbd lib: fix traffic engineering extended mask
RFC7471 and RFC8570 have defined the Extended Traffic Engineering
metrics that are carried within TLV of 32 bits data length. Extended
metrics, excepting bandwidth ones, use the following format:

>     0                   1                   2                   3
>     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
>    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>    |   Type        |     Length    |
>    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>    |A|  RESERVED   |                   Value                       |
>    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Data contains a flag/reserved of 8 bits and a 24 bits value.

The TE_EXT_MASK mask macro extracts a 28 bits value from a 32 bits
variable instead of 24 bits. It works in most of the case because
RESERVED bits are generally set to 0.

Fix the TE_EXT_MASK mask.

Fixes: 16f1b9ee29 ("Update Traffic Engineering Support for OSPFD")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-02-02 16:20:01 +01:00
David Lamparter
bd90faea56 lib: fix one more b0rked format string
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-01 03:00:22 +01:00
David Lamparter
c695bdbedb lib: apply more printf attributes
... missed some functions in the earlier commits :(

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-01 03:00:18 +01:00
Donald Sharp
bde30e78cb lib: Add missing enum's to switch statement
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-31 15:15:42 -05:00
Donald Sharp
ca411e386f lib: Add missing enum's to northbound.c
Some enums were missing for string conversions in northbound.c

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-31 12:29:08 -05:00
Donald Sharp
5c26054802 lib: Adding missing string to switch statement in mlag.c
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-31 12:29:08 -05:00
Mark Stapp
3b337b7d27
Merge pull request #12687 from opensourcerouting/build-mkdir-p
build: consistently mkdir -p output for redirect
2023-01-31 11:28:32 -05:00
Donald Sharp
ea768492f1
Merge pull request #12695 from opensourcerouting/format-warnings
build: `-Wformat-nonliteral -Wformat-security`
2023-01-31 09:01:32 -05:00
David Lamparter
e59bd527e9 lib: literal constant format string for termtable
While this wasn't a problematic use of a format string, make it a
literal constant so the compiler is happy.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-01-27 12:01:20 +01:00
David Lamparter
ae08de9f42 *: fix non-const northbound XPath format strings
Passing a pre-formatted buffer in these places needs a `"%s"` in front
so it doesn't get formatted twice.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-01-27 12:01:20 +01:00
David Lamparter
c84e518709 *: no-warn pragmas for non-const format strings
We do use non-constant/literal format strings in a few places for more
or less valid reasons;  put `ignored "-Wformat-nonliteral"` around those
so we can have the warning enabled for everywhere else.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-01-27 12:01:20 +01:00
David Lamparter
0f9de11a11 *: apply proper format string attributes
So that we get warnings about broken format strings.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-01-27 12:01:17 +01:00
Donald Sharp
8586a88abb lib: Remove global variable exposure struct host host
This was only used in one place and we have accessor functions
now.  So let's use them.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-26 11:40:33 -05:00
Donald Sharp
08c3dba719 lib: Forward declaration of a struct does not need to have data type
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-26 11:40:33 -05:00
Donald Sharp
e5a5e5388e lib: Remove dead code
wheel_stop and wheel_start have never been used.  Let's just remove
them.  After close to 7 years, if needed someone else can add back in.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-25 15:45:39 -05:00
Rafael Zalamena
21188a567a
Merge pull request #12670 from louis-6wind/fix-bfd-zclient
lib: do not reopen a zclient socket for bfd
2023-01-24 16:52:54 -03:00
David Lamparter
d173381edc build: consistently mkdir -p output for redirect
When running the build in a separate build directory, redirecting output
into a file can error out if the directory does not exist yet.  Some
places already had `mkdir -p` calls, but not all.

Make all occurences of this consistently use `@$(MKDIR_P)`.

(Extension of PR #12575 to catch more places.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-01-24 17:46:57 +01:00
Russ White
9b1b028cc2
Merge pull request #12682 from opensourcerouting/time-cs
*: fix time truncation in many places
2023-01-24 10:51:44 -05:00
Russ White
1ea7c32507
Merge pull request #12634 from anlancs/fix/lib-seq-adjust-return-value
lib: fix wrong returned value for filter
2023-01-24 10:36:17 -05:00
Louis Scalbert
f6e7fbdae9 lib: remove concurrent nexthop zapi (un)registration
Daemons like staticd already implement nexthop zapi (un)registration.
b7ca809d1c ("lib: BFD automatic source selection") has implemented a
concurrent nexthop (un)registration. Some nexthop could be unregistred
by the bfd whereas they were still needed by the daemon.

Let the deamons deal with nexthop zapi (un)registration.

Fixes: b7ca809d1c ("lib: BFD automatic source selection")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-01-24 16:08:26 +01:00
Louis Scalbert
a77ea81ef3 lib: do not reopen a zclient socket for bfd
b7ca809d1c ("lib: BFD automatic source selection") has added a dedicated
zclient socket for nht tracking. Since the bfd lib is used by daemons
that already has a zclient socket, those daemons has now a second
zclient socket. However, zebra does not distinguish the two zclient
sessions. For example, the interfaces are asked a second via
zebra_message_send(zclient, ZEBRA_INTERFACE_ADD, VRF_DEFAULT) in
zclient_start(). As a result, callbacks functions like bgp_ifp_create()
are called a second time, which causes some processing overhead and
might cause bugs.

Re-use the existing zclient socket for nht tracking.

Note that BFD automatic source selection is only currently implemented
in staticd. Other daemons will require to add the following in their
ZEBRA_NEXTHOP_UPDATE callback function:

> 	if (zclient->bfd_integration)
>		bfd_nht_update(&matched, &nhr);

Fixes: b7ca809d1c ("lib: BFD automatic source selection")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-01-24 16:08:04 +01:00
Rafael Zalamena
fce7f209fc *: introduce function for sequence numbers
Don't directly use `time()` for generating sequence numbers for two
reasons:
1. `time()` can go backwards (due to NTP or time adjustments)
2. Coverity Scan warns every time we truncate a `time_t` variable for
   good reason (verify that we are Y2K38 ready).

Found by Coverity Scan (CID 1519812, 1519786, 1519783 and 1519772)

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-01-20 15:40:28 -03:00
Manoj Naragund
701f4f616a ospfd: addition of OSPF_LOG.
Description:

Addition of OSPF_LOG for conditionally logging ospf messages,
at different log levels.

Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2023-01-19 21:03:03 -08:00
Donald Sharp
c4e0a69677
Merge pull request #12651 from opensourcerouting/fix/revert_bgp_orr
Revert BGP Optimal route reflector feature
2023-01-19 12:24:17 -05:00
Rafael Zalamena
ff9232c83b lib: remove dead logic code
If we got inside the condition of `vrfp->status == VRF_ACTIVE` then
don't make the same check again.

Found by Coverity Scan (CID 1519760)

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-01-19 10:42:01 -03:00
Donatas Abraitis
69306c44e8
Merge pull request #12657 from anlancs/fix/lib-debug-empty-ip
lib: show "(null)" for empty IP address
2023-01-19 09:12:04 +02:00
anlan_cs
927c633dd9 lib: show "(null)" for empty IP address
Use "(null)" for empty IP address.

One example in `bgp_zebra_send_remote_macip()` to install mac:

Before:
```
2023/01/18 02:09:09 BGP: [SCHS5-AK960] Tx ADD MACIP, VNI 200 MAC 06:6b:7c:db:83:72 IP  flags 0x0 seq 0 remote VTEP 88.88.88.88 esi -
```

After:
```
2023/01/18 20:19:57 BGP: [SCHS5-AK960] Tx ADD MACIP, VNI 200 MAC 06:6b:7c:db:83:72 IP (null) flags 0x0 seq 0 remote VTEP 88.88.88.88 esi -
```

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2023-01-19 09:30:49 +08:00
Mark Stapp
e7523b9a94
Merge pull request #12648 from opensourcerouting/gmtime-fix
lib: fix gmtime_assafe potential issues
2023-01-17 16:25:35 -05:00
Donatas Abraitis
af5d731255 Revert "lib: BGP registration with IGP for BGP ORR rSPF calc"
This reverts commit a5dd4bf47d.
2023-01-17 18:15:56 +02:00
Donatas Abraitis
3228977f58 Revert "ospfd: few fixes in rSPF calc when LSA received from non root node"
This reverts commit 9f2984d97c.
2023-01-17 18:09:55 +02:00
Donatas Abraitis
731d0769e2 Revert "bgpd, ospfd: update BGP when routes are removed from OSPF routing table"
This reverts commit bba9435157.
2023-01-17 18:07:41 +02:00
Russ White
00d7261e20
Merge pull request #12636 from opensourcerouting/fix/bgp_accept-own_connected_routes
bgpd: Allow importing local routes with accept-own mechanism
2023-01-17 09:31:37 -05:00
Rafael Zalamena
0839d0c742 lib: fix gmtime_assafe potential issues
Changes:
- Convert `unsigned int` to `time_t` to satisfy time truncation warnings
  even though at this point we had already used the modulus operator.

- Avoid trying to access outside the bounds of the array

  `months` array has a size of 13 elements, but the code inside the loop
  uses `i + 1` to peek on the next month.

Found by Coverity Scan (CID 1519752 and 1519769)

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-01-17 10:21:39 -03:00
anlan_cs
efa354a978 lib: fix wrong returned value for filter
When setting rule for access-list ( and prefix-list ) without sequence, it
will automatically get a sequence by `acl_get_seq()`, and return
`CMD_SUCCESS` for command even this sequence value is wrong.

In this scene, `CMD_WARNING_CONFIG_FAILED` should be returned with a
warning.

So, add the check in `acl_get_seq()` and move `nb_cli_enqueue_change()`
after the check of wrong sequence.

Both `plist_remove_if_empty()` and `acl_remove_if_empty()` should ignore
this check, there is no change on them.

Before:
```
anlan(config)# access-list aa seq 4294967295 deny 6.6.6.6/32
anlan(config)# access-list aa deny 6.6.6.7/32  <- Return CMD_SUCCESS
YANG error(s):
 Value "4294967300" is out of uint32's min/max bounds.
 Value "4294967300" is out of uint32's min/max bounds.
 Value "4294967300" is out of uint32's min/max bounds.
 Value "4294967300" is out of uint32's min/max bounds.
 Value "4294967300" is out of uint32's min/max bounds.
 YANG path: Schema location /frr-filter:lib/prefix-list/entry/sequence.
% Failed to edit configuration.
```

After:
```
anlan(config)# access-list aa seq 4294967295 deny 6.6.6.6/32
anlan(config)# access-list aa deny 6.6.6.7/32  <- Return CMD_WARNING_CONFIG_FAILED
% Malformed sequence value
```

Additionally, fixed the overflow issue on `acl_get_seq()` on **32bit** platforms.
Just change the returned type of `acl_get_seq()` from `long` to `int64_t`.

Before:
```
anlan(config)# access-list bb seq 4294967295 deny 6.6.6.6/32
anlan(config)# access-list bb deny 6.6.6.7/32
anlan(config)# do show run
...
access-list bb seq 4294967295 deny 6.6.6.6/32
access-list bb seq 4 deny 6.6.6.7/32 <- Overflow
```

After:
```
anlan(config)# access-list bb seq 4294967295 deny 6.6.6.6/32
anlan(config)# access-list bb deny 6.6.6.7/32
% Malformed sequence value
```

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2023-01-17 09:36:50 +08:00
Louis Scalbert
b2cfd204a8 lib: add a function to get the VRF or loopback interface
Add a function to find the VRF or the loopback interface: the loopback
interface for the default VRF and the VRF master interface otherwise.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-01-15 12:22:24 +02:00
Rafael Zalamena
e280279d5a lib,staticd: BFD integration CLI commands
Implement the static route monitoring feature with BFD integration.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-01-13 15:32:12 -03:00
Rafael Zalamena
4e35b32ee5 lib: BFD integration clean up function
Implement clean up function to be called on shutdown to make daemon exit
clean for valgrind and other memory sanitizers.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-01-13 15:32:12 -03:00
Rafael Zalamena
b7ca809d1c lib: BFD automatic source selection
Implement new BFD library issue to allow protocols to configure BFD
sessions with automatic source selection.

The source selection will be based on the Next Hop Tracking feature:
`zebra` will do RIB lookups to determine the output interface and the
primary source address of that interface will be used as source.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-01-13 15:32:12 -03:00
Donald Sharp
2bb8b49ce1 Revert "Merge pull request #11127 from louis-6wind/bgp-leak"
This reverts commit 16aa1809e7, reversing
changes made to f616e71608.
2023-01-13 08:13:52 -05:00
David Lamparter
a185874504 lib/clippy: fix symbol validity check
If symvalid is false, looking at symidx is bogus.

This fixes a build-time SEGV on mips64el.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-01-06 17:05:25 +01:00
David Lamparter
ee4a6b9f65 lib: disable xref ELF note on mips64el
mips64el does not have a 64-bit PC-relative relocation, which is needed
to emit the ELF note for xrefs.  Disabling the ELF note means clippy
takes the fallback path using section headers, so everything does still
work (... unless you strip the section headers.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-01-06 17:05:16 +01:00
Dmitrii Turlupov
ef78e4fdac lib: fix display cputime-warning and walltime-warning
Before patch:
```
# vtysh -c "c t" -c "service cputime-warning 1" -c "service walltime-warning 2"
# vtysh  -c "show run" | grep warn
service cputime-warning 1000
service walltime-warning 2000
```

After patch:
```
# vtysh -c "c t" -c "service cputime-warning 1" -c "service walltime-warning 2"
# vtysh  -c "show run" | grep warn
service cputime-warning 1
service walltime-warning 2
```

Signed-off-by: Dmitrii Turlupov <dturlupov@factor-ts.ru>
2022-12-28 11:33:09 +03:00
Russ White
16aa1809e7
Merge pull request #11127 from louis-6wind/bgp-leak
bgpd: multiple fixes for route leaking
2022-12-27 14:51:28 -05:00
Mark Stapp
17cb0eaa09
Merge pull request #12533 from donaldsharp/returns_are_needed
lib, staticd: return values even after an assert
2022-12-16 12:42:14 -05:00
Louis Scalbert
09e370e5ff lib: fix clang warning
Fix a CLANG warning

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 14:52:47 +01:00
Louis Scalbert
e7192e9d24 lib: add a function to get the VRF or loopback interface
Add a function to find the VRF or the loopback interface: the loopback
interface for the default VRF and the VRF master interface otherwise.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 14:52:47 +01:00
Donald Sharp
16c150f27b lib, staticd: return values even after an assert
When compiling with -fsanitize=thread.  I started getting this error:

staticd/static_zebra.c: In function ‘static_zebra_nht_get_prefix’:
staticd/static_zebra.c:316:1: error: control reaches end of non-void function [-Werror=return-type]
  316 | }
      | ^

Just to make future efforts still work, let's just make the compiler happy.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-16 07:38:58 -05:00
Donald Sharp
1fec35c3c7 lib: Fix free function
The list delete function on creation was set to srv6_locator_chunk_free
Which takes a double pointer and dereferences it to free the data.
When list_delete is called it calls the delete function like this:
                if (*list->del)
                        (*list->del)(node->data);

The data is not passed in by reference and as such we do not have
a double pointer.  Fortunately this list_delete is only really
called on shutdown when the locator was deleted and we do not
have a fun situation where we were suddenly freeing 'something'.

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
6f83bbd614 lib: On shutdown, disable snmp from working
When shutting down ensure that any daemon operating with
snmp tells it to stop operating so no more data is sent.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-15 11:14:53 -05:00
Donald Sharp
2fcd46fe38 lib: Convert agentx_enabled to a bool
FRR is using this as a bool.  Let's just use a bool.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-15 07:31:55 -05:00
Louis Scalbert
fa0f9ae38b lib: fix ls_prefix memory allocation
The wrong size is allocated for struct ls_prefix memory.

Fix ls_prefix memory allocation.

Fixes: b0c0b43348 ("lib: Update Link State Database")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-13 15:05:04 +01:00
Rafael Zalamena
eb23e17fc7 lib: fix capability double resource allocation
Don't let `zprivs_caps_init` allocate resources without checking if
there were other caps previously allocated.

This fixes a memory leak that happens on daemons that `fork()` and reuse
the `<daemon>_di` (see `ldpd`/`lde`/`ldpe` code).

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2022-12-12 10:39:17 -03:00
Donald Sharp
b3faf1aab6 lib: Hide list macros in linklist.c
The LISTNODE_ATTACH|DELETE macros are only used in
linklist.c.  Let's remove temptation from people
to use them.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-09 08:38:50 -05:00
Mark Stapp
447586fd3c lib: fix zlog command types table
Fix a number of differences between the zapi message enum
and the log description table.

Signed-off-by: Mark Stapp <mjs@labn.net>
2022-12-08 11:37:51 -05:00
Mark Stapp
4011543282 lib: use specific MTYPE for interface descriptions
Don't use MTYPE_TMP, use a real mem type.

Signed-off-by: Mark Stapp <mjs@labn.net>
2022-12-02 11:10:24 -05:00
Donald Sharp
5eb310087b
Merge pull request #12397 from opensourcerouting/vscode-intro
lib: handle visual studio code C/C++ extension
2022-12-01 11:01:45 -05:00
Rafael Zalamena
a082324649 lib: handle visual studio code C/C++ extension
Add some `pragma`s to handle errors that the C/C++ extension is not able
to understand.

Move `TRANSPARENT_UNION` to `lib/compiler.h` for consistency.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2022-11-28 08:21:25 -03:00
Donald Sharp
a8a0f80b63 lib: Do not log echo PING commands from watchfrr
Since the `echo PING` commands are from watchfrr and are sent
a whole bunch when an operator has `log commands` on the amount
of logging done is quite significant.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-11-26 09:30:48 -05:00
Russ White
d15c84fa22
Merge pull request #12317 from mobash-rasool/ospf-fixes
ospfd: Fix RFC conformance test cases 25.19 and 27.6
2022-11-24 10:21:25 -05:00
Stephen Worley
b14fa9c4dc lib: disable vrf before terminating interfaces
We must disable the vrf before we start terminating interfaces.

On termination, we free the 'zebra_if' struct from the interface ->info
pointer. We rely on that for subsystems like vxlan for cleanup when
shutting down.

'''
==497406== Invalid read of size 8
==497406==    at 0x47E70A: zebra_evpn_del (zebra_evpn.c:1103)
==497406==    by 0x47F004: zebra_evpn_cleanup_all (zebra_evpn.c:1363)
==497406==    by 0x4F2404: zebra_evpn_vxlan_cleanup_all (zebra_vxlan.c:1158)
==497406==    by 0x4917041: hash_iterate (hash.c:267)
==497406==    by 0x4F25E2: zebra_vxlan_cleanup_tables (zebra_vxlan.c:5676)
==497406==    by 0x4D52EC: zebra_vrf_disable (zebra_vrf.c:209)
==497406==    by 0x49A247F: vrf_disable (vrf.c:340)
==497406==    by 0x49A2521: vrf_delete (vrf.c:245)
==497406==    by 0x49A2E2B: vrf_terminate_single (vrf.c:533)
==497406==    by 0x49A2D8F: vrf_terminate (vrf.c:561)
==497406==    by 0x441240: sigint (main.c:192)
==497406==    by 0x4981F6D: frr_sigevent_process (sigevent.c:130)
==497406==  Address 0x6d68c68 is 200 bytes inside a block of size 272 free'd
==497406==    at 0x48470E4: free (vg_replace_malloc.c:872)
==497406==    by 0x4942CF0: qfree (memory.c:141)
==497406==    by 0x49196A9: if_delete (if.c:293)
==497406==    by 0x491C54C: if_terminate (if.c:1031)
==497406==    by 0x49A2E22: vrf_terminate_single (vrf.c:532)
==497406==    by 0x49A2D8F: vrf_terminate (vrf.c:561)
==497406==    by 0x441240: sigint (main.c:192)
==497406==    by 0x4981F6D: frr_sigevent_process (sigevent.c:130)
==497406==    by 0x499A5F0: thread_fetch (thread.c:1775)
==497406==    by 0x492850E: frr_run (libfrr.c:1197)
==497406==    by 0x441746: main (main.c:476)
==497406==  Block was alloc'd at
==497406==    at 0x4849464: calloc (vg_replace_malloc.c:1328)
==497406==    by 0x49429A5: qcalloc (memory.c:116)
==497406==    by 0x491D971: if_new (if.c:174)
==497406==    by 0x491ACC8: if_create_name (if.c:228)
==497406==    by 0x491ABEB: if_get_by_name (if.c:613)
==497406==    by 0x427052: netlink_interface (if_netlink.c:1178)
==497406==    by 0x43BC18: netlink_parse_info (kernel_netlink.c:1188)
==497406==    by 0x4266D7: interface_lookup_netlink (if_netlink.c:1288)
==497406==    by 0x42B634: interface_list (if_netlink.c:2368)
==497406==    by 0x4ABF83: zebra_ns_enable (zebra_ns.c:127)
==497406==    by 0x4AC17E: zebra_ns_init (zebra_ns.c:216)
==497406==    by 0x44166C: main (main.c:408)
'''

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-11-22 17:42:29 -05:00
Russ White
2387dca4dc
Merge pull request #12311 from opensourcerouting/feature/bgp_snmp_bgp4v2-mib
bgpd: Implement SNMP BGP4V2-MIB (bgp4V2PeerEntry)
2022-11-22 14:58:22 -05:00
Siger Yang
dfacea4ae7
zebra: traffic control ZAPI
This commit adds ZAPI encoders & decoders for traffic control operations, which
include tc_qdisc, tc_class and tc_filter.

Signed-off-by: Siger Yang <siger.yang@outlook.com>
2022-11-22 22:35:35 +08: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
e6648f01be lib, vtysh: Allow watchfrr to receive start/end lines
Watchfrr really should receive notification about start/end
read of configuration.  Let's fix that.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-11-21 12:04:12 -05:00
Mobashshera Rasool
ca5997cd01 ospfd: Fix RFC conformance test cases 25.19 and 27.6
Steps to reproduce:
--------------------------
1. ANVL: Establish full adjacency with DUT for neighbor Rtr-0-A on DIface-0 with DUT as DR.
2. ANVL: Listen (for up to 2 * <RxmtInterval> seconds) on DIface-0.
3. DUT: Send <OSPF-LSU> packet.
4. ANVL: Verify that the received <OSPF-LSU> packet contains a Network- LSA for network N1
   originated by DUT, and the LS Sequence Number is set to <InitialSequenceNumber>.
5. ANVL: Establish full adjacency with DUT for neighbor Rtr-0-B on DIface-0 with DUT as DR.
6. ANVL: Listen (for up to 2 * <RxmtInterval> seconds) on DIface-0.
7. DUT: Send <OSPF-LSU> packet.
8. ANVL: Verify that the received <OSPF-LSU> packet contains a new instance of the
   Network-LSA for network N1 originated by DUT, and the LS Sequence Number
   is set to (<InitialSequenceNumber> + 1).

Both the test cases were failing while verifying the initial sequence number for network LSA.

This is because currently OSPF does not reset its LSA sequence number when it is going down.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2022-11-21 03:19:33 -08:00
Donatas Abraitis
f8d69be43f
Merge pull request #12081 from sworleys/EMM-upstream
Rework of Various Handling in EVPN for Extended Mac Mobility
2022-11-17 16:46:58 +02:00
Russ White
54b3d90a4b
Merge pull request #11992 from pguibert6WIND/pathd_debug
Pathd debug
2022-11-16 21:41:33 -05:00
Philippe Guibert
c1657d2669 pathd: use a define to store the the length of endpoint string
The endpoint string is a 46 byte length buffer. Use a single
place to store the length of that buffer.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2022-11-14 17:42:55 +01:00
Donatas Abraitis
84f784fafa
Merge pull request #12219 from cscarpitta/feature/srv6-usid-behavior-support
bgpd, zebra: Add support for SRv6 uSID Behaviors
2022-11-14 16:13:39 +02:00
Donatas Abraitis
ff18b7b078 bgpd: Implement SNMP BGP4V2-MIB (bgp4V2PeerEntry)
http://www.circitor.fr/Mibs/Mib/B/BGP4V2-MIB.mib

Compared with Arista BGP4V2-MIB implementation, almost identical (despite that
Arista has slightly some additional MIBs).

Example:

```
iso.3.6.1.3.5.1.1.2.1.1.1.4.192.168.10.64 = Gauge32: 0
iso.3.6.1.3.5.1.1.2.1.1.1.4.192.168.10.65 = Gauge32: 0
iso.3.6.1.3.5.1.1.2.1.1.2.16.42.2.71.128.1.35.0.0.0.0.0.0.0.0.0.2 = Gauge32: 0
iso.3.6.1.3.5.1.1.2.1.1.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.121 = Gauge32: 0
iso.3.6.1.3.5.1.1.2.1.1.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.128 = Gauge32: 0
iso.3.6.1.3.5.1.1.2.1.2.1.4.192.168.10.64 = INTEGER: 0
iso.3.6.1.3.5.1.1.2.1.2.1.4.192.168.10.65 = INTEGER: 0
iso.3.6.1.3.5.1.1.2.1.2.2.16.42.2.71.128.1.35.0.0.0.0.0.0.0.0.0.2 = INTEGER: 2
iso.3.6.1.3.5.1.1.2.1.2.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.121 = INTEGER: 0
iso.3.6.1.3.5.1.1.2.1.2.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.128 = INTEGER: 0
iso.3.6.1.3.5.1.1.2.1.3.1.4.192.168.10.64 = Hex-STRING: 00 00 00 00
iso.3.6.1.3.5.1.1.2.1.3.1.4.192.168.10.65 = Hex-STRING: 00 00 00 00
iso.3.6.1.3.5.1.1.2.1.3.2.16.42.2.71.128.1.35.0.0.0.0.0.0.0.0.0.2 = Hex-STRING: 2A 02 47 80 01 23 00 00 00 00 00 00 00 00 00 01
iso.3.6.1.3.5.1.1.2.1.3.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.121 = Hex-STRING: 00 00 00 00
iso.3.6.1.3.5.1.1.2.1.3.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.128 = Hex-STRING: 00 00 00 00
iso.3.6.1.3.5.1.1.2.1.4.1.4.192.168.10.64 = INTEGER: 0
iso.3.6.1.3.5.1.1.2.1.4.1.4.192.168.10.65 = INTEGER: 0
iso.3.6.1.3.5.1.1.2.1.4.2.16.42.2.71.128.1.35.0.0.0.0.0.0.0.0.0.2 = INTEGER: 2
iso.3.6.1.3.5.1.1.2.1.4.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.121 = INTEGER: 0
iso.3.6.1.3.5.1.1.2.1.4.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.128 = INTEGER: 0
iso.3.6.1.3.5.1.1.2.1.5.1.4.192.168.10.64 = Hex-STRING: 00 00 00 00
iso.3.6.1.3.5.1.1.2.1.5.1.4.192.168.10.65 = Hex-STRING: 00 00 00 00
iso.3.6.1.3.5.1.1.2.1.5.2.16.42.2.71.128.1.35.0.0.0.0.0.0.0.0.0.2 = Hex-STRING: 2A 02 47 80 01 23 00 00 00 00 00 00 00 00 00 02
iso.3.6.1.3.5.1.1.2.1.5.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.121 = Hex-STRING: 00 00 00 00
iso.3.6.1.3.5.1.1.2.1.5.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.128 = Hex-STRING: 00 00 00 00
iso.3.6.1.3.5.1.1.2.1.6.1.4.192.168.10.64 = Gauge32: 0
iso.3.6.1.3.5.1.1.2.1.6.1.4.192.168.10.65 = Gauge32: 0
iso.3.6.1.3.5.1.1.2.1.6.2.16.42.2.71.128.1.35.0.0.0.0.0.0.0.0.0.2 = Gauge32: 179
iso.3.6.1.3.5.1.1.2.1.6.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.121 = Gauge32: 0
iso.3.6.1.3.5.1.1.2.1.6.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.128 = Gauge32: 0
iso.3.6.1.3.5.1.1.2.1.7.1.4.192.168.10.64 = Gauge32: 65000
iso.3.6.1.3.5.1.1.2.1.7.1.4.192.168.10.65 = Gauge32: 65000
iso.3.6.1.3.5.1.1.2.1.7.2.16.42.2.71.128.1.35.0.0.0.0.0.0.0.0.0.2 = Gauge32: 65000
iso.3.6.1.3.5.1.1.2.1.7.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.121 = Gauge32: 65000
iso.3.6.1.3.5.1.1.2.1.7.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.128 = Gauge32: 65000
iso.3.6.1.3.5.1.1.2.1.8.1.4.192.168.10.64 = Hex-STRING: C0 00 02 FC
iso.3.6.1.3.5.1.1.2.1.8.1.4.192.168.10.65 = Hex-STRING: C0 00 02 FC
iso.3.6.1.3.5.1.1.2.1.8.2.16.42.2.71.128.1.35.0.0.0.0.0.0.0.0.0.2 = Hex-STRING: C0 00 02 FC
iso.3.6.1.3.5.1.1.2.1.8.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.121 = Hex-STRING: C0 00 02 FC
iso.3.6.1.3.5.1.1.2.1.8.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.128 = Hex-STRING: C0 00 02 FC
iso.3.6.1.3.5.1.1.2.1.9.1.4.192.168.10.64 = Gauge32: 0
iso.3.6.1.3.5.1.1.2.1.9.1.4.192.168.10.65 = Gauge32: 0
iso.3.6.1.3.5.1.1.2.1.9.2.16.42.2.71.128.1.35.0.0.0.0.0.0.0.0.0.2 = Gauge32: 54814
iso.3.6.1.3.5.1.1.2.1.9.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.121 = Gauge32: 0
iso.3.6.1.3.5.1.1.2.1.9.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.128 = Gauge32: 0
iso.3.6.1.3.5.1.1.2.1.10.1.4.192.168.10.64 = Gauge32: 65002
iso.3.6.1.3.5.1.1.2.1.10.1.4.192.168.10.65 = Gauge32: 65002
iso.3.6.1.3.5.1.1.2.1.10.2.16.42.2.71.128.1.35.0.0.0.0.0.0.0.0.0.2 = Gauge32: 65002
iso.3.6.1.3.5.1.1.2.1.10.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.121 = Gauge32: 65001
iso.3.6.1.3.5.1.1.2.1.10.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.128 = Gauge32: 65001
iso.3.6.1.3.5.1.1.2.1.11.1.4.192.168.10.64 = Hex-STRING: 00 00 00 00
iso.3.6.1.3.5.1.1.2.1.11.1.4.192.168.10.65 = Hex-STRING: 00 00 00 00
iso.3.6.1.3.5.1.1.2.1.11.2.16.42.2.71.128.1.35.0.0.0.0.0.0.0.0.0.2 = STRING: "dddd"
iso.3.6.1.3.5.1.1.2.1.11.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.121 = Hex-STRING: 00 00 00 00
iso.3.6.1.3.5.1.1.2.1.11.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.128 = Hex-STRING: 00 00 00 00
iso.3.6.1.3.5.1.1.2.1.12.1.4.192.168.10.64 = INTEGER: 2
iso.3.6.1.3.5.1.1.2.1.12.1.4.192.168.10.65 = INTEGER: 2
iso.3.6.1.3.5.1.1.2.1.12.2.16.42.2.71.128.1.35.0.0.0.0.0.0.0.0.0.2 = INTEGER: 2
iso.3.6.1.3.5.1.1.2.1.12.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.121 = INTEGER: 2
iso.3.6.1.3.5.1.1.2.1.12.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.128 = INTEGER: 2
iso.3.6.1.3.5.1.1.2.1.13.1.4.192.168.10.64 = INTEGER: 1
iso.3.6.1.3.5.1.1.2.1.13.1.4.192.168.10.65 = INTEGER: 3
iso.3.6.1.3.5.1.1.2.1.13.2.16.42.2.71.128.1.35.0.0.0.0.0.0.0.0.0.2 = INTEGER: 1
iso.3.6.1.3.5.1.1.2.1.13.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.121 = INTEGER: 3
iso.3.6.1.3.5.1.1.2.1.13.2.16.42.12.47.7.72.150.6.102.0.0.0.0.0.0.177.128 = INTEGER: 1
iso.3.6.1.3.5.1.1.2.1.14.1.4.192.168.10.64 = Hex-STRING: 4F 4B 00
iso.3.6.1.3.5.1.1.2.1.14.1.4.192.168.10.65 = Hex-STRING: 4F 4B 32 00
iso.3.6.1.3.5.1.1.2.1.14.2.16.42.2.71.128.1.35.0.0.0.0.0.0.0.0.0.2 = Hex-STRING: 69 70 76 36 00
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-11-14 10:43:03 +02:00
Carmine Scarpitta
a3ff3dff3f lib,zebra: Add SRv6 uSID info to VTY output
In this commit, we extend to print the `SRV6_LOCATOR_USID` flag.
The output appears as follows:

```
{
  "locators":[
    {
      "name":"loc1",
      "prefix":"fc00:0:1::/48",
      "blockBitsLength":32,
      "nodeBitsLength":16,
      "functionBitsLength":16,
      "argumentBitsLength":0,
      "uSID":true,
      "statusUp":true,
      "chunks":[
        {
          "prefix":"fc00:0:1::/48",
          "proto":"bgp"
        }
      ]
    }
  ]
}
```

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-11-08 22:44:23 +01:00
Carmine Scarpitta
0494782554 lib: Add support for SRv6 Behavior codepoints
In this commit, we introduce a new enumeration to encode the SRv6
Endpoint Behaviors codepoints defined in the IANA SRv6 Endpoint
Behaviors Registry
(https://www.iana.org/assignments/segment-routing/segment-routing.xhtml).

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-11-08 22:44:23 +01:00
Donatas Abraitis
061f5d1cb4 lib: Add PCRE2 support
Some results:

```
====
PCRE
====
% ./a.out "^65001" "65001"
comparing: ^65001 / 65001

ret status: 0
[14:31] donatas-pc donatas /home/donatas
% ./a.out "^65001_" "65001"
comparing: ^65001_ / 65001

ret status: 0

=====
PCRE2
=====
% ./a.out "^65001" "65001"
comparing: ^65001 / 65001

ret status: 0
[14:30] donatas-pc donatas /home/donatas
% ./a.out "^65001_" "65001"
comparing: ^65001_ / 65001

ret status: 1
```

Seems that if using PCRE2, we need to escape outer `()` chars and `|`. Sounds
like a bug.
But this is only with some older PCRE2 versions. With >= 10.36, I wasn't able
to reproduce this, everything is fine and working as expected.

Adding _FRR_PCRE2_POSIX definition because pcre2posix.h does not have
include's guard.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-11-07 21:23:53 +02:00
Donatas Abraitis
47f3d0905b
Merge pull request #12238 from donaldsharp/append
lib, zebra: Allow for zebra to recognize that a route has gotten desy…
2022-11-07 10:37:05 +02:00
Donald Sharp
ca2b346783 *: Add ability to encode / decode resilence down zapi
At this point add abilty for the encode/decode of the
resilience down ZAPI to zebra.  Just hookup sharpd
at this point in time.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-11-04 13:34:27 -04:00
Donald Sharp
f3c6dd49f4 *: Add ability for daemons to notice resilience changes
This patch just introduces the callback mechanism for the
resilient nexthop changes so that upper level daemons
can take advantage of the change.  This does nothing
at this point but just call some code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-11-04 13:34:27 -04:00
Donald Sharp
f0f618dcdb lib, vtysh: Add ability to specify resilient nhgs
Add the ability to specify a resilient nexthop group

nexthop-group A
 resilient buckets 32 idle_timer 100 unbalanced_timer 500
 nexthop 192.168.100.1 enp7s0
 nexthop 192.168.100.33 enp7s0
 nexthop 192.168.122.1 enp1s0

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-11-04 13:34:27 -04:00
Donald Sharp
569e141113 lib, zebra: Add ability to encode/decode resilient nhg's
Add ability to read the nexthop group resilient linux
kernel data as well as write it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-11-04 13:29:36 -04:00
Donald Sharp
e483855d24 lib: When adding to front of list ensure we handle tail to
When inserting to the front of a list with listnode_add_head
if the list is empty, the tail will not be properly set and
subsuquent calls to insert/remove will cause the function
to crash.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-11-04 13:29:36 -04:00
Donald Sharp
a048d52399 lib, zebra: Allow for zebra to recognize that a route has gotten desynced
FRR does not use the NLM_F_APPEND semantics ( in fact I would argue that
the NLM_F_APPEND semantics just introduce pain for all parties involved )
I would also argue that most people who use the kernel netlink api
have recognized that NLM_F_APPEND for a route is a recipe for disaster
that is well documented and as such it is not used as anything other
than a curiousity by operators.

See:
https://bugzilla.redhat.com/show_bug.cgi?id=1337855
https://github.com/thom311/libnl/issues/226

Are 2 great examples of how confusing it is for anyone in user
space to know what the correct thing to do is.  Given that
new fields can be added with no semantics to allow us to know
what has resulted in a change or not.

In an attempt to recognize this, let's note that FRR
believes it has gotten out of sync with the kernel.
Future commits will react to the desynchronized route
and request from the kernel a reload of that specific
route if possible.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-11-04 12:02:00 -04:00
Donald Sharp
ac3ee3270b lib: Fix double set of event pointer to NULL
The event system when executing a thread already
sets the pointer of it to NULL.  No need to
do it again.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-11-03 12:50:24 -04:00
Donald Sharp
d7cde18c63
Merge pull request #12196 from opensourcerouting/xref-vtysh
*: rewrite `extract.pl` using `xref` infra
2022-11-03 08:54:09 -04:00
Russ White
a5dac02901
Merge pull request #12114 from opensourcerouting/feature/bgp_aigp_attribute
bgpd: Implement AIGP
2022-10-31 11:24:43 -04:00
mobash-rasool
6863cf6a5a
Merge pull request #12230 from cscarpitta/fix/replace-inet-top-in-srv6-lib
lib: Use `%pI6`/`%pI4` to print SRv6 seg6local ctx
2022-10-31 12:04:26 +05:30
Carmine Scarpitta
84410eb0fe lib: Use %pI6/%pI4 to print SRv6 seg6local ctx
This commit changes `seg6local_context2str()` to use `%pI6`/`%pI4`
instead of `inet_ntop` to print the SRv6 seg6local context information.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-10-30 09:15:06 +01:00
Donald Sharp
b7128471c6
Merge pull request #12224 from cscarpitta/fix/enhance-srv6-locator-chunk-free-api
bgpd: Enhance the `srv6_locator_chunk_free()` API by automatically setting the pointer to the freed memory to `NULL`
2022-10-29 19:56:07 -04:00
Carmine Scarpitta
6946731314 lib, bgpd: Enhance srv6_locator_chunk_free() API
A programmer can use the `srv6_locator_chunk_free()` function to free
the memory allocated for a `struct srv6_locator_chunk`.

The programmer invokes `srv6_locator_chunk_free()` by passing a single
pointer to the `struct srv6_locator_chunk` to be freed.
`srv6_locator_chunk_free()` uses `XFREE()` to free the memory.
It is the responsibility of the programmer to set the
`struct srv6_locator_chunk` pointer to NULL after freeing memory with
`srv6_locator_chunk_free()`.

This commit modifies the `srv6_locator_chunk_free()` function to take a
double pointer instead of a single pointer. In this way, setting the
`struct srv6_locator_chunk` pointer to NULL is no longer the
programmer's responsibility but is the responsibility of
`srv6_locator_chunk_free()`. This prevents programmers from making
mistakes such as forgetting to set the pointer to NULL after invoking
`srv6_locator_chunk_free()`.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-10-29 17:04:35 +02:00
Carmine Scarpitta
d537287a48 lib,zebra: Send SRv6 locator flags over the ZAPI
In this commit, we extend the ZAPI to support encoding and decoding the
locator flags contained in the messages exchanged between zebra and the
routing daemons.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-10-29 02:07:01 +02:00
Carmine Scarpitta
02b1544a5c lib: Add SRV6_LOCATOR_USID flag to SRv6 locator
In this commit, we add support for a new flag called
`SRV6_LOCATOR_USID`. When the `SRV6_LOCATOR_USID` flag is set, the
routing protocols will install SRv6 behaviors with the uSID in the
dataplane.

This flag is used to specify a locator as a uSID locator. When a locator
is specified as a uSID locator, all the SRv6 SIDs allocated from the
locator by the routing protocols (like BGP) are bound to the SRv6 uSID
behaviors and use the SRv6 uSID codepoints in the BGP update message.

We extend the SRv6 locator implementation to add support for a `usid`
flag. When the `usid` flag is set, the bgpd will install SRv6 behaviors
with the uSID in the dataplane and use the proper SRv6 Endpoint Behavior
codepoint in the BGP advertisement.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-10-29 02:04:57 +02:00
Carmine Scarpitta
9b7491e1fc lib: Add support for flags to the SRv6 locator
In this commit, we introduce the ability to specify flags for an SRv6
locator. Flags can be used to specify the properties of the locator.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-10-29 01:31:59 +02:00
Olivier Dugeon
d36cd56638
Merge pull request #12154 from louis-6wind/fix-te-default-bandwidth
lib: fix the default TE bandwidth
2022-10-28 09:29:12 +02:00
Louis Scalbert
d5a313e074 lib: fix the default TE bandwidth
When enabling the interface link-params, a default bandwidth is assigned
to the Max, Reservable and Unreserved Bandwidth variables. If the
bandwidth is set at in the interface context, this value is used.
Otherwise, a default bandwidth value of 10 Gbps is set.

Revert the default value to 10 Mbps as it was intended in the initial
commit. 10 Mbps is a low value so that the link will not be prioritized
when computing the paths.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-10-27 18:15:12 +02:00
Louis Scalbert
f6657a6ef3 lib: fix coverity scan failure in zebra_interface_link_params_read()
The code was working but the coverity scan reported a failure.

Clarify the code to make the coverity scan happy.

Fixes: fe0a129687 ("lib,zebra: link-params are not flushed after no enable")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-10-27 10:12:47 +02:00
David Lamparter
89cb86aeb0 build, vtysh: extract vtysh commands from .xref
Rather than running selected source files through the preprocessor and a
bunch of perl regex'ing to get the list of all DEFUNs, use the data
collected in frr.xref.

This not only eliminates issues we've been having with preprocessor
failures due to nonexistent header files, but is also much faster.
Where extract.pl would take 5s, this now finishes in 0.2s.  And since
this is a non-parallelizable build step towards the end of the build
(dependent on a lot of other things being done already), the speedup is
actually noticeable.

Also files containing CLI no longer need to be listed in `vtysh_scan`
since the .xref data covers everything.  `#ifndef VTYSH_EXTRACT_PL`
checks are equally obsolete.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-10-26 17:12:34 +01:00
Donatas Abraitis
97a52c82a5 bgpd: Implement Accumulated IGP Metric Attribute for BGP
https://www.rfc-editor.org/rfc/rfc7311.html

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-10-26 11:26:57 +03:00
Donatas Abraitis
0c969118c7 lib: Add ptr_get_be64() function
Get a single uint64_t value from two uint32_t values.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-10-26 11:22:43 +03:00
Olivier Dugeon
f274c9fde2
Merge pull request #12125 from louis-6wind/fix-link-params
lib,zebra,ospf: link-params are not flushed after "no enable"
2022-10-25 10:53:23 +02:00
Donatas Abraitis
695f387ed8
Merge pull request #11673 from cscarpitta/srv6-per-vrf-sid
bgpd: add support for SRv6 L3VPN for IPv4 and IPv6 address families using a single SID
2022-10-24 17:30:10 +03:00
Donald Sharp
78946603e1 lib: Remove unnecessary comparison, for linked list
In the comparison function for a linked list code was
always checking against passed in NULL's.  The comparison
function will never receive a NULL value for data from
the linklist.c code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-10-20 07:43:45 -04:00
Carmine Scarpitta
696f43700e lib: add block/node/arg len to SRv6 locator JSON
This commit adds the SRv6 locator's block length, node length and
argument length to the output of the command
"show segment-routing srv6 locator json"

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-10-18 15:37:26 +02:00
Carmine Scarpitta
8bea07e49f zebra, lib: add support for SRv6 End.DT46 behavior
This commit enables zebra to install End.DT46 nexthops into the Linux kernel.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-10-18 15:37:25 +02:00
Donatas Abraitis
272c6d5db1
Merge pull request #8647 from sworleys/DVNI-Config-Changes
bgpd: EVPN D-VNI L3 RT Config Enhancements
2022-10-18 14:17:04 +03:00
Louis Scalbert
fe0a129687 lib,zebra: link-params are not flushed after no enable
Daemons like isisd continue to use the previous link-params after they
are removed from zebra.

For example,
>r0# sh run zebra
> (...)
> interface eth-rt1
>  link-params
>   enable
>   metric 100
>  exit-link-params
> r0# conf
> r0(config)# interface eth-rt1
> r0(config-if)#  link-params
> r0(config-link-params)#   no enable

After "no enable", "sh run zebra" displays no more link-params context.

The "no enable" causes the release of the "link_params" pointer within
the "interface" structure. The zebra function to update daemons with
a ZEBRA_INTERFACE_LINK_PARAMS zapi message is called but the function
returns without doing anything because the "link_params" pointer is
NULL. Therefore, the "link_params" pointers are kept in daemons.

When the zebra "link_params" pointer is NULL:

- Send a zapi link param message that contains no link parameters
  instead of sending no message.
- At reception in daemons, the absence of link parameters causes the
  release of the "link_params" pointer.

Fixes: 16f1b9e ("Update Traffic Engineering Support for OSPFD")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-10-17 12:21:27 +02:00
Louis Scalbert
2e2dc4f024 lib,zebra: do not enable link-params when a link-params command fails
A given interface has no enabled link-params context. If a link-params
configuration command fails, the link-params is wrongly enabled:

> r4(config-link-params)# no enable
> r4(config-link-params)# delay
>   (0-16777215)  Average delay in micro-second as decimal (0...16777215)
> r4(config-link-params)# delay 50 min 300 max 500
> Average delay should be comprise between Min (300) and Max (500) delay
> r4(config-link-params)# do sh run zebra
> (...)
> interface eth-rt1
> link-params
>  enable
> exit-link-params

link-params are enabled if and only if the interface structure has a
valid link_params pointer. Before checking the command validity,
if_link_params_get() is called to retrieve the link-params pointer.
However, this function initializes the pointer if it is NULL.

Only use if_link_params_get() to retrieve the pointer to avoid
confusion. In command setting functions, initialize the link_params
pointer if needed only after the validation of the command.

Fixes: 16f1b9e ("Update Traffic Engineering Support for OSPFD")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-10-17 11:02:56 +02:00
Donald Sharp
e3e3d729c4
Merge pull request #12066 from opensourcerouting/cleanup-cli-xref
*: clean up various CLI-related bits
2022-10-13 13:47:04 -04:00
Donatas Abraitis
0407bb2dc0
Merge pull request #12108 from donaldsharp/general_mayhem
General mayhem
2022-10-13 08:08:27 +03:00
Donald Sharp
ca28a0f6fa lib: Free some memory in scripting subsystem at shutdown
Pre:
staticd: showing active allocations in memory group libfrr
staticd: memstats:  Scripting                     :     16 * (variably sized)
staticd: memstats:  Hash                          :      2 * (variably sized)
staticd: memstats:  Hash Bucket                   :      8 *         32
staticd: memstats:  Hash Index                    :      1 * (variably sized)
staticd: memstats:  Link List                     :      1 *         40
staticd: memstats:  Link Node                     :      1 *         24
staticd: showing active allocations in memory group logging subsystem
staticd: memstats:  log file target               :      1 *         88
staticd: showing active allocations in memory group staticd

Post:
staticd: showing active allocations in memory group libfrr
staticd: showing active allocations in memory group logging subsystem
staticd: memstats:  log file target               :      1 *         88
staticd: showing active allocations in memory group staticd

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-10-12 07:39:23 -04:00
Madhuri Kuruganti
bba9435157 bgpd, ospfd: update BGP when routes are removed from OSPF routing table
Signed-off-by: Madhuri Kuruganti <maduri111@gmail.com>
2022-10-12 13:43:55 +05:30
Madhuri Kuruganti
9f2984d97c ospfd: few fixes in rSPF calc when LSA received from non root node
Signed-off-by: Madhuri Kuruganti <maduri111@gmail.com>
2022-10-12 13:43:55 +05:30
Madhuri Kuruganti
a5dd4bf47d lib: BGP registration with IGP for BGP ORR rSPF calc
Signed-off-by: Madhuri Kuruganti <maduri111@gmail.com>
2022-10-12 13:29:24 +05:30
Donatas Abraitis
69c736ec06
Merge pull request #12074 from donaldsharp/lib_debugs
*: Create and use infrastructure to show debugs in lib
2022-10-12 10:38:21 +03:00
Stephen Worley
852d9f9757 bgpd,zebra,lib: bgp evpn vni macip into two tables
Re-work the bgp vni table to use separately keyed tables for type2
routes.

So, with type2 routes, we have the main table keyed off of the IP and a
new MAC table keyed off of MACs.

By separating out the two, we are able to run path selection separately
for the neigh and mac. Keeping the two separate is also more in-line
with what happens in zebra (they are managed comptletely seperate).

With this change type2 routes go into each table like so:

```
Remote MAC-IP -> IP Table & MAC Table
Remote MAC -> MAC Table

Local MAC-IP -> IP Table
Local MAC -> MAC Table
```

The difference for local is necessary because we should not ever allow
multiple paths for a local MAC.

Also cleaned up the commands for querying the vni tables:

```
show bgp vni all type ...
show bgp vni VNI type ...

```

Old commands will be deprecated in a separate commit.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-10-11 16:18:21 -04:00
Donatas Abraitis
eb53128367
Merge pull request #9998 from pguibert6WIND/bgp_tcp_keepalive
Bgp tcp keepalive
2022-10-10 15:46:30 +03:00
Donald Sharp
cf00164b69 *: Create and use infrastructure to show debugs in lib
There are lib debugs being set but never show up in
`show debug` commands because there was no way to show
that they were being used.  Add a bit of infrastructure
to allow this and then use it for `debug route-map`

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-10-07 12:39:05 -04:00
David Lamparter
a0dfca37b5 *: fix some malformed CLI docstrings
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-10-06 15:39:56 +02:00
David Lamparter
3df5764499 lib: add CMD_ATTR_NOSH
To propagate into .xref so extract.pl can be handled there.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-10-06 15:34:32 +02:00
David Lamparter
ba31dc303a lib: detangle DEFUN macros
Make the variants go into an _ATTR macro each.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-10-06 15:34:32 +02:00
David Lamparter
9eebf97e3d lib: make cmd_element->attr a bitmask & clarify
It already "looks" like a bitmask, but we currently can't flag a command
both YANG and HIDDEN at the same time.  It really should be a bitmask.

Also clarify DEPRECATED behaviour (or the absence thereof.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-10-06 15:34:32 +02:00
David Lamparter
53d8bf6d7a lib: remove unused CLI macros
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-10-06 15:34:32 +02:00
Francois Dumontet
5e0136c94f lib: fix typesafe hash add with hash collision
The typesafe hash data structure enforces items to be unique, but their
hash values may still collide.  To this extent, when two items have the
same hash value, the compare function is called to see if it returns 0
(aka "equal").

While the _find() function handles this correctly, the _add() function
mistakenly only checked the first item with a colliding hash value for
equality, and if it was inequal proceeded to add the new item.  There
may however be additional items with the same hash value collision, one
of which could still compare as equal.  In that case, _add() would
mistakenly add the new element, failing to notice the already added
item.  Breakage ensues.

Fix by looking for an equal element among *all* existing items with the
same hash value, not just the first.

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
[DL: rewrote commit message, fixed whitespace/formatting]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-10-06 15:09:15 +02:00
Donatas Abraitis
4c17bee53f lib: Fix show route-map NAME json command and memory leak
JSON object was generated, but not printed, because the function returned
immediatelly, even without freeing the memory.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-09-26 14:56:20 +03:00
Donatas Abraitis
c4f64ea94d bgpd: Use %pRD for prefix_rd2str()
Convert a bunch of prefix_rd2str() for json/vty stuff.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-09-22 13:12:11 +03:00
Donald Sharp
6bae02045b lib: Fix skip of every other plist deletion
When bulk deleting prefix lists on shutdown the code
was calling plist_delete, which removed the item
from the master->str list, and then popping the next
item on the list and just dropping it on the floor.
The pop is not needed.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-09-14 13:48:31 -04:00
Russ White
7fa5e07b1c
Merge pull request #11899 from opensourcerouting/feature/route_validation_extended_community
bgpd: Implement Origin Validation State via extended communities
2022-09-13 11:30:54 -04:00
Donald Sharp
71d987dbb9
Merge pull request #11868 from LabNConsulting/ziemba/bgp-labelpool-performance
bgpd: improve labelpool performance at scale
2022-09-12 10:45:43 -04:00
Donatas Abraitis
d3822e7983 lib: Replace route_map_clear_updated to void
Return status not used at all.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-09-12 04:42:41 +03:00
anlan_cs
b5d1433e6d lib: replace one path with macro
Replace all of the path name with macro, only the two places.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-09-07 01:10:14 -04:00
Rafael Zalamena
340ed5f9e2
Merge pull request #11823 from pguibert6WIND/bgp_vpnv4_gre_ebgp
Bgp vpnv4 convey without transport label
2022-09-06 13:37:19 -03:00
Philippe Guibert
1bb550b63c bgpd: add resolution for l3vpn traffic over gre interfaces
When a route imported from l3vpn is analysed, the nexthop from default
VRF is looked up against a valid MPLS path. Generally, this is done on
backbones with a MPLS signalisation transport layer like LDP. Generally,
the BGP connection is multiple hops away. That scenario is already
working.

There is case where it is possible to run L3VPN over GRE interfaces, and
where there is no LSP path over that GRE interface: GRE is just here to
tunnel MPLS traffic. On that case, the nexthop given in the path does not
have MPLS path, but should be authorized to convey MPLS traffic provided
that the user permits it via a configuration command.

That commit introduces a new command that can be activated in route-map:
 > set l3vpn next-hop encapsulation gre

That command authorizes the nexthop tracking engine to accept paths that
o have a GRE interface as output, independently of the presence of an LSP
path or not.

A configuration example is given below. When bgp incoming vpnv4 updates
are received, the nexthop of NLRI is 192.168.0.2. Based on nexthop
tracking service from zebra, BGP knows that the output interface to reach
192.168.0.2 is r1-gre0. Because that interface is not MPLS based, but is
a GRE tunnel, then the update will be using that nexthop to be installed.

    interface r1-gre0
     ip address 192.168.0.1/24
    exit
    router bgp 65500
     bgp router-id 1.1.1.1
     neighbor 192.168.0.2 remote-as 65500
     !
     address-family ipv4 unicast
      no neighbor 192.168.0.2 activate
     exit-address-family
     !
     address-family ipv4 vpn
      neighbor 192.168.0.2 activate
      neighbor 192.168.0.2 route-map rmap in
     exit-address-family
    exit
    !
    router bgp 65500 vrf vrf1
     bgp router-id 1.1.1.1
     no bgp network import-check
     !
     address-family ipv4 unicast
      network 10.201.0.0/24
      redistribute connected
      label vpn export 101
      rd vpn export 444:1
      rt vpn both 52:100
      export vpn
      import vpn
     exit-address-family
    exit
    !
    route-map rmap permit 1
     set l3vpn next-hop encapsulation gre
    exit

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2022-09-05 22:26:25 +02:00
Donatas Abraitis
324e8b1f79 bgpd: Handle Origin Validation State extended community via route-map match
Add an ability to match via route-maps. An additional route-map command

`match rpki-extcommunity <invalid|notfound|valid>` added.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-09-04 21:54:47 +03:00
Donatas Abraitis
1011b31a1c
Merge pull request #11884 from mjstapp/fix_cancel_ptrs
lib: ensure locals are inited to NULL
2022-09-02 13:49:10 +03:00
Mark Stapp
7e93a54c6c lib: ensure locals are inited to NULL
A couple of pointers in do_thread_cancel() we only inited at
the start of the function; make sure they're inited during
each iteration of the loop.

Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2022-08-31 11:47:39 -04:00
G. Paul Ziemba
80853c2ec7 bgpd: improve labelpool performance at scale
- double the size of each new chunk request from zebra
    - use bitfields to track label allocations in a chunk
    - When allocating:
        - skip chunks with no free labels
        - search biggest chunks first
        - start search in chunk where last search ended
    - Improve API documentation in comments (bgp_lp_get() and callback)
    - Tweak formatting of "show bgp labelpool chunks"
    - Add test features (compiled conditionally on BGP_LABELPOOL_ENABLE_TESTS)

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2022-08-31 08:21:27 -07:00
Donatas Abraitis
c29b1ce67c
Merge pull request #11855 from cscarpitta/fix-srv6-memleaks
*: Fix several memory leaks in SRv6 implementation
2022-08-29 14:35:24 +03:00
Weiguo Li
51a68f9b3e lib: Fix extra semicolon after if
Signed-off-by: Weiguo Li <liwg06@foxmail.com>
2022-08-25 17:52:21 +08:00
Carmine Scarpitta
d0c775e3eb lib: Fix memory leak in zclient_send_localsid()
Running `bgp_srv6l3vpn_to_bgp_vrf` and `bgp_srv6l3vpn_to_bgp_vrf2`
topotests with `--valgrind-memleaks` gives several memory leak errors.
This is due to the way FRR daemons pass local SIDs to zebra: to send a
local SID to zebra, FRR daemons call the `zclient_send_localsid()`
function.

The `zclient_send_localsid()` function performs the following sequence
of operations:
* create a temporary `struct nexthop`;
* call `nexthop_add_srv6_seg6local()` to fill the `struct nexthop` with
the proper local SID information;
* create a `struct zapi_route` and call `zapi_nexthop_from_nexthop()` to
copy the information from the `struct nexthop` to the
`struct zapi_route`;
* send the `struct zapi_route` to zebra through the ZAPI.

The `nexthop_add_srv6_seg6local()` function uses `XCALLOC()` to allocate
memory for the SRv6 nexthop. This memory is never freed.

Creating a temporary `struct nexthop` is unnecessary, as the local SID
information can be pushed directly to the `struct zapi_route`. This
patch simplifies the implementation of `zclient_send_localsid()` by
avoiding using the temporary `struct nexthop`. This eliminates the need
to use `nexthop_add_srv6_seg6local()` to fill the `struct nexthop` and
consequently fixes the memory leak.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-08-24 08:41:45 +02:00
Stephen Worley
5ad4fc6ce9 lib: use evpn type enum for prefix conversion
Use the evpn type enum for the evpn_prefix2prefix conversion.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-08-23 12:41:25 -04:00
Stephen Worley
a33b4d3f4c lib: handle type2/5 routes in optimized route-map
Handle matching type2/5 evpn routes via lookup in the optimized
route-maps used by plists.

Convert the evpn_prefix to ipv4/v6 prefix to perform longest
matching on in the tree.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-08-23 12:41:25 -04:00
Stephen Worley
6eb8350586 bgpd,lib: route-map/plist matching via type-2/5 routes
Implement the ability to match type-2 and type-5 routes
via a route-map and a prefix-list.

Add some library code to convert an evpn prefix into
a general ipv4/ipv6 prefix for type-2 and type-5 routes.
evpn prefix is really just another subtype of prefix so all
the info needed can be extracted right there.

Add a special handler to bgp_routemap for evpn type routes
when applying the outbound route-map. This calls the library
code to convert the evpn_prefix to a ipv4/ipv6 prefix and
run it through the plist code. In this we assume type-2 routes
are a /32.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-08-23 12:41:25 -04:00
Donald Sharp
43a8e0ac88 lib: Ensure ls_msg2edge does not use memory after freeing
ls_msg2edge calls ls_edge_del_all which will free the
edge variable.  Ensure that FRR properly returns NULL.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-15 15:45:05 -04:00
Weiguo Li
71a7567938 lib: Remove invalid function declaration
there is no definition of ttable_cell_del(), thus remove its declaration.

Signed-off-by: Weiguo Li <liwg06@foxmail.com>
2022-08-08 17:29:33 +08:00
Donald Sharp
f07b1a9fb4
Merge pull request #11716 from mobash-rasool/fixes2
pimd, pim6d: Send register msg via reg socket, solve FHR/RP same node issue
2022-08-04 22:06:49 -04:00
Mobashshera Rasool
7cf66a2220 lib: Add errno details to the sockopt_reuseaddr api
Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2022-08-04 01:38:33 -07:00
Donatas Abraitis
08c2bd9953
Merge pull request #11710 from donaldsharp/split_up_test_multicast_pim_static_rp
some test fixes and a coverity fix
2022-08-03 11:11:37 +03:00
Donald Sharp
c61a427870
Merge pull request #11715 from Orange-OpenSource/link_state
lib: Correct valgrind errors
2022-08-02 20:20:06 -04:00
David Lamparter
8c6f41ff1d build: unconditionally enable format checks
The format message checks done by clippy/xrelfo were still guarded
behind `--enable-dev-build`.  They've been clean and reliable, so it's
time to enable them unconditionally.

Fixes: #11680
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-08-02 10:37:55 -04:00
Donald Sharp
0418cf2e26 lib: Remove usage of inet_ntop in lib/sockopt.c
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-02 10:37:55 -04:00
Olivier Dugeon
9bf9bd1a0b lib: Correct valgrind errors
In CSPF topo test, valgrind detects uninitialized bytes when exporting TE
Opaque information through ZEBRA. This is due to C pragma compilation directive
__attribute__(aligned(8)) in struct ls_node_id in link_state.h. Valgrind
consideris that struct ls_node_id nid = {} doesn't initialized the padding
bytes introduced by gcc.

This patch simply removes the C pragma compilation directive and also takes
opportunity to remove the transmission of remote node id for vertices and
subnets which is not known. Indeed, remote node id is only pertinent for
edges.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2022-08-01 17:32:56 +02:00
Donald Sharp
9edb601666 lib: Use pI4 instead of inet_ntop in sockopt.c
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-29 18:31:58 -04:00
Donald Sharp
c4a97dc54a lib: Coverity wants strlen to include null character
Ensure that the string has the null terminating character available
as well.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-29 15:55:01 -04:00
Xiaofeng Liu
5c480b5db3 lib: add a function to configure tcp keepalive parameters
New function setsockopt_tcp_keepalive() is added to enable TCP keepalive
mechanism for specified socket. Also TCP keepalive idle time, interval
and maximum probes are configured.

Signed-off-by: Xiaofeng Liu <xiaofeng.liu@6wind.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2022-07-28 16:42:01 +02:00
Donatas Abraitis
eed5b70f94
Merge pull request #11657 from donaldsharp/why_timer
convert thread_cancel to THREAD_OFF
2022-07-22 08:26:08 +03:00
Donald Sharp
b8551584ee lib, vrrpd: Use THREAD_ARG
Don't auto set the thread->arg pointer.  It is private
and should be only accessed through the THREAD_ARG pointer.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-21 08:30:50 -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
Donald Sharp
a0d46bcd08 lib: thread pointer is already null at this point
in agentx_events_update the timeout_thr is canceled
on line 88 just above.  This already sets the pointer
to NULL.  No need to do this again.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-19 13:54:10 -04:00
Donatas Abraitis
13bcc010e3 lib: Return 0 as remaining msec if the thread is not scheduled
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-07-18 16:43:44 +03:00
Donald Sharp
05a95ab8ad lib: Prevent Uninitialized usage of data
Valgrind is reporting that prefix is being used uninitialized.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-16 18:59:51 -04:00
David Lamparter
c9aa57dcf1
Merge pull request #11585 from patrasar/sg_str 2022-07-13 16:51:10 +02:00
David Lamparter
8cb56fb273
Merge pull request #11285 from iqras23/conditional_def_orig 2022-07-12 17:41:09 +02:00
Sarita Patra
9deed2ad77 pimd: Fix description for PIM_SG_LEN
Signed-off-by: Sarita Patra <saritap@vmware.com>
2022-07-12 04:46:56 -07:00
kevinshen
30220d1e35 lib: check hostname in resolver_resolve
resolver_resolve should check hostname is null or not.

if ares_gethostbyname() get null hostname string, the hostname string will access a null pointer and crash.

Signed-off-by: kevinshen <kevinshen@inspur.com>
2022-07-07 12:10:03 +08:00
Iqra Siddiqui
a633fb579e bgpd: Fix insonsistencies with default-originate route-map
Description:
- When there are multiple policies configured with
  route-map then the first matching policy is not
  getting applied on default route originated with
  default-originate.

- In BGP we first run through the BGP RIB and then
  pass it to the route-map to find if its permit or
  deny. Due to this behaviour the first route in
  BGP RIB that passes the route-map will be applied.

Fix:
- Passing extra parameter to routemap_apply so that
  we can get the preference of the matching policy,
  keep comparing it with the old preference and finally
  consider the policy with less preference.

Co-authored-by: Abhinay Ramesh <rabhinay@vmware.com>
Signed-off-by: Iqra Siddiqui <imujeebsiddi@vmware.com>
2022-07-06 11:06:49 -07:00
David Lamparter
255a76a56a lib: use assume() for SA fixing, add explainer
Literally 4 minutes after hitting merge on Mark's previous fix for this
I remembered we have an `assume()` macro in compiler.h which seems like
the right tool for this.

(... and if I'm touching it, I might as well add a little text
explaining what's going on here.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-07-06 10:48:56 +02:00
David Lamparter
5adddad38f
Merge pull request #11534 from mjstapp/fix_typesafe_sa
lib: fix SA warning in typesafe code
2022-07-06 10:35:24 +02:00
Mark Stapp
f580074e61 lib: fix SA warning in typesafe code
There's a nagging SA warning, at least with the scan-build
version we use in the FRR CI.

Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2022-07-05 16:31:41 -04:00
Donatas Abraitis
e66b8e3942 lib: Convert ipv4_martian to bool
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-07-01 23:38:14 +03:00
Donatas Abraitis
d80132b137 lib: Allow using IPv4 (Class E) reserved block if enabled
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-07-01 23:38:13 +03:00
Donatas Abraitis
ac156aecb5 lib, vtysh: Add allow-reserved-ranges global command
It will be used to allow/deny using IPv4 reserved ranges (Class E) for Zebra
(configuring interface address) or BGP (allow next-hop to be from this range).

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-07-01 23:24:52 +03:00
Donald Sharp
88be4045c9 lib: Allow downgrade of all caps when none are specified
Staticd when run tells privs.c that it does not need any
priviledges.  The lib/privs.c code was not downgrading
any and all permissions it may have been given at startup.

Since we don't need any let's actually tell the system that
FRR does not need the capabilities anymore in the case
where a daemon does not ask for any cap's.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-29 14:40:57 -04:00
Anuradha Karuppiah
92b06d6bdd lib: add SYS_RAWIO to the capabilities definitions
Signed-off-by: Anuradha Karuppiah <anuradhak@nvidia.com>
2022-06-27 07:56:55 -04:00
Donatas Abraitis
f646c17a43
Merge pull request #11426 from error2407/open_policy
bgpd: Add RFC9234 implementation
2022-06-27 09:57:29 +03:00
Donald Sharp
c704cb44a9 lib, zebra: Notice when a nexthop is set linkdown
When a nexthop is set RTNH_F_LINKDOWN, start noticing
that this flag is set.  Allow FRR to know about this
flag but at this point do not do anything with it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-23 11:23:37 -04:00
Donald Sharp
52e8a7c4f0 lib: Increase nexthop flags size to 16 bits
commit: 5609e70fb8
Added a new flag to the `struct nexthop` and
this addition of a flag caused the flags size to
be too small.  Increase the size of flags to
allow more flags to be had.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-23 11:23:37 -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
Donald Sharp
a01887c40b
Merge pull request #11445 from opensourcerouting/fix/replace_sockunion2str
*: Replace sockunion2str => %pSU
2022-06-22 07:33:14 -04:00
Mobashshera Rasool
3a0d338bc9 lib: Add an api is_ipv6_global_unicast
Add api is_ipv6_global_unicast to identify whether a given
ipv6 address is global unicast or not.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2022-06-21 20:44:10 -07:00
Donatas Abraitis
47e1288431 *: Replace sockunion2str => %pSU
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-21 13:34:56 +03:00
Igor Ryzhov
2af482767c
Merge pull request #11146 from NicolasDichtel/master
lib/if: fix interface name comparison
2022-06-20 19:54:35 +03:00
Donatas Abraitis
4ed0abcb55
Merge pull request #11423 from donaldsharp/lgtm_fixes
Lgtm fixes
2022-06-19 22:33:01 +03:00
Donald Sharp
c08f56304b lib: Add some extra error messages for when things go wrong
In sockunion.c let's eliminate the silent and unexpected failure
mode to let the end operator figure out something is terribly wrong.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-17 13:47:03 -04:00
Eugene Bogomazov
d864dd9eb1 bgpd: Add RFC9234 implementation
RFC9234 is a way to establish correct connection roles (Customer/
Provider, Peer or with RS) between bgp speakers. This patch:
- Add a new configuration/terminal option to set the appropriate local
role;
- Add a mechanism for checking used roles, implemented by exchanging
the corresponding capabilities in OPEN messages;
- Add strict mode to force other party to use this feature;
- Add basic support for a new transitive optional bgp attribute - OTC
(Only to Customer);
- Add logic for default setting OTC attribute and filtering routes with
this attribute by the edge speakers, if the appropriate conditions are
met;
- Add two test stands to check role negotiation and route filtering
during role usage.

Signed-off-by: Eugene Bogomazov <eb@qrator.net>
2022-06-17 13:14:46 +03:00
Christian Hopps
1213e46bfd
lib: cleanup red-herring memleaks in parent of daemonizing fork
- The parent of the daemonizing fork reports memleaks for the early
northbound allocations (libyang). If these were real memleaks these
would show up in the child as well; however, ignoring all memleaks in
the parent of the fork is too hard a sale. Instead, spend some CPU
cycles cleaning up the allocations in the parent after the fork and
immeidatley prior to exiting the parent after the daemonizing fork.

Signed-off-by: Christian Hopps <chopps@labn.net>
2022-06-17 02:14:30 -04:00
Donald Sharp
8dfcf20fa0
Merge pull request #11419 from anlancs/fix/minor-1
zebra, lib: minor changes
2022-06-16 16:35:38 -04:00
Donald Sharp
00c89a3673 lib: Function crypt does not need to be declared mid function
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-16 16:31:35 -04:00
Russ White
93ab9a2c0b
Merge pull request #11409 from donaldsharp/zebra_nhg_debug
Zebra nhg debug
2022-06-16 10:13:20 -04:00
anlan_cs
f978382d78 lib: correct two comments
Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-06-16 08:39:34 -04:00
Donald Sharp
ab08ef8230 lib: stream_dup memory alloc cannot fail
If stream_dup calls stream_new, stream_new can never
return a NULL pointer so the check is unneeded.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-15 10:24:01 -04:00
Donald Sharp
f7a410a7c3 lib: Abstract usage of '%pNHs' so that nexthop groups can use it too
Abstract the usage of '%pNHs' so that when nexthop groups get
a new special printfrr that it can take advantage of this
functionality too.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-14 15:40:36 -04:00
Donald Sharp
be9778a3c1
Merge pull request #11395 from opensourcerouting/fix/autocompete_for_rmap_bgp
*: Use autocomplete for route-maps under commands that require it
2022-06-14 10:48:36 -04:00
Donatas Abraitis
70dd370f5a *: Use autocomplete for route-maps under commands that require it
For example:

```
donatas-laptop# show bgp ipv4 unicast neighbors 127.0.0.2 advertised-routes route-map ?
  RMAP_NAME  Name of the route map
       testas2 testas

donatas-laptop(config)# router bgp
donatas-laptop(config-router)# address-family ipv4
donatas-laptop(config-router-af)# redistribute connected route-map ?
  RMAP_NAME  Pointer to route-map entries
       testas2 testas

donatas-laptop(config-router-af)# network 192.168.0.0/23 route-map ?
  RMAP_NAME  Name of the route map
       testas2 testas
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-13 21:00:51 +03:00
Donatas Abraitis
e24a6977ee bgpd: Wrap IPV4_CLASS_DE into ipv4_unicast_valid() helper
Linux kernel allows (FreeBSD/OpenBSD too) using reserved class E IP ranges.

This is a preparation commit that ease the global switch to allow/deny
class E IP ranges in FRR.

https://datatracker.ietf.org/doc/html/draft-chen-ati-adaptive-ipv4-address-space

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-13 20:44:52 +03: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
Donatas Abraitis
1dd5ce9b93 lib: Update sysrepo code with the latest API changes
* sr_event_notif_send -> sr_notif_send
* sr_process_events -> sr_subscription_process_events
* sr_oper_get_items_subscribe -> sr_oper_get_subscribe
* Removed SR_SUBSCR_CTX_REUSE flag from the code at all

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-09 17:33:22 +03:00
Donald Sharp
0b96b8288a lib: Cleanup workqueue.h to have variable declarations
Cleanup workqueue.h to have variable declarations as per
our standard.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-08 11:38:22 -04:00
Donald Sharp
d1c276681f lib: Fixup workqueue.c to use proper thread.h semantics
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-08 11:38:22 -04:00
Pushpasis Sarkar
4d571bb3c4
Merge pull request #11158 from cyberstormdotmu/master
lib/md5,lib/sha256: Use explicit_bzero to clean up sensitive data.
2022-06-07 21:05:03 +05:30
Loganaden Velvindron
04b4b595d3 lib/md5,lib/sha256: Use explicit_bzero to clean up sensitive data.
explicit_bzero() is available as an API to clean up sensitive data
and avoid compiler optimizations that remove calls to memset() or bzero().

Signed-off-by: Loganaden Velvindron <logan@cyberstorm.mu>
2022-05-31 18:00:18 +04:00
Nicolas Dichtel
f33abb817d lib/if: fix interface name comparison
Using strtol() to compare two strings is a bad idea.
Before the patch, if_cmp_name_func() may confuse foo001 and foo1.

PR=79407
Fixes: 106d2fd572 ("2003-08-01 Cougar <cougar@random.ee>")
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Tested-by: Aurélien Degeorges <aurelien.degeorges@6wind.com>
Acked-by: Philippe Guibert <philippe.guibert@6wind.com>
2022-05-30 14:19:36 +02:00
Donald Sharp
cfb9e0ee59 lib: Make thread_is_scheduled a static inline
For performance, yo.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-20 09:53:44 -04:00
Donald Sharp
64b43136b9
Merge pull request #11195 from anlancs/fix/lib-qsort
lib: add one check in "list_sort()"
2022-05-13 11:49:51 -04:00
anlan_cs
2f58dc31e8 lib: add one check in "list_sort()"
Add one check in `list_sort()`:
Immediatly return if no any items in this list.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-05-12 22:36:54 -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
Donatas Abraitis
50f1f2e724
Merge pull request #11059 from anlancs/fix/bgpd-evnp-wrong-check-hashget
bgpd: fix memory leak for evpn
2022-05-04 21:19:51 +03:00
anlan_cs
8e3aae66ce *: remove the checking returned value for hash_get()
Firstly, *keep no change* for `hash_get()` with NULL
`alloc_func`.

Only focus on cases with non-NULL `alloc_func` of
`hash_get()`.

Since `hash_get()` with non-NULL `alloc_func` parameter
shall not fail, just ignore the returned value of it.
The returned value must not be NULL.
So in this case, remove the unnecessary checking NULL
or not for the returned value and add `void` in front
of it.

Importantly, also *keep no change* for the two cases with
non-NULL `alloc_func` -
1) Use `assert(<returned_data> == <searching_data>)` to
   ensure it is a created node, not a found node.
   Refer to `isis_vertex_queue_insert()` of isisd, there
   are many examples of this case in isid.
2) Use `<returned_data> != <searching_data>` to judge it
   is a found node, then free <searching_data>.
   Refer to `aspath_intern()` of bgpd, there are many
   examples of this case in bgpd.

Here, <returned_data> is the returned value from `hash_get()`,
and <searching_data> is the data, which is to be put into
hash table.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-05-03 00:41:48 +08:00
Rafael Zalamena
79378e4d10 lib: change FRR interface name length definition
Use the OS provided maximum name length instead of defining an arbitrary
one.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2022-05-02 13:03:19 -03:00
Rafael Zalamena
3682bd90f3 *: use FRR interface name definition everywhere
Don't rely on the OS interface name length definition and use the FRR
definition instead.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2022-05-02 13:00:12 -03:00
Donald Sharp
9ad0725081
Merge pull request #11118 from opensourcerouting/time-fmt-nulls
lib: format NULL timevals correctly
2022-04-29 10:00:05 -04:00
mobash-rasool
c4aa8aa669
Merge pull request #11114 from opensourcerouting/vrf-declvar-macros
lib, zebra, pimd: clean up/fix VRF DECLVAR macros
2022-04-29 13:53:08 +05:30
Donald Sharp
4c53ec41b9
Merge pull request #11090 from ton31337/fix/plist_alist_duplicate
lib: Ignore duplicate alist/plist entries in CLI
2022-04-28 12:42:18 -04:00
David Lamparter
782fe5e450 lib: format NULL timevals correctly
Passing NULL for a `%pTVMs` would result in `(null)Ms`, i.e. the `Ms`
flags not eaten up.  Change to eat those up, and print `-` instead for
NULL times.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-28 15:51:00 +02:00
Donald Sharp
8bb5f1db16
Merge pull request #11107 from opensourcerouting/prefix-more-unionizing
lib: `struct prefix` spring cleaning
2022-04-28 08:25:30 -04:00
David Lamparter
0cbed9511a lib, zebra, pimd: clean up/fix VRF DECLVAR macros
There's a common pattern of "get VRF context for CLI node" here, which
first got a helper macro in zebra that then permeated into pimd.

Unfortunately the pimd copy wasn't quite adjusted correctly and thus
caused two coverity warnings (CID 1517453, CID 1517454).

Fix the PIM one, and clean up by providing a common base macro in
`lib/vty.h`.

Also rename the macros (add `_VRF`) to make more clear what they do.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-28 11:09:26 +02:00
Donald Sharp
b6f754f89d
Merge pull request #11098 from opensourcerouting/zapi-mrib-v6
zebra, pimd: add IPv6 support to NEXTHOP_LOOKUP_MRIB
2022-04-27 09:27:49 -04:00
David Lamparter
3125fa6d42 lib: prefix unionization
Ahead of May 1st, the workers of the prefix have decided on more
unionization.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-27 14:43:28 +02:00
David Lamparter
ebc61d81b3 lib: remove unused struct prefix_ptr
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-27 13:21:18 +02:00
Russ White
032183e99a
Merge pull request #11079 from opensourcerouting/staticd-nht-refactor-fix-startrace
staticd: reorg, refactor and improve NHT code
2022-04-26 11:36:34 -04:00
David Lamparter
34ee41c6c9 zebra, pimd: add AF param on NEXTHOP_LOOKUP_MRIB
By changing this API call to use a `struct ipaddr`, which encodes the
type of IP address with it.  (And rename/remove the `IPV4` from the
command name.)

Also add a comment explaining that this function call is going to be
obsolete in the long run since pimd needs to move to proper MRIB NHT.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-26 16:15:00 +02:00
Russ White
13f52753d4
Merge pull request #11086 from ton31337/feature/rmap_aspath_replace
bgpd: Add `set as-path replace <any|ASN>` cmd for route-maps
2022-04-26 08:38:58 -04:00
Donatas Abraitis
1db0e0c6c8 lib: Ignore duplicate alist/plist entries in CLI
If duplicate value is entered, the whole plist/alist just dropped.

Before:
```
$ grep prefix-list /etc/frr/frr.conf
ip prefix-list test seq 5 permit 1.1.1.1/32
ip prefix-list test seq 10 permit 1.1.1.1/32
$ systemctl restart frr
$ vtysh -c 'show run | include prefix-list'
$
```

After:
```
$ grep prefix-list /etc/frr/frr.conf
ip prefix-list test seq 5 permit 1.1.1.1/32
ip prefix-list test seq 10 permit 1.1.1.1/32
$ systemctl restart frr
$ vtysh -c 'show run | include prefix-list'
ip prefix-list test seq 5 permit 1.1.1.1/32
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-25 19:41:17 +03:00
Donatas Abraitis
77e3d82167 bgpd: Add set as-path replace <any|ASN> cmd for route-maps
```
route-map tstas permit 10
 set as-path replace 1
exit
```

Before:

```
donatas-laptop(config-router-af)# do show ip bgp 10.10.10.10/32
BGP routing table entry for 10.10.10.10/32, version 13
Paths: (1 available, best #1, table default)
  Advertised to non peer-group peers:
  192.168.10.65
  65000 1 2 3 123
    192.168.10.65 from 192.168.10.65 (10.10.10.11)
      Origin IGP, metric 0, valid, external, best (First path received)
      Last update: Mon Apr 25 10:39:50 2022
```

After:

```
donatas-laptop(config-router-af)# do show ip bgp 10.10.10.10/32
BGP routing table entry for 10.10.10.10/32, version 15
Paths: (1 available, best #1, table default)
  Advertised to non peer-group peers:
  192.168.10.65
  65000 65010 2 3 123
    192.168.10.65 from 192.168.10.65 (10.10.10.11)
      Origin IGP, metric 0, valid, external, best (First path received)
      Last update: Mon Apr 25 10:40:16 2022
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-25 14:05:22 +03:00
David Lamparter
0e8d473b32 lib: prefix_afi() helper
Just quick shorthand to get an afi_t from a prefix.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-24 15:46:33 +02:00
Donald Sharp
a7141b85c8 lib: Ensure an empty string does not get printed for host/domain
End operator is showing:
!
frr version 8.0.1
frr defaults traditional
hostname test.example.com
domainname

domainname should not be printed in this case at all.  I do not
see any mechanism in current code that this could happen, but
what do I know?  Put some extra stupid insurance in place
to prevent bad config from being generated.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-21 14:13:01 -04:00
Donatas Abraitis
65b9c34d4b
Merge pull request #11055 from donaldsharp/plist_crash
lib: Prevent crash after shutdown request
2022-04-20 15:15:08 +03:00
Donald Sharp
a71e190d44
Merge pull request #10961 from opensourcerouting/build-ms-ext
build: enable `-fms-extensions`
2022-04-20 07:51:45 -04:00
Donald Sharp
10258b031a lib: Prevent crash after shutdown request
Recent commit e92508a741 changed
the prefix_master->str to a RB tree.  This introduced a condition
whnere on shutdown the prefix list was removed from the master list
and then operated on by passing around a name.  Which was then used
to lookup the prefix list again when we operated on the code.
This change to a RB Tree first deleted the item from the RB tree
first thus introducing this crash

Crash:
(gdb) bt
    index=0x556c07d59650, pentry=0x556c07d29380) at lib/routemap.c:2397
    arg=0x7ffdbf84bc60) at lib/hash.c:267
    event=RMAP_EVENT_PLIST_DELETED) at lib/routemap.c:2489

Grab the first item on the list, clean it and then remove it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-19 14:55:55 -04:00
Donald Sharp
8afb9d8a70 *: Fix spelling of seperator
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-19 08:15:23 -04:00
Donald Sharp
485ac9a79b *: Fix spelling of neccessary
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-19 08:11:29 -04:00
Donatas Abraitis
c90fab3c26 lib: Remove deprecated routemap_optimization_cmd
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-11 10:12:18 +03:00
David Lamparter
eeec411244 lib, pimd: add a bunch of address helpers
Just simple helpers to get a scope value, never-forward, and is-SSM for
a given address.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-07 14:00:36 +02:00
David Lamparter
5b4f4e626f build: first header *must* be zebra.h or config.h
This has already been a requirement for Solaris, it is still a
requirement for some of the autoconf feature checks to work correctly,
and it will be a requirement for `-fms-extensions`.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-04 18:33:10 +02:00
Donald Sharp
94202742fb lib, yang: Fix spellinig of miliseconds
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-02 07:48:18 -04:00
Donald Sharp
f89c0aed63 *: Fix spelling of wether
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-02 07:46:19 -04:00
Donald Sharp
aa5ced0ac8 isisd, lib, ospfd, pathd: Null out free'd pointer
The commands:

router isis 1
  mpls-te on
  no mpls-te on
  mpls-te on
  no mpls-te on
!

Will crash

Valgrind gives us this:
==652336== Invalid read of size 8
==652336==    at 0x49AB25C: typed_rb_min (typerb.c:495)
==652336==    by 0x4943B54: vertices_const_first (link_state.h:424)
==652336==    by 0x493DCE4: vertices_first (link_state.h:424)
==652336==    by 0x493DADC: ls_ted_del_all (link_state.c:1010)
==652336==    by 0x47E77B: isis_instance_mpls_te_destroy (isis_nb_config.c:1871)
==652336==    by 0x495BE20: nb_callback_destroy (northbound.c:1131)
==652336==    by 0x495B5AC: nb_callback_configuration (northbound.c:1356)
==652336==    by 0x4958127: nb_transaction_process (northbound.c:1473)
==652336==    by 0x4958275: nb_candidate_commit_apply (northbound.c:906)
==652336==    by 0x49585B8: nb_candidate_commit (northbound.c:938)
==652336==    by 0x495CE4A: nb_cli_classic_commit (northbound_cli.c:64)
==652336==    by 0x495D6C5: nb_cli_apply_changes_internal (northbound_cli.c:250)
==652336==  Address 0x6f928e0 is 272 bytes inside a block of size 320 free'd
==652336==    at 0x48399AB: free (vg_replace_malloc.c:538)
==652336==    by 0x494BA30: qfree (memory.c:141)
==652336==    by 0x493D99D: ls_ted_del (link_state.c:997)
==652336==    by 0x493DC20: ls_ted_del_all (link_state.c:1018)
==652336==    by 0x47E77B: isis_instance_mpls_te_destroy (isis_nb_config.c:1871)
==652336==    by 0x495BE20: nb_callback_destroy (northbound.c:1131)
==652336==    by 0x495B5AC: nb_callback_configuration (northbound.c:1356)
==652336==    by 0x4958127: nb_transaction_process (northbound.c:1473)
==652336==    by 0x4958275: nb_candidate_commit_apply (northbound.c:906)
==652336==    by 0x49585B8: nb_candidate_commit (northbound.c:938)
==652336==    by 0x495CE4A: nb_cli_classic_commit (northbound_cli.c:64)
==652336==    by 0x495D6C5: nb_cli_apply_changes_internal (northbound_cli.c:250)
==652336==  Block was alloc'd at
==652336==    at 0x483AB65: calloc (vg_replace_malloc.c:760)
==652336==    by 0x494B6F8: qcalloc (memory.c:116)
==652336==    by 0x493D7D2: ls_ted_new (link_state.c:967)
==652336==    by 0x47E4DD: isis_instance_mpls_te_create (isis_nb_config.c:1832)
==652336==    by 0x495BB29: nb_callback_create (northbound.c:1034)
==652336==    by 0x495B547: nb_callback_configuration (northbound.c:1348)
==652336==    by 0x4958127: nb_transaction_process (northbound.c:1473)
==652336==    by 0x4958275: nb_candidate_commit_apply (northbound.c:906)
==652336==    by 0x49585B8: nb_candidate_commit (northbound.c:938)
==652336==    by 0x495CE4A: nb_cli_classic_commit (northbound_cli.c:64)
==652336==    by 0x495D6C5: nb_cli_apply_changes_internal (northbound_cli.c:250)
==652336==    by 0x495D23E: nb_cli_apply_changes (northbound_cli.c:268)

Let's null out the pointer.  After this change.  Valgrind no longer reports issues
and isisd no longer crashes.

Fixes: #10939
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-31 15:59:46 -04:00
Donatas Abraitis
49ecb8b807 bgpd: Show match script SCRIPT in running config
Before:
```
route-map lua permit 10
exit
```

After:
```
route-map lua permit 10
 match script rm
exit
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-03-31 09:39:52 +03:00
Donald Sharp
eda1d29a06
Merge pull request #10918 from opensourcerouting/fix/bgpd_crash
bgpd: Fix Lua route-map crash
2022-03-30 07:53:03 -04:00
Russ White
dcaba5ae1a
Merge pull request #10719 from opensourcerouting/nb-show-fixes
lib: fix and improve yang operational data display
2022-03-29 10:51:02 -04:00
Donatas Abraitis
93b2d38aed bgpd: Do not print .lua extension twice
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-03-29 17:47:09 +03:00
David Lamparter
eb3c9d9774 *: add SAFI argument to zclient_send_rnh
Just pushing that SAFI_UNICAST up 1 level to the caller.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-27 14:57:22 +02:00
Donald Sharp
bddfc29741 lib: Ensure order of operations is expected with SECONDS
These 3 values:
ONE_DAY_SECOND
ONE_WEEK_SECOND
ONE_YEAR_SECOND

Are defined based upon the number of seconds.  Unfortunately doing math
on these values say something like:

days = t->tv_sec / ONE_DAY_SECOND;

Once you go over about a day causes the order of operations to cause the multiplication
to get messed up:

204		if (!t)
(gdb) n
207		w = d = h = m = ms = 0;
(gdb) set t->tv_sec = ONE_DAY_SECOND + 30
(gdb) n
208		memset(buf, 0, size);
(gdb)
210		us = t->tv_usec;
(gdb)
211		if (us >= 1000) {
(gdb)
212			ms = us / 1000;
(gdb)
213			us %= 1000;
(gdb)
217		if (ms >= 1000) {
(gdb)
222		if (t->tv_sec > ONE_WEEK_SECOND) {
(gdb)
227		if (t->tv_sec > ONE_DAY_SECOND) {
(gdb)
228			d = t->tv_sec / ONE_DAY_SECOND;
(gdb) n
229			t->tv_sec -= d * ONE_DAY_SECOND;
(gdb) n
232		if (t->tv_sec >= HOUR_IN_SECONDS) {
(gdb) p d
$6 = 2073600
(gdb) p t->tv_sec
$7 = -179158953570
(gdb)

Converting to adding paranthesis around around the ONE_DAY_SECOND causes
the order of operations to work as expected.

Fixes: #10880
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-26 16:20:53 -04:00