Skip to contentSkip to conversation

alfred: Drop deprecated debugfs support

PATCH New Sven Eckelmann 1 participant 2 messages Oct 31, 2020 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 alfred: Drop deprecated debugfs support

The debugfs support is disabled by default in batman-adv since a while and will be removed in 2021. The generic netlink interface should be used instead.

The alfred support for it should be removed with the same release as the removal in batman-adv.

---
 Makefile       |   1 -
 README.rst     |   7 +-
 batadv_query.c | 204 +------------------------------------------------
 debugfs.c      | 140 ---------------------------------
 debugfs.h      |  25 ------
 main.c         |   4 -
 vis/Makefile   |   1 -
 vis/debugfs.c  |   1 -
 vis/debugfs.h  |   1 -
 vis/vis.c      | 167 +---------------------------------------
 vis/vis.h      |   1 -
 11 files changed, 5 insertions(+), 547 deletions(-)
 delete mode 100644 debugfs.c
 delete mode 100644 debugfs.h
 delete mode 120000 vis/debugfs.c
 delete mode 120000 vis/debugfs.h
Makefile +0 -1
index 2bfe18c..6268cb9 100755
@@ -11,7 +11,6 @@ BINARY_NAME = alfred
 OBJ += batadv_query.o
 OBJ += batadv_querynl.o
 OBJ += client.o
-OBJ += debugfs.o
 OBJ += hash.o
 OBJ += main.o
 OBJ += netlink.o
README.rst +1 -6
index bf5fb05..2bc2119 100644
@@ -290,7 +290,7 @@ Operations requiring special capabilities:
 
 * bind to device
 * creating the unix socket
-* accessing the debugfs filesystem
+* accessing the netlink interface
 
 The first operation can still be executed when the admin grants the special
 capability CAP_NET_RAW+CAP_NET_ADMIN to anyone executing the alfred binary.
@@ -300,11 +300,6 @@ directory which can be accessed by the user::
   $ sudo setcap cap_net_admin,cap_net_raw+ep alfred
   $ ./alfred -u alfred.sock -i eth0
 
-The user running alfred must still be in a group which is allowed to access
-/sys/kernel/debugfs to correctly choose best neighbors for communication.
-It is possible (but not recommended) to disable the neighbor
-selection/prioritization using the parameter '-b none'.
-
 
 License
 =======
batadv_query.c +2 -202

259 lines not on this page · raw message

debugfs.c deleted +0 -140

140 lines not on this page · raw message

debugfs.h deleted +0 -25
deleted file mode 100644
index 61384f9..0000000
@@ -1,25 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* Copyright (C) 2009 Clark Williams <[email protected]>
- * Copyright (C) 2009 Xiao Guangrong <[email protected]>
- *
- * License-Filename: LICENSES/preferred/GPL-2.0
- */
-
-#ifndef __DEBUGFS_H__
-#define __DEBUGFS_H__
-
-#ifndef MAX_PATH
-# define MAX_PATH 256
-#endif
-
-#ifndef STR
-# define _STR(x) #x
-# define STR(x) _STR(x)
-#endif
-
-extern int debugfs_valid_entry(const char *path);
-extern char *debugfs_mount(const char *mountpoint);
-extern int debugfs_make_path(const char *fmt, const char *mesh_iface,
-			     char *buffer, int size);
-
-#endif /* __DEBUGFS_H__ */
main.c +0 -4
index b498d1e..5ae8187 100644
@@ -18,7 +18,6 @@
 #include <unistd.h>
 #endif
 #include "alfred.h"
-#include "debugfs.h"
 #include "packet.h"
 #include "list.h"
 
@@ -167,9 +166,6 @@ static struct globals *alfred_init(int argc, char *argv[])
 		{NULL,			0,			NULL,	0},
 	};
 
-	/* We need full capabilities to mount debugfs, so do that now */
-	debugfs_mount(NULL);
-
 	ret = reduce_capabilities();
 	if (ret < 0)
 		return NULL;
vis/Makefile +0 -1
index cfd0921..50c8efb 100755
@@ -8,7 +8,6 @@
 
 # batadv-vis build
 BINARY_NAME = batadv-vis
-OBJ += debugfs.o
 OBJ += netlink.o
 OBJ += vis.o
 MANPAGE = man/batadv-vis.8
vis/debugfs.c deleted +0 -1
deleted file mode 120000
index 45fb24d..0000000
@@ -1 +0,0 @@
-../debugfs.c
\ No newline at end of file
vis/debugfs.h deleted +0 -1
deleted file mode 120000
index 094e733..0000000
@@ -1 +0,0 @@
-../debugfs.h
\ No newline at end of file
vis/vis.c +2 -165

209 lines not on this page · raw message

vis/vis.h +0 -1
index 43d2974..bed6615 100644
@@ -24,7 +24,6 @@
 #define UPDATE_INTERVAL				10
 
 #define SYS_IFACE_PATH				"/sys/class/net"
-#define DEBUG_BATIF_PATH_FMT			"%s/batman_adv/%s"
 #define SYS_IFACE_STATUS_FMT			SYS_IFACE_PATH"/%s/batman_adv/iface_status"
 
 
Signature · 1 line
2.28.0
#1 lore raw

PATCH 2/2 alfred: Drop deprecated sysfs support

The sysfs support is disabled by default in batman-adv since a while and will be removed in 2021. The generic netlink interface should be used instead.

The alfred support for it should be removed with the same release as the removal in batman-adv.

---
 vis/vis.c | 50 ++++----------------------------------------------
 vis/vis.h |  3 ---
 2 files changed, 4 insertions(+), 49 deletions(-)
vis/vis.c +4 -46
index b62359c..1bb82ab 100644
@@ -36,39 +36,6 @@ struct vis_netlink_opts {
 	struct nlquery_opts query_opts;
 };
 
-static char *read_file(char *fname)
-{
-	FILE *fp;
-	char *buf = NULL, *buf_tmp;
-	size_t size, ret;
-
-	fp = fopen(fname, "r");
-
-	if (!fp)
-		return NULL;
-
-	size = 0;
-	while (!feof(fp)) {
-
-		buf_tmp = realloc(buf, size + 4097);
-		if (!buf_tmp) {
-			free(buf);
-			fclose(fp);
-			return NULL;
-		}
-
-		buf = buf_tmp;
-		ret = fread(buf + size, 1, 4096, fp);
-		size += ret;
-	}
-	fclose(fp);
-
-	if (buf)
-		buf[size] = 0;
-
-	return buf;
-}
-
 static char *mac_to_str(uint8_t *mac)
 {
 	static char macstr[20];
@@ -443,26 +410,17 @@ err_free_sock:
 	return ret_status;
 }
 
-static bool interface_active(unsigned int meshif, unsigned int hardif,
-			     const char *ifname)
+static bool interface_active(unsigned int meshif, unsigned int hardif)
 {
 	char iface_status[IFACE_STATUS_LEN];
-	char path_buff[PATH_BUFF_LEN];
 	char *file_content = NULL;
 	char *content_newline;
 	bool active = false;
 	char *status;
 
 	status = get_iface_status_netlink(meshif, hardif, iface_status);
-	if (!status) {
-		snprintf(path_buff, sizeof(path_buff), SYS_IFACE_STATUS_FMT,
-			 ifname);
-		file_content = read_file(path_buff);
-		if (!file_content)
-			return false;
-
-		status = file_content;
-	}
+	if (!status)
+		return false;
 
 	content_newline = strstr(status, "\n");
 	if (content_newline)
@@ -518,7 +476,7 @@ static int register_interfaces_rtnl_parse(struct nl_msg *msg, void *arg)
 	if (master != register_arg->ifindex)
 		goto err;
 
-	if (!interface_active(master, ifm->ifi_index, ifname))
+	if (!interface_active(master, ifm->ifi_index))
 		goto err;
 
 	get_if_index_byname(register_arg->globals, ifname);
vis/vis.h +0 -3
index bed6615..6f5b839 100644
@@ -23,9 +23,6 @@
 #define	VIS_PACKETVERSION			1
 #define UPDATE_INTERVAL				10
 
-#define SYS_IFACE_PATH				"/sys/class/net"
-#define SYS_IFACE_STATUS_FMT			SYS_IFACE_PATH"/%s/batman_adv/iface_status"
-
 
 enum opmode {
 	OPMODE_SERVER,
Signature · 1 line
2.28.0