From 548d96da95e0472ca9d863c65ed6386a07f1f438 Mon Sep 17 00:00:00 2001 From: Patricio Whittingslow Date: Thu, 9 Apr 2026 12:44:50 -0300 Subject: [PATCH] notify if icmp cannot be used due to bad StackConfig --- ipv4/icmpv4/client.go | 4 ++++ x/xnet/stack-async.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/ipv4/icmpv4/client.go b/ipv4/icmpv4/client.go index cacaa7e..7a278b2 100644 --- a/ipv4/icmpv4/client.go +++ b/ipv4/icmpv4/client.go @@ -78,6 +78,10 @@ func (client *Client) Reset() { client.responseRing.Reset() } +func (client *Client) IncomingEchoCapacity() int { + return cap(client.incomingEcho) +} + func (client *Client) Demux(carrierData []byte, frameOffset int) error { rawdata := carrierData[frameOffset:] ifrm, err := NewFrame(rawdata) diff --git a/x/xnet/stack-async.go b/x/xnet/stack-async.go index fd7385c..6294d4e 100644 --- a/x/xnet/stack-async.go +++ b/x/xnet/stack-async.go @@ -334,6 +334,10 @@ func (s *StackAsync) Gateway6() [6]byte { // EnableICMP registers an ICMP handler to the stack when enabled is true. // If enabled=false the currently registered ICMP handler is unregistered and state reset. func (s *StackAsync) EnableICMP(enabled bool) (err error) { + if s.icmp.IncomingEchoCapacity() == 0 { + err = lneto.ErrInvalidConfig + enabled = false // ensure aborted. + } if enabled { if s.ip.IsRegistered(lneto.IPProtoICMP) { return nil