Commit graph

482 commits

Author SHA1 Message Date
Donald Sharp 4e12ba08c4 lib: Help text correction
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-24 15:25:49 -04:00
Igor Ryzhov 830972cab2 lib: common debug status output
Implement common code for debug status output and remove daemon-specific
code that is duplicated everywhere.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-08-27 09:53:02 -04:00
Igor Ryzhov 57811a53ba lib, zebra: fix exit commands
If a command is not marked as `YANG`-converted, the current command
batching buffer is flushed before executing the command. We shouldn't
flush the buffer when executing an `exit` command. It should only be
flushed if the next command is not `YANG`-converted, which is checked by
the command itself, not the previous `exit`.

Fixes #15706.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-04-16 22:18:01 +03:00
Christian Hopps 29dba445b4 lib: add automatic xpath-based completion
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-03-03 17:59:36 -05:00
David Lamparter bbd858935f build: homologize path handling
Use consistent `e_somepath` names for expanded versions of `somepath`.
Also remove all paths from `config.h` and put them into
`lib/config_paths.h` - this is to make more obvious when someone is
doing something probably not quite properly structured.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-01-27 19:02:52 +01:00
David Lamparter cd35ecc575 lib: create frr_daemon_state_{load,save}
These functions load daemon-specific persistent state from
`/var/lib/frr` and supersede open-coded variants of similar calls in
ospfd, ospf6d and isisd to save GR state and/or sequence numbers.

Unlike the open-coded variants, the save call correctly `fsync()`s the
saved data to ensure disk contents are consistent.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-01-27 19:01:19 +01:00
Donald Sharp c6d94a7056 *: zebra.h should not have fcntl.h
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-09 12:50:40 -05:00
Donald Sharp 848dcf3d03 *: remove sys/stat.h from zebra.h
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-09 12:39:23 -05:00
Donald Sharp 496d87c14f lib: sys/utsname.h is not needed in zebra.h
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-04 15:34:22 -05:00
Donatas Abraitis 0af4541576
Merge pull request #14498 from idryzhov/fix-conf-t-file-lock
Fixes for `file-lock` mode of configuration node
2023-09-28 10:03:06 +03:00
Igor Ryzhov b8ebb7fc62 vty: fix configure terminal argument descriptions
"terminal" and "file-lock" description are mixed up.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-09-27 23:34:53 +03:00
Donatas Abraitis fd0fe0bb6a lib: Drop deprecated enable-time-check, enable-cpu-time compile options
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-09-24 20:41:24 +03:00
Igor Ryzhov 8c098c31db vtysh: remove unused cmd_filter_type
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-08-05 00:45:10 +03:00
Christian Hopps df0173ceeb mgmtd: KISS the locking code
Move away from things like "lock if not locked" type code, require the
user has locked prior to geting to that point.

For now we warn if we are taking a lock we already had; however, this
should really be a failure point.

New requirements:

SETCFG -
  not implicit commit - requires user has locked candidate DS and they
    must unlock after

  implicit commit - requires user has locked candidate and running DS
    both locks will be unlocked on reply to the SETCFG

COMMITCFG -
  requires user has locked candidate and running DS and they must unlock
  after

  rollback - this code now get both locks and then does an unlock and
  early return thing on the adapter side. It needs to be un-special
  cased in follow up work that would also include tests for this
  functionality.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-19 00:13:28 -04:00
Yuan Yuan f8aa257997 lib: fix vtysh core when handling questionmark
When issue vtysh command with ?, the initial buf size for the
element is 16. Then it would loop through each element in the cmd
output vector. If the required size for printing out the next
element is larger than the current buf size, realloc the buf memory
by doubling the current buf size regardless of the actual size
that's needed. This would cause vtysh core when the doubled size
is not enough for the next element.

Signed-off-by: Yuan Yuan <yyuanam@amazon.com>
2023-05-31 20:30:03 +00:00
Christian Hopps a1d8c7a36e mgmtd: fix reading of config file[s]
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-30 02:09:44 -04:00
Christian Hopps 3701780a15 lib: log commands read from config file
When the user specifies `--command-log-always` in CLI arguments then also log
commands executed from loading the config file.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-04 14:48:59 -04:00
Christian Hopps cfa0facbf9 mgmtd: fully implement debug flags for mgmtd and clients
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-01 13:47:12 -04:00
Donald Sharp 24a58196dd *: Convert event.h to frrevent.h
We should probably prevent any type of namespace collision
with something else.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp 5f6eaa9b96 *: Convert a bunch of thread_XX to event_XX
Convert these functions:

thread_getrusage
thread_cmd_init
thread_consumed_time
thread_timer_to_hhmmss
thread_is_scheduled
thread_ignore_late_timer

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp cb37cb336a *: Rename thread.[ch] to event.[ch]
This is a first in a series of commits, whose goal is to rename
the thread system in FRR to an event system.  There is a continual
problem where people are confusing `struct thread` with a true
pthread.  In reality, our entire thread.c is an event system.

In this commit rename the thread.[ch] files to event.[ch].

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:16 -04:00
Donald Sharp d8bc11a592 *: Add a hash_clean_and_free() function
Add a hash_clean_and_free() function as well as convert
the code to use it.  This function also takes a double
pointer to the hash to set it NULL.  Also it cleanly
does nothing if the pointer is NULL( as a bunch of
code tested for ).

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-21 08:54:21 -04:00
Russ White ba755d35e5
Merge pull request #12248 from pguibert6WIND/bgpasdot
lib, bgp: add initial support for asdot format
2023-02-21 08:01:03 -05:00
Donald Sharp 8383d53e43
Merge pull request #12780 from opensourcerouting/spdx-license-id
*: convert to SPDX License identifiers
2023-02-17 09:43:05 -05:00
Donatas Abraitis 234f6fd4f4 bgpd: Add BGP Software Version Capability
Implement: https://datatracker.ietf.org/doc/html/draft-abraitis-bgp-version-capability

Tested with GoBGP:

```
% ./gobgp neighbor 192.168.10.124
BGP neighbor is 192.168.10.124, remote AS 65001
  BGP version 4, remote router ID 200.200.200.202
  BGP state = ESTABLISHED, up for 00:01:49
  BGP OutQ = 0, Flops = 0
  Hold time is 3, keepalive interval is 1 seconds
  Configured hold time is 90, keepalive interval is 30 seconds

  Neighbor capabilities:
    multiprotocol:
        ipv4-unicast:	advertised and received
        ipv6-unicast:	advertised
    route-refresh:	advertised and received
    extended-nexthop:	advertised
        Local:  nlri: ipv4-unicast, nexthop: ipv6
    UnknownCapability(6):	received
    UnknownCapability(9):	received
    graceful-restart:	advertised and received
        Local: restart time 10 sec
	    ipv6-unicast
	    ipv4-unicast
        Remote: restart time 120 sec, notification flag set
	    ipv4-unicast, forward flag set
    4-octet-as:	advertised and received
    add-path:	received
      Remote:
         ipv4-unicast:	receive
    enhanced-route-refresh:	received
    long-lived-graceful-restart:	advertised and received
        Local:
	    ipv6-unicast, restart time 10 sec
	    ipv4-unicast, restart time 20 sec
        Remote:
	    ipv4-unicast, restart time 0 sec, forward flag set
    fqdn:	advertised and received
      Local:
         name: donatas-pc, domain:
      Remote:
         name: spine1-debian-11, domain:
    software-version:	advertised and received
      Local:
         GoBGP/3.10.0
      Remote:
         FRRouting/8.5-dev-MyOwnFRRVersion-gdc92f44a45-dirt
    cisco-route-refresh:	received
  Message statistics:
```

FRR side:

```
root@spine1-debian-11:~# vtysh -c 'show bgp neighbor 192.168.10.17 json' | \
> jq '."192.168.10.17".neighborCapabilities.softwareVersion.receivedSoftwareVersion'
"GoBGP/3.10.0"
root@spine1-debian-11:~#
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-02-15 23:14:48 +02:00
Philippe Guibert 8079a4138d lib, bgp: add initial support for asdot format
AS number can be defined as an unsigned long number, or
two uint16 values separated by a period (.). The possible
valus are:
- usual 32 bit values : [1;2^32 -1]
- <1.65535>.<0.65535> for dot notation
- <0.65535>.<0.65535> for dot+ notation.

The 0.0 value is forbidden when configuring BGP instances
or peer configurations.

A new ASN type is added for parsing in the vty.
The following commands use that new identifier:
- router bgp ..
- bgp confederation ..
- neighbor <> remote-as <>
- neighbor <> local-as <>
- clear ip bgp <>
- route-map / set as-path <>

An asn library is available in lib/ and provides some
services:
- convert an as string into an as number.
- parse an as path list string and extract a number.
- convert an as number into a string.

Also, the bgp tests forge an as_zero_path, and to do that,
an API to relax the possibility to have a 0 as value is
specifically called from the tests.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-02-10 10:27:17 +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
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
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
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
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 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
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 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
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
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
anlan_cs 4d4c404bf6 *: Add necessary new line for output of vty_out()
Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-02-27 10:59:19 +08:00
Donald Sharp 46b48b3302 lib: Add more information to show version
Add to lib/command.c the ability to remember the
release/version/system information and to allow
`show version` to dump some of it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-04 10:29:38 -05:00
David Lamparter dd2c81b8c0 lib: rework vty_check_node_for_xpath_decrement
...by having a flag in struct cmd_node rather than hardcoding it in
`lib/command.c`.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-11-16 18:51:22 +01:00
David Lamparter 0e06eb8b2e vtysh: defer CLI tree building
We don't need the CLI tree until we actually enter the node.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-10-18 19:48:11 +02:00
Quentin Young 32acb4a7ad
Merge pull request #9497 from opensourcerouting/cli-better-no 2021-09-09 12:22:53 -04:00
David Lamparter 90c8406c20 lib: add ![...] syntax for easy "no" forms
This allows defining a CLI command like this:
  `[no] some setting ![VALUE]`
with VALUE being optional for the "no" form, but required for the
positive form.  It's just a `[...]` where the empty branch can only be
taken for commands starting with `no`.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-08-26 21:03:44 +02:00
Igor Ryzhov c1e7a5e45e lib: make node_parent more generic
Instead of adding a separate case clause for every node, just find the
node structure in the global list and get its parent node from there.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-26 19:43:23 +03:00
Quentin Young 41d3d77496
Merge pull request #8982 from dlqs/lua-func-stack 2021-08-02 13:51:35 +00:00
Donald Lee 8be973f5c2 lib: Add function name to script command
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-24 00:45:22 +08:00
Igor Ryzhov d9331fc67c lib, zebra: fix exit from link-params node
When exiting from link-params node, we must not decrement xpath_index
because it is not incremented when entering the node.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-07-21 17:23:45 +03:00
Donald Lee 596b44af8a lib: Remove warning about script not found
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-18 06:32:03 +08:00
Donald Lee 64d457d7ac lib: Rename frrscript_unload to delete
frrscript_load now loads a function instead of a file, so frrscript_unload
should be renamed since it does not unload a function.

Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-18 06:32:03 +08:00
Donald Lee ad6e9b854d test: Use frrscript_unload
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-18 06:32:03 +08:00
Donald Lee a71096fb0a lib: Update Script command example to call function
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-18 06:32:03 +08:00