diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2021-01-23 20:48:50 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2021-01-23 21:43:01 +0100 |
commit | 2f6665827dd0c9f44d4007dfc7b4e76bed5854f5 (patch) | |
tree | 20b911e2a4ee0151830b9d66e99f650e8f9e4358 /pkg/tcpip | |
parent | 25c126c907e589e2eddcee265eb0418b5b517c47 (diff) |
gre: clean up Bind
Diffstat (limited to 'pkg/tcpip')
-rw-r--r-- | pkg/tcpip/link/gre/gre.go | 54 | ||||
-rw-r--r-- | pkg/tcpip/sample/tun_tcp_connect/main.go | 1 |
2 files changed, 0 insertions, 55 deletions
diff --git a/pkg/tcpip/link/gre/gre.go b/pkg/tcpip/link/gre/gre.go index bb3e69604..254a1b4d6 100644 --- a/pkg/tcpip/link/gre/gre.go +++ b/pkg/tcpip/link/gre/gre.go @@ -2,17 +2,10 @@ package gre import ( "log" - "math" - "net" - "os" "gvisor.dev/gvisor/pkg/tcpip" - "gvisor.dev/gvisor/pkg/tcpip/header" "gvisor.dev/gvisor/pkg/tcpip/link/channel" - "gvisor.dev/gvisor/pkg/tcpip/network/ipv4" "gvisor.dev/gvisor/pkg/tcpip/stack" - "gvisor.dev/gvisor/pkg/tcpip/transport/raw" - "gvisor.dev/gvisor/pkg/waiter" ) var SIZE = 16 @@ -36,53 +29,6 @@ func (e *Endpoint) GetChannel() *channel.Endpoint { return &e.Endpoint } -func (e *Endpoint) Bind(s *stack.Stack, laddr tcpip.FullAddress) { - log.Println("Bind begin") - - // Create TCP endpoint. - var wq waiter.Queue - ep, err := raw.NewEndpoint(s, ipv4.ProtocolNumber, header.GREProtocolNumber, &wq) - if err != nil { - log.Fatal(err) - } - log.Println("EP: %s", ep) - - raddr := tcpip.FullAddress{NIC: 1, Addr: tcpip.Address(net.ParseIP("10.0.0.1"))} - log.Println("Remote:", raddr.Addr, raddr) - - if err := ep.Bind(tcpip.FullAddress{1, "", 0}); err != nil { - log.Fatal("Bind failed: ", err) - } - - // if err := ep.Connect(raddr); err != nil { - // log.Fatal("Connect failed: ", err) - // } - - // Issue connect request and wait for it to complete. - waitEntry, notifyCh := waiter.NewChannelEntry(nil) - - // Read data and write to standard output until the peer closes the - // connection from its side. - wq.EventRegister(&waitEntry, waiter.EventIn) - for { - _, err := ep.Read(os.Stdout, math.MaxUint16, tcpip.ReadOptions{}) - if err != nil { - if err == tcpip.ErrClosedForReceive { - break - } - - if err == tcpip.ErrWouldBlock { - <-notifyCh - continue - } - - log.Fatal("Read() failed:", err) - } - } - wq.EventUnregister(&waitEntry) - log.Println("Bind end") -} - // Attach saves the stack network-layer dispatcher for use later when packets // are injected. func (e *Endpoint) Attach(dispatcher stack.NetworkDispatcher) { diff --git a/pkg/tcpip/sample/tun_tcp_connect/main.go b/pkg/tcpip/sample/tun_tcp_connect/main.go index 762c6dc29..4707585d1 100644 --- a/pkg/tcpip/sample/tun_tcp_connect/main.go +++ b/pkg/tcpip/sample/tun_tcp_connect/main.go @@ -266,7 +266,6 @@ func main() { s.SetTransportProtocolHandler(header.GREProtocolNumber, greFwd.HandlePacket) go greInfo.greRead(chEP) - //greEP.Bind(s, greIP) if err := s.CreateNIC(2, sniffer.New(greEP)); err != nil { log.Fatal(err) } |