2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-09-29 08:41:00 +00:00

Compare commits

..

6 Commits

Author SHA1 Message Date
Jarrod Johnson 978b52dbb6 Fix selection of suboptimal alias
When picking deploy server, stop on a close match if net.ipv4_address suggests
a same-subnet match rather than adding the last alias.
2021-12-28 09:47:47 -05:00
Jarrod Johnson d47b088753 Fix mistake in error output 2021-12-22 23:29:21 -05:00
Jarrod Johnson 47a83f4628 Do not trace out if a packet can't be replied to 2021-12-20 12:37:18 -05:00
Jarrod Johnson abec8c498c Break netlink address fetch on invalid rta_len
It is considered valid for kernel to return a null rta_len
in the midst of data and expect the caller to terminate.
2021-12-20 12:28:35 -05:00
Jarrod Johnson a8132d87a7 Blacklist the tianocore default uuid
If a platform doesn't have a uuid, Tiano hardbakes
yet another invalid uuid to ignore.
2021-12-17 09:13:49 -05:00
Jarrod Johnson 65d6ff13fa 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.
2021-12-17 08:44:46 -05:00
7 changed files with 37 additions and 14 deletions
@@ -55,10 +55,10 @@ def get_my_addresses():
rta = v[nlhdrsz+ifaddrsz:length]
while len(rta):
rtalen, rtatyp = struct.unpack('HH', rta[:4])
if rtalen < 4:
break
if rtatyp == 1:
addrs.append((fam, rta[4:rtalen], plen, ridx))
if not rtalen:
break
rta = rta[rtalen:]
v = v[length:]
return addrs
+2 -2
View File
@@ -364,7 +364,7 @@ def oslist():
print("Distributions:")
for rsp in c.read('/deployment/distributions'):
if 'error' in rsp:
sys.stderr.write(res['error'] + '\n')
sys.stderr.write(rsp['error'] + '\n')
exitcode = 1
else:
print(" " + rsp['item']['href'].replace('/', ''))
@@ -373,7 +373,7 @@ def oslist():
print("Profiles:")
for rsp in c.read('/deployment/profiles'):
if 'error' in rsp:
sys.stderr.write(res['error'] + '\n')
sys.stderr.write(rsp['error'] + '\n')
exitcode = 1
else:
print(" " + rsp['item']['href'].replace('/', ''))
@@ -205,6 +205,7 @@ def uuid_is_valid(uuid):
return uuid.lower() not in ('00000000-0000-0000-0000-000000000000',
'ffffffff-ffff-ffff-ffff-ffffffffffff',
'00112233-4455-6677-8899-aabbccddeeff',
'03000200-0400-0500-0006-000700080009',
'20202020-2020-2020-2020-202020202020')
def _printable_ip(sa):
@@ -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']
@@ -112,7 +112,10 @@ def _parse_slp_packet(packet, peer, rsps, xidmap, defer=None, sock=None):
identifier = addr
else:
probepeer = (peer[0], struct.unpack('H', os.urandom(2))[0] | 1025) + peer[2:]
sock.sendto(b'\x00', probepeer)
try:
sock.sendto(b'\x00', probepeer)
except Exception:
return
defer.append((packet, peer))
return
if (identifier, parsed['xid']) in rsps:
@@ -487,7 +490,10 @@ def snoop(handler, protocol=None):
mac = neighutil.get_hwaddr(peer[0])
if not mac:
probepeer = (peer[0], struct.unpack('H', os.urandom(2))[0] | 1025) + peer[2:]
s.sendto(b'\x00', probepeer)
try:
s.sendto(b'\x00', probepeer)
except Exception:
continue
deferpeers.append(peer)
continue
process_peer(newmacs, known_peers, peerbymacaddress, peer)
@@ -167,7 +167,10 @@ def snoop(handler, byehandler=None, protocol=None, uuidlookup=None):
continue
mac = neighutil.get_hwaddr(peer[0])
if not mac:
s.sendto(b'\x00', peer)
try:
s.sendto(b'\x00', peer)
except Exception:
continue
deferrednotifies.append((peer, rsp))
continue
_process_snoop(peer, rsp, mac, known_peers, newmacs, peerbymacaddress, byehandler, machandlers)
@@ -311,8 +314,11 @@ def _find_service(service, target):
for s in r:
(rsp, peer) = s.recvfrom(9000)
if not neighutil.get_hwaddr(peer[0]):
try:
s.sendto(b'\x00', peer)
except Exception:
continue
deferparse.append((rsp, peer))
s.sendto(b'\x00', peer)
continue
_parse_ssdp(peer, rsp, peerdata)
timeout = deadline - util.monotonic_time()
+10 -4
View File
@@ -398,15 +398,18 @@ def get_nic_config(configmanager, node, ip=None, mac=None, ifidx=None,
foundaddr = False
candgws = []
candsrvs = []
bestsrvbyfam = {}
for myaddr in myaddrs:
fam, svrip, prefix = myaddr[:3]
candsrvs.append((fam, svrip, prefix))
if fam == socket.AF_INET:
cfgdata['deploy_server'] = socket.inet_ntop(socket.AF_INET, svrip)
nver = '4'
srvkey = 'deploy_server'
elif fam == socket.AF_INET6:
cfgdata['deploy_server_v6'] = socket.inet_ntop(socket.AF_INET6, svrip)
nver = '6'
srvkey = 'deploy_server_v6'
if fam not in bestsrvbyfam:
cfgdata[srvkey] = socket.inet_ntop(fam, svrip)
for candidate in cfgbyname:
ipmethod = cfgbyname[candidate].get('ipv{}_method'.format(nver), 'static')
if ipmethod == 'dhcp':
@@ -425,6 +428,7 @@ def get_nic_config(configmanager, node, ip=None, mac=None, ifidx=None,
for inf in socket.getaddrinfo(candip, 0, fam, socket.SOCK_STREAM):
candipn = socket.inet_pton(fam, inf[-1][0])
if ipn_on_same_subnet(fam, svrip, candipn, prefix):
bestsrvbyfam[fam] = svrip
cfgdata['ipv{}_address'.format(nver)] = candip
cfgdata['ipv{}_method'.format(nver)] = ipmethod
cfgdata['ipv{}_gateway'.format(nver)] = cfgbyname[candidate].get(
@@ -563,6 +567,8 @@ def get_my_addresses(idx=0, family=0, matchlla=None):
rta = v[nlhdrsz+ifaddrsz:length]
while len(rta):
rtalen, rtatyp = struct.unpack('HH', rta[:4])
if rtalen < 4:
break
if rta[4:rtalen].tobytes() == matchlla:
return get_my_addresses(idx=ridx)
rta = rta[rtalen:]
@@ -570,10 +576,10 @@ def get_my_addresses(idx=0, family=0, matchlla=None):
rta = v[nlhdrsz+ifaddrsz:length]
while len(rta):
rtalen, rtatyp = struct.unpack('HH', rta[:4])
if rtalen < 4:
break
if rtatyp == 1:
addrs.append((fam, rta[4:rtalen].tobytes(), plen, ridx))
if not rtalen:
break
rta = rta[rtalen:]
v = v[length:]
return addrs