Skip to content

Commit 8abf987

Browse files
milan-zededaOhmSpectator
authored andcommitted
Support ICMP cellular connectivity probe with undefined host IP
This commit fixes handling of ICMP-based cellular connectivity probes when the probe host is not specified. Users can configure periodic connectivity probes for cellular networks, using either ICMP or TCP. For ICMP, the probe host can be left empty to use the default target (Google DNS: 8.8.8.8), as was the implicit behavior in older EVE versions where the probe address was not yet configurable. However, it turned out that EVE did not handle the case of an undefined ICMP probe IP at all. This went unnoticed because parsing errors (such as "missing endpoint host address for ICMP probe") were only logged, while the configuration was still applied — and probing happened to work as intended. With recent improvements in zedagent, parsing failures are now reported to the controller, and EVE rejects configurations with such errors. This commit fixes the parsing logic to correctly accept an undefined ICMP probe endpoint and ensures it is properly handled by mmagent. Signed-off-by: Milan Lenco <[email protected]> (cherry picked from commit e2e5e95)
1 parent 241dcdd commit 8abf987

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

pkg/pillar/cmd/zedagent/parseconfig.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -577,15 +577,28 @@ func parseConnectivityProbe(probe *zconfig.ConnectivityProbe) (
577577
case zconfig.ConnectivityProbeMethod_CONNECTIVITY_PROBE_METHOD_ICMP:
578578
parsedProbe.Method = types.ConnectivityProbeMethodICMP
579579
parsedProbe.ProbeHost = probe.GetProbeEndpoint().GetHost()
580-
if parsedProbe.ProbeHost == "" {
581-
return parsedProbe, errors.New("missing endpoint host address for ICMP probe")
580+
// Undefined host for ICMP probing is allowed - EVE will probe Google DNS
581+
// (8.8.8.8) in that case.
582+
// However, if host address is defined, it should be a valid IP address.
583+
if parsedProbe.ProbeHost != "" {
584+
probeIP := net.ParseIP(parsedProbe.ProbeHost)
585+
if probeIP == nil {
586+
return parsedProbe, fmt.Errorf("invalid IP address for ICMP probe: %s",
587+
parsedProbe.ProbeHost)
588+
}
582589
}
583590
case zconfig.ConnectivityProbeMethod_CONNECTIVITY_PROBE_METHOD_TCP:
584591
parsedProbe.Method = types.ConnectivityProbeMethodTCP
592+
// Host address should be a valid (and non-empty) IP address.
585593
parsedProbe.ProbeHost = probe.GetProbeEndpoint().GetHost()
586594
if parsedProbe.ProbeHost == "" {
587595
return parsedProbe, errors.New("missing endpoint host address for TCP probe")
588596
}
597+
probeIP := net.ParseIP(parsedProbe.ProbeHost)
598+
if probeIP == nil {
599+
return parsedProbe, fmt.Errorf("invalid IP address for TCP probe: %s",
600+
parsedProbe.ProbeHost)
601+
}
589602
probePort := probe.GetProbeEndpoint().GetPort()
590603
if probePort == 0 {
591604
return parsedProbe, errors.New("missing endpoint port number for TCP probe")
@@ -2223,7 +2236,7 @@ func parseNetworkWirelessConfig(ctx *getconfigContext,
22232236
if err != nil {
22242237
return wconfig, err
22252238
}
2226-
if customProbe.Method == types.ConnectivityProbeMethodNone || err != nil {
2239+
if customProbe.Method == types.ConnectivityProbeMethodNone {
22272240
// For backward compatibility.
22282241
if probeCfg.GetProbeAddress() != "" {
22292242
customProbe = types.ConnectivityProbe{

pkg/wwan/mmagent/agent.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,15 @@ func (a *MMAgent) probeModemConnectivity(modem *ModemInfo) error {
11171117
return nil
11181118
}
11191119
case types.ConnectivityProbeMethodICMP:
1120+
if probeConfig.UserDefinedProbe.ProbeHost == "" {
1121+
// When ICMP probe is selected but probe host is undefined, we use the default
1122+
// probing endpoint (Google DNS).
1123+
err = a.runICMPProbe(modemIP, defaultProbeAddr)
1124+
if err == nil {
1125+
return nil
1126+
}
1127+
break
1128+
}
11201129
// User-configured ICMP probe address.
11211130
remoteIP := net.ParseIP(probeConfig.UserDefinedProbe.ProbeHost)
11221131
if remoteIP == nil {

0 commit comments

Comments
 (0)