specificity edge cases

This commit is contained in:
Will Scott
2020-03-08 15:21:16 -07:00
parent 1305487144
commit 84fa87828b
+8 -2
View File
@@ -135,8 +135,14 @@ func (r *router) route(routes routeSlice, input net.HardwareAddr, src, dst net.I
continue
}
if mostSpecificRt != nil {
candSpec, _ := rt.Dst.Mask.Size()
if curSpec, _ := mostSpecificRt.Dst.Mask.Size(); candSpec < curSpec {
var candSpec, curSpec int
if rt.Dst != nil {
candSpec, _ = rt.Dst.Mask.Size()
}
if mostSpecificRt.Dst != nil {
curSpec, _ = mostSpecificRt.Dst.Mask.Size()
}
if candSpec < curSpec {
continue
}
}