Page MenuHomeVyOS Platform

XML: generator should support override of variables
Closed, ResolvedPublicFEATURE REQUEST

Description

All our interfaces have a default MTU of 1500 bytes. Some interfaces (PPPoE, L2TPv3, MACsec) do not have a default MTU of 1500 bytes, but as we inherit the XML definition we "pull-in" this invalid value.

The default value is later exchanged during runtime of the script here:

This simply "feels wrong" to change the value in the handler script. It would be nice to add an XML statement into interfaces-pppoe.xml.in stating:

#include <include/interface-mtu-68-1500.xml.i>
<leafNode name="mtu">
  <defaultValue>1492</defaultValue>
</leafNode>

to override the default value with the correct one on this interface. This would mean "true inheritance" like in C++/Python.

Details

Version
-
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Internal change (not visible to end users)

Event Timeline

c-po triaged this task as Normal priority.
c-po added subscribers: dmbaturin, jestabro.
jestabro changed the task status from Open to Needs testing.EditedJan 19 2021, 8:32 PM

Preprocessing solution in testing here:
https://github.com/vyos/vyos-1x/compare/current...jestabro:override-default

in response to the following constraints:
(1) Agreed that maintaining defaults in the conf_mode scripts feels incorrect, and defeats the purpose of the tag 'defaultValue'.
(2) Overriding of the tag within the XML must be processed before 'build-command-templates' is invoked, as the check against the schema will fail if more than one 'defaultValue' tag exists for a given path.
(3) Overriding of the tag within the XML must be processed after the preprocessing of the *.xml.in files, for the obvious reason that all instances will not be collected until after that step.

Consequently, a script is provided to run at the outset of 'make interface_definitions' to process the XML to collect, replace, and remove the appropriate elements, with result the updated 'defaultValue' contents.

The script is a terse application of lxml's xpath capability. The link above includes the test case outlined in the description.

Two minor comments left out of the above:
(1) The script in question runs a check on all interface definitions, however, there is no measurable increase in compile time.
(2) lxml will escape characters '>', '<', however these are unescaped by build-command-templates, so the issue is mooted. One can see the single line changed in the XML by running the test case above; it is noted that some interface definitions already have a mixed use of, say, '>' and '&gt;'.

Will remove test case and rebase to create PR and merge for 1.4; will later backport to 1.3 pending any issue.

jestabro changed the task status from Resolved to Unknown Status.
jestabro changed the status of subtask T3239: XML: override 'defaultValue' for mtu of certain interfaces; remove workarounds from Resolved to Unknown Status.
jestabro changed the task status from Unknown Status to Resolved.Feb 3 2021, 6:43 PM
jestabro changed the status of subtask T3239: XML: override 'defaultValue' for mtu of certain interfaces; remove workarounds from Unknown Status to Resolved.
jestabro moved this task from In Progress to Finished on the VyOS 1.3 Equuleus board.
erkin set Issue type to Internal change (not visible to end users).Aug 29 2021, 12:58 PM
erkin removed a subscriber: Global Notifications.