ping: Fix not handling reject

This commit is contained in:
世界 2025-08-27 00:12:17 +08:00
parent 055fe13ec0
commit 4c43f4af12
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
3 changed files with 21 additions and 5 deletions

View file

@ -668,7 +668,11 @@ func (s *System) processIPv4ICMP(ipHdr header.IPv4, icmpHdr header.ICMPv4) (bool
)
})
if err != nil {
return false, nil
if errors.Is(err, ErrReset) {
return false, s.rejectIPv4WithICMP(ipHdr, header.ICMPv4PortUnreachable)
} else if errors.Is(err, ErrDrop) {
return false, nil
}
}
if action != nil {
return false, action.WritePacket(buf.As(ipHdr).ToOwned())
@ -739,7 +743,9 @@ func (s *System) processIPv6ICMP(ipHdr header.IPv6, icmpHdr header.ICMPv6) (bool
timeout,
)
})
if err != nil {
if errors.Is(err, ErrReset) {
return false, s.rejectIPv6WithICMP(ipHdr, header.ICMPv6PortUnreachable)
} else if errors.Is(err, ErrDrop) {
return false, nil
}
if action != nil {