Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vtysh / issue with command parser when some vty commands are set/unset upon configuration #2232

Closed
pguibert6WIND opened this issue May 15, 2018 · 7 comments
Labels

Comments

@pguibert6WIND
Copy link
Member

example:
When starting zebra, some vty commands are installed or not, depending on the vrf backend kind.
The issue #1976 illustrates the issue.

Actually, the vtysh parser that forges the vtysh client to populate the various vty commands does not know what is the vrf backend used. As such, it will parse both lines in zebra containing install_element, and will install it in vtysh client, thus resulting in the following message:

localhost.localdomain(config)# ip route 1.1.1.1/32 10.1.2.3 
% Ambiguous command: ip route 1.1.1.1/32 10.1.2.3 

this ticket should solve that issue; among possibilities to resolve this:

  • solution 1 : do not make any differences at all between the various vrf backends
  • solution 2 : vtysh should have an optional parameter that could permit at compilation time to know which command to installl/to ignore
  • solution 3 : any proposal is welcome
@qlyoung
Copy link
Member

qlyoung commented May 15, 2018

#1 sounds good to me. Could you define a single command that handles both cases, rather than two commands with mutually ambiguous definitions that handle each case?

#2 is probably the wrong way to go. Being a shell, vtysh shouldn't know about things like what VRF backend is being used.

@pguibert6WIND
Copy link
Member Author

issue 1968. I want to hide the table ID

@qlyoung qlyoung added the bug label May 15, 2018
@pguibert6WIND
Copy link
Member Author

in 1968, I have 2 vty commands:;
A] ip route A.B.C.D E.F.G.H label
B] ip route A.B.C.D E.F.G.H
If vrf backend is default, then B command is installed.
If vrf backend is netns, then A command is installed

using solution#2 would know which command has to be parsed ( at compilation time ?)
using solution #1, I am puzzled because I don't want to offer on default vrf backend the ability to configure ( and display) label option.
how to handle that ?

  • at the DEFUN_VTY definition ( arguments could be dynamically hidden ?)
  • somewhere else ?

@qlyoung
Copy link
Member

qlyoung commented May 16, 2018

if (backend == netns)
   install_element(ip_route_netns_cmd);
else
   install_element(ip_route_cmd);

@pguibert6WIND
Copy link
Member Author

This is what i did in #1968, but vtysh parser fails -> Ambiguous command:

I dont know how to put the if backend=netns on vtysh

@qlyoung
Copy link
Member

qlyoung commented May 16, 2018

You're right, I forgot you can't do it that way because extract.pl only sees installation calls and none of the surrounding logic. Instead you can do

DEFUN(...)
{
    if (user provided label && !netns) {
        "X is only available when running on network namespace"
        return CMD_WARNING;
    }
    ...
}

I agree it sucks.

@pguibert6WIND
Copy link
Member Author

I updated #1976 accordingly.
let wait for 1976 CI success, and review, then, before closing the issue.

I would also check with Donald if he thinks it is ok to keep table as argument ( meaning that the parameter will be visible)

@qlyoung qlyoung closed this as completed Apr 24, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants