Commit graph

588 commits

Author SHA1 Message Date
Mark Stapp bf6e7c1da5 vtysh: clean up variable-shadow warnings
Clean up various variable-shadowing warnings from -Wshadow

Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-04-08 14:41:27 -04:00
Carmine Scarpitta 96134d1964 vtysh: Add no static-sids command
Previous commits introduced the `no` form for the `static-sids` command.
This change allow users to remove all static SIDs at once.

This commit makes the `no static-sids` command available in vtysh.

```
router# config
router(config)# segment-routing
router(sr)# srv6
router(srv6)# no static-sids
```

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2025-02-27 12:17:26 +01:00
Russ White adeb30d8f3
Merge pull request #17336 from forrestchu/sbfd
implement SBFD
2025-02-04 06:36:43 -05:00
wumu.zsl 2d6a4265e1 bfdd: add vtysh commands for sbfd
config examples:
    SBFD Initiator: peer 200::D bfd-mode sbfd-init bfd-name a-b-d multihop local-address 200::A remote-discr 456 srv6-source-ipv6 200::A srv6-encap-data 100::B 100::D
    SBFD Reflector: sbfd reflector source-address 200::D discriminator 456
    Echo SBFD: peer 200::A bfd-mode sbfd-echo bfd-name a-b-d local-address 200::A srv6-source-ipv6 200::A srv6-encap-data 100::B 100::D

Signed-off-by: wumu.zsl <wumu.zsl@alibaba-inc.com>
2025-01-23 01:27:55 +00:00
Yuqing Zhao 52c4028195 vtysh: Add SRv6 static SIDs CLI to vtysh
Signed-off-by: Yuqing Zhao <galadriel.zyq@alibaba-inc.com>
2025-01-18 10:28:49 +00:00
Donald Sharp 959dbe27cd lib,vtysh: Use backoff setsockopt option for freebsd
Commit: 9112fb367b

Introduced the idea of setting the socket buffer
send/receive sizes.  BSD's in general have the fun
issue of not allowing nearly as large as a size as
linux.  Since the above commit was developed on linux
and not run on bsd it was never tested.  Modify the
codebase to use the backoff setsockopt that we have
in the code base and use the returned values to allow
us to notice what was set and respond appropriately.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-12-03 18:49:59 -05:00
David Lamparter e8006bc2cb vtysh: make clang-SA happy about reusing stdin
While the logic here is perfectly fine, clang-SA doesn't understand that
the fopen() and fclose() match up with each other.  Just use a separate
variable to make clang-SA happy.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16 13:30:25 +02:00
David Lamparter 42d468800d vtysh: remove duplicate nonblocking handling
non-blocking retries are already handled in `vtysh_client_receive()`.
And by the point we're back in `vtysh_client_run()`, errno may have been
overwritten by the close() call in vtysh_client_receive().

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-16 13:30:25 +02:00
Srujana 9112fb367b lib: Memory spike reduction for sh cmds at scale
The output buffer vty->obuf is a linked list where
each element is of 4KB.
Currently, when a huge sh command  like <show ip route json>
is executed on a large scale, all the vty_outs are
processed and the entire data is accumulated.
After the entire vty execution, vtysh_flush proceeses
and puts this data in the socket (131KB at a time).

Problem here is the memory spike for such heavy duty
show commands.

The fix here is to chunkify the output on VTY shell by
flushing it intermediately for every 128 KB of output
accumulated and free the memory allocated for the buffer data.

This way, we achieve ~25-30% reduction in the memory spike.

Fixes: #16498
Note: This is a continuation of MR #16498

Signed-off-by: Srujana <skanchisamud@nvidia.com>

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2024-08-27 12:47:00 -07:00
David Lamparter e26c580588 vtysh: de-conditionalize and reorder install_node
There is entirely no point to these being conditional.  And pull them up
so the upcoming pre-parse code can work on a clean slate.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-07-31 08:08:53 -04:00
Jafar Al-Gharaibeh 7aeb51e194
Merge pull request #16406 from opensourcerouting/fix/remove_deprecation_for_show_threads
Drop deprecation for `show thread ...`
2024-07-19 13:19:17 -04:00
Donatas Abraitis f46ce043fc lib, vtysh: Removed deprecated aliases for show thread ...
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-07-17 02:12:48 +03:00
Nathan Bahr fd8edc3dfb pimd, lib, vtysh: Added new 'router pim[6] [vrf NAME]' config node
Moved all existing global/vrf PIM config to the new subnode.
Existing configuration updated to be hidden and deprecated.
Both versions of configuration still work together.

Signed-off-by: Nathan Bahr <nbahr@atcorp.com>
2024-07-16 13:30:35 -05:00
Carmine Scarpitta b3ca230a8f vtysh: CLI to override default SID format config
Add CLI commands to support overriding default configuration of the SID
format.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-06-13 14:54:16 +02:00
Piotr Suchy 70e5005cba lib, vtysh, topotests: fix 'show ip[v6] access-list ... json' formatting
Similarly to recently fixed 'show ip[v6] prefix-list ...' - PR#15750,
json output is not valid for 'show ip[v6] access-list ... json' commands,
as it goes through all the running daemons and for each one it calls
'filter_show' creating a new json object. To aggreagate the output
and create a valid json that can later be parsed, the commands were
moved to vtysh and formatted accordingly

Signed-off-by: Piotr Suchy <piotrsuchy@proton.me>
2024-05-14 13:22:20 +02:00
Mark Stapp 3a59d4f984 lib,bgpd,vtysh: move bgp vty defines to lib
Stop including a bgp header file from vtysh; move a couple
of cli string defines to a library header.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2024-04-24 08:23:12 -04:00
Piotr Suchy 0a17289a3b vtysh, lib: fix 'show ip[v6] prefix-list ... json' formatting by moving it to vtysh
Json output is not valid for 'show ip[v6] prefix-list ... json' commands,
as it goes through all the running daemons and for each one it calls
'vty_show_prefix_list' creating a new json object. To aggreagate the output
and create a valid json that can be parsed, the commands were moved to vtysh.

Before:
{
  "ZEBRA":{
    "DEFAULT":{
      "addressFamily":"IPv4",
      "entries":[
        {
          "sequenceNumber":10,
          "type":"permit",
          "prefix":"0.0.0.0/0"
        }
      ]
    }
  }
}
{
  "OSPF":{
    "DEFAULT":{
      "addressFamily":"IPv4",
      "entries":[
        {
          "sequenceNumber":10,
          "type":"permit",
          "prefix":"0.0.0.0/0"
        }
      ]
    }
  }
}
{
  "BGP":{
    "DEFAULT":{
      "addressFamily":"IPv4",
      "entries":[
        {
          "sequenceNumber":10,
          "type":"permit",
          "prefix":"0.0.0.0/0"
        }
      ]
    }
  }
}

After:
{"zebra":{
  "DEFAULT":{
    "addressFamily":"IPv4",
    "entries":[
      {
        "sequenceNumber":10,
        "type":"permit",
        "prefix":"0.0.0.0/0"
      }
    ]
  }
}
,"ospfd":{
  "DEFAULT":{
    "addressFamily":"IPv4",
    "entries":[
      {
        "sequenceNumber":10,
        "type":"permit",
        "prefix":"0.0.0.0/0"
      }
    ]
  }
}
,"bgpd":{
  "DEFAULT":{
    "addressFamily":"IPv4",
    "entries":[
      {
        "sequenceNumber":10,
        "type":"permit",
        "prefix":"0.0.0.0/0"
      }
    ]
  }
}
}

Signed-off-by: Piotr Suchy <piotrsuchy@proton.me>
2024-04-21 23:40:06 +02:00
Donatas Abraitis 9b8f18a66c vtysh: Fix show route-map command when calling via do
Before:

```
ton(config)# do sh route-map
% [ZEBRA] Unknown command: show route-map
% [BGP] Unknown command: show route-map
% [ISIS] Unknown command: show route-map
```

Fixes: 570fdc55fd ("lib,vtysh: fix show route map JSON output")

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-04-19 19:17:11 +03:00
Donatas Abraitis d9d6db4582 vtysh: Check if bgpd is enabled before installing vtysh commands for RPKI
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-04-16 11:56:39 +03:00
Donatas Abraitis 4952f23cee
Merge pull request #15288 from donaldsharp/shell_access_removal
vtysh: Remove deprecated shell_access code
2024-02-14 11:20:36 +02:00
Igor Ryzhov 3ac3a6605d lib, mgmtd: rework processing of yang notifications
Currently, YANG notification processing is done using a special type of
callbacks registered in backend clients. In this commit, we start using
regular northbound infrastructure instead, because it already has a
convenient way of registering xpath-specific callbacks without the need
for creating additional structures for each necessary notification. We
also now pass a notification data to the callback, instead of a plain
JSON. This allows to use regular YANG library functions for inspecting
notification fields, instead of manually parsing the JSON.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-11 13:26:52 +02:00
Igor Ryzhov 2574f03a13 vtysh: remove resync workaround when exiting to config node
When exiting from a level below the config node, like `router rip`,
vtysh executes a resync by sending "end" and "conf term [file-lock]"
commands to all the daemons. As statet in the description comment, it's
done "in case one of the daemons is somewhere else". I don't think this
actually ever happens, but even if it is, it is a bug in a daemon that
needs to be fixed. This resync was okay before the introduction of
mgmtd, but now it unlocks and locks back the datastores during the
configuration reading process, which can lead to a failure which is
explained in the previous commit.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-07 18:37:29 +02:00
Donald Sharp afb034b0bb vtysh: Remove deprecated shell_access code
This code has been deprecated for over a year and frankly
needs to be removed from the system.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-02-05 08:49:18 -05:00
Mark Stapp 678292b9be vtysh: un-hide the show configuration nb cli
The "show configuration running" cli is pretty useful when
doing NB work; unhide it so it's easier to use.

Signed-off-by: Mark Stapp <mjs@labn.net>
2024-01-30 08:09:25 -05:00
Igor Ryzhov 3900813298 zebra: convert to mgmtd
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28 23:28:40 +02:00
Igor Ryzhov b688eb7e9e zebra: convert interface link-params command to NB
Make link-params a presence container and activate it when entering the
node. The "enable" command is not necessary anymore but kept hidden for
backwards compatibility.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28 23:28:39 +02:00
Christian Hopps e6eec072ab ripngd: convert ripngd to mgmtd
- a couple small fixes for ripd conversion as well.

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-26 17:40:55 -05:00
Christian Hopps 83abe9c3cb ripd: ripd convert to mgmtd
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-26 12:34:46 -05:00
Christian Hopps dabc92de9e lib: convert route-map to mgmtd
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-26 12:34:23 -05:00
Donatas Abraitis 20ec72d7ca
Merge pull request #15052 from louis-6wind/rpki-vrf-92
bgpd: add VRF support to RPKI
2024-01-22 16:16:34 +02:00
Philippe Guibert 1420189c11 bgpd: add support of rpki in vrf configure context
Add support of RPKI commands in the VRF configure context.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-01-18 13:23:33 +01:00
Mark Stapp 31015c3ad9 lib,vtysh: add per-daemon log file config
Add a config that specifies per-deamon log file names.
Move the handy generated list of daemon names from vtysh to lib;
edit the gitignore files to match.

Signed-off-by: Mark Stapp <mjs@labn.net>
2024-01-17 16:15:07 -05:00
Donald Sharp b6f1a4089f lib: zebra.h uses pwd.h when it should not
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-09 12:50:40 -05:00
Donatas Abraitis e0422df53b vtysh: Rename show thread ... to show event ...
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-01-07 14:43:38 +02:00
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
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
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
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
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
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
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