mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 09:41:54 +00:00
maria's test aggregator minor fixes
This commit is contained in:
parent
887cc893b4
commit
442bea27d4
@ -68,6 +68,9 @@ class IPTrie:
|
|||||||
if len(intersection) > 0:
|
if len(intersection) > 0:
|
||||||
nap.local = self.agrclass(net, sorted(intersection)[0])
|
nap.local = self.agrclass(net, sorted(intersection)[0])
|
||||||
nap.buckets = intersection
|
nap.buckets = intersection
|
||||||
|
else if net == self.rootnet:
|
||||||
|
nap.buckets = ac[0].buckets | ac[1].buckets
|
||||||
|
nap.local = self.local
|
||||||
else:
|
else:
|
||||||
nap.buckets = ac[0].buckets | ac[1].buckets
|
nap.buckets = ac[0].buckets | ac[1].buckets
|
||||||
nap.local = None
|
nap.local = None
|
||||||
@ -88,14 +91,19 @@ class IPTrie:
|
|||||||
else:
|
else:
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def prune(self, up=None, net=ipaddress.IPv6Network("::/0"), covered=None):
|
def prune(self, up=None, net=None, covered=None):
|
||||||
if self.children[0] is None and self.children[1] is None:
|
if self.children[0] is None and self.children[1] is None:
|
||||||
r = self.reduce(covered)
|
r = self.reduce(covered)
|
||||||
# print(f"Prune NR at {net}, C {covered}, L {self.local} -> {r}")
|
# print(f"Prune NR at {net}, C {covered}, L {self.local} -> {r}")
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
if net is None:
|
||||||
|
net = self.rootnet
|
||||||
|
|
||||||
loc = covered if self.local is None else self.local
|
loc = covered if self.local is None else self.local
|
||||||
assert(loc)
|
if loc is None:
|
||||||
|
raise Exception(f"Loc is None at {net}, covered {covered}")
|
||||||
|
|
||||||
sn = list(net.subnets())
|
sn = list(net.subnets())
|
||||||
nap = IPTrie(up)
|
nap = IPTrie(up)
|
||||||
nap.children = [ None if self.children[b] is None else self.children[b].prune(nap, sn[b], loc) for b in (0,1) ]
|
nap.children = [ None if self.children[b] is None else self.children[b].prune(nap, sn[b], loc) for b in (0,1) ]
|
||||||
@ -155,6 +163,7 @@ try:
|
|||||||
t.add(AgrPointv6("::/0", "__auto_unreachable"))
|
t.add(AgrPointv6("::/0", "__auto_unreachable"))
|
||||||
nexthops.add("__auto_unreachable")
|
nexthops.add("__auto_unreachable")
|
||||||
except ipaddress.AddressValueError:
|
except ipaddress.AddressValueError:
|
||||||
|
print("IPv6 failed, trying IPv4")
|
||||||
t.add(AgrPointv4(data[0], data[1]))
|
t.add(AgrPointv4(data[0], data[1]))
|
||||||
nexthops.add(data[1])
|
nexthops.add(data[1])
|
||||||
try:
|
try:
|
||||||
@ -164,6 +173,7 @@ except ipaddress.AddressValueError:
|
|||||||
nexthops.add(data[1])
|
nexthops.add(data[1])
|
||||||
except EOFError:
|
except EOFError:
|
||||||
if t.local is None:
|
if t.local is None:
|
||||||
|
print("Adding default")
|
||||||
t.add(AgrPointv4("0.0.0.0/0", "__auto_unreachable"))
|
t.add(AgrPointv4("0.0.0.0/0", "__auto_unreachable"))
|
||||||
nexthops.add("__auto_unreachable")
|
nexthops.add("__auto_unreachable")
|
||||||
|
|
||||||
@ -173,8 +183,8 @@ print("Dump After Load")
|
|||||||
print(t.dump())
|
print(t.dump())
|
||||||
|
|
||||||
tt = t.aggregate()
|
tt = t.aggregate()
|
||||||
#print("Dump After Aggr")
|
print("Dump After Aggr")
|
||||||
#print(tt.dump())
|
print(tt.dump())
|
||||||
|
|
||||||
ttt = tt.prune()
|
ttt = tt.prune()
|
||||||
print("Dump After Prune")
|
print("Dump After Prune")
|
||||||
|
Loading…
Reference in New Issue
Block a user