brmon: continue polling the socket after an error occured
authorFelix Fietkau <nbd@nbd.name>
Wed, 25 Aug 2021 11:29:14 +0000 (13:29 +0200)
committerFelix Fietkau <nbd@nbd.name>
Wed, 25 Aug 2021 11:29:16 +0000 (13:29 +0200)
Fixes a corner case with edge-trigger epoll

Signed-off-by: Felix Fietkau <nbd@nbd.name>
brmon.c
libnetlink.c

diff --git a/brmon.c b/brmon.c
index d25dae44563bf8934e04d1a5996b1bc74d6ef17a..5546ac02a7e1ba2824a41d0298928b7cc3758278 100644 (file)
--- 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;
 }
index 95162ec8dc4afea4545cb2678755bd9ea8acffe7..477e1a25126ee423bd0736cb64a79f8316ef7c50 100644 (file)
@@ -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;
                }
        }
 }