mirror of
https://github.com/containers/podman.git
synced 2025-12-04 20:28:40 +08:00
Update common, image, and storage deps
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
committed by
Paul Holzinger
parent
32d96f40c3
commit
444f19cb2a
37
vendor/github.com/containers/common/libnetwork/internal/util/validate.go
generated
vendored
37
vendor/github.com/containers/common/libnetwork/internal/util/validate.go
generated
vendored
@@ -81,6 +81,43 @@ func ValidateSubnets(network *types.Network, addGateway bool, usedNetworks []*ne
|
||||
return nil
|
||||
}
|
||||
|
||||
func ValidateRoutes(routes []types.Route) error {
|
||||
for _, route := range routes {
|
||||
err := ValidateRoute(route)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func ValidateRoute(route types.Route) error {
|
||||
if route.Destination.IP == nil {
|
||||
return fmt.Errorf("route destination ip nil")
|
||||
}
|
||||
|
||||
if route.Destination.Mask == nil {
|
||||
return fmt.Errorf("route destination mask nil")
|
||||
}
|
||||
|
||||
if route.Gateway == nil {
|
||||
return fmt.Errorf("route gateway nil")
|
||||
}
|
||||
|
||||
// Reparse to ensure destination is valid.
|
||||
ip, ipNet, err := net.ParseCIDR(route.Destination.String())
|
||||
if err != nil {
|
||||
return fmt.Errorf("route destination invalid: %w", err)
|
||||
}
|
||||
|
||||
// check that destination is a network and not an address
|
||||
if !ip.Equal(ipNet.IP) {
|
||||
return fmt.Errorf("route destination invalid")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func ValidateSetupOptions(n NetUtil, namespacePath string, options types.SetupOptions) error {
|
||||
if namespacePath == "" {
|
||||
return errors.New("namespacePath is empty")
|
||||
|
||||
Reference in New Issue
Block a user