From a17695ad0653e7ee7425a371179b6f6d223ce783 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 1 Feb 2024 16:38:04 -0500 Subject: [PATCH] Extend confluent PXE support For relay agent options, preserve and echo back the option, needed for certain environments. Also, it turns out that for whatever reason on some platforms, iPXE's proxyDHCP logic can't seem to get a reply. In this scenario, provide the filename in the DHCP offer without waiting for proxyDHCP. This change may be worth evaluating more broadly, but may carry risk of not working right with unmanaged DHCP servers. --- .../confluent/discovery/protocols/pxe.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/confluent_server/confluent/discovery/protocols/pxe.py b/confluent_server/confluent/discovery/protocols/pxe.py index a9a07963..6dd34efa 100644 --- a/confluent_server/confluent/discovery/protocols/pxe.py +++ b/confluent_server/confluent/discovery/protocols/pxe.py @@ -771,6 +771,14 @@ def reply_dhcp4(node, info, packet, cfg, reqview, httpboot, cfd, profile): node, profile, len(bootfile) - 127)}) return repview[108:108 + len(bootfile)] = bootfile + elif info['architecture'] == 'uefi-aarch64' and packet.get(77, None) == b'iPXE': + if not profile: + profile = get_deployment_profile(node, cfg) + if not profile: + log.log({'info': 'No pending profile for {0}, skipping proxyDHCP eply'.format(node)}) + return + bootfile = 'http://{0}/confluent-public/os/{1}/boot.ipxe'.format(myipn, profile).encode('utf8') + repview[108:108 + len(bootfile)] = bootfile myip = myipn myipn = socket.inet_aton(myipn) orepview[12:16] = myipn @@ -812,6 +820,13 @@ def reply_dhcp4(node, info, packet, cfg, reqview, httpboot, cfd, profile): repview[replen - 1:replen + 1] = b'\x03\x04' repview[replen + 1:replen + 5] = gateway replen += 6 + if 82 in packet: + reloptionslen = len(packet[82]) + reloptionshdr = struct.pack('BB', 82, reloptionslen) + repview[replen - 1:replen + 1] = reloptionshdr + repview[replen + 1:replen + reloptionslen + 1] = packet[82] + replen += 2 + reloptionslen + repview[replen - 1:replen] = b'\xff' # end of options, should always be last byte repview = memoryview(reply) pktlen = struct.pack('!H', replen + 28) # ip+udp = 28