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

net: no checksum processing on loopback #23599

Closed
xunleer opened this issue Jan 29, 2018 · 4 comments

Comments

Projects
None yet
5 participants
@xunleer
Copy link

commented Jan 29, 2018

Please answer these questions before submitting your issue. Thanks!

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

1.8.5/1.9.3 (linux-amd64)

Does this issue reproduce with the latest release?

yes, 1.9.3 still has this issue

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

go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/somebody/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build426968180=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

write a simple UDP client to test:

cat client.go
package main
import (
    "fmt"
    "net"
    "bufio"
)

func main() {
    p :=  make([]byte, 2048)
    conn, err := net.Dial("udp", "127.0.0.1:1234")
    if err != nil {
        fmt.Printf("Some error %v", err)
        return
    }
    fmt.Fprintf(conn, "Hi UDP Server, How are you doing?")
    _, err = bufio.NewReader(conn).Read(p)
    if err == nil {
        fmt.Printf("%s\n", p)
    } else {
        fmt.Printf("Some error %v\n", err)
    }
    conn.Close()
}
go run client.go
tcpdump -xxx -vvv -eni lo

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

What did you expect to see?

The Client send packets with correct checksum

What did you see instead?

17:31:06.558648 00:00:00:00:00:00 > 00:00:00:00:00:00, ethertype IPv4 (0x0800), length 103: (tos 0xc0, ttl 64, id 22375, offset 0, flags [none], proto ICMP (1), length 89)
    127.0.0.1 > 127.0.0.1: ICMP 127.0.0.1 udp port search-agent unreachable, length 69
        (tos 0x0, ttl 64, id 22374, offset 0, flags [DF], proto UDP (17), length 61)
    127.0.0.1.22533 > 127.0.0.1.search-agent: [bad udp cksum 0xfe3c -> 0x99b2!] UDP, length 33
        0x0000:  0000 0000 0000 0000 0000 0000 0800 45c0
        0x0010:  0059 5767 0000 4001 247b 7f00 0001 7f00
        0x0020:  0001 0303 96af 0000 0000 4500 003d 5766
        0x0030:  4000 4011 e547 7f00 0001 7f00 0001 5805
        0x0040:  04d2 0029 fe3c 4869 2055 4450 2053 6572
        0x0050:  7665 722c 2048 6f77 2061 7265 2079 6f75
        0x0060:  2064 6f69 6e67 3f

seems that the fe3c is fixed for the UDP checksum.

@crvv

This comment has been minimized.

Copy link
Contributor

commented Jan 29, 2018

This is not a bug in Go but a feature of the operation system.
Just run tcpdump -xxx -vvv -eni lo and you can see a lot of packets with wrong checksum.

http://lkml.iu.edu/hypermail/linux/kernel/0308.1/2205.html

@xunleer

This comment has been minimized.

Copy link
Author

commented Jan 29, 2018

this is just a sample, when i sent request to another host, it still has such issue. the checksum is wrong, either.

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Jan 29, 2018

It is not Go that computes the UDP checksum. It is the networking layer. Closing because there is nothing we can change in Go to fix this.

@mikioh mikioh added the OS-Linux label Jan 30, 2018

@mikioh mikioh changed the title udp bad checksum net: no checksum processing on loopback Jan 30, 2018

@crvv

This comment has been minimized.

Copy link
Contributor

commented Jan 30, 2018

this is just a sample, when i sent request to another host, it still has such issue. the checksum is wrong, either.

I think that is another feature of the operating system.

https://wiki.wireshark.org/CaptureSetup/Offloading

@golang golang locked and limited conversation to collaborators Jan 30, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.