From be3623c5511f6d9c35d1d8b98ab2041a66f59fae Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Wed, 18 Nov 2026 04:47:29 +0100 Subject: [PATCH 1/2] Use the iPXE shim for IPv6 UEFI HTTP boot IPv6 UEFI HTTP boot always served boot.img. Offer the iPXE shim when the profile has boot.ipxe.shim and the shim of the booting architecture is installed, as the IPv4 path does. iPXE then sends its own DHCPv6 request with user class iPXE and a PXEClient vendor class, which was refused as IPv6 PXE. Answer it with the boot.ipxe.shim URL, or boot.ipxe when the profile has no shim script. With only the other configuration flag in the router advertisement, iPXE sends an Information-request, which was not handled at all and carries no IA_NA. Handle it and only assign an address when the request asks for one. Before it starts the shim, the firmware releases the address and retransmits the Release while it is unanswered, which delayed the handoff by over a minute. Answer a Release sent to this server. --- .../confluent/discovery/protocols/pxe.py | 44 +++++++++++++++---- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/confluent_server/confluent/discovery/protocols/pxe.py b/confluent_server/confluent/discovery/protocols/pxe.py index 65370413..443e1d4d 100644 --- a/confluent_server/confluent/discovery/protocols/pxe.py +++ b/confluent_server/confluent/discovery/protocols/pxe.py @@ -418,8 +418,18 @@ def new_dhcp6_packet(handler, net6, cfg, nodeguess): if len(pkt) < 64: return rqv = memoryview(pkt) - if rqv[0] in (1, 3): + if rqv[0] in (1, 3, 11): # solicit, request, information-request tasks.spawn(process_dhcp6req(handler, rqv, addr, net6, cfg, nodeguess)) + elif rqv[0] == 8: # release, firmware retransmits it until answered + req, _ = v6opts_to_dict(bytearray(rqv[4:])) + serverid = b'\x00\x04' + get_my_duid() + if 1 in req and req.get(2, b'') == serverid: + reply = bytearray(rqv[:4]) + reply[0] = 7 + reply += struct.pack('!HH', 1, len(req[1])) + req[1] + reply += struct.pack('!HH', 2, len(serverid)) + serverid + reply += struct.pack('!HHH', 13, 2, 0) # status code success + net6.sendto(reply, addr) async def snoop(handler, protocol=None, nodeguess=None): @@ -619,7 +629,8 @@ async def check_reply(node, info, packet, sock, cfg, reqview, addr, requestor): )}) return if addr: - if packet['vci'] and packet['vci'].startswith('PXEClient'): + if (packet['vci'] and packet['vci'].startswith('PXEClient') + and packet.get(15, b'')[2:] != b'iPXE'): log.log({'info': 'IPv6 PXE boot attempt by {0}, but IPv6 PXE is not supported, try IPv6 HTTP boot or IPv4 boot'.format(node)}) return return await reply_dhcp6(node, addr, cfg, packet, cfd, profile, sock) @@ -646,15 +657,30 @@ async def reply_dhcp6(node, addr, cfg, packet, cfd, profile, sock, niccfg=None): if not insecuremode: insecuremode = 'never' proto = 'https' if insecuremode == 'never' else 'http' - bootfile = '{0}://[{1}]/confluent-public/os/{2}/boot.img'.format( - proto, ipv6srvaddr, profile - ) + isipxe = packet.get(15, b'')[2:] == b'iPXE' + bootarch = pxearchs.get(bytes(packet[61]), None) + shimarch = 'aarch64' if bootarch in ('uefi-aarch64', 'uefi-httpboot-arm') else 'x86_64' + hasshim = os.path.exists('/var/lib/confluent/public/os/{}/boot.ipxe.shim'.format(profile)) + if isipxe: + bootfile = '{0}://[{1}]/confluent-public/os/{2}/boot.ipxe'.format( + proto, ipv6srvaddr, profile + ) + if hasshim and bootarch != 'bios-x86': + bootfile += '.shim' + elif hasshim and os.path.exists('/var/lib/confluent/public/ipxe/{}/ipxe-shim.efi'.format(shimarch)): + bootfile = '{0}://[{1}]/confluent-public/ipxe/{2}/ipxe-shim.efi'.format( + proto, ipv6srvaddr, shimarch + ) + else: + bootfile = '{0}://[{1}]/confluent-public/os/{2}/boot.img'.format( + proto, ipv6srvaddr, profile + ) if not isinstance(bootfile, bytes): bootfile = bootfile.encode('utf8') ipass = [] if ipv6method == 'firmwarenone': return - if ipv6method not in ('dhcp', 'firmwaredhcp') and ipv6addr: + if ipv6method not in ('dhcp', 'firmwaredhcp') and ipv6addr and 3 in packet: if not ipv6prefix: log.log({'info': 'Unable to determine prefix to serve to address {} for node {}'.format(ipv6addr, node)}) return @@ -663,9 +689,9 @@ async def reply_dhcp6(node, addr, cfg, packet, cfd, profile, sock, niccfg=None): ipass[4:16] = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x18' ipass[16:32] = socket.inet_pton(socket.AF_INET6, ipv6addr) ipass[32:40] = b'\x00\x00\x00\x78\x00\x00\x01\x2c' - elif (not packet['vci']) or not packet['vci'].startswith( - 'HTTPClient:Arch:'): - # do not send ip-less replies to anything but HTTPClient specifically + elif not isipxe and ((not packet['vci']) or not packet['vci'].startswith( + 'HTTPClient:Arch:')): + # do not send ip-less replies to anything but HTTPClient and iPXE return # 1 msgtype # 3 txid From a328123357f07db4d2a75d1ea2dbc946ecc9f95c Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Wed, 18 Nov 2026 13:06:14 +0100 Subject: [PATCH 2/2] Ignore DHCPv6 requests sent to another server A client sends its Request to the server whose Advertise it picked, named by the server identifier. confluent answered every Request, so with several DHCPv6 servers on the segment, such as the members of a collective, all of them replied to it. --- confluent_server/confluent/discovery/protocols/pxe.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/confluent_server/confluent/discovery/protocols/pxe.py b/confluent_server/confluent/discovery/protocols/pxe.py index 443e1d4d..02616ff3 100644 --- a/confluent_server/confluent/discovery/protocols/pxe.py +++ b/confluent_server/confluent/discovery/protocols/pxe.py @@ -483,6 +483,8 @@ async def process_dhcp6req(handler, rqv, addr, net, cfg, nodeguess): req, disco = v6opts_to_dict(bytearray(rqv[4:])) req['txid'] = rqv[1:4] req['rqtype'] = bytearray(rqv[:1])[0] + if req['rqtype'] == 3 and req.get(2, b'') != b'\x00\x04' + get_my_duid(): + return # request for another server if not disco.get('uuid', None) or not disco.get('arch', None): return if disco['uuid'] == '03000200-0400-0500-0006-000700080009':