Support ips capability in static and mac capability in tuning
This change introduces new capability flag to change MAC address and to specify IP addresses by tuning and static.
This commit is contained in:
@ -43,9 +43,14 @@ type TuningConf struct {
|
||||
Mac string `json:"mac,omitempty"`
|
||||
Promisc bool `json:"promisc,omitempty"`
|
||||
Mtu int `json:"mtu,omitempty"`
|
||||
|
||||
RuntimeConfig struct {
|
||||
Mac string `json:"mac,omitempty"`
|
||||
} `json:"runtimeConfig,omitempty"`
|
||||
}
|
||||
|
||||
type MACEnvArgs struct {
|
||||
// MacEnvArgs represents CNI_ARG
|
||||
type MacEnvArgs struct {
|
||||
types.CommonArgs
|
||||
MAC types.UnmarshallableString `json:"mac,omitempty"`
|
||||
}
|
||||
@ -56,9 +61,9 @@ func parseConf(data []byte, envArgs string) (*TuningConf, error) {
|
||||
return nil, fmt.Errorf("failed to load netconf: %v", err)
|
||||
}
|
||||
|
||||
// Parse custom MAC from both env args
|
||||
// Parse custom Mac from both env args
|
||||
if envArgs != "" {
|
||||
e := MACEnvArgs{}
|
||||
e := MacEnvArgs{}
|
||||
err := types.LoadArgs(envArgs, &e)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -69,6 +74,11 @@ func parseConf(data []byte, envArgs string) (*TuningConf, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// Parse custom Mac from RuntimeConfig
|
||||
if conf.RuntimeConfig.Mac != "" {
|
||||
conf.Mac = conf.RuntimeConfig.Mac
|
||||
}
|
||||
|
||||
return &conf, nil
|
||||
}
|
||||
|
||||
@ -230,7 +240,7 @@ func cmdCheck(args *skel.CmdArgs) error {
|
||||
|
||||
err = ns.WithNetNSPath(args.Netns, func(_ ns.NetNS) error {
|
||||
// Check each configured value vs what's currently in the container
|
||||
for key, conf_value := range tuningConf.SysCtl {
|
||||
for key, confValue := range tuningConf.SysCtl {
|
||||
fileName := filepath.Join("/proc/sys", strings.Replace(key, ".", "/", -1))
|
||||
fileName = filepath.Clean(fileName)
|
||||
|
||||
@ -238,9 +248,9 @@ func cmdCheck(args *skel.CmdArgs) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cur_value := strings.TrimSuffix(string(contents), "\n")
|
||||
if conf_value != cur_value {
|
||||
return fmt.Errorf("Error: Tuning configured value of %s is %s, current value is %s", fileName, conf_value, cur_value)
|
||||
curValue := strings.TrimSuffix(string(contents), "\n")
|
||||
if confValue != curValue {
|
||||
return fmt.Errorf("Error: Tuning configured value of %s is %s, current value is %s", fileName, confValue, curValue)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user