Skip to content

[dhcp4relay] Reject first-hop requests with relay information#124

Draft
Xichen96 wants to merge 2 commits into
sonic-net:masterfrom
Xichen96:dev/xichenlin/item10-first-hop-option82
Draft

[dhcp4relay] Reject first-hop requests with relay information#124
Xichen96 wants to merge 2 commits into
sonic-net:masterfrom
Xichen96:dev/xichenlin/item10-first-hop-option82

Conversation

@Xichen96

@Xichen96 Xichen96 commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Description of PR

Summary:

Reject a zero-giaddr DHCP request that already contains Option 82 before the
relay assigns giaddr or appends another relay information option.

This is a low-priority placeholder for a non-current deployment scenario. This
draft must not merge yet.

Type of change

  • Bug fix

Approach

What is the motivation for this PR?

SONiC has no trusted-circuit configuration. RFC 3046 safe untrusted behavior,
and the SONiC ISC relay default, require dropping a first-hop request that
already carries relay information. The native relay currently assigns giaddr
and appends a duplicate Option 82.

How did you do it?

  • Detect pre-existing Option 82 on zero-giaddr client requests.
  • Increment the drop counter and emit a clear diagnostic before modifying the
    packet.
  • Add focused native unit coverage proving send_udp is not called, giaddr
    and hops remain unchanged, and no duplicate option is appended.

How did you verify/test it?

Focused native unit code is included but was NOT RUN, per explicit test
deferral. Test execution is deferred until the higher-priority DHCP relay PRs
listed below merge.

Any platform specific information?

None. This covers a lower-priority, non-current deployment scenario.

Dependencies and future validation TODOs

Validation sequencing depends on these higher-priority relay PRs merging first
(no code dependency; this branch is independently based on fresh origin/master):

Before marking ready or merging:

  • Execute the focused native unit coverage included in this PR.
  • Open the dependent sonic-mgmt PR that sends zero-giaddr DHCP with a
    pre-existing Option 82 and proves no packet reaches the upstream server:
    [dhcp_relay] Cover first-hop requests with Option 82 sonic-mgmt#26322
  • Verify the DHCP relay drop counter and diagnostic for the rejected packet.
  • Run applicable PR CI/hardware validation after the dependency PRs merge.
  • Keep this PR in draft; do not merge before these TODOs are complete.

Documentation

Behavior follows RFC 3046 untrusted-circuit handling and the SONiC ISC default.

Drop untrusted first-hop requests that already carry Option 82 before assigning giaddr or appending relay information.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2b881aa9-3a3a-4aaf-b2ca-b941705b2438
Signed-off-by: Xichen96 <lukelin0907@gmail.com>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Walk DHCP options with cookie, length, PAD, and END validation so bytes after END cannot trigger the untrusted first-hop drop.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2b881aa9-3a3a-4aaf-b2ca-b941705b2438
Signed-off-by: Xichen96 <lukelin0907@gmail.com>
@Xichen96
Xichen96 force-pushed the dev/xichenlin/item10-first-hop-option82 branch from 8f0a9b7 to 81379c2 Compare July 19, 2026 17:52
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

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