diff options
author | Mikio Hara <mikioh.mikioh@gmail.com> | 2015-06-23 21:40:33 +0900 |
---|---|---|
committer | Mikio Hara <mikioh.mikioh@gmail.com> | 2015-06-27 00:39:30 +0000 |
commit | 258bf65d8b157bfe311ce70c93dd854022a25c9d (patch) | |
tree | bc248520f7297c884d21aee39d1af197b18d5735 /src/net/interface_linux_test.go | |
parent | aea348a3af088bc3bc05c5ee5cfc567215008f6f (diff) | |
download | go-git-258bf65d8b157bfe311ce70c93dd854022a25c9d.tar.gz |
net: relax IP interface address determination on linux
Linux allows to have a peer IP address on IP interface over ethernet
link encapsulation, though it only installs a static route with the peer
address as an on-link nexthop.
Fixes #11338.
Change-Id: Ie2583737e4c7cec39baabb89dd732463d3f10a61
Reviewed-on: https://go-review.googlesource.com/11352
Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/net/interface_linux_test.go')
-rw-r--r-- | src/net/interface_linux_test.go | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/net/interface_linux_test.go b/src/net/interface_linux_test.go index 059bde11c6..6251b2674c 100644 --- a/src/net/interface_linux_test.go +++ b/src/net/interface_linux_test.go @@ -20,6 +20,14 @@ func (ti *testInterface) setBroadcast(suffix int) error { Path: xname, Args: []string{"ip", "link", "add", ti.name, "type", "dummy"}, }) + ti.setupCmds = append(ti.setupCmds, &exec.Cmd{ + Path: xname, + Args: []string{"ip", "address", "add", ti.local, "peer", ti.remote, "dev", ti.name}, + }) + ti.teardownCmds = append(ti.teardownCmds, &exec.Cmd{ + Path: xname, + Args: []string{"ip", "address", "del", ti.local, "peer", ti.remote, "dev", ti.name}, + }) ti.teardownCmds = append(ti.teardownCmds, &exec.Cmd{ Path: xname, Args: []string{"ip", "link", "delete", ti.name, "type", "dummy"}, @@ -27,29 +35,27 @@ func (ti *testInterface) setBroadcast(suffix int) error { return nil } -func (ti *testInterface) setPointToPoint(suffix int, local, remote string) error { +func (ti *testInterface) setPointToPoint(suffix int) error { ti.name = fmt.Sprintf("gotest%d", suffix) - ti.local = local - ti.remote = remote xname, err := exec.LookPath("ip") if err != nil { return err } ti.setupCmds = append(ti.setupCmds, &exec.Cmd{ Path: xname, - Args: []string{"ip", "tunnel", "add", ti.name, "mode", "gre", "local", local, "remote", remote}, + Args: []string{"ip", "tunnel", "add", ti.name, "mode", "gre", "local", ti.local, "remote", ti.remote}, + }) + ti.setupCmds = append(ti.setupCmds, &exec.Cmd{ + Path: xname, + Args: []string{"ip", "address", "add", ti.local, "peer", ti.remote, "dev", ti.name}, }) ti.teardownCmds = append(ti.teardownCmds, &exec.Cmd{ Path: xname, - Args: []string{"ip", "tunnel", "del", ti.name, "mode", "gre", "local", local, "remote", remote}, + Args: []string{"ip", "address", "del", ti.local, "peer", ti.remote, "dev", ti.name}, }) - xname, err = exec.LookPath("ifconfig") - if err != nil { - return err - } - ti.setupCmds = append(ti.setupCmds, &exec.Cmd{ + ti.teardownCmds = append(ti.teardownCmds, &exec.Cmd{ Path: xname, - Args: []string{"ifconfig", ti.name, "inet", local, "dstaddr", remote}, + Args: []string{"ip", "tunnel", "del", ti.name, "mode", "gre", "local", ti.local, "remote", ti.remote}, }) return nil } |