Commit Graph

4978 Commits

Author SHA1 Message Date
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