Skip to content

[dhcp6relay] Add VRF support for upstream sockets (VLAN vrf and server_vrf) - #117

Open
AnantKishorSharma wants to merge 3 commits into
sonic-net:masterfrom
AnantKishorSharma:dhcp6relay-vrf-support
Open

[dhcp6relay] Add VRF support for upstream sockets (VLAN vrf and server_vrf)#117
AnantKishorSharma wants to merge 3 commits into
sonic-net:masterfrom
AnantKishorSharma:dhcp6relay-vrf-support

Conversation

@AnantKishorSharma

@AnantKishorSharma AnantKishorSharma commented Jun 30, 2026

Copy link
Copy Markdown

Why I did it

dhcp6relay always sent relay-forward to the DHCPv6 servers through the global routing table, so it could not reach servers that live in a non-default VRF. Fixes #89.

How I did it

Bind the upstream (server-facing) socket to a VRF via SO_BINDTODEVICE:

  • Option A — a relay VLAN placed in a non-default VRF (VLAN_INTERFACE vrf_name): the per-VLAN upstream socket is bound to that VRF.
  • Option B — an explicit server_vrf on the DHCP_RELAY row (servers reachable in a VRF different from the VLAN's): a shared per-VRF upstream socket is opened, demultiplexed back to the owning VLAN by link-address. The shared socket is released once the last VLAN referencing it is removed/re-pointed, so a deleted/recreated server VRF leaves no stale socket behind.

All applied at runtime through the existing reconcile path — no container restart. A runtime VRF change tears the relay down and re-arms it — SO_BINDTODEVICE cannot be rebound in place, so the upstream sockets are recreated under the new VRF.

How to verify it

  • 68/68 unit tests pass (make test), including new coverage for the server-VRF socket lifecycle.
  • On a qfx5200 t0 hardware testbed: the existing v6 relay suite passes (no regression) plus new control-plane and data-plane VRF tests.

Stacked on #116 — until #116 merges this PR's diff also shows #116's commit; it will be rebased to a clean diff afterwards.

…restart

dhcp6relay read DHCP_RELAY once at startup and required a dhcp_relay
container restart for any relay config change. Apply changes at runtime
instead: a detached monitor thread watches CONFIG_DB/STATE_DB and the
libevent main thread reconciles the live config.

Signed-off-by: Anant Kishor Sharma <anant.kishor-sharma@hpe.com>
…r_vrf)

Bind the server-facing socket to the VLAN's VRF or an explicit server_vrf via SO_BINDTODEVICE, and release shared server-VRF sockets on last use. Fixes sonic-net#89.

Signed-off-by: Anant Kishor Sharma <anant.kishor-sharma@hpe.com>
@AnantKishorSharma

Copy link
Copy Markdown
Author

@Xichen96 @yaqiangz @jcaiMR @saiarcot895 @yxieca @kellyyeh - Please review when you have a chance.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

@mssonicbld

Copy link
Copy Markdown
Collaborator

Hi, there are workflow run(s) waiting for approval, you may be first-time contributor. I will notify maintainers to help approve once PR is approved. Thanks!

---Powered by SONiC BuildBot

Comment thread dhcp6relay/src/config_interface.cpp Outdated
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

…to avoid a shutdown race

Signed-off-by: Anant Kishor Sharma <anant.kishor-sharma@hpe.com>
@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.

vrf support

3 participants