Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0fa4c30d authored by Sven Eckelmann's avatar Sven Eckelmann Committed by Simon Wunderlich
Browse files

batman-adv: Make sysfs support optional



The sysfs files will be marked as deprecated in the near future. They are
already replaced by the batadv generic netlink family. Add an Kconfig
option to disable the sysfs support for users who want to test their tools
or want to safe some space. This setting should currently still be enabled
by default to keep backward compatible with legacy tools.

Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
Signed-off-by: default avatarSimon Wunderlich <sw@simonwunderlich.de>
parent 52735a6f
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -97,6 +97,18 @@ config BATMAN_ADV_DEBUG
	  buffer. The output is controlled via the batadv netdev specific
	  log_level setting.

config BATMAN_ADV_SYSFS
	bool "batman-adv sysfs entries"
	depends on BATMAN_ADV
	default y
	help
	  Say Y here if you want to enable batman-adv device configuration and
	  status interface through sysfs attributes. It is replaced by the
	  batadv generic netlink family but still used by various userspace
	  tools and scripts.

	  If unsure, say Y.

config BATMAN_ADV_TRACING
	bool "B.A.T.M.A.N. tracing support"
	depends on BATMAN_ADV
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ batman-adv-y += originator.o
batman-adv-y += routing.o
batman-adv-y += send.o
batman-adv-y += soft-interface.o
batman-adv-y += sysfs.o
batman-adv-$(CONFIG_BATMAN_ADV_SYSFS) += sysfs.o
batman-adv-$(CONFIG_BATMAN_ADV_TRACING) += trace.o
batman-adv-y += tp_meter.o
batman-adv-y += translation-table.o
+0 −1
Original line number Diff line number Diff line
@@ -47,7 +47,6 @@
#include "netlink.h"
#include "originator.h"
#include "soft-interface.h"
#include "sysfs.h"
#include "translation-table.h"

static const u8 batadv_announce_mac[4] = {0x43, 0x05, 0x43, 0x05};
+0 −1
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@
#include "originator.h"
#include "routing.h"
#include "soft-interface.h"
#include "sysfs.h"
#include "translation-table.h"

/* These are the offsets of the "hw type" and "hw address length" in the dhcp
+73 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
#include <linux/build_bug.h>
#include <linux/byteorder/generic.h>
#include <linux/crc32c.h>
#include <linux/device.h>
#include <linux/errno.h>
#include <linux/genetlink.h>
#include <linux/gfp.h>
@@ -19,6 +20,7 @@
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/kernel.h>
#include <linux/kobject.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/module.h>
@@ -28,6 +30,7 @@
#include <linux/rcupdate.h>
#include <linux/seq_file.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/stddef.h>
#include <linux/string.h>
@@ -72,6 +75,22 @@ struct workqueue_struct *batadv_event_workqueue;

static void batadv_recv_handler_init(void);

#define BATADV_UEV_TYPE_VAR	"BATTYPE="
#define BATADV_UEV_ACTION_VAR	"BATACTION="
#define BATADV_UEV_DATA_VAR	"BATDATA="

static char *batadv_uev_action_str[] = {
	"add",
	"del",
	"change",
	"loopdetect",
};

static char *batadv_uev_type_str[] = {
	"gw",
	"bla",
};

static int __init batadv_init(void)
{
	int ret;
@@ -666,6 +685,60 @@ bool batadv_vlan_ap_isola_get(struct batadv_priv *bat_priv, unsigned short vid)
	return ap_isolation_enabled;
}

/**
 * batadv_throw_uevent() - Send an uevent with batman-adv specific env data
 * @bat_priv: the bat priv with all the soft interface information
 * @type: subsystem type of event. Stored in uevent's BATTYPE
 * @action: action type of event. Stored in uevent's BATACTION
 * @data: string with additional information to the event (ignored for
 *  BATADV_UEV_DEL). Stored in uevent's BATDATA
 *
 * Return: 0 on success or negative error number in case of failure
 */
int batadv_throw_uevent(struct batadv_priv *bat_priv, enum batadv_uev_type type,
			enum batadv_uev_action action, const char *data)
{
	int ret = -ENOMEM;
	struct kobject *bat_kobj;
	char *uevent_env[4] = { NULL, NULL, NULL, NULL };

	bat_kobj = &bat_priv->soft_iface->dev.kobj;

	uevent_env[0] = kasprintf(GFP_ATOMIC,
				  "%s%s", BATADV_UEV_TYPE_VAR,
				  batadv_uev_type_str[type]);
	if (!uevent_env[0])
		goto out;

	uevent_env[1] = kasprintf(GFP_ATOMIC,
				  "%s%s", BATADV_UEV_ACTION_VAR,
				  batadv_uev_action_str[action]);
	if (!uevent_env[1])
		goto out;

	/* If the event is DEL, ignore the data field */
	if (action != BATADV_UEV_DEL) {
		uevent_env[2] = kasprintf(GFP_ATOMIC,
					  "%s%s", BATADV_UEV_DATA_VAR, data);
		if (!uevent_env[2])
			goto out;
	}

	ret = kobject_uevent_env(bat_kobj, KOBJ_CHANGE, uevent_env);
out:
	kfree(uevent_env[0]);
	kfree(uevent_env[1]);
	kfree(uevent_env[2]);

	if (ret)
		batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
			   "Impossible to send uevent for (%s,%s,%s) event (err: %d)\n",
			   batadv_uev_type_str[type],
			   batadv_uev_action_str[action],
			   (action == BATADV_UEV_DEL ? "NULL" : data), ret);
	return ret;
}

module_init(batadv_init);
module_exit(batadv_exit);

Loading