Skip to content

Commit 42c50d2

Browse files
EHfivexiaokangwang
authored andcommitted
fix: set TTL for incoming UDP IP packets from TUN with PacketAddr dispatcher
Fixes UDP packets being dropped in non-local routing path(e.g. forwarding to LAN or container veth) due to 0-TTL.
1 parent c0a0ce2 commit 42c50d2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

app/tun/packetparse/udp.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ func constructIPv4UDPPacket(src, dst net.Destination, data []byte) ([]byte, erro
7878
Protocol: layers.IPProtocolUDP,
7979
SrcIP: src.Address.IP(),
8080
DstIP: dst.Address.IP(),
81+
TTL: 64, // set TTL to a reasonable non-zero value to allow non-local routing
8182
}
8283
udp := &layers.UDP{
8384
SrcPort: layers.UDPPort(src.Port),
@@ -103,6 +104,7 @@ func constructIPv6UDPPacket(src, dst net.Destination, data []byte) ([]byte, erro
103104
NextHeader: layers.IPProtocolUDP,
104105
SrcIP: src.Address.IP(),
105106
DstIP: dst.Address.IP(),
107+
HopLimit: 64,
106108
}
107109
udp := &layers.UDP{
108110
SrcPort: layers.UDPPort(src.Port),

0 commit comments

Comments
 (0)