From 9e087b4e69bfeb0634dbfebf1d2eb5beb4cf2a47 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 25 Aug 2021 13:29:14 +0200 Subject: [PATCH] brmon: continue polling the socket after an error occured Fixes a corner case with edge-trigger epoll Signed-off-by: Felix Fietkau --- brmon.c | 1 + libnetlink.c | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/brmon.c b/brmon.c index d25dae4..5546ac0 100644 --- a/brmon.c +++ b/brmon.c @@ -219,6 +219,7 @@ int init_bridge_ops(void) ufd.fd = rth.fd; ufd.cb = bridge_event_cb; uloop_fd_add(&ufd, ULOOP_READ | ULOOP_EDGE_TRIGGER); + bridge_event_cb(&ufd, 0); return 0; } diff --git a/libnetlink.c b/libnetlink.c index 95162ec..477e1a2 100644 --- a/libnetlink.c +++ b/libnetlink.c @@ -411,7 +411,7 @@ int rtnl_listen(struct rtnl_handle *rtnl, rtnl_filter_t handler, void *jarg) if (msg.msg_namelen != sizeof(nladdr)) { ERROR("Sender address length == %d\n", msg.msg_namelen); - return -1; + continue; } for (h = (struct nlmsghdr *)buf; status >= sizeof(*h);) { int err; @@ -421,17 +421,17 @@ int rtnl_listen(struct rtnl_handle *rtnl, rtnl_filter_t handler, void *jarg) if (l < 0 || len > status) { if (msg.msg_flags & MSG_TRUNC) { ERROR("Truncated message\n"); - return -1; + continue; } ERROR( "!!!malformed message: len=%d\n", len); - return -1; + continue; } err = handler(&nladdr, h, jarg); if (err < 0) { ERROR("Handler returned %d\n", err); - return err; + continue; } status -= NLMSG_ALIGN(len); @@ -443,7 +443,7 @@ int rtnl_listen(struct rtnl_handle *rtnl, rtnl_filter_t handler, void *jarg) } if (status) { ERROR("!!!Remnant of size %d\n", status); - return -1; + continue; } } } -- 2.30.2