patchpanel: Generate neighbor failed/recovered events
Currently, we have a "connected" state for each neighbor monitored by
NeighborLinkMonitor, which is determined by whether the NUD state is in
NUD_VALID or not, and send D-Bus signals when that state changes. This
logic has the following issues:
- We don't really need a "connected" state changed event, what we need
is the event of link failed and recovered. One difference between them
is that when the link is going down, it will be disconnected but there
may not be a failure. We don't need to emit metrics or performing the
WiFi reattach in that case.
- The current logic for this state could be problematic. NUD_VALID means
the entry in the kernel neighbor table has a layer 2 address, but not
bidirectionally reachable. For example, when the device receives a ARP
request from an unknown neighbor, it will create an entry with state
of NUD_STALE, it's valid but actually the reachability is not
confirmed. We should only rely on NUD_REACHABLE and NUD_FAILED to
defer its reachability state.
So this patch does the following changes:
- Change the signal name from "NeighborConnectedStateChanged" to
"NeighborReachablilityEvent", which contains an event type of FAILED
or RECOVERED;
- Change the logic for generating events to rely on NUD_REACHABLE and
NUD_FAILED, instead of NUD_VALID.
BUG=b:162194516
TEST=Manually set the NUD state of gateway to NUD_FAILED, observed the
FAILED log on the shill side, and another RECOVERED log after some
time.
Change-Id: I580639917ed4bcf7ffe36e5128566cde4282ae8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2532026
Reviewed-by: Hugo Benichi <hugobenichi@google.com>
Tested-by: Jie Jiang <jiejiang@chromium.org>
Commit-Queue: Jie Jiang <jiejiang@chromium.org>
diff --git a/patchpanel/dbus/client.h b/patchpanel/dbus/client.h
index 2675065..c6662bf 100644
--- a/patchpanel/dbus/client.h
+++ b/patchpanel/dbus/client.h
@@ -28,8 +28,8 @@
public:
using GetTrafficCountersCallback =
base::OnceCallback<void(const std::vector<TrafficCounter>&)>;
- using NeighborConnectedStateChangedHandler =
- base::RepeatingCallback<void(const NeighborConnectedStateChangedSignal&)>;
+ using NeighborReachabilityEventHandler =
+ base::RepeatingCallback<void(const NeighborReachabilityEventSignal&)>;
static std::unique_ptr<Client> New();
@@ -97,12 +97,12 @@
const std::string& dst_ip,
uint32_t dst_port) = 0;
- // Registers a handler that will be called on receiving a signal of neighbor
- // connected state changed. Currently these events are generated only for WiFi
+ // Registers a handler that will be called on receiving a neighbor
+ // reachability event. Currently these events are generated only for WiFi
// devices. The handler is registered for as long as this patchpanel::Client
// instance is alive.
- virtual void RegisterNeighborConnectedStateChangedHandler(
- NeighborConnectedStateChangedHandler handler) = 0;
+ virtual void RegisterNeighborReachabilityEventHandler(
+ NeighborReachabilityEventHandler handler) = 0;
protected:
Client() = default;