Skip to content

Add module data to VLAN neighbors#2696

Merged
ipspace merged 1 commit intodevfrom
vlan-ngb
Sep 27, 2025
Merged

Add module data to VLAN neighbors#2696
ipspace merged 1 commit intodevfrom
vlan-ngb

Conversation

@ipspace
Copy link
Owner

@ipspace ipspace commented Sep 20, 2025

Add module data to VLAN neighbors

  • Copy node VLAN data to interface data during link_pre_transform to
    have them available when the neighbor list is built during link
    transformation
  • Copy most of the SVI interface data to the neighbor data structure
    when recreating the VLAN-wide neighbor list

Also:

  • Fix the DHCP attributes in the neighbor data to reflect the final
    state of the device interfaces. This allows the 'get gw of last
    resort' function to return the actual default gateway
  • Add an optional 'limit merge to these attributes' parameter to the
    'data.merge_with_removed_attributes' utility function
  • An IRB VLAN was added to the 'bgp-ibgp-localas' integration test
    as a regression test for [BUG] bgp.local_as not working with VLAN #2615

Fixes #2615

@ipspace ipspace marked this pull request as draft September 20, 2025 16:33
@ipspace
Copy link
Owner Author

ipspace commented Sep 20, 2025

This is an attempt to solve #2615. I will push several iterations because it's easier to review changes to transformation tests on GH web interface. Once the whole thing is done, I'll mark it ready for review.

# These attributes will be used to populate neighbor's "neighbor" list in VLANs
# with mode = route. We have to fix the IRB neighbors when rebuilding neighbor list.
#
data.merge_with_removed_attributes(intf,vdata,topology.nodes[intf.node].get('module',[]))
Copy link
Owner Author

Choose a reason for hiding this comment

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

The only significant impact of this change is in the stp.yml results where the VLAN STP priority is applied to a VLAN access port. I would claim this is the correct behavior anyway.

In all other changes to transformation test results, the VLAN data is applied to link interfaces entry, which is expected, and there are no further changes.

@ipspace ipspace force-pushed the vlan-ngb branch 2 times, most recently from 87d0a4c to de21d94 Compare September 21, 2025 10:11
# The current node data must be based on physical interfaces
# Remove the current node from the neighbor list and add the SVI information
#
vlan_data.neighbors = [ n for n in vlan_data.neighbors if n.node != node.name ] + [ svi_ifdata ]
Copy link
Owner Author

Choose a reason for hiding this comment

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

Impact of this change: potentially rearranged list of VLAN neighbors, which might trigger a change in the default gateway (because a different router becomes the first neighbor) and a related change in the static routes on attached hosts.

vlan_data.neighbors.append(n_data) # Add current node as a neighbor to VLAN neighbor list
# The current node is not yet in the VLAN neighbor list, add the SVI information
#
vlan_data.neighbors.append(svi_ifdata)
Copy link
Owner Author

Choose a reason for hiding this comment

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

Impact of this change: module data from SVI interface is added to the VLAN (and subsequently interface) neighbor list


# Try to get the gateway-of-last-resort from the fake "interface" neighbors
#
(gw_data,_) = routing.create_gateway_last_resort(ifdata,data.get_box({'ipv4': True}),topology)
Copy link
Owner Author

Choose a reason for hiding this comment

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

Impact of this change: the DHCP state of link- or VLAN-level neighbors is aligned with the final interface DHCP state, removing the impact of copying SVI interface module attributes to the VLAN neighbor list.

@ipspace ipspace requested review from jbemmel and ssasso September 21, 2025 13:34
@ipspace ipspace marked this pull request as ready for review September 21, 2025 13:34
@ipspace
Copy link
Owner Author

ipspace commented Sep 21, 2025

As expected, these changes resulted in massive changes in transformation test results. I went through all of those, and they all looked legit to me. I also documented the impact of individual changes to the test results to help you understand what's going on.

The whole thing should now be working the way I expect it should work (how's that for a definitive statement 😜). It solves the BGP local_as problem and the "correct" VLAN neighbor data might help us solve a few others (for example, some reports and graphs struggled with VLANs).

ipspace added a commit that referenced this pull request Sep 25, 2025
Fixes #2477

WARNING: This is a snapshot of work-in-progress, it probably
depends on #2696 to get 'vrf' attribute on VLAN neighbors.
* Copy node VLAN data to interface data during link_pre_transform to
  have them available when the neighbor list is built during link
  transformation
* Copy most of the SVI interface data to the neighbor data structure
  when recreating the VLAN-wide neighbor list

Also:

* Fix the DHCP attributes in the neighbor data to reflect the final
  state of the device interfaces. This allows the 'get gw of last
  resort' function to return the actual default gateway
* Add an optional 'limit merge to these attributes' parameter to the
  'data.merge_with_removed_attributes' utility function
* An IRB VLAN was added to the 'bgp-ibgp-localas' integration test
  as a regression test for #2615

Fixes #2615
@ipspace ipspace merged commit 3ee233a into dev Sep 27, 2025
13 checks passed
@ipspace ipspace deleted the vlan-ngb branch September 27, 2025 10:29
ipspace added a commit that referenced this pull request Sep 27, 2025
Fixes #2477

WARNING: This is a snapshot of work-in-progress, it probably
depends on #2696 to get 'vrf' attribute on VLAN neighbors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] bgp.local_as not working with VLAN

1 participant