summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/templates/dhcp-client/ipv4.j29
-rw-r--r--interface-definitions/include/interface/dhcp-options.xml.i12
-rw-r--r--smoketest/scripts/cli/base_interfaces_test.py3
3 files changed, 24 insertions, 0 deletions
diff --git a/data/templates/dhcp-client/ipv4.j2 b/data/templates/dhcp-client/ipv4.j2
index 4a5d5e54d..77905e054 100644
--- a/data/templates/dhcp-client/ipv4.j2
+++ b/data/templates/dhcp-client/ipv4.j2
@@ -25,6 +25,15 @@ interface "{{ ifname }}" {
{% endif %}
send vendor-class-identifier {{ vendor_class_id }};
{% endif %}
+{% if dhcp_options.user_class is vyos_defined %}
+{% set user_class = dhcp_options.user_class %}
+{# Use HEX representation of client-id as it is send in MAC-address style using hex characters. #}
+{# If not HEX, use double quotes ASCII format #}
+{% if not user_class.split(':') | length >= 3 %}
+{% set user_class = '"' ~ dhcp_options.user_class ~ '"' %}
+{% endif %}
+ send user-class {{ user_class }};
+{% endif %}
# The request statement causes the client to request that any server responding to the
# client send the client its values for the specified options.
request subnet-mask, broadcast-address,{{ " routers," if dhcp_options.no_default_route is not vyos_defined }} domain-name-servers,
diff --git a/interface-definitions/include/interface/dhcp-options.xml.i b/interface-definitions/include/interface/dhcp-options.xml.i
index fff83fd5c..733512a98 100644
--- a/interface-definitions/include/interface/dhcp-options.xml.i
+++ b/interface-definitions/include/interface/dhcp-options.xml.i
@@ -43,6 +43,18 @@
</constraint>
</properties>
</leafNode>
+ <leafNode name="user-class">
+ <properties>
+ <help>Identify to the DHCP server, user configurable option</help>
+ <valueHelp>
+ <format>txt</format>
+ <description>DHCP option string</description>
+ </valueHelp>
+ <constraint>
+ #include <include/constraint/dhcp-client-string-option.xml.i>
+ </constraint>
+ </properties>
+ </leafNode>
#include <include/interface/no-default-route.xml.i>
#include <include/interface/default-route-distance.xml.i>
<leafNode name="reject">
diff --git a/smoketest/scripts/cli/base_interfaces_test.py b/smoketest/scripts/cli/base_interfaces_test.py
index 1edcda4fd..da196133a 100644
--- a/smoketest/scripts/cli/base_interfaces_test.py
+++ b/smoketest/scripts/cli/base_interfaces_test.py
@@ -162,6 +162,7 @@ class BasicInterfaceTest:
distance = '100'
hostname = 'vyos'
vendor_class_id = 'vyos-vendor'
+ user_class = 'vyos'
for interface in self._interfaces:
for option in self._options.get(interface, []):
@@ -172,6 +173,7 @@ class BasicInterfaceTest:
self.cli_set(self._base_path + [interface, 'dhcp-options', 'default-route-distance', distance])
self.cli_set(self._base_path + [interface, 'dhcp-options', 'host-name', hostname])
self.cli_set(self._base_path + [interface, 'dhcp-options', 'vendor-class-id', vendor_class_id])
+ self.cli_set(self._base_path + [interface, 'dhcp-options', 'user-class', user_class])
self.cli_commit()
@@ -186,6 +188,7 @@ class BasicInterfaceTest:
self.assertIn(f'send host-name "{hostname}";', dhclient_config)
self.assertIn(f'send dhcp-client-identifier "{client_id}";', dhclient_config)
self.assertIn(f'send vendor-class-identifier "{vendor_class_id}";', dhclient_config)
+ self.assertIn(f'send user-class "{user_class}";', dhclient_config)
# and the commandline has the appropriate options
cmdline = read_file(f'/proc/{dhclient_pid}/cmdline')