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.cc b/patchpanel/dbus/client.cc
index 53fda20..ff7d85e 100644
--- a/patchpanel/dbus/client.cc
+++ b/patchpanel/dbus/client.cc
@@ -65,11 +65,11 @@
{response.counters().begin(), response.counters().end()});
}
-void OnNeighborConnectedStateChangedSignal(
- const Client::NeighborConnectedStateChangedHandler& handler,
+void OnNeighborReachabilityEventSignal(
+ const Client::NeighborReachabilityEventHandler& handler,
dbus::Signal* signal) {
dbus::MessageReader reader(signal);
- NeighborConnectedStateChangedSignal proto;
+ NeighborReachabilityEventSignal proto;
if (!reader.PopArrayOfBytesAsProto(&proto)) {
LOG(ERROR) << "Failed to parse NeighborConnectedStateChangedSignal proto";
return;
@@ -133,8 +133,8 @@
const std::string& dst_ip,
uint32_t dst_port) override;
- void RegisterNeighborConnectedStateChangedHandler(
- NeighborConnectedStateChangedHandler handler) override;
+ void RegisterNeighborReachabilityEventHandler(
+ NeighborReachabilityEventHandler handler) override;
private:
scoped_refptr<dbus::Bus> bus_;
@@ -587,11 +587,11 @@
return true;
}
-void ClientImpl::RegisterNeighborConnectedStateChangedHandler(
- NeighborConnectedStateChangedHandler handler) {
+void ClientImpl::RegisterNeighborReachabilityEventHandler(
+ NeighborReachabilityEventHandler handler) {
proxy_->ConnectToSignal(
- kPatchPanelInterface, kNeighborConnectedStateChangedSignal,
- base::BindRepeating(OnNeighborConnectedStateChangedSignal, handler),
+ kPatchPanelInterface, kNeighborReachabilityEventSignal,
+ base::BindRepeating(OnNeighborReachabilityEventSignal, handler),
base::BindOnce(OnSignalConnectedCallback));
}