Skip to content

Commit e86a307

Browse files
committed
tunnel: warn if not dual-stack
1 parent a0f3a49 commit e86a307

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tunnel/tunnel.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ type Tunnel interface {
6161
SetLink(fd int) error
6262
// Sets the MTU.
6363
SetMTU(mtu int32)
64-
// Unsets existing link and closes the fd (tun device).
65-
Unlink() error
6664
// New route
6765
SetRoute(engine int) error
66+
// Unsets existing link and closes the fd (tun device).
67+
Unlink() error
6868
// Set or unset the pcap sink
6969
SetPcap(fpcap string) error
7070
// NIC, IP, TCP, UDP, and ICMP stats.
@@ -167,7 +167,7 @@ func (t *gtunnel) Write([]byte) (int, error) {
167167
}
168168

169169
// fd must be non-blocking.
170-
func NewGTunnel(pctx context.Context, fd, mtu int, hdl netstack.GConnHandler) (t *gtunnel, rev netstack.GConnHandler, err error) {
170+
func NewGTunnel(pctx context.Context, fd, mtu int, l3 string, hdl netstack.GConnHandler) (t *gtunnel, rev netstack.GConnHandler, err error) {
171171
dupfd, err := dup(fd) // tunnel will own dupfd
172172
if err != nil {
173173
return nil, nil, err
@@ -180,7 +180,11 @@ func NewGTunnel(pctx context.Context, fd, mtu int, hdl netstack.GConnHandler) (t
180180
if eerr != nil {
181181
return nil, nil, eerr
182182
}
183-
netstack.Route(stack, settings.IP46) // always dual-stack
183+
184+
if l3 != settings.IP46 {
185+
log.W("tun: new netstack(%d) l3 is %s needed %s", fd, l3, settings.IP46)
186+
}
187+
netstack.Route(stack, l3)
184188

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

0 commit comments

Comments
 (0)