kernelkit / infix

Linux :yellow_heart: NETCONF = Infix
https://kernelkit.org
GNU General Public License v2.0
52 stars 12 forks source link

Add custom-phys-address for interfaces #680

Closed troglobit closed 1 month ago

troglobit commented 1 month ago

Description

In some use-cases it would be useful to be able to infer using the base MAC (chassis MAC) address on an interface, e.g., VETH pairs or layer-2 tunnel interfaces.

This issue details a proposal to extend the ietf-interfaces.yang model with options to tweak and override the defaults.

Furthermore, in an effort (very small) to reduce the deviations, we propose reverting the config true; change for ietf-interfaces:phys-address and fold that support as well into this new syntax.

YANG Model

augment "/if:interfaces/if:interface" {
  description "Custom phys-address management, static or derived from chassis MAC.";

  container custom-phys-address {
    description "Container for custom physical address options";

    choice address-type {
      description "Choose between static MAC address or chassis-derived MAC";

      case static {
        leaf static {
          type yang:phys-address;
          description "Statically configured interface address on protocol sub-layer, e.g., MAC.";
        }
      }

      case chassis {
        container chassis {
          presence "Enable chassis-derived address options";
          description "Container for options when using chassis-derived address.";

          leaf offset {
            type yang:phys-address;
            description "Address offset to add to the chassis-derived MAC.";
          }
        }
      }
    }
  }
}

Note: node and container names are of course just suggestions at this point.

Example

Base MAC address of the device, sometimes referred to Chassis MAC, is read from VPD and parsed by probe at boot into /run/system.json. In this example the Base MAC is 00:53:00:c0:ff:ee.

1) Fixed custom

admin@example:/config/> edit interface veth0a
admin@example:/config/interface/veth0a/> set custom-phys-address static 00:ab:00:11:22:33

=> 00:ab:00:11:22:33

2) Use Chassis MAC

admin@example:/config/> edit interface veth0a
admin@example:/config/interface/veth0a/> set custom-phys-address chassis

=> 00:53:00:c0:ff:ee

3) Use Chassis MAC, with local bit

admin@example:/config/> edit interface veth0a
admin@example:/config/interface/veth0a/> set custom-phys-address chassis offset 02:00:00:00:00:00

=> 02:53:00:c0:ff:ee

4) Use Chassis MAC, with offset

admin@example:/config/> edit interface veth0a
admin@example:/config/interface/veth0a/> set custom-phys-address chassis offset 00:00:00:00:00:02

=> 00:53:00:c0:ff:f0

5) Use Chassis MAC, with offset and local bit

admin@example:/config/> edit interface veth0a
admin@example:/config/interface/veth0a/> set custom-phys-address chassis offset 02:00:00:00:00:02

=> 02:53:00:c0:ff:f0

Additional Information

A previous proposal used format specifiers, which exist today in an extension to ietf-system.yang, for hostname. That proposal was scrapped in favor of this current one, which is a more YANG friendly alternative.

General Information

Anyone can help out by sponsoring development of new features or contributing pull requests. Please use this issue for discussions related to the feature.