Skip to content

Commit

Permalink
Merge pull request #1502 from aboch/mc
Browse files Browse the repository at this point in the history
Run API check to assert xfrm modules
  • Loading branch information
mavenugo authored Oct 14, 2016
2 parents 04025f2 + 8f68ca8 commit 7768939
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions ns/init_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ func NlHandle() *netlink.Handle {
func getSupportedNlFamilies() []int {
fams := []int{syscall.NETLINK_ROUTE}
if err := loadXfrmModules(); err != nil {
log.Warnf("Could not load necessary modules for IPSEC rules: %v", err)
return fams
if checkXfrmSocket() != nil {
log.Warnf("Could not load necessary modules for IPSEC rules: %v", err)
return fams
}
}
return append(fams, syscall.NETLINK_XFRM)
}
Expand All @@ -84,3 +86,13 @@ func loadXfrmModules() error {
}
return nil
}

// API check on required xfrm modules (xfrm_user, xfrm_algo)
func checkXfrmSocket() error {
fd, err := syscall.Socket(syscall.AF_NETLINK, syscall.SOCK_RAW, syscall.NETLINK_XFRM)
if err != nil {
return err
}
syscall.Close(fd)
return nil
}

0 comments on commit 7768939

Please sign in to comment.