Skip to content

Commit df860e1

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

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

cmd/ocitools/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"
@@ -397,6 +398,26 @@ func checkLinuxResources(r rspec.Resources, hostCheck bool) (msgs []string) {
397398
msgs = append(msgs, fmt.Sprintf("Minimum memory limit should be larger than memory reservation"))
398399
}
399400
}
401+
if r.Network != nil && hostCheck {
402+
var exist bool
403+
interfaces, err := net.Interfaces()
404+
if err != nil {
405+
msgs = append(msgs, err.Error())
406+
return
407+
}
408+
for _, prio := range r.Network.Priorities {
409+
exist = false
410+
for _, ni := range interfaces {
411+
if prio.Name == ni.Name {
412+
exist = true
413+
break
414+
}
415+
}
416+
if !exist {
417+
msgs = append(msgs, fmt.Sprintf("Interface %s does not exist on host", prio.Name))
418+
}
419+
}
420+
}
400421

401422
return
402423
}

0 commit comments

Comments
 (0)