Skip to content

DHCP Relay support for Physical and PO L3 interfaces #1311

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

Conversation

AkhileshSamineni
Copy link
Contributor

@AkhileshSamineni AkhileshSamineni commented Dec 16, 2020

Currently DHCP Relay support is for Vlan interfaces only.
This PR, extending the DHCP Relay support to Physical and Port channels L3 interfaces.

Config Commands :

**config interface ip dhcp-relay add <interface_name> <ip_addr1> <ip_addr2> <ip_addr3> <ip_addr4>**

This command enables user to configure IPv4 DHCP Server address on an interface. 
- One address is mandatory and a maximum of four addresses are allowed. 
- If the command is used multiple times with different addresses, the addresses are appended to the list of server addresses.

- Examples:

  admin@sonic:~$ sudo config interface ip dhcp-relay add Ethernet52 1.2.0.1 3.4.0.1 192.168.0.1
  admin@sonic:~$ sudo config interface ip dhcp-relay add Vlan206 1.2.0.1 3.4.0.1
  admin@sonic:~$ sudo config interface ip dhcp-relay add PortChannel007 192.168.0.1

**config interface ip dhcp-relay remove <interface_name> <ip_addr1> <ip_addr2> <ip_addr3> <ip_addr4>**

This command enables user to remove the configured DHCP Server address on an interface. 
- One address is mandatory and a maximum of four addresses are allowed. 
- A single server address can be deleted from the list of configured addresses by providing that address as argument.

- Examples:

  admin@sonic:~$ sudo config interface ip dhcp-relay remove Ethernet52 1.2.0.1 3.4.0.1 192.168.0.1 192.168.5.1
  admin@sonic:~$ sudo config interface ip dhcp-relay remove Vlan206 1.2.0.1 3.4.0.1 
  admin@sonic:~$ sudo config interface ip dhcp-relay remove PortChannel007 192.168.0.1 

These add/remove new commands are inline with the below existing command, which is used to configure the dhcp-relay on a VLAN.
  config vlan dhcp_relay add <vlan_id> <dhcp_relay_destination_ip>
  config vlan dhcp_relay del <vlan-id> <dhcp_relay_destination_ip>

Show Command :

**show ip dhcp-relay brief**

This command displays all the configured DHCP Server address configurations.

Sample Output:
admin@sonic:~$ sudo show ip dhcp-relay brief

+------------------+-------------------------+
| Interface Name   | DHCP Helper Address     |
+==========+=================================+
| Vlan10           | 20.20.1.2               |
|                  | 1.2.0.1                 |
+------------------+-------------------------+
| PortChannel10    | 40.20.1.2               |
+------------------+-------------------------+
| Ethernet52       | 10.10.1.2               |
+------------------+-------------------------+

Signed-off-by: Akhilesh Samineni [email protected]

@lgtm-com
Copy link

lgtm-com bot commented Dec 16, 2020

This pull request introduces 1 alert when merging b0c5cb7cd2117b3bd24dbfb408364838ce3d5f9d into 394b202 - view on LGTM.com

new alerts:

  • 1 for Unused local variable

@lguohan
Copy link
Contributor

lguohan commented Dec 16, 2020

can you add test?

@ben-gale
Copy link
Collaborator

Retest please

@AkhileshSamineni AkhileshSamineni changed the title DHCP Relay support for Physical and PO L3 interfaces and also src-Interface and Link-select support DHCP Relay support for Physical and PO L3 interfaces Jan 13, 2021
@@ -547,7 +547,7 @@
"NULL": "NULL"
},
"INTERFACE|Ethernet0": {
"NULL": "NULL"
"dhcp_servers@": "12.0.0.1,12.0.0.2,12.0.0.3"
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not according to the existing schema. INTERFACE tables does not have dhcp_servers as attribute . Are you proposing a schema change? Currently for vlans, it is part of VLAN table and not VLAN_INTERFACE

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, "dhcp_servers" is an L3 attribute, so added it to INTERFACE and PORTCHANNEL_INTERFACE tables.
For Vlan case, still using VLAN table only.

Copy link
Contributor

Choose a reason for hiding this comment

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

It will be inconsistent with VLAN_INTERFACE. Fine with me if @tahmed-dev, @jleveque and @lguohan sign off.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @prsunny. Lumping dhcp_servers with the interface is inconsistent with the current. I think since PR:6221 attempts to have DHCP relay preside on almost ever interface, it would be better to have separate table for DHCP_RELAY configuration. @lguohan, @jleveque what are your thoughts on that?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is debatable. Previously we considered the list of DHCP server IPs to be an attribute of a VLAN table entry. This approach is consistent with the current approach, extending it to INTERFACE and PORTCHANNEL_INTERFACE tables. We could take your approach, but this would require refactoring to create a DHCP_RELAY table and I guess have the attributes be the interface names? Basically inverting this approach?

Copy link
Contributor

Choose a reason for hiding this comment

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

It is indeed. I am thinking of having just one binary to serve as DHCP relay down the road and so having those entries consolidated under DHCP_RELAY table would be self contained and eliminate the need to search multiple tables.

Yes, the attributes would be interface name serving as a key and a downlink at the same time and the map/table would contain uplink interfaces and DHCP helper IPs (helper IPs could be per DHCP feature.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a conclusion here please guys?

Copy link
Contributor Author

@AkhileshSamineni AkhileshSamineni Feb 4, 2021

Choose a reason for hiding this comment

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

If we add new table like "DHCP_RELAY" table, then we need to change the supervisord.conf.j2 file also accordingly right, it be leads more changes for now.

Can we move the dhcp_servers from VLAN table to VLAN_INTERFACE table to be more consistent ??

config/main.py Outdated
# Use this method to validate unicast IPv4 address
#
def is_ip4_addr_valid(addr, display):
v4_invalid_list = [ipaddress.IPv4Address(unicode('0.0.0.0')), ipaddress.IPv4Address(unicode('255.255.255.255'))]
Copy link
Contributor

Choose a reason for hiding this comment

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

Conversion to unicode() should not be necessary, now that sonic-utilities is Python 3-only. This may also be causing the PR test failures.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Removed unicode function.

config/main.py Outdated
def is_ip4_addr_valid(addr, display):
v4_invalid_list = [ipaddress.IPv4Address(unicode('0.0.0.0')), ipaddress.IPv4Address(unicode('255.255.255.255'))]
try:
ip = ipaddress.ip_address(unicode(addr))
Copy link
Contributor

Choose a reason for hiding this comment

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

Conversion to unicode() should not be necessary, now that sonic-utilities is Python 3-only. This may also be causing the PR test failures.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Removed unicode function.

@prsunny prsunny requested review from tahmed-dev and lguohan January 29, 2021 19:12
@AkhileshSamineni
Copy link
Contributor Author

Retest this please.

4 similar comments
@AkhileshSamineni
Copy link
Contributor Author

Retest this please.

@AkhileshSamineni
Copy link
Contributor Author

Retest this please.

@AkhileshSamineni
Copy link
Contributor Author

Retest this please.

@AkhileshSamineni
Copy link
Contributor Author

Retest this please.

@AkhileshSamineni AkhileshSamineni force-pushed the dhcp_relay_support_ports branch from 8f445c9 to 25f6d41 Compare March 4, 2021 11:32
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.

6 participants