daemon: Validate MacAddress on container create

This was previously checked only on ContainerStart.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
This commit is contained in:
Albin Kerouanton 2023-08-04 16:47:34 +02:00
parent ee9f0ed895
commit 61c78d9438
No known key found for this signature in database
GPG key ID: 630B8E1DCBDB1864

View file

@ -612,6 +612,13 @@ func validateEndpointSettings(nw *libnetwork.Network, nwName string, epConfig *n
}
}
if epConfig.MacAddress != "" {
_, err := net.ParseMAC(epConfig.MacAddress)
if err != nil {
return fmt.Errorf("invalid MAC address %s", epConfig.MacAddress)
}
}
if err := multierror.Join(errs...); err != nil {
return fmt.Errorf("invalid endpoint settings:\n%w", err)
}