From 4f40d9635aada58ff8076d1194c956a35836c18f Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 12 Oct 2021 15:32:30 -0400 Subject: [PATCH] Fix nic config with mismatched gateway family When a gateway exists on a family the node does not exist for, handle the gateway better. --- confluent_server/confluent/netutil.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/confluent_server/confluent/netutil.py b/confluent_server/confluent/netutil.py index 95edc6e8..c5f3f6a2 100644 --- a/confluent_server/confluent/netutil.py +++ b/confluent_server/confluent/netutil.py @@ -337,9 +337,10 @@ def get_nic_config(configmanager, node, ip=None, mac=None, ifidx=None, elif fam == socket.AF_INET6: nver = '6' bynodename = ip6bynodename - bynodenamn = socket.inet_pton(fam, bynodename) - if ipn_on_same_subnet(fam, candgwn, bynodenamn, prefix): - cfgdata['ipv{}_gateway'.format(nver)] = socket.inet_ntop(fam, candgwn) + if bynodename: + bynodenamn = socket.inet_pton(fam, bynodename) + if ipn_on_same_subnet(fam, candgwn, bynodenamn, prefix): + cfgdata['ipv{}_gateway'.format(nver)] = socket.inet_ntop(fam, candgwn) return cfgdata if ip is not None: for prefixinfo in get_prefix_len_for_ip(ip):