Skip to content

Commit

Permalink
Added check AF_INET/AF_INET6 for dual-stack environments
Browse files Browse the repository at this point in the history
  • Loading branch information
TrekkieCoder committed Oct 15, 2024
1 parent f919f5a commit f354fa8
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions api/loxinlp/nlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -1188,10 +1188,19 @@ func DelNeigh(neigh nlp.Neigh, link nlp.Link) int {
func AddRoute(route nlp.Route) int {
var ipNet net.IPNet
if route.Dst == nil {
r := net.IPv4(0, 0, 0, 0)
m := net.CIDRMask(0, 32)
r = r.Mask(m)
ipNet = net.IPNet{IP: r, Mask: m}
if route.Family == 2 {
r := net.IPv4(0, 0, 0, 0)
m := net.CIDRMask(0, 32)
r = r.Mask(m)
ipNet = net.IPNet{IP: r, Mask: m}
} else if route.Family == 10 {
r := net.ParseIP("::")
m := net.CIDRMask(0, 128)
r = r.Mask(m)
ipNet = net.IPNet{IP: r, Mask: m}
} else {
return -1
}
} else {
ipNet = *route.Dst
}
Expand Down

0 comments on commit f354fa8

Please sign in to comment.