Skip to content

Commit

Permalink
tunnel: warn if not dual-stack
Browse files Browse the repository at this point in the history
  • Loading branch information
ignoramous committed Jan 23, 2025
1 parent a0f3a49 commit e86a307
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tunnel/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ type Tunnel interface {
SetLink(fd int) error
// Sets the MTU.
SetMTU(mtu int32)
// Unsets existing link and closes the fd (tun device).
Unlink() error
// New route
SetRoute(engine int) error
// Unsets existing link and closes the fd (tun device).
Unlink() error
// Set or unset the pcap sink
SetPcap(fpcap string) error
// NIC, IP, TCP, UDP, and ICMP stats.
Expand Down Expand Up @@ -167,7 +167,7 @@ func (t *gtunnel) Write([]byte) (int, error) {
}

// fd must be non-blocking.
func NewGTunnel(pctx context.Context, fd, mtu int, hdl netstack.GConnHandler) (t *gtunnel, rev netstack.GConnHandler, err error) {
func NewGTunnel(pctx context.Context, fd, mtu int, l3 string, hdl netstack.GConnHandler) (t *gtunnel, rev netstack.GConnHandler, err error) {
dupfd, err := dup(fd) // tunnel will own dupfd
if err != nil {
return nil, nil, err
Expand All @@ -180,7 +180,11 @@ func NewGTunnel(pctx context.Context, fd, mtu int, hdl netstack.GConnHandler) (t
if eerr != nil {
return nil, nil, eerr
}
netstack.Route(stack, settings.IP46) // always dual-stack

if l3 != settings.IP46 {
log.W("tun: new netstack(%d) l3 is %s needed %s", fd, l3, settings.IP46)
}
netstack.Route(stack, l3)

var nic tcpip.NICID
// Enabled() may temporarily return false when Up() is in progress.
Expand Down

0 comments on commit e86a307

Please sign in to comment.