Skip to content

staticd: in route config, reject keywords as ifname - #20311

Merged
Jafaral merged 2 commits into
FRRouting:masterfrom
mjstapp:fix_staticd_config_keywords
Feb 18, 2026
Merged

staticd: in route config, reject keywords as ifname#20311
Jafaral merged 2 commits into
FRRouting:masterfrom
mjstapp:fix_staticd_config_keywords

Conversation

@mjstapp

@mjstapp mjstapp commented Dec 19, 2025

Copy link
Copy Markdown
Contributor

Reject cli keywords from the various 'ip route' configs if the vty code interprets them as interface names; some examples are "tag", "label", "color". Here's an example:

mjs-ubu-24-arm(config)# ip route 10.1.1.1/32 2.2.2.22 tag
% Invalid interface name tag
mjs-ubu-24-arm(config)# ip route 10.1.1.1/32 2.2.2.22 tag 15
mjs-ubu-24-arm(config)# do sho runn
Building configuration...

Current configuration:
!
frr version 10.6-dev-DEV
frr defaults traditional
hostname mjs-ubu-24-arm
!
ip route 10.1.1.1/32 2.2.2.22 tag 15
!
end
mjs-ubu-24-arm(config)#

@frrbot frrbot Bot added the staticd label Dec 19, 2025
@donaldsharp

Copy link
Copy Markdown
Member

I think we need to add this to the staticd documentation.

Comment thread staticd/static_vty.c
"segments",
"nexthop-vrf",
NULL /*End sentinel*/
};

@choppsv1 choppsv1 Dec 20, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bit fragile given these are all coming from inside DEFPY's defined elsewhere in this file. I'm curious if @eqvinox can take a look and see if there's some way we can leverage the cli parsing logic to disallow these automatically from the CLI command definition.

If I understand correctly this is coming from defs that look like:

   ...
   <INTERFACE|Null0>
   [{tag (1-4294967295)
    |(1-255)$distance
    |vrf NAME
   ...

I'm wondering if the CLI parser can automatically handle this.

BTW, is vrf foobar actually accepted as well? From my read here it's allowing tag NUM b/c tag is consumed by INTERFACE and then the number is consumed by (1-255)$distance, but there's no generic WORD in that follow on selection so I would expect vrf foobar to fail to parse. If that logic holds I think the only keywords that will trigger this bug are ones followed by a number from 1 to 255, as it's the (1-255)$distance atom that's causing us all the pain. If distance had had a keyword like distance i don't think we'd have this issue. :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the 'vrf XXX' tokens work - the matching is willing to use the more-specific match on the keyword 'vrf' followed by another word. but the lower-level match that would accept 'vrf' as an interface name will be rejected.

as you say, it's brittle to have to encode the ambiguous keywords, and it would be better to have an explicit "ifname YYY" instead of the positional matching. let's all try to squash examples like this as we review cli change proposals going forward...?

@choppsv1 choppsv1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eqvinox any way to have the CLI parser deal with this?

@mjstapp
mjstapp force-pushed the fix_staticd_config_keywords branch from 906852f to a5bd6b7 Compare December 22, 2025 18:23
@mjstapp

mjstapp commented Dec 22, 2025

Copy link
Copy Markdown
Contributor Author

rebased to newer master

@frrbot frrbot Bot added the documentation label Dec 22, 2025
@mjstapp

mjstapp commented Dec 22, 2025

Copy link
Copy Markdown
Contributor Author

yes, sure, I've pushed a small doc update too.

I think we need to add this to the staticd documentation.

@mjstapp
mjstapp force-pushed the fix_staticd_config_keywords branch from 4026428 to 8852762 Compare January 5, 2026 16:10
@mjstapp

mjstapp commented Jan 5, 2026

Copy link
Copy Markdown
Contributor Author

rebased to newer master

@mjstapp
mjstapp force-pushed the fix_staticd_config_keywords branch from 8852762 to cdd24d0 Compare January 20, 2026 20:33
@mjstapp

mjstapp commented Jan 20, 2026

Copy link
Copy Markdown
Contributor Author

rebased to newer master

@mjstapp
mjstapp force-pushed the fix_staticd_config_keywords branch from cdd24d0 to f9b5e44 Compare February 9, 2026 19:33
@mjstapp

mjstapp commented Feb 9, 2026

Copy link
Copy Markdown
Contributor Author

rebased to newer master

@mjstapp mjstapp removed the rebase PR needs rebase label Feb 9, 2026

@choppsv1 choppsv1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eqvinox confirmed during meeting not really a way to deal with this easily in infra.

Comment thread staticd/static_vty.c
NULL /*End sentinel*/
};

for (cp = invalid_names; cp != NULL && *cp != NULL; cp++)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a case sensitive strmatch, but we use case insenstive on line 142. Do we care?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks to me like the token-matching is case-sensitive, so "TAG" isn't the same as "tag" in the problem config commands.

@Jafaral Jafaral left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comment

Comment thread doc/user/static.rst Outdated
Mark Stapp added 2 commits February 13, 2026 14:00
Reject cli keywords from the various 'ip route' configs if
the vty code interprets them as interface names.

Signed-off-by: Mark Stapp <mjs@cisco.com>
Add a note to the docs that static route config keywords are
not valid ifnames.

Signed-off-by: Mark Stapp <mjs@cisco.com>
@mjstapp
mjstapp force-pushed the fix_staticd_config_keywords branch from f9b5e44 to 9569593 Compare February 13, 2026 19:12
@mjstapp

mjstapp commented Feb 13, 2026

Copy link
Copy Markdown
Contributor Author

rebased and added the list of keywords to the user doc

@Jafaral
Jafaral merged commit d387c53 into FRRouting:master Feb 18, 2026
19 checks passed
@mjstapp
mjstapp deleted the fix_staticd_config_keywords branch February 24, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants