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/manager.h b/patchpanel/manager.h
index 6fd5e76..fdf36bd 100644
--- a/patchpanel/manager.h
+++ b/patchpanel/manager.h
@@ -159,11 +159,12 @@
std::unique_ptr<dbus::Response> OnModifyPortRule(
dbus::MethodCall* method_call);
- // Sends out DBus signal for notifying neighbor connected state changed.
- void OnNeighborConnectedStateChanged(int ifindex,
- const shill::IPAddress& ip_addr,
- NeighborLinkMonitor::NeighborRole role,
- bool connected);
+ // Sends out DBus signal for notifying neighbor reachability event.
+ void OnNeighborReachabilityEvent(
+ int ifindex,
+ const shill::IPAddress& ip_addr,
+ NeighborLinkMonitor::NeighborRole role,
+ NeighborReachabilityEventSignal::EventType event_type);
std::unique_ptr<patchpanel::ConnectNamespaceResponse> ConnectNamespace(
base::ScopedFD client_fd,