Derive the DHCP subnet from the FOG address, not the interface (GH-1747) - #1754
Merged
Conversation
On an interface with more than one IPv4 address, the installer wrote a
DHCP subnet that was not a network. The report shows a saved mask of
255.255.0.0 on a /24, a Kea subnet of "10.0.45.2/24", a pool starting at
.12, and "arithmetic syntax error ... /8" during interface selection.
Each helper took "the interface" and read a different address from it:
- input.sh took every inet address, link-local 169.254.x.x included.
Listed first, a link-local address became the primary.
- getCidr() printed the SECOND global address's prefix
(head -n2 | tail -n1), through an unanchored grep, so eth1 also read
eth10. A global 169.254.x.x/16 next to a /24 gave 255.255.0.0.
- writeKeaSample passed every global address, unquoted, to
mask2network, so a second address became the mask. 10.0.45.2 with
10.0.45.14 gave the network 10.0.45.2.
- configureDHCP took the first global address, which is not always
${NET_fog_server_ip}.
- interface2broadcast() took the first brd, whichever address it
belonged to.
Now everything derives from ${NET_fog_server_ip}, the address FOG
advertises as next-server:
- input.sh takes global addresses only, and never 169.254.0.0/16.
- getCidr IFACE [ADDR] prints the prefix of ADDR, or of the first global
address. It reads only that interface.
- interface2broadcast IFACE [ADDR] prints the brd of ADDR. It keeps awk:
busybox grep has no -P (#863).
- configureDHCP and writeKeaSample use ${NET_fog_server_ip}.
- The default storage group's trusted CIDR takes the prefix of
${NET_fog_server_ip}. On a multi-address interface it used to take
the second address's prefix and apply it to the FOG address.
Also:
- cidr2mask with no prefix returns nothing instead of printing the /8
arithmetic error.
- mask2cidr's error message went to stdout, where every caller takes the
value as the prefix. It now goes to stderr.
- The ifconfig fallbacks in input.sh and configureDHCP are removed. The
input.sh one stored mask2cidr's prefix length in ${NET_subnet_mask},
and ifconfig is not installed before the package step.
- With -y, an interface with no usable address now exits. It used to
repeat the same answer forever, and the link-local filter adds a way
to reach that path.
tests/installer-subnet-detection.test.sh replays address layouts through
the real functions and the real input.sh lines, with a fake `ip` built
from real `ip -o` output. On the old code it fails 37 of 58 checks and
reproduces the report: "10.0.45.2/24", pool "10.0.45.12 - 10.0.45.254",
the saved 255.255.0.0, and the /8 error. It passes all 58 after.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012JsEqysRdWb914YC94Shvo
mastacontrola
marked this pull request as ready for review
September 10, 2026 12:43
mastacontrola
enabled auto-merge
September 10, 2026 12:43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On an interface with more than one IPv4 address, the installer writes a DHCP subnet that is not a network. #1747 shows a saved mask of
255.255.0.0on a /24, a Kea subnet of"10.0.45.2/24", a pool starting at.12, andarithmetic syntax error ... /8during interface selection.This is the
working-1.6side of #1753, which fixeddev-branch.Cause
Each helper reads "the interface" and takes a different address from it:
input.sh169.254.x.xincluded, so a link-local address listed first became the primarygetCidr()head -n2 | tail -n1), through an unanchored grep, soeth1also readeth10writeKeaSamplemask2network, so a second address became the maskconfigureDHCP${NET_fog_server_ip}interface2broadcast()brd, whichever address it belonged toA second address in the same /24 gives exactly the reported config. A global
169.254.x.x/16next to the /24 gives the saved255.255.0.0. A link-local-only NIC gives the/8error.Fix
Everything derives from
${NET_fog_server_ip}, the address FOG advertises as next-server.input.shtakes global addresses only, and never169.254.0.0/16.getCidr IFACE [ADDR]andinterface2broadcast IFACE [ADDR]read the named address on that interface only. Both stay awk, so they work with busybox (Installer support for Alpine Linux as host OS #863).configureDHCPandwriteKeaSamplecompute the network from${NET_fog_server_ip}.cidr2maskwith no prefix returns nothing, instead of printing the arithmetic error.mask2cidrsends its error message to stderr instead of into the caller's value.ifconfigfallbacks ininput.shandconfigureDHCPare removed.ifconfigis not installed before the package step, and theinput.shone stored a prefix length as the mask.Behavior changes
-y, an interface with no usable address now exits. It used to repeat the same answer forever.storageDefaultCidrnow takes the prefix of${NET_fog_server_ip}. On a multi-address interface it used to take the second address's prefix and apply it to the FOG address. On an interface with one address, nothing changes. This is the trusted CIDR for node-to-node status calls, so this PR is a draft until that change is approved.Test
tests/installer-subnet-detection.test.shreplays address layouts through the real functions and the realinput.shlines. The fakeipprints realip -ooutput.ipandawkon a dummy interface with the same addresses, with the same results.Refs #1747
🤖 Generated with Claude Code
https://claude.ai/code/session_012JsEqysRdWb914YC94Shvo