@@ -20,9 +20,7 @@ import (
2020// packets will be truncated to snapLen.
2121const SnapLen uint32 = 2048 // in bytes; some sufficient value
2222
23- var (
24- errNoFdSwapper = errors .New ("magiclink: no FdSwapper" )
25- )
23+ var errNoFdSwapper = errors .New ("magiclink: no FdSwapper" )
2624
2725type FdSwapper interface {
2826 // Swap closes existing FDs; uses new fd.
@@ -77,6 +75,7 @@ type magiclink struct {
7775
7876var _ stack.LinkEndpoint = (* magiclink )(nil )
7977var _ stack.NetworkDispatcher = (* magiclink )(nil )
78+ var _ stack.GSOEndpoint = (* magiclink )(nil )
8079var _ FdSwapper = (* magiclink )(nil )
8180
8281// ref: github.com/google/gvisor/blob/91f58d2cc/pkg/tcpip/sample/tun_tcp_echo/main.go#L102
@@ -166,21 +165,24 @@ func (l *magiclink) Swap(fd int) error {
166165 FDs : []int {fd },
167166 MTU : umtu ,
168167 }
169- if ep , err := newFdbasedInjectableEndpoint (& opt ); err == nil {
170- if old := l .e .Swap (ep ); old != nil {
171- core .Go ("magic." + strconv .Itoa (fd ), old .Close )
172- }
173- if l .d .Load () == nil {
174- log .W ("netstack: %d magic(mtu: %d); new ep but no dispatcher" , fd , umtu )
175- ep .Attach (nil ) // attach the new endpoint to the dispatcher
176- } else {
177- log .I ("netstack: %d magic(mtu: %d); new ep, attaching dispatcher" , fd , umtu )
178- ep .Attach (l ) // attach the new endpoint to the existing dispatcher
179- }
180- } else {
168+
169+ ep , err := newFdbasedInjectableEndpoint (& opt )
170+ if err != nil {
181171 log .E ("netstack: magic(%d); err %v" , fd , err )
182172 return err
183173 }
174+
175+ if old := l .e .Swap (ep ); old != nil {
176+ core .Go ("magic." + strconv .Itoa (fd ), old .Close )
177+ }
178+
179+ d := l .d .Load ()
180+ if d == nil {
181+ ep .Attach (nil ) // attach the new endpoint to the dispatcher
182+ } else {
183+ ep .Attach (l ) // attach the new endpoint to the existing dispatcher
184+ }
185+ logei (d == nil )("netstack: %d magic(mtu: %d); new ep... dispatch? %t" , fd , umtu , d != nil )
184186 }
185187
186188 return err
@@ -300,3 +302,8 @@ func (l *magiclink) SetOnCloseAction(f func()) {
300302 e .SetOnCloseAction (f )
301303 }
302304}
305+
306+ func (l * magiclink ) GSOMaxSize () uint32 { return 0 }
307+
308+ // SupportedGSO returns the supported segmentation offloading.
309+ func (l * magiclink ) SupportedGSO () stack.SupportedGSO { return stack .GSONotSupported }
0 commit comments