forked from moby/moby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request moby#8367 from crosbymichael/update-libcontainer-sep9
Update libconatiner to b3570267c7b7995d5d618974d8f
- Loading branch information
Showing
11 changed files
with
288 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
vendor/src/github.com/docker/libcontainer/network/veth_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// +build linux | ||
|
||
package network | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/docker/libcontainer/netlink" | ||
) | ||
|
||
func TestGenerateVethNames(t *testing.T) { | ||
if testing.Short() { | ||
return | ||
} | ||
|
||
prefix := "veth" | ||
|
||
name1, name2, err := createVethPair(prefix) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if name1 == "" { | ||
t.Fatal("name1 should not be empty") | ||
} | ||
|
||
if name2 == "" { | ||
t.Fatal("name2 should not be empty") | ||
} | ||
} | ||
|
||
func TestCreateDuplicateVethPair(t *testing.T) { | ||
if testing.Short() { | ||
return | ||
} | ||
|
||
prefix := "veth" | ||
|
||
name1, name2, err := createVethPair(prefix) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
// retry to create the name interfaces and make sure that we get the correct error | ||
err = CreateVethPair(name1, name2) | ||
if err == nil { | ||
t.Fatal("expected error to not be nil with duplicate interface") | ||
} | ||
|
||
if err != netlink.ErrInterfaceExists { | ||
t.Fatalf("expected error to be ErrInterfaceExists but received %q", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// +build linux | ||
|
||
package xattr | ||
|
||
import ( | ||
"syscall" | ||
|
||
"github.com/docker/libcontainer/system" | ||
) | ||
|
||
func XattrEnabled(path string) bool { | ||
if Setxattr(path, "user.test", "") == syscall.ENOTSUP { | ||
return false | ||
} | ||
return true | ||
} | ||
|
||
func stringsfromByte(buf []byte) (result []string) { | ||
offset := 0 | ||
for index, b := range buf { | ||
if b == 0 { | ||
result = append(result, string(buf[offset:index])) | ||
offset = index + 1 | ||
} | ||
} | ||
return | ||
} | ||
|
||
func Listxattr(path string) ([]string, error) { | ||
size, err := system.Llistxattr(path, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
buf := make([]byte, size) | ||
read, err := system.Llistxattr(path, buf) | ||
if err != nil { | ||
return nil, err | ||
} | ||
names := stringsfromByte(buf[:read]) | ||
return names, nil | ||
} | ||
|
||
func Getxattr(path, attr string) (string, error) { | ||
value, err := system.Lgetxattr(path, attr) | ||
if err != nil { | ||
return "", err | ||
} | ||
return string(value), nil | ||
} | ||
|
||
func Setxattr(path, xattr, value string) error { | ||
return system.Lsetxattr(path, xattr, []byte(value), 0) | ||
} |
Oops, something went wrong.