Skip to content

Commit

Permalink
libnet: Revert "Only check if route overlaps routes with scope: LINK"
Browse files Browse the repository at this point in the history
This reverts commit ee9e526.

Route scope is used by the kernel to choose what source IP address
should be used when establishing an outbound connection. As such,
filtering routes based on their scope doesn't make sense.

Resolve #46615.
  • Loading branch information
akerouanton committed Oct 12, 2023
1 parent d7caea2 commit cead284
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
2 changes: 1 addition & 1 deletion libnetwork/netutils/utils_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func CheckRouteOverlaps(toCheck *net.IPNet) error {
return err
}
for _, network := range networks {
if network.Dst != nil && network.Scope == netlink.SCOPE_LINK && NetworkOverlaps(toCheck, network.Dst) {
if network.Dst != nil && NetworkOverlaps(toCheck, network.Dst) {
return ErrNetworkOverlaps
}
}
Expand Down
10 changes: 1 addition & 9 deletions libnetwork/netutils/utils_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@ func TestCheckRouteOverlaps(t *testing.T) {
routes := []netlink.Route{}
for _, addr := range routesData {
_, netX, _ := net.ParseCIDR(addr)
routes = append(routes, netlink.Route{Dst: netX, Scope: netlink.SCOPE_LINK})
routes = append(routes, netlink.Route{Dst: netX})
}
// Add a route with a scope which should not overlap
_, netX, _ := net.ParseCIDR("10.0.5.0/24")
routes = append(routes, netlink.Route{Dst: netX, Scope: netlink.SCOPE_UNIVERSE})
return routes, nil
}
defer func() { networkGetRoutesFct = nil }()
Expand All @@ -67,11 +64,6 @@ func TestCheckRouteOverlaps(t *testing.T) {
if err := CheckRouteOverlaps(netX); err == nil {
t.Fatal("10.0.2.0/24 and 10.0.2.0 should overlap but it doesn't")
}

_, netX, _ = net.ParseCIDR("10.0.5.0/24")
if err := CheckRouteOverlaps(netX); err != nil {
t.Fatal("10.0.5.0/24 and 10.0.5.0 with scope UNIVERSE should not overlap but it does")
}
}

func TestCheckNameserverOverlaps(t *testing.T) {
Expand Down

0 comments on commit cead284

Please sign in to comment.