summaryrefslogtreecommitdiff
path: root/vendor/github.com/containernetworking
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/containernetworking')
-rw-r--r--vendor/github.com/containernetworking/cni/libcni/api.go6
-rw-r--r--vendor/github.com/containernetworking/cni/pkg/invoke/args.go4
-rw-r--r--vendor/github.com/containernetworking/cni/pkg/invoke/raw_exec.go8
-rw-r--r--vendor/github.com/containernetworking/cni/pkg/types/020/types.go14
-rw-r--r--vendor/github.com/containernetworking/cni/pkg/types/current/types.go17
-rw-r--r--vendor/github.com/containernetworking/cni/pkg/types/types.go3
-rw-r--r--vendor/github.com/containernetworking/cni/pkg/utils/utils.go39
7 files changed, 50 insertions, 41 deletions
diff --git a/vendor/github.com/containernetworking/cni/libcni/api.go b/vendor/github.com/containernetworking/cni/libcni/api.go
index 22b111742..7e52bd838 100644
--- a/vendor/github.com/containernetworking/cni/libcni/api.go
+++ b/vendor/github.com/containernetworking/cni/libcni/api.go
@@ -409,6 +409,9 @@ func (c *CNIConfig) addNetwork(ctx context.Context, name, cniVersion string, net
if err := utils.ValidateNetworkName(name); err != nil {
return nil, err
}
+ if err := utils.ValidateInterfaceName(rt.IfName); err != nil {
+ return nil, err
+ }
newConf, err := buildOneConfig(name, cniVersion, net, prevResult, rt)
if err != nil {
@@ -629,6 +632,9 @@ func (c *CNIConfig) validatePlugin(ctx context.Context, pluginName, expectedVers
if err != nil {
return err
}
+ if expectedVersion == "" {
+ expectedVersion = "0.1.0"
+ }
vi, err := invoke.GetVersionInfo(ctx, pluginPath, c.exec)
if err != nil {
diff --git a/vendor/github.com/containernetworking/cni/pkg/invoke/args.go b/vendor/github.com/containernetworking/cni/pkg/invoke/args.go
index d31a44e87..3cdb4bc8d 100644
--- a/vendor/github.com/containernetworking/cni/pkg/invoke/args.go
+++ b/vendor/github.com/containernetworking/cni/pkg/invoke/args.go
@@ -60,8 +60,8 @@ func (args *Args) AsEnv() []string {
pluginArgsStr = stringify(args.PluginArgs)
}
- // Duplicated values which come first will be overrided, so we must put the
- // custom values in the end to avoid being overrided by the process environments.
+ // Duplicated values which come first will be overridden, so we must put the
+ // custom values in the end to avoid being overridden by the process environments.
env = append(env,
"CNI_COMMAND="+args.Command,
"CNI_CONTAINERID="+args.ContainerID,
diff --git a/vendor/github.com/containernetworking/cni/pkg/invoke/raw_exec.go b/vendor/github.com/containernetworking/cni/pkg/invoke/raw_exec.go
index ad8498ba2..4f89a5dda 100644
--- a/vendor/github.com/containernetworking/cni/pkg/invoke/raw_exec.go
+++ b/vendor/github.com/containernetworking/cni/pkg/invoke/raw_exec.go
@@ -44,10 +44,14 @@ func (e *RawExec) ExecPlugin(ctx context.Context, pluginPath string, stdinData [
}
func pluginErr(err error, output []byte) error {
- if _, ok := err.(*exec.ExitError); ok {
+ if exitError, ok := err.(*exec.ExitError); ok {
emsg := types.Error{}
if len(output) == 0 {
- emsg.Msg = "netplugin failed with no error message"
+ if len(exitError.Stderr) == 0 {
+ emsg.Msg = "netplugin failed with no error message"
+ } else {
+ emsg.Msg = fmt.Sprintf("netplugin failed: %q", string(exitError.Stderr))
+ }
} else if perr := json.Unmarshal(output, &emsg); perr != nil {
emsg.Msg = fmt.Sprintf("netplugin failed but error parsing its diagnostic message %q: %v", string(output), perr)
}
diff --git a/vendor/github.com/containernetworking/cni/pkg/types/020/types.go b/vendor/github.com/containernetworking/cni/pkg/types/020/types.go
index 53256167f..36f31678a 100644
--- a/vendor/github.com/containernetworking/cni/pkg/types/020/types.go
+++ b/vendor/github.com/containernetworking/cni/pkg/types/020/types.go
@@ -86,20 +86,6 @@ func (r *Result) PrintTo(writer io.Writer) error {
return err
}
-// String returns a formatted string in the form of "[IP4: $1,][ IP6: $2,] DNS: $3" where
-// $1 represents the receiver's IPv4, $2 represents the receiver's IPv6 and $3 the
-// receiver's DNS. If $1 or $2 are nil, they won't be present in the returned string.
-func (r *Result) String() string {
- var str string
- if r.IP4 != nil {
- str = fmt.Sprintf("IP4:%+v, ", *r.IP4)
- }
- if r.IP6 != nil {
- str += fmt.Sprintf("IP6:%+v, ", *r.IP6)
- }
- return fmt.Sprintf("%sDNS:%+v", str, r.DNS)
-}
-
// IPConfig contains values necessary to configure an interface
type IPConfig struct {
IP net.IPNet
diff --git a/vendor/github.com/containernetworking/cni/pkg/types/current/types.go b/vendor/github.com/containernetworking/cni/pkg/types/current/types.go
index 7267a2e6d..754cc6e72 100644
--- a/vendor/github.com/containernetworking/cni/pkg/types/current/types.go
+++ b/vendor/github.com/containernetworking/cni/pkg/types/current/types.go
@@ -207,23 +207,6 @@ func (r *Result) PrintTo(writer io.Writer) error {
return err
}
-// String returns a formatted string in the form of "[Interfaces: $1,][ IP: $2,] DNS: $3" where
-// $1 represents the receiver's Interfaces, $2 represents the receiver's IP addresses and $3 the
-// receiver's DNS. If $1 or $2 are nil, they won't be present in the returned string.
-func (r *Result) String() string {
- var str string
- if len(r.Interfaces) > 0 {
- str += fmt.Sprintf("Interfaces:%+v, ", r.Interfaces)
- }
- if len(r.IPs) > 0 {
- str += fmt.Sprintf("IP:%+v, ", r.IPs)
- }
- if len(r.Routes) > 0 {
- str += fmt.Sprintf("Routes:%+v, ", r.Routes)
- }
- return fmt.Sprintf("%sDNS:%+v", str, r.DNS)
-}
-
// Convert this old version result to the current CNI version result
func (r *Result) Convert() (*Result, error) {
return r, nil
diff --git a/vendor/github.com/containernetworking/cni/pkg/types/types.go b/vendor/github.com/containernetworking/cni/pkg/types/types.go
index 3e185c1ce..3fa757a5d 100644
--- a/vendor/github.com/containernetworking/cni/pkg/types/types.go
+++ b/vendor/github.com/containernetworking/cni/pkg/types/types.go
@@ -100,9 +100,6 @@ type Result interface {
// Prints the result in JSON format to provided writer
PrintTo(writer io.Writer) error
-
- // Returns a JSON string representation of the result
- String() string
}
func PrintResult(result Result, version string) error {
diff --git a/vendor/github.com/containernetworking/cni/pkg/utils/utils.go b/vendor/github.com/containernetworking/cni/pkg/utils/utils.go
index 324c40dea..b8ec38874 100644
--- a/vendor/github.com/containernetworking/cni/pkg/utils/utils.go
+++ b/vendor/github.com/containernetworking/cni/pkg/utils/utils.go
@@ -15,14 +15,22 @@
package utils
import (
+ "bytes"
+ "fmt"
"regexp"
+ "unicode"
"github.com/containernetworking/cni/pkg/types"
)
-// cniValidNameChars is the regexp used to validate valid characters in
-// containerID and networkName
-const cniValidNameChars = `[a-zA-Z0-9][a-zA-Z0-9_.\-]`
+const (
+ // cniValidNameChars is the regexp used to validate valid characters in
+ // containerID and networkName
+ cniValidNameChars = `[a-zA-Z0-9][a-zA-Z0-9_.\-]`
+
+ // maxInterfaceNameLength is the length max of a valid interface name
+ maxInterfaceNameLength = 15
+)
var cniReg = regexp.MustCompile(`^` + cniValidNameChars + `*$`)
@@ -49,3 +57,28 @@ func ValidateNetworkName(networkName string) *types.Error {
}
return nil
}
+
+// ValidateInterfaceName will validate the interface name based on the three rules below
+// 1. The name must not be empty
+// 2. The name must be less than 16 characters
+// 3. The name must not be "." or ".."
+// 3. The name must not contain / or : or any whitespace characters
+// ref to https://github.com/torvalds/linux/blob/master/net/core/dev.c#L1024
+func ValidateInterfaceName(ifName string) *types.Error {
+ if len(ifName) == 0 {
+ return types.NewError(types.ErrInvalidEnvironmentVariables, "interface name is empty", "")
+ }
+ if len(ifName) > maxInterfaceNameLength {
+ return types.NewError(types.ErrInvalidEnvironmentVariables, "interface name is too long", fmt.Sprintf("interface name should be less than %d characters", maxInterfaceNameLength+1))
+ }
+ if ifName == "." || ifName == ".." {
+ return types.NewError(types.ErrInvalidEnvironmentVariables, "interface name is . or ..", "")
+ }
+ for _, r := range bytes.Runes([]byte(ifName)) {
+ if r == '/' || r == ':' || unicode.IsSpace(r) {
+ return types.NewError(types.ErrInvalidEnvironmentVariables, "interface name contains / or : or whitespace characters", "")
+ }
+ }
+
+ return nil
+}