SagerNet / SagerNet/sing-tun

Error reading data from Darwin Tun network card while writing to Linux Tun network card

Open
#28 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Go
Stars
237
Forks
228
PR merge metrics
No merged PRs in 30d

Description

Mac Tun device creation code


	srcPrefix, err := netip.ParsePrefix("10.0.0.1/24")
	if err != nil {
		return nil, err
	}
	dstPrefix, err := netip.ParsePrefix("10.0.0.0/24")
	if err != nil {
		return nil, err
	}

	tun, err := stun.New(stun.Options{
		Name:              "utun3",
		Inet4Address:      []netip.Prefix{srcPrefix},
		MTU:               uint32(1420),
		AutoRoute:         true,
		Inet4RouteAddress: []netip.Prefix{dstPrefix},
	})

Linux Tun device creation code

	srcPrefix, err := netip.ParsePrefix("10.0.0.2/24")
	if err != nil {
		return nil, err
	}
	option := stun.Options{
		Name:         "tun3",
		Inet4Address: []netip.Prefix{srcPrefix},
		MTU:          uint32(1420),
	}
	tun, err := stun.New(option)

I established a tunnel between two machines, but when I forwarded the data packet read from the Mac tun device to the Linux tun device, he encountered this error

write tun: invalid argument

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the tunnel with the Darwin and Linux TUN creation options shown in the issue, then trace the write path that returns "write tun: invalid argument." Compare the packet and device expectations on both platforms; done means identifying the incompatibility and providing a verified fix or a documented limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
networking, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.