Bug #18674
closedon [commit,release,expiry] sections in dhcpd.conf cause subnet to not load in smart proxy
Description
In the process of upgrading our foreman infrastructure to 1.13.x I ran into an issue where the smart proxy will not load a subnet if it has the "on [commit,release,expiry]" sections enabled, resulting in these error message in the smart proxy log when trying to create a host in that subnet. There are no other errors in the logs.
E, [2017-02-24T12:01:41.909161 #23812] ERROR -- : Subnet 192.168.48.0 not found
I, [2017-02-24T12:01:41.909773 #23812] INFO -- : X.X.X.X - - [24/Feb/2017:12:01:41 0800] "GET /dhcp/192.168.48.0/unused_ip?from=192.168.48.30&to=192.168.49.254 HTTP/1.1" 404 28 0.0016
E, [2017-02-24T12:03:54.996984 #23812] ERROR -- : Subnet 192.168.48.0 not found
I, [2017-02-24T12:03:54.997342 #23812] INFO -- : X.X.X.X - - [24/Feb/2017:12:03:54 0800] "GET /dhcp/192.168.48.0/unused_ip?from=192.168.48.30&to=192.168.49.254 HTTP/1.1" 404 28 0.0016
We use these for dynamic DNS updates. Commenting out the relevant sections and restarting foreman-proxy allows it to be loaded successfully.
--- dhcpd.conf snippet ---
pool {
never-broadcast on;
authoritative;
range 192.168.50.0 192.168.51.240;
next-server x.x.x.x;
filename "pxelinux.0";
default-lease-time 86400; # 1 Day
ddns-updates on;
on commit {
set noname = concat("dhcp-", binary-to-ascii(10, 8, "-", leased-address));
set ClientIP = binary-to-ascii(10, 8, ".", leased-address);
set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
set ClientName = pick-first-value(option host-name, host-decl-name, config-option host-name, noname);
log(concat("Commit: IP: ", ClientIP, " Mac: ", ClientMac, " Name: ", ClientName));
execute("/etc/dhcp/dhcp-dyndns.sh", "add", ClientIP, ClientMac, ClientName);
}
on release {
set ClientIP = binary-to-ascii(10, 8, ".", leased-address);
set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
log(concat("Release: IP: ", ClientIP, " Mac: ", ClientMac));
execute("/etc/dhcp/dhcp-dyndns.sh", "delete", ClientIP, "", ClientMac);
}
on expiry {
set ClientIP = binary-to-ascii(10, 8, ".", leased-address);
log(concat("Expired: IP: ", ClientIP));
execute("/etc/dhcp/dhcp-dyndns.sh", "delete", ClientIP, "", "0");
}
}
---end snippet---
This was working on smart proxy 1.8.4, and it is failing on both 1.13.0 and 1.13.4.
Updated by Johann Agnarsson over 7 years ago
updated REGEX from 1.14 correctly parses the subnet.
SUBNET_BLOCK_REGEX = %r{
subnet\s+(?<subnet>[\d\.]+)\s+
netmask\s+(?<netmask>[\d\.]+)\s*
(?<body>
\{
(?:
(?> [^{}]+ )
|
\g<body>
)*
\}
)
}x
Updated by Johann Agnarsson over 7 years ago
updated REGEX from 1.14 correctly parses the subnet.
foreman-proxy/modules/dhcp_isc/isc_file_parser.rb
SUBNET_BLOCK_REGEX = %r{
subnet\s+(?<subnet>[\d\.]+)\s+
netmask\s+(?<netmask>[\d\.]+)\s*
(?<body>
\{
(?:
(?> [^{}]+ )
|
\g<body>
)*
\}
)
}x
Updated by Dominic Cleal over 7 years ago
- Is duplicate of Bug #16079: ISC DHCP subnets fail to parse with host or class stanzas inside added
Updated by Anonymous over 7 years ago
- Related to Refactor #19441: Rewrite isc dhcpd config parser to support various nested blocks added