WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@0x-0ddc0de
Copy link
Contributor

For IPv4 point-to-point (p2p) links, Linux rtnetlink provides two IP addresses for the link: IFA_LOCAL, which is the IP of the local interface, and IFA_ADDRESS, which is the peer's IP address. The existing parsing of the rtnetlink data uses IFA_ADDRESS as the local interface IP, regardless of the type of link it is, resulting in the peer IP being returned for p2p links. This manifests itself, for example, in conf.ifaces and get_if_addr().

This PR fixes the bug by detecting the existence of IFA_LOCAL and if present, using its value instead of IFA_ADDRESS. For non-p2p links, either both IFA_LOCAL and IFA_ADDRESS exist and are identical or just IFA_ADDRESS exists.

This fix was tested on local Linux machines connected to a remote VPN server, as a VPN tunnel forms a p2p link.

Fixes issue #4884

- For point-to-point links, IFA_ADDRESS is the peer rather than local interface IP; we need to instead use IFA_LOCAL
@codecov
Copy link

codecov bot commented Dec 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.86%. Comparing base (e73137e) to head (965ec19).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4887   +/-   ##
=======================================
  Coverage   80.86%   80.86%           
=======================================
  Files         368      368           
  Lines       90271    90274    +3     
=======================================
+ Hits        72996    73002    +6     
+ Misses      17275    17272    -3     
Files with missing lines Coverage Δ
scapy/arch/linux/rtnetlink.py 92.76% <100.00%> (+0.09%) ⬆️

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gpotter2
Copy link
Member

Thanks a lot for the PR !

@gpotter2 gpotter2 merged commit 9c3d51c into secdev:master Dec 22, 2025
25 checks passed
@gpotter2 gpotter2 added this to the 2.7.0 milestone Dec 22, 2025
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.

2 participants