mirror of
https://github.com/vishvananda/netlink.git
synced 2025-09-27 04:05:59 +08:00
1. Fixed endianity probem with geneve VNI (ID)
2. Parse remote IP 3. Added unit test to test geneve paramters against "ip link"
This commit is contained in:

committed by
Alessandro Boch

parent
f2f0bfd10a
commit
88079d98e6
@@ -4,6 +4,8 @@ package netlink
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
@@ -43,6 +45,43 @@ func setUpNetlinkTest(t *testing.T) tearDownNetlinkTest {
|
||||
}
|
||||
}
|
||||
|
||||
// setUpNamedNetlinkTest create a temporary named names space with a random name
|
||||
func setUpNamedNetlinkTest(t *testing.T) (string, tearDownNetlinkTest) {
|
||||
skipUnlessRoot(t)
|
||||
|
||||
origNS, err := netns.Get()
|
||||
if err != nil {
|
||||
t.Fatal("Failed saving orig namespace")
|
||||
}
|
||||
|
||||
// create a random name
|
||||
rnd := make([]byte, 4)
|
||||
if _, err := rand.Read(rnd); err != nil {
|
||||
t.Fatal("failed creating random ns name")
|
||||
}
|
||||
name := "netlinktest-" + hex.EncodeToString(rnd)
|
||||
|
||||
ns, err := netns.NewNamed(name)
|
||||
if err != nil {
|
||||
t.Fatal("Failed to create new ns", err)
|
||||
}
|
||||
|
||||
runtime.LockOSThread()
|
||||
cleanup := func() {
|
||||
ns.Close()
|
||||
netns.DeleteNamed(name)
|
||||
netns.Set(origNS)
|
||||
runtime.UnlockOSThread()
|
||||
}
|
||||
|
||||
if err := netns.Set(ns); err != nil {
|
||||
cleanup()
|
||||
t.Fatal("Failed entering new namespace", err)
|
||||
}
|
||||
|
||||
return name, cleanup
|
||||
}
|
||||
|
||||
func setUpNetlinkTestWithLoopback(t *testing.T) tearDownNetlinkTest {
|
||||
skipUnlessRoot(t)
|
||||
|
||||
|
Reference in New Issue
Block a user