From 65d6ff13facd9e85627825c75e51f66e774ab008 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 17 Dec 2021 08:44:46 -0500 Subject: [PATCH] Ignore and warn on bad gateway If user specifies a bad gateway, spare the firmware from seeing it and log that the gateway is a problem. --- confluent_server/confluent/discovery/protocols/pxe.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/confluent_server/confluent/discovery/protocols/pxe.py b/confluent_server/confluent/discovery/protocols/pxe.py index d8c259f4..8a8adda1 100644 --- a/confluent_server/confluent/discovery/protocols/pxe.py +++ b/confluent_server/confluent/discovery/protocols/pxe.py @@ -1,6 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright 2017 Lenovo +# Copyright 2017-2021 Lenovo # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -664,9 +664,13 @@ def reply_dhcp4(node, info, packet, cfg, reqview, httpboot, cfd, profile): clipn = socket.inet_aton(niccfg['ipv4_address']) repview[16:20] = clipn gateway = niccfg['ipv4_gateway'] + netmask = niccfg['prefix'] if gateway: gateway = socket.inet_aton(gateway) - netmask = niccfg['prefix'] + if not netutil.ipn_on_same_subnet(socket.AF_INET, clipn, gateway, netmask): + log.log( + {'warning': 'Ignoring gateway {0} due to mismatch with address {1}/{2}'.format(niccfg['ipv4_gateway'], niccfg['ipv4_address'], netmask)}) + gateway = None netmask = (2**32 - 1) ^ (2**(32 - netmask) - 1) netmask = struct.pack('!I', netmask) myipn = niccfg['deploy_server']