add tests

This commit is contained in:
Pascal Fischer
2023-06-09 16:18:48 +02:00
parent 3724323f76
commit bc8ee8fc3c
2 changed files with 15 additions and 7 deletions

View File

@@ -107,16 +107,11 @@ func existsInRouteTable(prefix netip.Prefix) (bool, error) {
}
dst, err := toIPAddr(m.Addrs[0])
log.Debugf("checking route: %s", dst)
if err != nil {
return true, fmt.Errorf("unexpected RIB destination: %v", err)
}
mask, err := toIPAddr(m.Addrs[2])
log.Debugf("checking route mask: %s", mask)
if err != nil {
return true, fmt.Errorf("unexpected RIB destination: %v", err)
}
mask, _ := toIPAddr(m.Addrs[2])
cidr, _ := net.IPMask(mask.To4()).Size()
if dst.String() == prefix.Addr().String() && cidr == prefix.Bits() {
return true, nil