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

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

Merge tag 'batman-adv-for-davem' of git://git.open-mesh.org/linux-merge



Antonio Quartulli says:

====================
Included changes:
- increase internal module version
- increase BLA wait periods to 6
- purge BLA backbone table when it is disabled
- make sure post function is invoked only if sysfs value is changed
- simplify code by removing useless NULL checks
- various corrections to existing kerneldoc
- minor cleanups
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 12f1501e ed21d170
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -115,14 +115,17 @@ The "bat0" interface can be used like any other regular inter-
face.  It needs an IP address which can be either statically con-
figured or dynamically (by using DHCP or similar services):

# NodeA: ifconfig bat0 192.168.0.1
# NodeB: ifconfig bat0 192.168.0.2
# NodeA: ip link set up dev bat0
# NodeA: ip addr add 192.168.0.1/24 dev bat0

# NodeB: ip link set up dev bat0
# NodeB: ip addr add 192.168.0.2/24 dev bat0
# NodeB: ping 192.168.0.1

Note:  In  order to avoid problems remove all IP addresses previ-
ously assigned to interfaces now used by batman advanced, e.g.

# ifconfig eth0 0.0.0.0
# ip addr flush dev eth0


LOGGING/DEBUGGING
+0 −3
Original line number Diff line number Diff line
@@ -361,7 +361,6 @@ batadv_iv_ogm_primary_iface_set(struct batadv_hard_iface *hard_iface)
	unsigned char *ogm_buff = hard_iface->bat_iv.ogm_buff;

	batadv_ogm_packet = (struct batadv_ogm_packet *)ogm_buff;
	batadv_ogm_packet->flags = BATADV_PRIMARIES_FIRST_HOP;
	batadv_ogm_packet->ttl = BATADV_TTL;
}

@@ -842,8 +841,6 @@ static void batadv_iv_ogm_forward(struct batadv_orig_node *orig_node,
		   "Forwarding packet: tq: %i, ttl: %i\n",
		   batadv_ogm_packet->tq, batadv_ogm_packet->ttl);

	/* switch of primaries first hop flag when forwarding */
	batadv_ogm_packet->flags &= ~BATADV_PRIMARIES_FIRST_HOP;
	if (is_single_hop_neigh)
		batadv_ogm_packet->flags |= BATADV_DIRECTLINK;
	else
+20 −0
Original line number Diff line number Diff line
@@ -1168,6 +1168,26 @@ void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
	}
}

/**
 * batadv_bla_status_update - purge bla interfaces if necessary
 * @net_dev: the soft interface net device
 */
void batadv_bla_status_update(struct net_device *net_dev)
{
	struct batadv_priv *bat_priv = netdev_priv(net_dev);
	struct batadv_hard_iface *primary_if;

	primary_if = batadv_primary_if_get_selected(bat_priv);
	if (!primary_if)
		return;

	/* this function already purges everything when bla is disabled,
	 * so just call that one.
	 */
	batadv_bla_update_orig_address(bat_priv, primary_if, primary_if);
	batadv_hardif_free_ref(primary_if);
}

/* periodic work to do:
 *  * purge structures when they are too old
 *  * send announcements
+2 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@

#include <linux/types.h>

struct net_device;
struct seq_file;
struct sk_buff;

@@ -42,6 +43,7 @@ int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
				    struct batadv_hard_iface *primary_if,
				    struct batadv_hard_iface *oldif);
void batadv_bla_status_update(struct net_device *net_dev);
int batadv_bla_init(struct batadv_priv *bat_priv);
void batadv_bla_free(struct batadv_priv *bat_priv);

+49 −68
Original line number Diff line number Diff line
@@ -31,27 +31,23 @@
#include "packet.h"

/**
 * batadv_parse_gw_bandwidth - parse supplied string buffer to extract download
 *  and upload bandwidth information
 * batadv_parse_throughput - parse supplied string buffer to extract throughput
 *  information
 * @net_dev: the soft interface net device
 * @buff: string buffer to parse
 * @down: pointer holding the returned download bandwidth information
 * @up: pointer holding the returned upload bandwidth information
 * @description: text shown when throughput string cannot be parsed
 * @throughput: pointer holding the returned throughput information
 *
 * Returns false on parse error and true otherwise.
 */
static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff,
				      u32 *down, u32 *up)
static bool batadv_parse_throughput(struct net_device *net_dev, char *buff,
				    const char *description, u32 *throughput)
{
	enum batadv_bandwidth_units bw_unit_type = BATADV_BW_UNIT_KBIT;
	char *slash_ptr, *tmp_ptr;
	u64 ldown, lup;
	u64 lthroughput;
	char *tmp_ptr;
	int ret;

	slash_ptr = strchr(buff, '/');
	if (slash_ptr)
		*slash_ptr = 0;

	if (strlen(buff) > 4) {
		tmp_ptr = buff + strlen(buff) - 4;

@@ -63,90 +59,75 @@ static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff,
			*tmp_ptr = '\0';
	}

	ret = kstrtou64(buff, 10, &ldown);
	ret = kstrtou64(buff, 10, &lthroughput);
	if (ret) {
		batadv_err(net_dev,
			   "Download speed of gateway mode invalid: %s\n",
			   buff);
			   "Invalid throughput speed for %s: %s\n",
			   description, buff);
		return false;
	}

	switch (bw_unit_type) {
	case BATADV_BW_UNIT_MBIT:
		/* prevent overflow */
		if (U64_MAX / 10 < ldown) {
		if (U64_MAX / 10 < lthroughput) {
			batadv_err(net_dev,
				   "Download speed of gateway mode too large: %s\n",
				   buff);
				   "Throughput speed for %s too large: %s\n",
				   description, buff);
			return false;
		}

		ldown *= 10;
		lthroughput *= 10;
		break;
	case BATADV_BW_UNIT_KBIT:
	default:
		ldown = div_u64(ldown, 100);
		lthroughput = div_u64(lthroughput, 100);
		break;
	}

	if (U32_MAX < ldown) {
	if (lthroughput > U32_MAX) {
		batadv_err(net_dev,
			   "Download speed of gateway mode too large: %s\n",
			   buff);
			   "Throughput speed for %s too large: %s\n",
			   description, buff);
		return false;
	}

	*down = ldown;

	/* we also got some upload info */
	if (slash_ptr) {
		bw_unit_type = BATADV_BW_UNIT_KBIT;

		if (strlen(slash_ptr + 1) > 4) {
			tmp_ptr = slash_ptr + 1 - 4 + strlen(slash_ptr + 1);

			if (strncasecmp(tmp_ptr, "mbit", 4) == 0)
				bw_unit_type = BATADV_BW_UNIT_MBIT;

			if ((strncasecmp(tmp_ptr, "kbit", 4) == 0) ||
			    (bw_unit_type == BATADV_BW_UNIT_MBIT))
				*tmp_ptr = '\0';
		}
	*throughput = lthroughput;

		ret = kstrtou64(slash_ptr + 1, 10, &lup);
		if (ret) {
			batadv_err(net_dev,
				   "Upload speed of gateway mode invalid: %s\n",
				   slash_ptr + 1);
			return false;
	return true;
}

		switch (bw_unit_type) {
		case BATADV_BW_UNIT_MBIT:
			/* prevent overflow */
			if (U64_MAX / 10 < lup) {
				batadv_err(net_dev,
					   "Upload speed of gateway mode too large: %s\n",
					   slash_ptr + 1);
				return false;
			}
/**
 * batadv_parse_gw_bandwidth - parse supplied string buffer to extract download
 *  and upload bandwidth information
 * @net_dev: the soft interface net device
 * @buff: string buffer to parse
 * @down: pointer holding the returned download bandwidth information
 * @up: pointer holding the returned upload bandwidth information
 *
 * Return: false on parse error and true otherwise.
 */
static bool batadv_parse_gw_bandwidth(struct net_device *net_dev, char *buff,
				      u32 *down, u32 *up)
{
	char *slash_ptr;
	bool ret;

			lup *= 10;
			break;
		case BATADV_BW_UNIT_KBIT:
		default:
			lup = div_u64(lup, 100);
			break;
		}
	slash_ptr = strchr(buff, '/');
	if (slash_ptr)
		*slash_ptr = 0;

		if (U32_MAX < lup) {
			batadv_err(net_dev,
				   "Upload speed of gateway mode too large: %s\n",
				   slash_ptr + 1);
	ret = batadv_parse_throughput(net_dev, buff, "download gateway speed",
				      down);
	if (!ret)
		return false;
		}

		*up = lup;
	/* we also got some upload info */
	if (slash_ptr) {
		ret = batadv_parse_throughput(net_dev, slash_ptr + 1,
					      "upload gateway speed", up);
		if (!ret)
			return false;
	}

	return true;
Loading