Skip to content

Commit cd38aa8

Browse files
Fix panic on TCP packets of an unconfigured address family in system stack (#22)
(cherry picked from commit f3b42b8) --------- Co-authored-by: 世界 <i@sekai.icu>
1 parent 5c6a065 commit cd38aa8

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

stack_system.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,9 @@ func (s *System) processIPv6(ipHdr header.IPv6) (writeBack bool, err error) {
401401
}
402402

403403
func (s *System) processIPv4TCP(ipHdr header.IPv4, tcpHdr header.TCP) (bool, error) {
404+
if s.tcpNat4 == nil {
405+
return false, nil
406+
}
404407
source := netip.AddrPortFrom(ipHdr.SourceAddr(), tcpHdr.SourcePort())
405408
destination := netip.AddrPortFrom(ipHdr.DestinationAddr(), tcpHdr.DestinationPort())
406409
if !destination.Addr().IsGlobalUnicast() {
@@ -492,6 +495,9 @@ func (s *System) resetIPv4TCP(origIPHdr header.IPv4, origTCPHdr header.TCP) erro
492495
}
493496

494497
func (s *System) processIPv6TCP(ipHdr header.IPv6, tcpHdr header.TCP) (bool, error) {
498+
if s.tcpNat6 == nil {
499+
return false, nil
500+
}
495501
source := netip.AddrPortFrom(ipHdr.SourceAddr(), tcpHdr.SourcePort())
496502
destination := netip.AddrPortFrom(ipHdr.DestinationAddr(), tcpHdr.DestinationPort())
497503
if !destination.Addr().IsGlobalUnicast() {

0 commit comments

Comments
 (0)