Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/net: IPConn.Read() Not able to read FIN/FIN-ACK/ACK packet #47946

Open
vikash-s1 opened this issue Aug 25, 2021 · 1 comment
Open

x/net: IPConn.Read() Not able to read FIN/FIN-ACK/ACK packet #47946

vikash-s1 opened this issue Aug 25, 2021 · 1 comment
Labels
NeedsInvestigation
Milestone

Comments

@vikash-s1
Copy link

@vikash-s1 vikash-s1 commented Aug 25, 2021

What version of Go are you using (go version)?

$ go version
1.5

Does this issue reproduce with the latest release?

didnt check, but possible on latest go lang version also

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
dev-dsk-smvikash-2a-be3e7414 % go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/user/.cache/go-build"
GOENV="/home/user/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/user/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/user/go"
GOPRIVATE=""
GOPROXY="direct"
GOROOT="/usr/lib/golang"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build710417058=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I am trying to create raw tcp connection using dialIP().
//Creating
conn, err := net.DialIP("ip4:tcp", &localaddr, &remoteaddr)

// Sending SYN packet
packetbuf := gopacket.NewSerializeBuffer()
opts := gopacket.SerializeOptions{
FixLengths: true,
ComputeChecksums: true,
}

ipv4 := &layers.IPv4{
SrcIP:    rawInput.SrcIP,
DstIP:    rawInput.DstIP,
Protocol: layers.IPProtocolTCP,
}

tcp := &layers.TCP{
SrcPort: rawInput.SrcPort,
DstPort: rawInput.DstPort,
Window:  rawInput.Window,
Urgent:  rawInput.Urgent,
Seq:     rawInput.Sequence,
Ack:     0,
SYN:     true,
}
tcp.SetNetworkLayerForChecksum(ipv4)
payload := gopacket.Payload(rawhandoffBytes)
gopacket.SerializeLayers(packetbuf, opts, tcp, payload)

println("Sending PacketData..")
_, err := conn.Write(packetbuf.Bytes())

// Reading on connection for FIN/FINACK, as connection is closed at server side
conn.SetReadDeadline(time.Now().Add(5 * time.Second))
n, err := conn.Read(packet_data)

But couldnot capture the FIN-ACK packet, but working for SYN-ACK.

What did you expect to see?

Able to capture FIN-ACK packet

What did you see instead?

Stuck in reading bytes

@toothrot toothrot changed the title Not able to read FIN/FIN-ACK/ACK packet from net.IPConn Read() x/net: IPConn.Read() Not able to read FIN/FIN-ACK/ACK packet Aug 25, 2021
@gopherbot gopherbot added this to the Unreleased milestone Aug 25, 2021
@toothrot
Copy link
Contributor

@toothrot toothrot commented Aug 25, 2021

Go 1.15 is no longer supported. Does this reproduce with Go 1.17?

@toothrot toothrot added the NeedsInvestigation label Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation
Projects
None yet
Development

No branches or pull requests

3 participants