Page MenuHomePhabricator

Enable DHCP option 121 processing
Confirmed, HighPublicFEATURE REQUEST

Description

Hello!
In VyOS 1.2.1 and 1.2.0-rolling+201905130337 if you are configure address dhcp for some interface, configuration scripts create dedicated dhclient.conf for this interface, located in /var/lib/dhcp/. For example:

root@test-06:/home/vyos# cat /var/lib/dhcp/dhclient_eth0.conf 
#
# autogenerated by vyatta-interfaces.pl on Tue May 14 14:32:15 UTC 2019
#
interface "eth0" {
	send host-name "test-06";
	request subnet-mask, broadcast-address, routers, domain-name-servers, domain-name, interface-mtu;
}

Then, this configuration used by the dhclient to obtain an IP address.
But, with this autogenerated configuration system can't handle DHCP option 121, which can be processed with default /etc/dhcp/dhclient.conf. To make DHCP option 121 operable, we need to apply the next changes:

  1. Generate dhclient.conf with rfc3442-classless-static-routes option.
  2. Patch rfc3442-classless-static-routes hook to process routes with FRRouting, and not "ip" command.

This can be done with the following changes:

diff -Naur origin/etc/dhcp/dhclient-exit-hooks.d/rfc3442-classless-routes option-121/etc/dhcp/dhclient-exit-hooks.d/rfc3442-classless-routes
--- origin/etc/dhcp/dhclient-exit-hooks.d/rfc3442-classless-routes	2019-05-14 19:37:38.003209345 +0300
+++ option-121/etc/dhcp/dhclient-exit-hooks.d/rfc3442-classless-routes	2019-05-14 19:50:40.574760057 +0300
@@ -55,8 +55,7 @@
 				fi
 
 				# set route (ip detects host routes automatically)
-				ip -4 route add "${net_address}/${net_length}" \
-					${via_arg} dev "${interface}" >/dev/null 2>&1
+				vtysh -c "configure terminal" -c "ip route ${net_address}/${net_length} ${via_arg} ${interface}" >/dev/null 2>&1
 			done
 		fi
 	fi
diff -Naur origin/opt/vyatta/sbin/vyatta-interfaces.pl option-121/opt/vyatta/sbin/vyatta-interfaces.pl
--- origin/opt/vyatta/sbin/vyatta-interfaces.pl	2019-05-14 19:36:17.968076176 +0300
+++ option-121/opt/vyatta/sbin/vyatta-interfaces.pl	2019-05-14 19:46:13.641637198 +0300
@@ -163,11 +163,12 @@
   my $output = dhcp_conf_header();
   my $hostname = get_hostname();
 
+  $output .= "option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;\n";
   $output .= "interface \"$intf\" {\n";
   if (defined($hostname)) {
     $output .= "\tsend host-name \"$hostname\";\n";
   }
-  $output .= "\trequest subnet-mask, broadcast-address, routers, domain-name-servers";
+  $output .= "\trequest subnet-mask, broadcast-address, routers, domain-name-servers, rfc3442-classless-static-routes";
   my $domainname = is_domain_name_set();
   if (!defined($domainname)) {
     $output .= ", domain-name";

Affected files:
https://github.com/vyos/vyos-replace/blob/current/files/dhclient-script
https://github.com/vyos/vyatta-cfg-system/blob/current/scripts/vyatta-interfaces.pl
/etc/dhcp/dhclient-exit-hooks.d/rfc3442-classless-routes

We need to implement this to solve T1369.

Details

Difficulty level
Easy (less than an hour)
Version
-
Why the issue appeared?
Will be filled on close

Related Objects

Event Timeline

zsdc created this task.May 14 2019, 5:10 PM
zsdc changed the task status from Open to Confirmed.May 14 2019, 5:14 PM
zsdc assigned this task to hagbard.
zsdc triaged this task as High priority.
zsdc updated the task description. (Show Details)
zsdc changed Difficulty level from Unknown (require assessment) to Easy (less than an hour).
hagbard removed hagbard as the assignee of this task.May 14 2019, 5:58 PM
hagbard added a subscriber: hagbard.
pasik added a subscriber: pasik.May 14 2019, 6:04 PM
hagbard assigned this task to UnicronNL.May 14 2019, 8:38 PM
joshua added a subscriber: joshua.May 15 2019, 2:55 PM
syncer lowered the priority of this task from High to Normal.Jun 2 2019, 4:06 PM
syncer edited projects, added VyOS 1.3 Equuleus; removed VyOS 1.2 Crux.
zsdc raised the priority of this task from Normal to High.Jul 10 2019, 2:33 PM
syncer reassigned this task from UnicronNL to dmbaturin.Aug 31 2019, 12:35 AM
syncer added a subscriber: UnicronNL.