Commit graph

967 commits

Author SHA1 Message Date
Donald Sharp 88f8c90073 lib, vtysh: Remove inclusion of grp.h for everyone
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-04 14:34:41 -05:00
Carmine Scarpitta 69bff19c43 zebra, lib, vtysh: Add CLI cmd to set/unset SRv6 encap source address
- Add a new node `SRV6_ENCAP_NODE` to the CLI graph. This node allows
users to configure encapsulation parameters for SRv6, including the
source address of the outer encapsulating IPv6 header.

- Install a new CLI command `source-address` under the
`SRV6_ENCAP_NODE` node. This command is used to configure the source
address of the outer encapsulating IPv6 header.

- Install a new CLI command `no source-address` under the
`SRV6_ENCAP_NODE` node. This command is used to unset the
source address of the outer encapsulating IPv6 header and restore the
default source address.

Examples:

```
router# segment-routing
router(sr)# srv6
router(srv6)# encapsulation
router(srv6-encap)# source-address fc00:0:1::1
```

```
router# segment-routing
router(sr)# srv6
router(srv6)# encapsulation
router(srv6-encap)# no source-address
```

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-12-14 14:58:33 +01:00
Rafael Zalamena 570fdc55fd lib,vtysh: fix show route map JSON output
Move the command from 'lib' to 'vtysh' so we can properly format the
JSON output in a correct manner.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-11-24 10:00:25 -03:00
Igor Ryzhov 40def43dfa vtysh: clean vtysh_file_locked when exiting config node
The flag should be cleared to make sure it's not reused the next time
we enter the config node.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-11-17 03:16:36 +01:00
Christian Hopps 59beac5013 lib: mgmtd: fix debug cli commands and memleaks
- Cannot have 2 cmd_node's with same .node number. Install the mgmtd
client library debug nodes (client frontend and client backend) using
new unique node numbers. Fixes memleaks.

- Fix "debug mgmt client backend" to generate correct config (and not
for frontend).

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-11-11 19:25:03 +01:00
Donald Sharp ac78d70bb8
Merge pull request #14563 from opensourcerouting/fix/cpuwarning_starvation
lib: Suppress HOB/STARVATION warnings when running in vtysh
2023-10-11 07:21:43 -04:00
Donatas Abraitis 3ff671b830 lib: Suppress HOB/STARVATION warnings when running in vtysh
Running ping/traceroute/etc. (any kind of commands that use execute_command()
suffer with this kind of warnings.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-10-11 09:52:19 +03:00
Donald Sharp ddd96b51b0 Revert "bgpd: add bgp link-state address-family configuration context"
This reverts commit ae2f3bb5b4.
2023-10-10 16:45:32 -04:00
Igor Ryzhov 1a09cf3894 vtysh: fix entering configuration node in file-lock mode
When the config node is entered in file-lock mode, we should actually
remember it to correctly apply the workaround in `vtysh_exit`.
Otherwise, the file-lock mode is dropped once we exit any node one level
below the config node.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-09-28 02:45:05 +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
Russ White 8e755a03a3
Merge pull request #12649 from louis-6wind/bgp-link-state
bgpd: add basic support of BGP Link-State RFC7752
2023-09-26 10:07:02 -04:00
Russ White a9a89805ec
Merge pull request #14398 from m-varasteh/ospfd-rfc5709
ospfd: add support for RFC 5709 OSPFv2 HMAC-SHA Cryptographic Authentication
2023-09-19 10:14:14 -04:00
Louis Scalbert ae2f3bb5b4 bgpd: add bgp link-state address-family configuration context
Add the bgp link-state configuration context cli:

> router bgp 65001
>  address-family link-state link-state
>   neighbor 192.0.2.2 activate
>  exit-address-family

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-09-18 14:39:56 +02:00
Mahdi Varasteh f5011cd5dd [ospfd]: add support for RFC 5709 HMAC-SHA Auth
This patch includes:
* Implementation of RFC 5709 support in OSPF. Using
openssl library and FRR key-chain,
one can use SHA1, SHA256, SHA384, SHA512 and
keyed-MD5( backward compatibility with RFC 2328) HMAC algs.
* Updating documentation of OSPF
* add topotests for new HMAC algorithms

Signed-off-by: Mahdi Varasteh <varasteh@amnesh.ir>
2023-09-16 07:38:23 +03:30
Russ White 48d6039e14
Merge pull request #13724 from cscarpitta/feature/isisd-srv6-support
isisd: Add support for SRv6 uSID (RFC 9352)
2023-09-12 08:33:42 -04:00
Carmine Scarpitta 3a89bbfb99 vtysh: Add CLI nodes for SRv6
Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-09-11 22:11:50 +02:00
Donatas Abraitis 8fa9f2bc2a vtysh: Print uniq lines when parsing no service ...
Before this patch:

```
no service cputime-warning
no service cputime-warning
no ipv6 forwarding
no service cputime-warning
no service cputime-warning
no service cputime-warning
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-08-11 18:25:43 +03:00
Igor Ryzhov cedba2406f vtysh: fix checking empty interface node
vtysh is not supposed to show empty interface node in running config,
however the corresponding check is broken and empty nodes are shown.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-08-05 00:46:45 +03:00
Donald Sharp 3031b32ba8
Merge pull request #14048 from LabNConsulting/chopps/staticd-stop-parsing
static: stop vtysh from sending VRF commands to staticd
2023-07-18 19:18:12 -04:00
Christian Hopps 61954faf19 static: stop sending VRF commands to staticd from vtysh
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-07-18 12:45:04 -04:00
Christian Hopps 07035ce954 vtysh: track and fix file-lock use in the workaround from 2004
There's a workaround in the code from a bug from back in 2004, it ends
and re-enters config mode anytime an `exit` is done from a level below
the top-level config node (e.g., from a `router isis` node). We need to
re-enter config mode with or without a lock according to how we actually
entered it to begin with.

fixes #13920

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-07-14 18:24:44 -04:00
Christian Hopps 76835fd558 lib: mgmtd: only clear pending for the in-progress command
The lock/unlocks are being done short-circuit so they are never pending;
however, the handling of the unlock notification was always resuming the command
if pending was set. In all cases pending is set for another command. For example
implicit commit locks then when notified its done unlocks which was clearing the
set-config pending flag and resuming that command incorrectly.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-07-14 18:24:30 -04: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
Christian Hopps 315e9032e4 vtysh: stop reading config file if user exits from root level.
This is required to make sure that we properly send the
XFRR_end_configuration tag to the daemons. Previously if the user had an
`exit` at the root level the parser would just drop out of the config
node and so XFRR_end_configuration, even if sent, would be ignored

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-12 02:32:29 -04:00
Donald Sharp 8495b425bd vtysh: Give actual pam error messages
Code was was written where the pam error message put out
was the result from a previous call to the pam modules
instead of the current call to the pam module.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-05-26 07:44:11 -04:00
Donatas Abraitis 0b7d911ec3 vtysh: Fix typo in warning message for -b -f ...
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-05-25 10:20:53 +03:00
Hiroki Shirokura 46fb37cf67 lib,vtysh,isisd,yang: algo cli/yang/callbacks
Define the IS-IS flex-algo structure in yang, the CLI configuration
commands and the skeletons of frontend and backend functions that are
called by the CLI code.

Signed-off-by: Hiroki Shirokura <hiroki.shirokura@linecorp.com>
Signed-off-by: Eric Kinzie <ekinzie@labn.net>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-04-18 10:13:59 +02:00
Donald Sharp 172b231c03 vtysh: Exit with first received error code when forking
vtysh -f forks.  Gather the return codes and report the first
failed return code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-28 10:10:33 -04:00
Quentin Young ac76809027 vtysh: use fork() workflow for -f too
It was being used for -b only; we should be able to use it for -f as
well.

This also merges the codepaths for -b and -f since they have no real
functional difference.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2023-03-28 10:10:33 -04:00
Mark Stapp 449f66552f vtysh: use daemon type and handle multi-instance types
To handle multi-instance daemons (ospf, e.g.), each forked
vtysh handles all of the instances of a daemon type.

Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2023-03-28 10:10:33 -04:00
Quentin Young 916af6559c vtysh, doc: add doc & help text for -t/--timestamp
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2023-03-28 10:10:33 -04:00
Quentin Young f887c00ad4 vtysh: fork() on boot
When using -b flag to apply config to all running daemons, fork a copy
of vtysh for each daemon we need to configure instead of doing them one
at a time. This is about N times faster when you have N daemons.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>

mergeme
2023-03-28 10:10:33 -04:00
Donald Sharp cd9d053741 *: Convert struct event_master to struct event_loop
Let's find a better name for it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp ce50d11c4d *: Convert thread_master_XXX functions to event_master_XXX
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp e16d030c65 *: Convert THREAD_XXX macros to EVENT_XXX macros
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp 2453d15dbf *: Convert struct thread_master to struct event_master and it's ilk
Convert the `struct thread_master` to `struct event_master`
across the code base.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp de2754be3a *: Convert thread_fetch and thread_call to event_fetch and event_call
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp 907a2395f4 *: Convert thread_add_XXX functions to event_add_XXX
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp e6685141aa *: Rename struct thread to struct event
Effectively a massive search and replace of
`struct thread` to `struct event`.  Using the
term `thread` gives people the thought that
this event system is a pthread when it is not

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Christian Hopps 39c329bbd1 lib: staticd: vtysh: apply frrbot style requirements
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-03-22 05:22:56 +00:00
Christian Hopps 1c84efe4fa mgmtd: Bringup MGMTD daemon and datastore module support
Features added in this commit:
1. Bringup/shutdown new management daemon 'mgmtd' along with FRR.
2. Support for Startup, Candidate and Running DBs.
3. Lock/Unlock DS feature using pthread lock.
4. Load config from a JSON file onto candidate DS.
5. Save config to a JSON file from running/candidate DS.
6. Dump candidate or running DS contents on the terminal or a file in
   JSON/XML format.
7. Maintaining commit history (Full rollback support to be added in
   future commits).
8. Addition of debug commands.

Co-authored-by: Yash Ranjan <ranjany@vmware.com>
Co-authored-by: Abhinay Ramesh <rabhinay@vmware.com>
Co-authored-by: Ujwal P <ujwalp@vmware.com>
Signed-off-by: Pushpasis Sarkar <pushpasis@gmail.com>
2023-03-21 22:08:32 -04:00
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
Philippe Guibert e55b088399 bgpd: add as-notation keyword to 'router bgp' vty command
A new keyword permits changing the BGP as-notation output:
- [no] router bgp <> [vrf BLABLA] [as-notation [<dot|plain|dot+>]]

At the BGP instance creation, the output will inherit the way the
BGP instance is declared. For instance, the 'router bgp 1.1'
command will configure the output in the dot format. However, if
the client wants to choose an alternate output, he will have to
add the extra command: 'router bgp 1.1 as-notation dot+'.

Also, if the user wants to have plain format, even if the BGP
instance is declared in dot format, the keyword can also be used
for that.

The as-notation output is only taken into account at the BGP
instance creation. In the case where VPN instances are used,
a separate instance may be dynamically created. In that case,
the real as-notation format will be taken into acccount at the
first configuration.

Linking the as-notation format with the BGP instance makes sense,
as the operators want to keep consistency of what they configure.

One technical reason why to link the as-notation output with the
BGP instance creation is that the as-path segment lists stored
in the BGP updates use a string representation to handle aspath
operations (by using regexp for instance). Changing on the fly
the output needs to regenerate this string representation to the
correct format. Linking the configuration to the BGP instance
creation avoids refreshing the BGP updates. A similar mechanism
is put in place in junos too.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-02-10 10:27:23 +01: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
Louis Scalbert 8300f2f56c isisd: add affinity-map support
Add the support of the affinity-map command to isisd.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-02-09 15:48:38 +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
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
Donald Sharp 0876b4c1b8 vtysh: Schedule shell access for deprecation
Schedule shell access for deprecation and removal in
a years time.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-01 10:29:02 -05:00
Donatas Abraitis 6520483a8f
Merge pull request #12704 from donaldsharp/pim6_route_map
pimd: v6 intentionally turned off route-maps.  Turn it on.
2023-01-31 20:51:45 +02: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 f51c430a17 pimd: v6 intentionally turned off route-maps. Turn it on.
Why?

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-30 09:18:15 -05: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 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
anlan_cs 99c5b6d430 vtysh: fix build failure for certain case
The build failed if two conditions are met at the same time:

1. Configure with `--disable-dependency-tracking`
2. Set an indenpendent build directory

```
anlan@host:~/frr/build$ make
make: Entering directory '/home/anlan/frr/build'
true
/usr/bin/perl ../vtysh/daemons.pl zebra bgpd ripd ripngd ospfd ospf6d isisd fabricd nhrpd ldpd babeld eigrpd  pimd pim6d pbrd staticd bfdd vrrpd pathd > vtysh/vtysh_daemons.h
/bin/bash: line 1: vtysh/vtysh_daemons.h: No such file or directory
make: *** [Makefile:17644: vtysh/vtysh_daemons.h] Error 1
make: Leaving directory '/home/anlan/frr/build'
```

`~/frr/` is source directory, `~/frr/build/` is the specified build
directory.

So, just create necessary directory - `vtysh/`.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2023-01-09 09:28:35 +08:00
Donald Sharp 99a9f25ce8 vtysh: Remove double retrieve of env VTYSH_HISTFILE
The code is double checking the VTYSH_HISTFILE env variable,
additionally clang-15 when running SA over it doesn't fully
understand the code pattern.  Reduce the double check to
one check to reduce program run-time (ha!) and make SA happy.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-21 08:04:34 -05:00
Russ White be51a45984
Merge pull request #12410 from ghzserg/master
Add motd command
2022-12-06 08:55:20 -05:00
Donatas Abraitis 90bf4243fb
Merge pull request #12443 from donaldsharp/vtysh_mem_leak_2
vtysh: free memory given to us by readline
2022-12-06 08:57:00 +02:00
Donald Sharp ab91425266 vtysh: Cleanup memory leak
When multiple daemons report a exit line for the same
node, vtysh was just dropping the previous pointer.
Ensure that we free it first.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-05 08:50:24 -05:00
Donald Sharp 5098d577d2 vtysh: free memory given to us by readline
The rl_callback_handler_install function manual says this:

Set up the terminal for Readline I/O and display the initial expanded value of prompt.
Save the value of lhandler to use as a handler function to call when a complete line
of input has been entered. The handler function receives the text of the line as an
argument. As with readline(), the handler function should free the line when it is
finished with it.

Adding a free removes this memory leak that I am seeing with address sanitizer enabled;

SUMMARY: AddressSanitizer: 99 byte(s) leaked in 5 allocation(s).:
2022-12-05 07:50:57,231 INFO: topolog.r7: vtysh result:
	Hello, this is FRRouting (version 8.5-dev).
	Copyright 1996-2005 Kunihiro Ishiguro, et al.

	r7# clear log cmdline-targets
	r7# conf t
	r7(config)# log file staticd.log debug
	r7(config)# log commands
	r7(config)# log timestamp precision 3
	r7(config)#

	=================================================================
	==976989==ERROR: LeakSanitizer: detected memory leaks

	Direct leak of 99 byte(s) in 5 object(s) allocated from:
	    #0 0x49cadd in malloc (/usr/bin/vtysh+0x49cadd)
	    #1 0x7fc57135d8e8 in xmalloc build/shlib/./xmalloc.c:59:10

	SUMMARY: AddressSanitizer: 99 byte(s) leaked in 5 allocation(s).

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-05 08:26:01 -05:00
Sergei Rozhkov 012f7ae4e9 vtysh: add motd command
Add "show motd" commad.
The vtysh user can call the "show motd" command to re-show the welcome message.
This is necessary if the user saves frequently used commands in motd.

Signed-off-by: Sergei Rozhkov <gh@zserg.ru>
2022-11-30 09:43:55 +05: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
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 f531fae829 vtysh: Allow service ... lines to not repeat
When any `service ...` line is entered and there are multiple
daemons running prevent this from being displayed multiple times.

Fixes: #5475
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-11-03 13:01:35 -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
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
Nico Berlee 36d223bb6b
vtysh: Ensure an empty string does not get printed for host/domain
vtysh show running-config is showing:
frr version 8.3.1_git
frr defaults traditional
hostname test
log file /etc/frr/frr.log informational
log timestamp precision 3
domainname
service integrated-vtysh-config

domainname should not be printed in this case at all. If the
host has no search/domainname configured, frr_reload.py
crashes on invalid config from `vtysh show running-config`

Basically the same change as commit a7141b8

Signed-off-by: Nico Berlee <nico.berlee@on2it.net>
2022-10-25 07:40:01 +02:00
David Lamparter 8ba718d7f7 vtysh: fix bugged command definitions
DAEMON_LIST really needs a space.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-10-06 15:40:06 +02:00
Donatas Abraitis ac67c0e4c7 vtysh: Show allow-reserved-ranges once in config
Before:

```
donatas-pc# sh run | include allow-reserved-ranges
allow-reserved-ranges
allow-reserved-ranges
allow-reserved-ranges
allow-reserved-ranges
allow-reserved-ranges
allow-reserved-ranges
donatas-pc#
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-09-27 21:41:24 +03:00
Donald Sharp 17c149ff1b vtysh: Properly handle service cputime-warning XX in config
Prevent duplicate lines from each daemon in vtysh output.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-09-27 09:05:30 -04:00
Donald Sharp 54b7d471f3 vtysh: Properly handle [no] service cputime-stats in config
Prevent duplicate lines from each daemon in vtysh output.

Fixes: #12022
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-09-27 09:02:26 -04:00
Philippe Guibert 4cd690ae4d bgpd: add 'mpls bgp forwarding' to ease mpls vpn ebgp peering
RFC4364 describes peerings between multiple AS domains, to ease
the continuity of VPN services across multiple SPs. This commit
implements a sub-set of IETF option b) described in chapter 10 b.

The ASBR to ASBR approach is taken, with an EBGP peering between
the two routers. The EBGP peering must be directly connected to
the outgoing interface used. In those conditions, the next hop
is directly connected, and there is no need to have a transport
label to convey the VPN label. A new vty command is added on a
per interface basis:

This command if enabled, will permit to convey BGP VPN labels
without any transport labels (i.e. with implicit-null label).

restriction:
this command is used only for EBGP directly connected peerings.
Other use cases are not covered.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2022-09-05 22:26:33 +02:00
Donatas Abraitis 149a3fffe0 vtysh: Handle SIGTSTP (C-z) without exiting the vty shell
After 4c92dd90d3 switching to poll-based I/O,
vtysh prompt exits on C-z signal.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-08-10 16:18:49 +03:00
Donatas Abraitis ce2e1a0ed8 vtysh: Ignore end when parsing frr.conf
If we have `end` at the end of the frr.conf, then we never execute
XFRR_end_configuration command, and start/end markers do not work.

This leads to for example waiting BGP configuration parsing thread to hang,
and the peers are in shutdown state until the timer expires.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-07-20 22:57:33 +03:00
Donatas Abraitis 00e6edb97d bgpd: Add constants for some repetitive CLI strings
"Address Family\n"
"Address Family modifier\n"

Before:

```
donatas-laptop(config-router)# address-family ipv4
  <cr>
  flowspec         Address Family Modifier
  labeled-unicast  Address Family modifier
  multicast        Address Family modifier
  unicast          Address Family Modifier
  vpn              Address Family modifier
```

After:

```
donatas-laptop(config-router)# address-family
  ipv4   Address Family
  ipv6   Address Family
  l2vpn  Address Family
donatas-laptop(config-router)# address-family ipv4
  <cr>
  flowspec         Address Family modifier
  labeled-unicast  Address Family modifier
  multicast        Address Family modifier
  unicast          Address Family modifier
  vpn              Address Family modifier
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-07-18 10:12:57 +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
Anuradha Karuppiah 36c3b29675 zebra: infastructure for the new dataplane plugin
Signed-off-by: Anuradha Karuppiah <anuradhak@nvidia.com>
2022-06-27 07:56:55 -04:00
rgirada 264a2a273f vtysh: Account validity should be verified when authenticating users with PAM.
Description:
	SonarQube detects the following behaviour as a vulanarability.
	When authenticating users using PAM, it is strongly recommended to
	check the validity of the account (not locked, not expired ...),
	otherwise it leads to unauthorized access to resources.

	pam_acct_mgmt() should be called for account validity after
	calling pam_authenticate().

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2022-06-23 11:15:47 -07:00
Donatas Abraitis bfe7dcb880 vtysh: Add autocomplete for VRFs when using with router bgp
```
donatas-laptop(config)# router bgp 123 vrf ?
  VIEWVRFNAME  View/VRF name
       default mgmt1 servers2
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-14 13:41:13 +03: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 789c5919cf vtysh: Call fflush+fsync before calling fclose() when saving the config
A safety check we flushed the data to the storage.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-19 14:01:13 +03:00
David Lamparter edae23ff58 vtysh: remove extraneous newline
vtysh_client_execute() expects just a string without a newline; the
newline is passed through and ends up in logging output where newlines
are not quite wanted.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-07 17:55:35 +02:00
Donald Sharp f75b916348 bgpd, vtysh: Fix spelliing of explicitely
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-02 07:25:18 -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
Mobashshera Rasool ec6ac9b197 pim6d: Correct the show ip prefix-list display for pim6d
Currently the PIM6d component is getting displayed under
"show ip prefix-list" instead of "show ipv6 prefix-list".
Fixed it.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2022-03-28 03:23:48 -07:00
sarita patra 8fc3ba676e pim6d: Enable protocol as VTYSH_PIM6D for pim6_cmd.c
Signed-off-by: sarita patra <saritap@vmware.com>
2022-03-15 23:16:41 -07:00
David Lamparter a4af82ee2b lib, vtysh: report lost messages on live log
The vtysh live logs don't try to buffer messages when vtysh isn't
reading them fast enough.  Either the kernel has space and can accept
messages without delay, or it doesn't and we continue on.

While this is intentional (otherwise slow vtysh could block a routing
daemon), at least give the user an indication if messages were dropped.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-07 18:03:16 +01:00
David Lamparter 834585bdb9 lib: add a few more bits to live log header
... and add some comments explaining the individual fields.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-07 18:03:16 +01:00
Rafael Zalamena 54aeec5ef0 lib,vtysh: show operational data with config
Add option to merge configuration data in the operational data show
command.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2022-03-02 16:37:43 -03:00
David Lamparter 3030e7b5ac vtysh: fix coverity issues in live-log code
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-01 16:00:56 +01:00
David Lamparter 2821405a69
Merge pull request #10640 from donaldsharp/thread_timers 2022-03-01 11:45:36 +01:00
David Lamparter bec667a6bc vtysh: show live log messages
https://www.youtube.com/watch?v=8psFQCEgA18

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-02-28 13:33:27 +01:00
David Lamparter 4c92dd90d3 vtysh: use poll/callback-driven readline interface
Create a thread_master and funnel readline terminal I/O through it.
This allows processing other input in parallel, e.g. log messages.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-02-28 13:28:43 +01:00
David Lamparter 12d25fa69a vtysh: receive file descriptors from daemons
The other half of yielding back a file descriptor from a daemon to
vtysh.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-02-28 13:28:43 +01:00
Donald Sharp 22f31b8c52 lib, vtysh: Add show thread timers command
Add the ability to inspect the timers and when they will pop
per daemon:

sharpd@eva ~/frr (thread_return_null)> vtysh -c "show thread timers"
Thread timers for zebra:

Showing timers for default
--------------------------
  rtadv_timer                                       00:00:00.520
  if_zebra_speed_update                             00:00:02.745
  if_zebra_speed_update                             00:00:02.745
  if_zebra_speed_update                             00:00:02.745
  if_zebra_speed_update                             00:00:02.745
  if_zebra_speed_update                             00:00:02.745
  if_zebra_speed_update                             00:00:02.745
  if_zebra_speed_update                             00:00:02.746
  if_zebra_speed_update                             00:00:02.744
  if_zebra_speed_update                             00:00:02.745

Showing timers for Zebra dplane thread
--------------------------------------

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-28 06:39:07 -05:00
David Lamparter d7da6520e9
Merge pull request #10376 from patrasar/master_pimv6_vtysh 2022-02-28 10:26:22 +01:00
sarita patra e8515e32a4 pim6d: Adding PIMV6 as VTYSH client
Co-authored-by: Mobashshera Rasool <mrasool@vmware.com>
Signed-off-by: sarita patra <saritap@vmware.com>
2022-02-25 06:08:42 -08:00
Donald Sharp 11743d1041 vtysh: Fix spelling mistakes
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-14 12:56:04 -05:00
Abhinay Ramesh b25bd2ad6e ospf6d: support keychain for ospf6 authentication
Problem Statement:
==================
As of now there is no support for ospf6 authentication.
To support ospf6 authentication need to have keychain support for
managing the auth key. 
 
RCA:
====
New support
 
Fix:
====
Enabling keychain for ospf6 authentication feature.
 
Risk:
=====
Low risk
 
Tests Executed:
===============
Have verified the support for ospf6 auth trailer feature.

Signed-off-by: Abhinay Ramesh <rabhinay@vmware.com>
2022-02-09 01:56:38 +00:00