Skip to content

Commit 71b840a

Browse files
author
Ma Shimiao
committed
validate: add network host-specific check
Signed-off-by: Ma Shimiao <[email protected]>
1 parent 96609ba commit 71b840a

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

cmd/oci-runtime-tool/validate.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"errors"
77
"fmt"
88
"io/ioutil"
9+
"net"
910
"os"
1011
"path"
1112
"path/filepath"
@@ -408,6 +409,26 @@ func checkLinuxResources(r rspec.Resources, hostCheck bool) (msgs []string) {
408409
msgs = append(msgs, fmt.Sprintf("Minimum memory limit should be larger than memory reservation"))
409410
}
410411
}
412+
if r.Network != nil && hostCheck {
413+
var exist bool
414+
interfaces, err := net.Interfaces()
415+
if err != nil {
416+
msgs = append(msgs, err.Error())
417+
return
418+
}
419+
for _, prio := range r.Network.Priorities {
420+
exist = false
421+
for _, ni := range interfaces {
422+
if prio.Name == ni.Name {
423+
exist = true
424+
break
425+
}
426+
}
427+
if !exist {
428+
msgs = append(msgs, fmt.Sprintf("Interface %s does not exist on host", prio.Name))
429+
}
430+
}
431+
}
411432

412433
return
413434
}

0 commit comments

Comments
 (0)