Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[201811][dhcp_relay] Add support for DHCP client(s) on one VLAN and DHCP server(s) on another #2919

Merged
merged 8 commits into from
May 18, 2019
Merged

[201811][dhcp_relay] Add support for DHCP client(s) on one VLAN and DHCP server(s) on another #2919

merged 8 commits into from
May 18, 2019

Conversation

jleveque
Copy link
Contributor

Previously, the DHCP relay agent in SONiC would not relay DHCP requests to other VLANs. Therefore, if a DHCP client and the DHCP server it needed to communicate with resided on different VLANs under the same ToR device, the DHCP server would never receive the requests. The reason for this was because there was no way to specify whether the agent should only listen for requests or responses on each interface, so each DHCP relay agent could only listen on one VLAN to avoid sending DHCP requests and replies to incorrect DHCP servers.

How I did it

  • Backport upstream enhancements from isc-dhcp-relay version 4.3.5-3.1 into 4.3.3-6 to allow for new -id and -iu arguments, which allow us to specify 'downstream' and 'upstream' interfaces, respectively (the relay agent will only listen for requests on downstream interfaces, and will only listen for replies on upstream interfaces.
  • For each VLAN which has DHCP server IP addresses configured, we create a DHCP relay agent process, passing that VLAN as the downstream interface (-id), and all other interfaces (including all other VLAN interfaces) as upstream interfaces (-iu).
  • After implementing the above changes, I found that when the relay agent would relay directed broadcast packets on the upstream VLAN, the send was failing with the message ERR dhcrelay[172]: send_packet: Permission denied. I discovered that this was due to the relay agent being built by default to open one shared socket on a "fallback" interface, without the SO_BROADCAST flag set. I then added a patch to force the relay agent to open one socket per interface, each with the SO_BROADCAST flag set. I then noticed, however, that when built with this configuration, the relay agent would only relay packets on one upstream interface, so I created another patch, firstly fixing a bug that prevented a fallback interface from being created if USE_SOCKETS was defined. With this fix, I was able to open sockets on all specified interfaces, as well as a fallback interface. Then I was able to create a patch to relay request packets as follows:
    • If the BOOTREQUEST packet is destined for the broadcast IP of one of our upstream interfaces, send the directed broadcast packet directly on that interface, otherwise the kernel will drop directed broadcast packets.
    • Otherwise:
      • If we have a fallback interface, forward the packet on that interface and let the kernel route it
      • Otherwise, forward the packet on all upstream interfaces
  • Resolves Per Vlan DHCP relay is broken if DHCP server is connected via Vlan interface #1247 on the 201811 branch. A nearly identical PR ([201803][dhcp_relay] Add support for DHCP client(s) on one VLAN and DHCP server(s) on another #2857) has been merged into the 201803 branch. Once this PR is merged, I will create a similar PR against the master branch.

@jleveque
Copy link
Contributor Author

Retest this please.

@lguohan lguohan merged commit bd7b96f into sonic-net:201811 May 18, 2019
@jleveque jleveque deleted the uplink_downlink_support_isc-dhcp-relay_201811 branch May 21, 2019 07:23
yxieca pushed a commit that referenced this pull request Aug 11, 2023
…atically (#16110)

src/sonic-utilities

* 0f001c56 - (HEAD -> 202205, origin/202205) UT change: for db_migrator test do not check for RESTAPI cert values (#2919) (4 hours ago) [Vaibhav Hemant Dixit]
* 69d348d1 - [CLI][Show][BGP] Show BGP Change for no neighbor scenario (#2885) (6 hours ago) [Dev Ojha]
* 4c6af3c3 - [multi-asic] Refine [override config table] for corner cases (#2918) (6 hours ago) [wenyiz2021]
* bef3ffeb - [db_migrator] Set docker_routing_config_mode to the value obtained from minigraph parser (#2890) (#2922) (7 hours ago) [Vaibhav Hemant Dixit]
qiluo-msft pushed a commit that referenced this pull request Aug 17, 2023
…atically (#14745)

#### Why I did it
src/sonic-utilities
```
* 7fe50faa - (HEAD -> 202012, origin/202012) UT change: for db_migrator test do not check for RESTAPI cert values (#2919) (6 minutes ago) [Vaibhav Hemant Dixit]
```
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.

3 participants