Added kernel version checks for macvlan/ipvlan

ipvlan >= 4.0.0 due to early instability
macvlan >= 3.9

Signed-off-by: Brent Salisbury <brent@docker.com>
This commit is contained in:
Brent Salisbury 2016-03-10 17:09:48 -05:00
parent 469ea4eb3f
commit af75e8a624
4 changed files with 25 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import (
"fmt"
"github.com/Sirupsen/logrus"
"github.com/docker/docker/pkg/parsers/kernel"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/libnetwork/driverapi"
"github.com/docker/libnetwork/netlabel"
@ -13,6 +14,15 @@ import (
// CreateNetwork the network for the specified driver type
func (d *driver) CreateNetwork(nid string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) error {
kv, err := kernel.GetKernelVersion()
if err != nil {
return fmt.Errorf("Failed to check kernel version for %s driver support: %v", ipvlanType, err)
}
// ensure Kernel version is greater then v4.0 for ipvlan support
if kv.Kernel < ipvlanKernelVer {
return fmt.Errorf("kernel version failed to meet the minimum ipvlan kernel requirement of %d.%d, found %d.%d.%d",
ipvlanKernelVer, ipvlanMajorVer, kv.Kernel, kv.Major, kv.Minor)
}
// parse and validate the config and bind to networkConfiguration
config, err := parseNetworkOptions(nid, option)
if err != nil {

View File

@ -14,8 +14,9 @@ import (
)
const (
dummyPrefix = "di-" // ipvlan prefix for dummy parent interface
ipvlanKernelVer = "3.19" // minimum ipvlan kernel version support
dummyPrefix = "di-" // ipvlan prefix for dummy parent interface
ipvlanKernelVer = 4 // minimum ipvlan kernel support
ipvlanMajorVer = 0 // minimum ipvlan major kernel support
)
// createIPVlan Create the ipvlan slave specifying the source name

View File

@ -4,6 +4,7 @@ import (
"fmt"
"github.com/Sirupsen/logrus"
"github.com/docker/docker/pkg/parsers/kernel"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/libnetwork/driverapi"
"github.com/docker/libnetwork/netlabel"
@ -13,6 +14,15 @@ import (
// CreateNetwork the network for the specified driver type
func (d *driver) CreateNetwork(nid string, option map[string]interface{}, ipV4Data, ipV6Data []driverapi.IPAMData) error {
kv, err := kernel.GetKernelVersion()
if err != nil {
return fmt.Errorf("failed to check kernel version for %s driver support: %v", macvlanType, err)
}
// ensure Kernel version is greater then v3.9 for macvlan support
if kv.Kernel < macvlanKernelVer || (kv.Kernel == macvlanKernelVer && kv.Major < macvlanMajorVer) {
return fmt.Errorf("kernel version failed to meet the minimum macvlan kernel requirement of %d.%d, found %d.%d.%d",
macvlanKernelVer, macvlanMajorVer, kv.Kernel, kv.Major, kv.Minor)
}
// parse and validate the config and bind to networkConfiguration
config, err := parseNetworkOptions(nid, option)
if err != nil {

View File

@ -15,7 +15,8 @@ import (
const (
dummyPrefix = "dm-" // macvlan prefix for dummy parent interface
macvlanKernelVer = "3.9" // minimum ipvlan kernel version support
macvlanKernelVer = 3 // minimum macvlan kernel support
macvlanMajorVer = 9 // minimum macvlan major kernel support
)
// Create the macvlan slave specifying the source name