inex / IXP-Manager

Full stack web application powering peering at over 200 Internet Exchange Points (IXPs) globally.
https://www.ixpmanager.org/
GNU General Public License v2.0
375 stars 160 forks source link

Include VLAN interface ID in API output (layer2interfaces) #832

Closed 9er closed 1 year ago

9er commented 1 year ago

Feature

The output of the layer2interfaces API endpoint returns something like this:

- type: edge
  name: Ethernet49/1
  vlans:
  - number: 100
    macaddresses:
    - 08:96:ad:26:0c:c9
    ipaddresses:
      ipv4: 193.138.31.16
      ipv6: 2001:7f8:56::16:1

But it does not contain the VLAN Interface ID, which in this case would be 44. My proposal would be to add the ID as vlaninterfaceid, similar to the already included virtualinterfaceid:

- type: edge
  name: Ethernet49/1
  vlans:
  - number: 100
    vlaninterfaceid: 44  # <<<
    macaddresses:
    - 08:96:ad:26:0c:c9
    ipaddresses:
      ipv4: 193.138.31.16
      ipv6: 2001:7f8:56::16:1

Maybe this could be a one-liner in SwitchConfigurationGenerator.php, but I really don't know any remotly modern PHP, so I'm not entirely sure.

Why?

The VLAN interface ID is already used outside IXP Manager, most prominently for sflow things and Bird configuration, where the protocol names look something like pb_0044_as553. The 0044 is an expanded VLAN interface ID.

I would like to make monitoring and alerting to be aware of which sessions belong to which interfaces. With that, we can have a dashboard that shows all the information that belongs to an interface, including the BGP sessions running on it. Or we could have smarter alerting that won't bug you with BGP session alerts while the port is down.

Alternatives

Well, the vliid in the Bird protocol/filter names could be replaced by something else (?) but I think it's a quite clever solution.

A workaround would be to write a script that fetches layer2interfaces and sflow-db-mapper/configured-macs (bear with me), because that includes something like "0896ad260cc9":44 and use that to map the MAC in layer2interfaces to the MAC in configured-macs and get the vliid, but that's far from bullet proof and quite a hack...