Re: [PATCH net 11/12] batman-adv: fix iflink detection in batadv_is_on_batman_iface

2022-05-14 Thread Sven Eckelmann
On Thursday, 1 October 2020 09:59:35 CEST Sabrina Dubroca wrote:
> device has the same ifindex as its link. Let's use the presence of a
> ndo_get_iflink operation, rather than the value it returns, to detect
> a device without a link.

There wasn't any activity in this patchset since a while, it doesn't apply
anymore and the assumptions made here doesn't seem to be reflect the current
situation in the kernel. See commit 6c1f41afc1db ("batman-adv: Don't expect
inter-netns unique iflink indices"):

> But only checking for dev->netdev_ops->ndo_get_iflink is also not an option
> because ipoib_get_iflink implements it even when it sometimes returns an
> iflink != ifindex and sometimes iflink == ifindex. The caller must
> therefore make sure itself to check both netns and iflink + ifindex for
> equality. Only when they are equal, a "physical" interface was detected
> which should stop the traversal. On the other hand, vxcan_get_iflink can
> also return 0 in case there was currently no valid peer. In this case, it
> is still necessary to stop.

It would would be nice when the situation would be better but the proposed 
patches don't solve it. So I will mark the two patches as "Rejected" (from 
"Changes requested") in batadv's patchwork. It is not meant as sign of
disapproval of someone working in this area to improve the situation - I just
don't want to wait for the v2 [1] anymore.

Kind regards,
Sven

[1] https://lore.kernel.org/all/20201002090703.GD3565727@bistromath.localdomain/

signature.asc
Description: This is a digitally signed message part.


Re: [PATCH v2] alfred: notify event listener via unix socket

2022-05-14 Thread Sven Eckelmann
On Monday, 2 May 2022 13:46:51 CEST Marek Lindner wrote:
> The alfred server instance accepts event notification registration
> via the unix socket. These notification sockets only inform
> registered parties of the availability of an alfred datatype change.
> The actual data itself needs to be retrieved via the existing data
> retrieval mechanisms.
> 
> Unlike the update-command this event monitor allows:
> 
> - multiple parallel listeners
> - programmatic access to changes without requiring multiple processes
> 
> The alfred client allows to monitor events via the newly added '-E'
> (event monitor) command line option. Serving as debugging tool and
> example code at the same time.
> 
> Signed-off-by: Marek Lindner 
> ---
> 
> v2:
> - fix typ0s
> - replace list_del_init() with list_del()
> - remove unnecessary INIT_LIST_HEAD()
> - change --event-monitor to not require an argument

This version cannot be applied on top of the current master. I have attached 
the diff for the things which (afaik) need to be changed when you rebase the 
patch.

I have also attached the change to support the reporting of the source mac for 
the changed dataset.


Kind regards,
Svendiff --git a/alfred.h b/alfred.h
index 668e856..f00346d 100644
--- a/alfred.h
+++ b/alfred.h
@@ -121,6 +121,7 @@ struct interface {
 
 struct event_listener {
 	int fd;
+	struct epoll_handle epoll;
 
 	struct list_head list;
 };
@@ -208,10 +209,6 @@ int unix_sock_open_client(struct globals *globals);
 int unix_sock_close(struct globals *globals);
 int unix_sock_req_data_finish(struct globals *globals,
 			  struct transaction_head *head);
-int unix_sock_events_select_prepare(struct globals *globals, fd_set *fds,
-fd_set *errfds, int maxsock);
-void unix_sock_events_select_handle(struct globals *globals,
-fd_set *fds, fd_set *errfds);
 void unix_sock_events_close_all(struct globals *globals);
 void unix_sock_event_notify(struct globals *globals, uint8_t type);
 /* vis.c */
diff --git a/main.c b/main.c
index 885b950..3fe7b42 100644
--- a/main.c
+++ b/main.c
@@ -164,12 +164,8 @@ static struct globals *alfred_init(int argc, char *argv[])
 		{"modeswitch",		required_argument,	NULL,	'M'},
 		{"change-interface",	required_argument,	NULL,	'I'},
 		{"change-bat-iface",	required_argument,	NULL,	'B'},
-<<< HEAD
 		{"server-status",	no_argument,		NULL,	'S'},
-===
-		{"server-status",	required_argument,	NULL,	'S'},
 		{"event-monitor",	no_argument,		NULL,	'E'},
->>> 08415c9 (alfred: notify event listener via unix socket)
 		{"unix-path",		required_argument,	NULL,	'u'},
 		{"update-command",	required_argument,	NULL,	'c'},
 		{"version",		no_argument,		NULL,	'v'},
diff --git a/server.c b/server.c
index 15b4d77..0d792b0 100644
--- a/server.c
+++ b/server.c
@@ -513,54 +513,7 @@ int alfred_server(struct globals *globals)
 
 	while (1) {
 		netsock_reopen(globals);
-<<< HEAD
 		process_events(globals);
-===
-
-		FD_ZERO();
-		FD_ZERO();
-		FD_SET(globals->unix_sock, );
-		maxsock = globals->unix_sock;
-
-		maxsock = netsock_prepare_select(globals, , maxsock);
-		maxsock = netsock_prepare_select(globals, , maxsock);
-		maxsock = unix_sock_events_select_prepare(globals, ,
-			  , maxsock);
-
-		ret = pselect(maxsock + 1, , NULL, , , NULL);
-
-		if (ret == -1) {
-			perror("main loop select failed ...");
-		} else if (ret) {
-			netsock_check_error(globals, );
-
-			unix_sock_events_select_handle(globals, , );
-
-			if (FD_ISSET(globals->unix_sock, )) {
-unix_sock_read(globals);
-continue;
-			} else {
-recvs = netsock_receive_packet(globals, );
-if (recvs > 0)
-	continue;
-			}
-		}
-		clock_gettime(CLOCK_MONOTONIC, _check);
-
-		if (globals->opmode == OPMODE_PRIMARY) {
-			/* we are a primary */
-			printf("[%ld.%09ld] announce primary ...\n", last_check.tv_sec, last_check.tv_nsec);
-			announce_primary(globals);
-			sync_data(globals);
-		} else {
-			/* send local data to server */
-			update_server_info(globals);
-			push_local_data(globals);
-		}
-		purge_data(globals);
-		check_if_sockets(globals);
-		execute_update_command(globals);
->>> 08415c9 (alfred: notify event listener via unix socket)
 	}
 
 	netsock_close_all(globals);
diff --git a/unix_sock.c b/unix_sock.c
index 2d7fc2e..14d63dd 100644
--- a/unix_sock.c
+++ b/unix_sock.c
@@ -27,6 +27,9 @@
 static void unix_sock_read(struct globals *globals,
 			   struct epoll_handle *handle __unused,
 			   struct epoll_event *ev __unused);
+static void unix_sock_event_listener_handle(struct globals *globals __unused,
+	struct epoll_handle *handle,
+	struct epoll_event *ev);
 
 int unix_sock_open_daemon(struct globals *globals)
 {
@@ -496,14 +499,10 @@ err:
 	return ret;
 }
 
-<<< HEAD
-static void unix_sock_read(struct globals *globals,
-			   struct epoll_handle *handle __unused,
-			   struct epoll_event *ev __unused)
-===
 static int unix_sock_register_listener(struct globals *globals, int client_sock)
 {
 	struct