Skip to content

Fix AF_PACKET protocol on raw L3 sends#5015

Open
cinit wants to merge 1 commit into
secdev:masterfrom
cinit:fix-ppp-send
Open

Fix AF_PACKET protocol on raw L3 sends#5015
cinit wants to merge 1 commit into
secdev:masterfrom
cinit:fix-ppp-send

Conversation

@cinit

@cinit cinit commented Jun 15, 2026

Copy link
Copy Markdown

Description

Set the sockaddr_ll protocol explicitly when sending raw L3 packets through Linux AF_PACKET sockets. This prevents PPP/PPPoE drivers from seeing skb->protocol as 0 and dropping IPv4/IPv6 packets sent with send() or sendp().

Add Linux regression coverage for IPv4 padding retry and IPv6 protocol selection on L3PacketSocket and raw-L3 L2Socket paths.

Tested send and sendp can work on ppp0.

Fixes #4964

AI-Assisted: yes (OpenAI Codex)

Set the sockaddr_ll protocol explicitly when sending raw L3 packets through Linux AF_PACKET sockets. This prevents PPP/PPPoE drivers from seeing skb->protocol as 0 and dropping IPv4/IPv6 packets sent with send() or sendp().

Add Linux regression coverage for IPv4 padding retry and IPv6 protocol selection on L3PacketSocket and raw-L3 L2Socket paths.

Fixes secdev#4964

AI-Assisted: yes (OpenAI Codex)
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 46.51163% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.36%. Comparing base (503e1fc) to head (f02b611).
⚠️ Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
scapy/arch/linux/__init__.py 46.51% 23 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5015      +/-   ##
==========================================
- Coverage   80.38%   80.36%   -0.03%     
==========================================
  Files         385      386       +1     
  Lines       95889    95993     +104     
==========================================
+ Hits        77083    77145      +62     
- Misses      18806    18848      +42     
Files with missing lines Coverage Δ
scapy/arch/linux/__init__.py 79.53% <46.51%> (-3.80%) ⬇️

... and 11 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 gpotter2 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR !
Although it may work, the code doesn't really make sense. I've made some comments

i = 0
for p in x.fragment():
i += fd.send(bytes(self.LL() / p))
if sock.lvl == 2:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What's the use case of this 'if' ?


def send(self, x):
# type: (Packet) -> int
if self.lvl == 3:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What's the use case of this? I'm a bit lost

elif isinstance(iff, NetworkInterface):
iff = network_name(iff)
type_x = type(x)
sdto = (iff, conf.l3types.layer2num.get(type_x, self.type))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why define this tuple?

self.send_socks[iff] = L3PacketSocket(
iface=iff,
type=conf.l3types.layer2num.get(type_x, self.type),
type=sdto[1],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just to extract if afterwards ?

sx = bytes(sock.LL() / x)
else:
sx = bytes(x)
sdto = (iff, _get_packet_protocol(x, sx, sdto[1]))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And redefine it here ? _get_packet_protocol looks awfully like a duplicate of what this function is already doing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

send() and sendp() not working on PPPoE interface

2 participants