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

T6068: dhcp-server: add split option to dhcp-server configuration. #3168

Closed
wants to merge 1 commit into from

Conversation

nicolas-fort
Copy link
Contributor

@nicolas-fort nicolas-fort commented Mar 22, 2024

Change Summary

Add split option to dhcp-server configuration.This adds the hability to the user to specify load balancing towards dhcp servers defined in failover.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • Other (please describe):

Related Task(s)

https://vyos.dev/T6068

Related PR(s)

Component(s) name

dhcp-server

Proposed changes

How to test

Config

set service dhcp-server failover name 'TEST'
set service dhcp-server failover remote '198.51.100.2'
set service dhcp-server failover source-address '198.51.100.1'
set service dhcp-server failover split '256'
set service dhcp-server failover status 'primary'
set service dhcp-server shared-network-name LAN subnet 198.51.100.0/24 default-router '198.51.100.1'
set service dhcp-server shared-network-name LAN subnet 198.51.100.0/24 enable-failover
set service dhcp-server shared-network-name LAN subnet 198.51.100.0/24 name-server '8.8.8.8'
set service dhcp-server shared-network-name LAN subnet 198.51.100.0/24 range 0 start '198.51.100.101'
set service dhcp-server shared-network-name LAN subnet 198.51.100.0/24 range 0 stop '198.51.100.200'

Config file:

cat /run/dhcp-server/dhcpd.conf
...
failover peer "TEST" {
    primary;
    mclt 1800;
    split 256;
    address 198.51.100.1;
    port 647;
    peer address 198.51.100.2;
    peer port 647;
    max-response-delay 30;
    max-unacked-updates 10;
    load balance max seconds 3;
}
..

And error check if setting it to server secondary dhcp-server:

vyos@dhcp-sag-main# run show config comm | grep failover
set service dhcp-server failover name 'TEST'
set service dhcp-server failover remote '198.51.100.2'
set service dhcp-server failover source-address '198.51.100.1'
set service dhcp-server failover status 'secondary'
set service dhcp-server shared-network-name LAN subnet 198.51.100.0/24 enable-failover
[edit]
vyos@dhcp-sag-main# set service dhcp-server failover split 123
[edit]
vyos@dhcp-sag-main# commit

DHCP failover split parameter can only be used if status is primary

[[service dhcp-server]] failed
Commit failed
[edit]
vyos@dhcp-sag-main# 

Smoketest result

root@dhcp-sag-main:/usr/libexec/vyos/tests/smoke/cli# ./test_service_dhcp-server.py                                                   

test_dhcp_exclude_in_range (__main__.TestServiceDHCPServer.test_dhcp_exclude_in_range) ... ok
test_dhcp_exclude_not_in_range (__main__.TestServiceDHCPServer.test_dhcp_exclude_not_in_range) ... ok
test_dhcp_failover (__main__.TestServiceDHCPServer.test_dhcp_failover) ... 
No DHCP address range or active static-mapping configured within shared-
network "FAILOVER, 192.0.2.0/25"!


DHCP failover must be enabled for at least one subnet!

ok
test_dhcp_failover_split (__main__.TestServiceDHCPServer.test_dhcp_failover_split) ... ok
test_dhcp_invalid_raw_options (__main__.TestServiceDHCPServer.test_dhcp_invalid_raw_options) ... 
DEPRECATION WARNING: Additional global parameters are subject of
removal in VyOS 1.5! Please raise a feature request for proper CLI
nodes!


Configuration file errors encountered - check your options!

ok
test_dhcp_multiple_pools (__main__.TestServiceDHCPServer.test_dhcp_multiple_pools) ... ok
test_dhcp_relay_server (__main__.TestServiceDHCPServer.test_dhcp_relay_server) ... ok
test_dhcp_single_pool_options (__main__.TestServiceDHCPServer.test_dhcp_single_pool_options) ... 
No DHCP address range or active static-mapping configured within shared-
network "SMOKE-0815, 192.0.2.0/25"!

ok
test_dhcp_single_pool_range (__main__.TestServiceDHCPServer.test_dhcp_single_pool_range) ... 
No DHCP address range or active static-mapping configured within shared-
network "SMOKE-1, 192.0.2.0/25"!

ok
test_dhcp_single_pool_static_mapping (__main__.TestServiceDHCPServer.test_dhcp_single_pool_static_mapping) ... 
No DHCP address range or active static-mapping configured within shared-
network "SMOKE-2, 192.0.2.0/25"!


Configured IP address for static mapping "dupe1" already exists on
another static mapping


Configured MAC address for static mapping "dupe2" already exists on
another static mapping

ok

----------------------------------------------------------------------
Ran 10 tests in 33.143s

OK
root@dhcp-sag-main:/usr/libexec/vyos/tests/smoke/cli# 

Checklist:

  • I have read the CONTRIBUTING document
  • I have linked this PR to one or more Phabricator Task(s)
  • I have run the components SMOKETESTS if applicable
  • My commit headlines contain a valid Task id
  • My change requires a change to the documentation
  • I have updated the documentation accordingly

…is adds the hability to the user to specify load balancing towards dhcp servers defined in failover.
@github-actions github-actions bot added the sagitta VyOS 1.4 LTS label Mar 22, 2024
@vyosbot vyosbot requested review from a team, dmbaturin, sarthurdev, zdc, jestabro, sever-sever and c-po and removed request for a team March 22, 2024 14:40
@sarthurdev
Copy link
Member

This will need to also be looked into for 1.5 or it will fail on migration.

<constraint>
<validator name="numeric" argument="--range 0-256"/>
</constraint>
</properties>
Copy link
Member

Choose a reason for hiding this comment

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

Any reason to not use <defaultValue>128</defaultValue>?

Copy link
Member

Choose a reason for hiding this comment

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

As I understand In the "secondary" node shouldn't be any split option
That's why we cannot use default

Copy link
Member

Choose a reason for hiding this comment

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

Yes I've seen this. We have a lot of other places where default values are only set if certain preconditions match. It's a bit more complicated but then we have a non disconnect between XML (help) and CLI/implementation.

Inspiration:

# git grep "del default_values"
src/conf_mode/pki.py:                    del default_values['certificate'][name]['acme']
src/conf_mode/protocols_ospf.py:        del default_values['default_information']
src/conf_mode/protocols_ospf.py:        del default_values['mpls_te']
src/conf_mode/protocols_ospf.py:        del default_values['graceful_restart']
src/conf_mode/protocols_ospf.py:            del default_values['area'][area_num]['area_type']['nssa']
src/conf_mode/protocols_ospf.py:            del default_values['redistribute'][protocol]
src/conf_mode/protocols_ospf.py:        del default_values['redistribute']
src/conf_mode/protocols_ospf.py:            del default_values['interface'][interface]['dead_interval']
src/conf_mode/protocols_ospfv3.py:        del default_values['default_information']
src/conf_mode/protocols_ospfv3.py:        del default_values['graceful_restart']
src/conf_mode/protocols_ospfv3.py:            del default_values['redistribute'][protocol]
src/conf_mode/protocols_ospfv3.py:        del default_values['redistribute']
src/conf_mode/protocols_pim.py:            del default_values['interface'][interface]['igmp']
src/conf_mode/service_https.py:        del default_values['api']
src/conf_mode/system_flow-accounting.py:            del default_values[flow_type]

@nicolas-fort
Copy link
Contributor Author

I'm closing this PR.
As decided, first we are going to re-name the node, then we will add this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sagitta VyOS 1.4 LTS
Development

Successfully merging this pull request may close these issues.

4 participants