Skip to content

Commit

Permalink
fix: set TTL for incoming UDP IP packets from TUN with PacketAddr dis…
Browse files Browse the repository at this point in the history
…patcher

Fixes UDP packets being dropped in non-local routing path(e.g. forwarding to LAN or container veth) due to 0-TTL.
  • Loading branch information
EHfive authored and xiaokangwang committed Nov 1, 2023
1 parent c0a0ce2 commit 42c50d2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/tun/packetparse/udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func constructIPv4UDPPacket(src, dst net.Destination, data []byte) ([]byte, erro
Protocol: layers.IPProtocolUDP,
SrcIP: src.Address.IP(),
DstIP: dst.Address.IP(),
TTL: 64, // set TTL to a reasonable non-zero value to allow non-local routing
}
udp := &layers.UDP{
SrcPort: layers.UDPPort(src.Port),
Expand All @@ -103,6 +104,7 @@ func constructIPv6UDPPacket(src, dst net.Destination, data []byte) ([]byte, erro
NextHeader: layers.IPProtocolUDP,
SrcIP: src.Address.IP(),
DstIP: dst.Address.IP(),
HopLimit: 64,
}
udp := &layers.UDP{
SrcPort: layers.UDPPort(src.Port),
Expand Down

0 comments on commit 42c50d2

Please sign in to comment.