Skip to content

Commit d27b648

Browse files
authored
Update to Azure Linux 3 (#14049)
* Update StartDhcpClient to use dhcpcd which is the Azure Linux 3 equivalent * Update Microsoft.WSLg to version 1.0.72 which moves to Azure Linux 3
1 parent 5e09668 commit d27b648

File tree

2 files changed

+16
-35
lines changed

2 files changed

+16
-35
lines changed

packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<package id="Microsoft.WSL.Kernel" version="6.6.114.1-1" targetFramework="native" />
2323
<package id="Microsoft.WSL.LinuxSdk" version="1.20.0" targetFramework="native" />
2424
<package id="Microsoft.WSL.TestDistro" version="2.5.7-47" />
25-
<package id="Microsoft.WSLg" version="1.0.71" />
25+
<package id="Microsoft.WSLg" version="1.0.72" />
2626
<package id="Microsoft.Xaml.Behaviors.WinUI.Managed" version="3.0.0" />
2727
<package id="StrawberryPerl" version="5.32.1.1" />
2828
<package id="vswhere" version="3.1.7" />

src/linux/init/main.cpp

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ Module Name:
7272
#define CROSS_DISTRO_SHARE_PATH "/mnt/wsl"
7373
#define DEVFS_PATH "/dev"
7474
#define DEVNULL_PATH DEVFS_PATH "/null"
75-
#define DHCLIENT_CONF_PATH "/dhclient.conf"
76-
#define DHCLIENT_PATH "/usr/sbin/dhclient"
75+
#define DHCPCD_CONF_PATH "/dhcpcd.conf"
76+
#define DHCPCD_PATH "/usr/sbin/dhcpcd"
77+
7778
#define DISTRO_PATH "/distro"
7879
#define ETC_PATH "/etc"
7980
#define GPU_SHARE_PREFIX "/gpu_"
@@ -1230,11 +1231,12 @@ int StartDhcpClient(int DhcpTimeout)
12301231
12311232
Routine Description:
12321233
1233-
Starts the dhcp client daemon.
1234+
Starts the dhcp client daemon. Blocks until the initial DHCP lease is acquired,
1235+
then the daemon continues running in the background to handle renewals.
12341236
12351237
Arguments:
12361238
1237-
None.
1239+
DhcpTimeout - Supplies the timeout in seconds for the DHCP request.
12381240
12391241
Return Value:
12401242
@@ -1243,50 +1245,29 @@ Return Value:
12431245
--*/
12441246

12451247
{
1246-
int ChildPid = UtilCreateChildProcess("dhcp", [DhcpTimeout]() {
1248+
int ChildPid = UtilCreateChildProcess("dhcpcd", [DhcpTimeout]() {
12471249
//
1248-
// Create a new mount namespace for dhclient.
1249-
//
1250-
1251-
THROW_LAST_ERROR_IF(unshare(CLONE_NEWNS) < 0);
1252-
1253-
//
1254-
// When dhclient receives a DHCP response, it calls dhclient-script
1255-
// which creates a new file, and then moves it to /etc/resolv.conf.
1256-
// Because it's moved, it will overwrite any symlinks / hardlinks.
1257-
// Mounting /etc over /share allows resolv.conf to be written to /share.
1258-
//
1259-
1260-
THROW_LAST_ERROR_IF(mount(CROSS_DISTRO_SHARE_PATH, ETC_PATH, NULL, MS_BIND, NULL) < 0);
1261-
1262-
//
1263-
// Write the dhclient.conf config file.
1250+
// Write the dhcpcd.conf config file.
12641251
//
12651252

12661253
std::string Config = std::format(
1267-
"request subnet-mask, broadcast-address, routers,"
1268-
"domain-name, domain-name-servers, domain-search, host-name,"
1269-
"interface-mtu;\n"
1270-
"timeout {};\n",
1254+
"option subnet_mask, routers, broadcast, domain_name, domain_name_servers, domain_search, host_name, interface_mtu\n"
1255+
"noarp\n"
1256+
"timeout {}\n",
12711257
DhcpTimeout);
12721258

1273-
THROW_LAST_ERROR_IF(WriteToFile(DHCLIENT_CONF_PATH, Config.c_str()) < 0);
1259+
THROW_LAST_ERROR_IF(WriteToFile(DHCPCD_CONF_PATH, Config.c_str()) < 0);
12741260

1275-
execl(DHCLIENT_PATH, DHCLIENT_PATH, "-4", "eth0", "-cf", DHCLIENT_CONF_PATH, NULL);
1276-
LOG_ERROR("execl() failed, {}", errno);
1261+
execl(DHCPCD_PATH, DHCPCD_PATH, "-w", "-4", "-f", DHCPCD_CONF_PATH, "eth0", NULL);
1262+
LOG_ERROR("execl({}) failed, {}", DHCPCD_PATH, errno);
12771263
});
12781264

12791265
if (ChildPid < 0)
12801266
{
12811267
return -1;
12821268
}
12831269

1284-
//
1285-
// Note: dhclient returns when the interface is successfully configured,
1286-
// but keeps a daemon running to maintain it.
1287-
//
1288-
1289-
return WaitForChild(ChildPid, DHCLIENT_PATH);
1270+
return WaitForChild(ChildPid, DHCPCD_PATH);
12901271
}
12911272

12921273
int StartGuestNetworkService(int GnsFd, wil::unique_fd&& DnsTunnelingFd, uint32_t DnsTunnelingIpAddress)

0 commit comments

Comments
 (0)