Fix PTF/DUT subnet mismatch when VLAN has multiple IPv4 addresses#23204
Merged
StormLiangMS merged 1 commit intosonic-net:masterfrom Mar 24, 2026
Merged
Conversation
After the community added a second VLAN IP (192.169.0.1), get_first_vlan_ipv4 and ip_and_intf_info diverged: the former returned the first IPv4 (192.168.0.1) while the latter assigned PTF an IP in the last IPv4's subnet (192.169.x.x). This put PTF and DUT in different subnets, causing ping failures and MAC learning tests to break. Rename get_first_vlan_ipv4 to get_vlan_last_ipv4 and change it to return the last IPv4 in the VLAN, matching the behavior of ip_and_intf_info in conftest. Also improve robustness by using ip_network/IPv4Network type checking instead of the naive ":" in addr heuristic, and add try/except for malformed addresses. Signed-off-by: Shivashankar CR <shivashankar.c.r@gmail.com>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
|
Following |
StormLiangMS
approved these changes
Mar 24, 2026
Collaborator
StormLiangMS
left a comment
There was a problem hiding this comment.
LGTM — correctly aligns DUT/PTF subnet selection by using the last IPv4 address. CI all green.
Minor (non-blocking): Prefer isinstance(ip_network(addr, strict=False), IPv4Network) over type(...) is IPv4Network for Pythonic type checking.
ravaliyel
pushed a commit
to ravaliyel/sonic-mgmt
that referenced
this pull request
Mar 27, 2026
…nic-net#23204) After the community added a second VLAN IP (192.169.0.1), get_first_vlan_ipv4 and ip_and_intf_info diverged: the former returned the first IPv4 (192.168.0.1) while the latter assigned PTF an IP in the last IPv4's subnet (192.169.x.x). This put PTF and DUT in different subnets, causing ping failures and MAC learning tests to break. Rename get_first_vlan_ipv4 to get_vlan_last_ipv4 and change it to return the last IPv4 in the VLAN, matching the behavior of ip_and_intf_info in conftest. Also improve robustness by using ip_network/IPv4Network type checking instead of the naive ":" in addr heuristic, and add try/except for malformed addresses. Signed-off-by: Shivashankar CR <shivashankar.c.r@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of PR
Summary:
Fix PTF/DUT subnet mismatch in ARP tests when a VLAN interface has multiple IPv4 addresses.
Root Cause
After the community added a second VLAN IP (
192.169.0.1), two APIs used by the ARP tests diverged in which IPv4 they selected:get_first_vlan_ipv4192.168.0.1(DUT)ip_and_intf_info(conftest)192.169.x.x(PTF)This put PTF and DUT in different subnets, causing ping failures and MAC learning tests to break.
Fix
Rename
get_first_vlan_ipv4toget_vlan_last_ipv4so it returns the last IPv4 in the VLAN, matching the behavior ofip_and_intf_info. Both APIs now consistently use192.169.0.1, keeping PTF and DUT in the same subnet.Additionally, improve robustness:
ip_network/IPv4Networktype checking for IPv4 detection instead of the":" in addrheuristictry/exceptforValueErroron malformed addressesFiles Changed
tests/arp/arp_utils.py— renamed function, updated import, new selection logictests/arp/test_arp_update.py— updated import and call siteType of change
Back port request
Approach
What is the motivation for this PR?
How did you do it?
How did you verify/test it?
Any platform specific information?
Supported testbed topology if it's a new test case?
Documentation