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

Commit eac56465 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'batman-adv/next' of git://git.open-mesh.org/ecsv/linux-merge

parents 1b9c4134 43676ab5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
config BATMAN_ADV
	tristate "B.A.T.M.A.N. Advanced Meshing Protocol"
	depends on NET
	select CRC16
        default n
	---help---

+11 −14
Original line number Diff line number Diff line
@@ -20,17 +20,12 @@
 */

#include "main.h"
#include "translation-table.h"
#include "aggregation.h"
#include "send.h"
#include "routing.h"
#include "hard-interface.h"

/* calculate the size of the tt information for a given packet */
static int tt_len(const struct batman_packet *batman_packet)
{
	return batman_packet->num_tt * ETH_ALEN;
}

/* return true if new_packet can be aggregated with forw_packet */
static bool can_aggregate_with(const struct batman_packet *new_batman_packet,
			       int packet_len,
@@ -195,7 +190,7 @@ static void aggregate(struct forw_packet *forw_packet_aggr,

void add_bat_packet_to_list(struct bat_priv *bat_priv,
			    unsigned char *packet_buff, int packet_len,
			    struct hard_iface *if_incoming, char own_packet,
			    struct hard_iface *if_incoming, int own_packet,
			    unsigned long send_time)
{
	/**
@@ -264,18 +259,20 @@ void receive_aggr_bat_packet(const struct ethhdr *ethhdr,
	batman_packet = (struct batman_packet *)packet_buff;

	do {
		/* network to host order for our 32bit seqno, and the
		   orig_interval. */
		/* network to host order for our 32bit seqno and the
		   orig_interval */
		batman_packet->seqno = ntohl(batman_packet->seqno);
		batman_packet->tt_crc = ntohs(batman_packet->tt_crc);

		tt_buff = packet_buff + buff_pos + BAT_PACKET_LEN;
		receive_bat_packet(ethhdr, batman_packet,
				   tt_buff, tt_len(batman_packet),
				   if_incoming);

		buff_pos += BAT_PACKET_LEN + tt_len(batman_packet);
		receive_bat_packet(ethhdr, batman_packet, tt_buff, if_incoming);

		buff_pos += BAT_PACKET_LEN +
			tt_len(batman_packet->tt_num_changes);

		batman_packet = (struct batman_packet *)
			(packet_buff + buff_pos);
	} while (aggregated_packet(buff_pos, packet_len,
				   batman_packet->num_tt));
				   batman_packet->tt_num_changes));
}
+5 −3
Original line number Diff line number Diff line
@@ -25,9 +25,11 @@
#include "main.h"

/* is there another aggregated packet here? */
static inline int aggregated_packet(int buff_pos, int packet_len, int num_tt)
static inline int aggregated_packet(int buff_pos, int packet_len,
				    int tt_num_changes)
{
	int next_buff_pos = buff_pos + BAT_PACKET_LEN + (num_tt * ETH_ALEN);
	int next_buff_pos = buff_pos + BAT_PACKET_LEN + (tt_num_changes *
						sizeof(struct tt_change));

	return (next_buff_pos <= packet_len) &&
		(next_buff_pos <= MAX_AGGREGATION_BYTES);
@@ -35,7 +37,7 @@ static inline int aggregated_packet(int buff_pos, int packet_len, int num_tt)

void add_bat_packet_to_list(struct bat_priv *bat_priv,
			    unsigned char *packet_buff, int packet_len,
			    struct hard_iface *if_incoming, char own_packet,
			    struct hard_iface *if_incoming, int own_packet,
			    unsigned long send_time);
void receive_aggr_bat_packet(const struct ethhdr *ethhdr,
			     unsigned char *packet_buff, int packet_len,
+72 −1
Original line number Diff line number Diff line
@@ -40,6 +40,20 @@ static struct bat_priv *kobj_to_batpriv(struct kobject *obj)
	return netdev_priv(net_dev);
}

#define UEV_TYPE_VAR	"BATTYPE="
#define UEV_ACTION_VAR	"BATACTION="
#define UEV_DATA_VAR	"BATDATA="

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

static char *uev_type_str[] = {
	"gw"
};

/* Use this, if you have customized show and store functions */
#define BAT_ATTR(_name, _mode, _show, _store)	\
struct bat_attribute bat_attr_##_name = {	\
@@ -375,7 +389,7 @@ BAT_ATTR_UINT(gw_sel_class, S_IRUGO | S_IWUSR, 1, TQ_MAX_VALUE,
static BAT_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, show_gw_bwidth,
		store_gw_bwidth);
#ifdef CONFIG_BATMAN_ADV_DEBUG
BAT_ATTR_UINT(log_level, S_IRUGO | S_IWUSR, 0, 3, NULL);
BAT_ATTR_UINT(log_level, S_IRUGO | S_IWUSR, 0, 7, NULL);
#endif

static struct bat_attribute *mesh_attrs[] = {
@@ -601,3 +615,60 @@ void sysfs_del_hardif(struct kobject **hardif_obj)
	kobject_put(*hardif_obj);
	*hardif_obj = NULL;
}

int throw_uevent(struct bat_priv *bat_priv, enum uev_type type,
		 enum uev_action action, const char *data)
{
	int ret = -1;
	struct hard_iface *primary_if = NULL;
	struct kobject *bat_kobj;
	char *uevent_env[4] = { NULL, NULL, NULL, NULL };

	primary_if = primary_if_get_selected(bat_priv);
	if (!primary_if)
		goto out;

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

	uevent_env[0] = kmalloc(strlen(UEV_TYPE_VAR) +
				strlen(uev_type_str[type]) + 1,
				GFP_ATOMIC);
	if (!uevent_env[0])
		goto out;

	sprintf(uevent_env[0], "%s%s", UEV_TYPE_VAR, uev_type_str[type]);

	uevent_env[1] = kmalloc(strlen(UEV_ACTION_VAR) +
				strlen(uev_action_str[action]) + 1,
				GFP_ATOMIC);
	if (!uevent_env[1])
		goto out;

	sprintf(uevent_env[1], "%s%s", UEV_ACTION_VAR, uev_action_str[action]);

	/* If the event is DEL, ignore the data field */
	if (action != UEV_DEL) {
		uevent_env[2] = kmalloc(strlen(UEV_DATA_VAR) +
					strlen(data) + 1, GFP_ATOMIC);
		if (!uevent_env[2])
			goto out;

		sprintf(uevent_env[2], "%s%s", UEV_DATA_VAR, data);
	}

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

	if (primary_if)
		hardif_free_ref(primary_if);

	if (ret)
		bat_dbg(DBG_BATMAN, bat_priv, "Impossible to send "
			"uevent for (%s,%s,%s) event (err: %d)\n",
			uev_type_str[type], uev_action_str[action],
			(action == UEV_DEL ? "NULL" : data), ret);
	return ret;
}
+2 −0
Original line number Diff line number Diff line
@@ -38,5 +38,7 @@ int sysfs_add_meshif(struct net_device *dev);
void sysfs_del_meshif(struct net_device *dev);
int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev);
void sysfs_del_hardif(struct kobject **hardif_obj);
int throw_uevent(struct bat_priv *bat_priv, enum uev_type type,
		 enum uev_action action, const char *data);

#endif /* _NET_BATMAN_ADV_SYSFS_H_ */
Loading