Skip to content

Commit a8f65da

Browse files
author
null
committed
drop log
1 parent ad8d33f commit a8f65da

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

proxy/tun/stack_gvisor.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,16 @@ func (t *stackGVisor) Start() error {
112112
// source/destination of the packet we process as incoming, on gVisor side are Remote/Local
113113
// in other terms, src is the side behind tun, dst is the side behind gVisor
114114
// this function handle packets passing from the tun to the gVisor, therefore the src/dst assignement
115-
src := net.UDPDestination(net.IPAddress(id.RemoteAddress.AsSlice()), net.Port(id.RemotePort))
116-
dst := net.UDPDestination(net.IPAddress(id.LocalAddress.AsSlice()), net.Port(id.LocalPort))
115+
srcIP := net.IPAddress(id.RemoteAddress.AsSlice())
116+
dstIP := net.IPAddress(id.LocalAddress.AsSlice())
117+
if srcIP == nil {
118+
errors.LogDebug(context.Background(), "drop udp with size ", len(data), " > invalid src address ", id.RemoteAddress.AsSlice())
119+
}
120+
if dstIP == nil {
121+
errors.LogDebug(context.Background(), "drop udp with size ", len(data), " > invalid dst address ", id.LocalAddress.AsSlice())
122+
}
123+
src := net.UDPDestination(srcIP, net.Port(id.RemotePort))
124+
dst := net.UDPDestination(dstIP, net.Port(id.LocalPort))
117125

118126
return udpForwarder.HandlePacket(src, dst, data)
119127
})

proxy/tun/udp_fullcone.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func (u *udpConnectionHandler) HandlePacket(src net.Destination, dst net.Destina
4848
dest: &dst,
4949
}:
5050
default:
51+
errors.LogDebug(context.Background(), "drop udp with size ", len(data), " to ", dst.NetAddr(), " original ", conn.dst.NetAddr(), " > queue full")
5152
}
5253
u.RUnlock()
5354
return true
@@ -73,6 +74,7 @@ func (u *udpConnectionHandler) HandlePacket(src net.Destination, dst net.Destina
7374
dest: &dst,
7475
}:
7576
default:
77+
errors.LogDebug(context.Background(), "drop udp with size ", len(data), " to ", dst.NetAddr(), " original ", conn.dst.NetAddr(), " > queue full")
7678
}
7779

7880
return true
@@ -108,7 +110,7 @@ func (c *udpConn) ReadMultiBuffer() (buf.MultiBuffer, error) {
108110

109111
_, err := b.Write(e.data)
110112
if err != nil {
111-
errors.LogInfoInner(context.Background(), err, "drop udp with size ", len(e.data), " to ", e.dest.NetAddr(), " original ", c.dst.NetAddr())
113+
errors.LogDebugInner(context.Background(), err, "drop udp with size ", len(e.data), " to ", e.dest.NetAddr(), " original ", c.dst.NetAddr())
112114
b.Release()
113115
continue
114116
}

0 commit comments

Comments
 (0)