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

Commit cf88585b 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:
- remove useless skb size check in batadv_interface_rx
- basic netns support introduced by Andrew Lunn:
    - prevent virtual interface from changing netns by setting
      NETIF_F_NETNS_LOCAL
    - create virtual interface within the netns of the first
      hard-interface
- introduce detection of complex bridge loops and report event
  to the user (via udev) when the Bridge Loop Avoidance mechanism
  can't prevent them
- minor reference counting bugfixes for the hard_iface object that
  couldn't make it via the net tree
- use kref_get() instead of kref_get_unless_zero() to make reference
  counting bug more visible
- use batadv_compare_eth() all over the code when possible instead of
  plain memcmp()
- minor code cleanup and style adjustments
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 953abb38 676970e5
Loading
Loading
Loading
Loading
+26 −22
Original line number Original line Diff line number Diff line
@@ -681,18 +681,12 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff,
	unsigned char *skb_buff;
	unsigned char *skb_buff;
	unsigned int skb_size;
	unsigned int skb_size;


	if (!kref_get_unless_zero(&if_incoming->refcount))
		return;

	if (!kref_get_unless_zero(&if_outgoing->refcount))
		goto out_free_incoming;

	/* own packet should always be scheduled */
	/* own packet should always be scheduled */
	if (!own_packet) {
	if (!own_packet) {
		if (!batadv_atomic_dec_not_zero(&bat_priv->batman_queue_left)) {
		if (!batadv_atomic_dec_not_zero(&bat_priv->batman_queue_left)) {
			batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
			batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
				   "batman packet queue full\n");
				   "batman packet queue full\n");
			goto out_free_outgoing;
			return;
		}
		}
	}
	}


@@ -718,6 +712,8 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff,
	forw_packet_aggr->packet_len = packet_len;
	forw_packet_aggr->packet_len = packet_len;
	memcpy(skb_buff, packet_buff, packet_len);
	memcpy(skb_buff, packet_buff, packet_len);


	kref_get(&if_incoming->refcount);
	kref_get(&if_outgoing->refcount);
	forw_packet_aggr->own = own_packet;
	forw_packet_aggr->own = own_packet;
	forw_packet_aggr->if_incoming = if_incoming;
	forw_packet_aggr->if_incoming = if_incoming;
	forw_packet_aggr->if_outgoing = if_outgoing;
	forw_packet_aggr->if_outgoing = if_outgoing;
@@ -747,10 +743,6 @@ static void batadv_iv_ogm_aggregate_new(const unsigned char *packet_buff,
out_nomem:
out_nomem:
	if (!own_packet)
	if (!own_packet)
		atomic_inc(&bat_priv->batman_queue_left);
		atomic_inc(&bat_priv->batman_queue_left);
out_free_outgoing:
	batadv_hardif_put(if_outgoing);
out_free_incoming:
	batadv_hardif_put(if_incoming);
}
}


/* aggregate a new packet into the existing ogm packet */
/* aggregate a new packet into the existing ogm packet */
@@ -987,9 +979,15 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
	list_for_each_entry_rcu(tmp_hard_iface, &batadv_hardif_list, list) {
	list_for_each_entry_rcu(tmp_hard_iface, &batadv_hardif_list, list) {
		if (tmp_hard_iface->soft_iface != hard_iface->soft_iface)
		if (tmp_hard_iface->soft_iface != hard_iface->soft_iface)
			continue;
			continue;

		if (!kref_get_unless_zero(&tmp_hard_iface->refcount))
			continue;

		batadv_iv_ogm_queue_add(bat_priv, *ogm_buff,
		batadv_iv_ogm_queue_add(bat_priv, *ogm_buff,
					*ogm_buff_len, hard_iface,
					*ogm_buff_len, hard_iface,
					tmp_hard_iface, 1, send_time);
					tmp_hard_iface, 1, send_time);

		batadv_hardif_put(tmp_hard_iface);
	}
	}
	rcu_read_unlock();
	rcu_read_unlock();


@@ -1170,9 +1168,9 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
 * @if_incoming: interface where the packet was received
 * @if_incoming: interface where the packet was received
 * @if_outgoing: interface for which the retransmission should be considered
 * @if_outgoing: interface for which the retransmission should be considered
 *
 *
 * Return: 1 if the link can be considered bidirectional, 0 otherwise
 * Return: true if the link can be considered bidirectional, false otherwise
 */
 */
static int batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node,
static bool batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node,
				  struct batadv_orig_node *orig_neigh_node,
				  struct batadv_orig_node *orig_neigh_node,
				  struct batadv_ogm_packet *batadv_ogm_packet,
				  struct batadv_ogm_packet *batadv_ogm_packet,
				  struct batadv_hard_iface *if_incoming,
				  struct batadv_hard_iface *if_incoming,
@@ -1184,9 +1182,10 @@ static int batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node,
	u8 total_count;
	u8 total_count;
	u8 orig_eq_count, neigh_rq_count, neigh_rq_inv, tq_own;
	u8 orig_eq_count, neigh_rq_count, neigh_rq_inv, tq_own;
	unsigned int neigh_rq_inv_cube, neigh_rq_max_cube;
	unsigned int neigh_rq_inv_cube, neigh_rq_max_cube;
	int tq_asym_penalty, inv_asym_penalty, if_num, ret = 0;
	int tq_asym_penalty, inv_asym_penalty, if_num;
	unsigned int combined_tq;
	unsigned int combined_tq;
	int tq_iface_penalty;
	int tq_iface_penalty;
	bool ret = false;


	/* find corresponding one hop neighbor */
	/* find corresponding one hop neighbor */
	rcu_read_lock();
	rcu_read_lock();
@@ -1298,7 +1297,7 @@ static int batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node,
	 * consider it bidirectional
	 * consider it bidirectional
	 */
	 */
	if (batadv_ogm_packet->tq >= BATADV_TQ_TOTAL_BIDRECT_LIMIT)
	if (batadv_ogm_packet->tq >= BATADV_TQ_TOTAL_BIDRECT_LIMIT)
		ret = 1;
		ret = true;


out:
out:
	if (neigh_node)
	if (neigh_node)
@@ -1327,9 +1326,9 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
	struct batadv_orig_ifinfo *orig_ifinfo = NULL;
	struct batadv_orig_ifinfo *orig_ifinfo = NULL;
	struct batadv_neigh_node *neigh_node;
	struct batadv_neigh_node *neigh_node;
	struct batadv_neigh_ifinfo *neigh_ifinfo;
	struct batadv_neigh_ifinfo *neigh_ifinfo;
	int is_dup;
	bool is_dup;
	s32 seq_diff;
	s32 seq_diff;
	int need_update = 0;
	bool need_update = false;
	int set_mark;
	int set_mark;
	enum batadv_dup_status ret = BATADV_NO_DUP;
	enum batadv_dup_status ret = BATADV_NO_DUP;
	u32 seqno = ntohl(batadv_ogm_packet->seqno);
	u32 seqno = ntohl(batadv_ogm_packet->seqno);
@@ -1439,7 +1438,7 @@ batadv_iv_ogm_process_per_outif(const struct sk_buff *skb, int ogm_offset,
	struct sk_buff *skb_priv;
	struct sk_buff *skb_priv;
	struct ethhdr *ethhdr;
	struct ethhdr *ethhdr;
	u8 *prev_sender;
	u8 *prev_sender;
	int is_bidirect;
	bool is_bidirect;


	/* create a private copy of the skb, as some functions change tq value
	/* create a private copy of the skb, as some functions change tq value
	 * and/or flags.
	 * and/or flags.
@@ -1767,8 +1766,13 @@ static void batadv_iv_ogm_process(const struct sk_buff *skb, int ogm_offset,
		if (hard_iface->soft_iface != bat_priv->soft_iface)
		if (hard_iface->soft_iface != bat_priv->soft_iface)
			continue;
			continue;


		if (!kref_get_unless_zero(&hard_iface->refcount))
			continue;

		batadv_iv_ogm_process_per_outif(skb, ogm_offset, orig_node,
		batadv_iv_ogm_process_per_outif(skb, ogm_offset, orig_node,
						if_incoming, hard_iface);
						if_incoming, hard_iface);

		batadv_hardif_put(hard_iface);
	}
	}
	rcu_read_unlock();
	rcu_read_unlock();


+13 −1
Original line number Original line Diff line number Diff line
@@ -26,6 +26,7 @@
#include <linux/if_ether.h>
#include <linux/if_ether.h>
#include <linux/jiffies.h>
#include <linux/jiffies.h>
#include <linux/kernel.h>
#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/list.h>
#include <linux/netdevice.h>
#include <linux/netdevice.h>
#include <linux/random.h>
#include <linux/random.h>
@@ -176,6 +177,9 @@ static void batadv_v_ogm_send(struct work_struct *work)
		if (hard_iface->soft_iface != bat_priv->soft_iface)
		if (hard_iface->soft_iface != bat_priv->soft_iface)
			continue;
			continue;


		if (!kref_get_unless_zero(&hard_iface->refcount))
			continue;

		batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
		batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
			   "Sending own OGM2 packet (originator %pM, seqno %u, throughput %u, TTL %d) on interface %s [%pM]\n",
			   "Sending own OGM2 packet (originator %pM, seqno %u, throughput %u, TTL %d) on interface %s [%pM]\n",
			   ogm_packet->orig, ntohl(ogm_packet->seqno),
			   ogm_packet->orig, ntohl(ogm_packet->seqno),
@@ -185,10 +189,13 @@ static void batadv_v_ogm_send(struct work_struct *work)


		/* this skb gets consumed by batadv_v_ogm_send_to_if() */
		/* this skb gets consumed by batadv_v_ogm_send_to_if() */
		skb_tmp = skb_clone(skb, GFP_ATOMIC);
		skb_tmp = skb_clone(skb, GFP_ATOMIC);
		if (!skb_tmp)
		if (!skb_tmp) {
			batadv_hardif_put(hard_iface);
			break;
			break;
		}


		batadv_v_ogm_send_to_if(skb_tmp, hard_iface);
		batadv_v_ogm_send_to_if(skb_tmp, hard_iface);
		batadv_hardif_put(hard_iface);
	}
	}
	rcu_read_unlock();
	rcu_read_unlock();


@@ -704,9 +711,14 @@ static void batadv_v_ogm_process(const struct sk_buff *skb, int ogm_offset,
		if (hard_iface->soft_iface != bat_priv->soft_iface)
		if (hard_iface->soft_iface != bat_priv->soft_iface)
			continue;
			continue;


		if (!kref_get_unless_zero(&hard_iface->refcount))
			continue;

		batadv_v_ogm_process_per_outif(bat_priv, ethhdr, ogm_packet,
		batadv_v_ogm_process_per_outif(bat_priv, ethhdr, ogm_packet,
					       orig_node, neigh_node,
					       orig_node, neigh_node,
					       if_incoming, hard_iface);
					       if_incoming, hard_iface);

		batadv_hardif_put(hard_iface);
	}
	}
	rcu_read_unlock();
	rcu_read_unlock();
out:
out:
+8 −8
Original line number Original line Diff line number Diff line
@@ -38,11 +38,11 @@ static void batadv_bitmap_shift_left(unsigned long *seq_bits, s32 n)
 *  the last sequence number
 *  the last sequence number
 * @set_mark: whether this packet should be marked in seq_bits
 * @set_mark: whether this packet should be marked in seq_bits
 *
 *
 * Return: 1 if the window was moved (either new or very old),
 * Return: true if the window was moved (either new or very old),
 *  0 if the window was not moved/shifted.
 *  false if the window was not moved/shifted.
 */
 */
int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, s32 seq_num_diff,
bool batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
			  int set_mark)
			   s32 seq_num_diff, int set_mark)
{
{
	struct batadv_priv *bat_priv = priv;
	struct batadv_priv *bat_priv = priv;


@@ -52,7 +52,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, s32 seq_num_diff,
	if (seq_num_diff <= 0 && seq_num_diff > -BATADV_TQ_LOCAL_WINDOW_SIZE) {
	if (seq_num_diff <= 0 && seq_num_diff > -BATADV_TQ_LOCAL_WINDOW_SIZE) {
		if (set_mark)
		if (set_mark)
			batadv_set_bit(seq_bits, -seq_num_diff);
			batadv_set_bit(seq_bits, -seq_num_diff);
		return 0;
		return false;
	}
	}


	/* sequence number is slightly newer, so we shift the window and
	/* sequence number is slightly newer, so we shift the window and
@@ -63,7 +63,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, s32 seq_num_diff,


		if (set_mark)
		if (set_mark)
			batadv_set_bit(seq_bits, 0);
			batadv_set_bit(seq_bits, 0);
		return 1;
		return true;
	}
	}


	/* sequence number is much newer, probably missed a lot of packets */
	/* sequence number is much newer, probably missed a lot of packets */
@@ -75,7 +75,7 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, s32 seq_num_diff,
		bitmap_zero(seq_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
		bitmap_zero(seq_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
		if (set_mark)
		if (set_mark)
			batadv_set_bit(seq_bits, 0);
			batadv_set_bit(seq_bits, 0);
		return 1;
		return true;
	}
	}


	/* received a much older packet. The other host either restarted
	/* received a much older packet. The other host either restarted
@@ -94,5 +94,5 @@ int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, s32 seq_num_diff,
	if (set_mark)
	if (set_mark)
		batadv_set_bit(seq_bits, 0);
		batadv_set_bit(seq_bits, 0);


	return 1;
	return true;
}
}
+8 −7
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@


#include <linux/bitops.h>
#include <linux/bitops.h>
#include <linux/compiler.h>
#include <linux/compiler.h>
#include <linux/stddef.h>
#include <linux/types.h>
#include <linux/types.h>


/**
/**
@@ -31,17 +32,17 @@
 * @last_seqno: latest sequence number in seq_bits
 * @last_seqno: latest sequence number in seq_bits
 * @curr_seqno: sequence number to test for
 * @curr_seqno: sequence number to test for
 *
 *
 * Return: 1 if the corresponding bit in the given seq_bits indicates true
 * Return: true if the corresponding bit in the given seq_bits indicates true
 * and curr_seqno is within range of last_seqno. Otherwise returns 0.
 * and curr_seqno is within range of last_seqno. Otherwise returns false.
 */
 */
static inline int batadv_test_bit(const unsigned long *seq_bits,
static inline bool batadv_test_bit(const unsigned long *seq_bits,
				   u32 last_seqno, u32 curr_seqno)
				   u32 last_seqno, u32 curr_seqno)
{
{
	s32 diff;
	s32 diff;


	diff = last_seqno - curr_seqno;
	diff = last_seqno - curr_seqno;
	if (diff < 0 || diff >= BATADV_TQ_LOCAL_WINDOW_SIZE)
	if (diff < 0 || diff >= BATADV_TQ_LOCAL_WINDOW_SIZE)
		return 0;
		return false;
	return test_bit(diff, seq_bits) != 0;
	return test_bit(diff, seq_bits) != 0;
}
}


@@ -55,7 +56,7 @@ static inline void batadv_set_bit(unsigned long *seq_bits, s32 n)
	set_bit(n, seq_bits); /* turn the position on */
	set_bit(n, seq_bits); /* turn the position on */
}
}


int batadv_bit_get_packet(void *priv, unsigned long *seq_bits, s32 seq_num_diff,
bool batadv_bit_get_packet(void *priv, unsigned long *seq_bits,
			  int set_mark);
			   s32 seq_num_diff, int set_mark);


#endif /* _NET_BATMAN_ADV_BITARRAY_H_ */
#endif /* _NET_BATMAN_ADV_BITARRAY_H_ */
+227 −87
Original line number Original line Diff line number Diff line
@@ -50,6 +50,7 @@
#include "hash.h"
#include "hash.h"
#include "originator.h"
#include "originator.h"
#include "packet.h"
#include "packet.h"
#include "sysfs.h"
#include "translation-table.h"
#include "translation-table.h"


static const u8 batadv_announce_mac[4] = {0x43, 0x05, 0x43, 0x05};
static const u8 batadv_announce_mac[4] = {0x43, 0x05, 0x43, 0x05};
@@ -100,9 +101,9 @@ static inline u32 batadv_choose_backbone_gw(const void *data, u32 size)
 * @node: list node of the first entry to compare
 * @node: list node of the first entry to compare
 * @data2: pointer to the second backbone gateway
 * @data2: pointer to the second backbone gateway
 *
 *
 * Return: 1 if the backbones have the same data, 0 otherwise
 * Return: true if the backbones have the same data, false otherwise
 */
 */
static int batadv_compare_backbone_gw(const struct hlist_node *node,
static bool batadv_compare_backbone_gw(const struct hlist_node *node,
				       const void *data2)
				       const void *data2)
{
{
	const void *data1 = container_of(node, struct batadv_bla_backbone_gw,
	const void *data1 = container_of(node, struct batadv_bla_backbone_gw,
@@ -111,12 +112,12 @@ static int batadv_compare_backbone_gw(const struct hlist_node *node,
	const struct batadv_bla_backbone_gw *gw2 = data2;
	const struct batadv_bla_backbone_gw *gw2 = data2;


	if (!batadv_compare_eth(gw1->orig, gw2->orig))
	if (!batadv_compare_eth(gw1->orig, gw2->orig))
		return 0;
		return false;


	if (gw1->vid != gw2->vid)
	if (gw1->vid != gw2->vid)
		return 0;
		return false;


	return 1;
	return true;
}
}


/**
/**
@@ -124,9 +125,9 @@ static int batadv_compare_backbone_gw(const struct hlist_node *node,
 * @node: list node of the first entry to compare
 * @node: list node of the first entry to compare
 * @data2: pointer to the second claims
 * @data2: pointer to the second claims
 *
 *
 * Return: 1 if the claim have the same data, 0 otherwise
 * Return: true if the claim have the same data, 0 otherwise
 */
 */
static int batadv_compare_claim(const struct hlist_node *node,
static bool batadv_compare_claim(const struct hlist_node *node,
				 const void *data2)
				 const void *data2)
{
{
	const void *data1 = container_of(node, struct batadv_bla_claim,
	const void *data1 = container_of(node, struct batadv_bla_claim,
@@ -135,12 +136,12 @@ static int batadv_compare_claim(const struct hlist_node *node,
	const struct batadv_bla_claim *cl2 = data2;
	const struct batadv_bla_claim *cl2 = data2;


	if (!batadv_compare_eth(cl1->addr, cl2->addr))
	if (!batadv_compare_eth(cl1->addr, cl2->addr))
		return 0;
		return false;


	if (cl1->vid != cl2->vid)
	if (cl1->vid != cl2->vid)
		return 0;
		return false;


	return 1;
	return true;
}
}


/**
/**
@@ -407,6 +408,14 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, u8 *mac,
			   ethhdr->h_source, ethhdr->h_dest,
			   ethhdr->h_source, ethhdr->h_dest,
			   BATADV_PRINT_VID(vid));
			   BATADV_PRINT_VID(vid));
		break;
		break;
	case BATADV_CLAIM_TYPE_LOOPDETECT:
		ether_addr_copy(ethhdr->h_source, mac);
		batadv_dbg(BATADV_DBG_BLA, bat_priv,
			   "bla_send_claim(): LOOPDETECT of %pM to %pM on vid %d\n",
			   ethhdr->h_source, ethhdr->h_dest,
			   BATADV_PRINT_VID(vid));

		break;
	}
	}


	if (vid & BATADV_VLAN_HAS_TAG)
	if (vid & BATADV_VLAN_HAS_TAG)
@@ -426,6 +435,36 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, u8 *mac,
		batadv_hardif_put(primary_if);
		batadv_hardif_put(primary_if);
}
}


/**
 * batadv_bla_loopdetect_report - worker for reporting the loop
 * @work: work queue item
 *
 * Throws an uevent, as the loopdetect check function can't do that itself
 * since the kernel may sleep while throwing uevents.
 */
static void batadv_bla_loopdetect_report(struct work_struct *work)
{
	struct batadv_bla_backbone_gw *backbone_gw;
	struct batadv_priv *bat_priv;
	char vid_str[6] = { '\0' };

	backbone_gw = container_of(work, struct batadv_bla_backbone_gw,
				   report_work);
	bat_priv = backbone_gw->bat_priv;

	batadv_info(bat_priv->soft_iface,
		    "Possible loop on VLAN %d detected which can't be handled by BLA - please check your network setup!\n",
		    BATADV_PRINT_VID(backbone_gw->vid));
	snprintf(vid_str, sizeof(vid_str), "%d",
		 BATADV_PRINT_VID(backbone_gw->vid));
	vid_str[sizeof(vid_str) - 1] = 0;

	batadv_throw_uevent(bat_priv, BATADV_UEV_BLA, BATADV_UEV_LOOPDETECT,
			    vid_str);

	batadv_backbone_gw_put(backbone_gw);
}

/**
/**
 * batadv_bla_get_backbone_gw - finds or creates a backbone gateway
 * batadv_bla_get_backbone_gw - finds or creates a backbone gateway
 * @bat_priv: the bat priv with all the soft interface information
 * @bat_priv: the bat priv with all the soft interface information
@@ -464,6 +503,7 @@ batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, u8 *orig,
	atomic_set(&entry->request_sent, 0);
	atomic_set(&entry->request_sent, 0);
	atomic_set(&entry->wait_periods, 0);
	atomic_set(&entry->wait_periods, 0);
	ether_addr_copy(entry->orig, orig);
	ether_addr_copy(entry->orig, orig);
	INIT_WORK(&entry->report_work, batadv_bla_loopdetect_report);


	/* one for the hash, one for returning */
	/* one for the hash, one for returning */
	kref_init(&entry->refcount);
	kref_init(&entry->refcount);
@@ -735,22 +775,22 @@ static void batadv_bla_del_claim(struct batadv_priv *bat_priv,
 * @backbone_addr: originator address of the sender (Ethernet source MAC)
 * @backbone_addr: originator address of the sender (Ethernet source MAC)
 * @vid: the VLAN ID of the frame
 * @vid: the VLAN ID of the frame
 *
 *
 * Return: 1 if handled
 * Return: true if handled
 */
 */
static int batadv_handle_announce(struct batadv_priv *bat_priv, u8 *an_addr,
static bool batadv_handle_announce(struct batadv_priv *bat_priv, u8 *an_addr,
				   u8 *backbone_addr, unsigned short vid)
				   u8 *backbone_addr, unsigned short vid)
{
{
	struct batadv_bla_backbone_gw *backbone_gw;
	struct batadv_bla_backbone_gw *backbone_gw;
	u16 backbone_crc, crc;
	u16 backbone_crc, crc;


	if (memcmp(an_addr, batadv_announce_mac, 4) != 0)
	if (memcmp(an_addr, batadv_announce_mac, 4) != 0)
		return 0;
		return false;


	backbone_gw = batadv_bla_get_backbone_gw(bat_priv, backbone_addr, vid,
	backbone_gw = batadv_bla_get_backbone_gw(bat_priv, backbone_addr, vid,
						 false);
						 false);


	if (unlikely(!backbone_gw))
	if (unlikely(!backbone_gw))
		return 1;
		return true;


	/* handle as ANNOUNCE frame */
	/* handle as ANNOUNCE frame */
	backbone_gw->lasttime = jiffies;
	backbone_gw->lasttime = jiffies;
@@ -783,7 +823,7 @@ static int batadv_handle_announce(struct batadv_priv *bat_priv, u8 *an_addr,
	}
	}


	batadv_backbone_gw_put(backbone_gw);
	batadv_backbone_gw_put(backbone_gw);
	return 1;
	return true;
}
}


/**
/**
@@ -794,29 +834,29 @@ static int batadv_handle_announce(struct batadv_priv *bat_priv, u8 *an_addr,
 * @ethhdr: ethernet header of a packet
 * @ethhdr: ethernet header of a packet
 * @vid: the VLAN ID of the frame
 * @vid: the VLAN ID of the frame
 *
 *
 * Return: 1 if handled
 * Return: true if handled
 */
 */
static int batadv_handle_request(struct batadv_priv *bat_priv,
static bool batadv_handle_request(struct batadv_priv *bat_priv,
				  struct batadv_hard_iface *primary_if,
				  struct batadv_hard_iface *primary_if,
				  u8 *backbone_addr, struct ethhdr *ethhdr,
				  u8 *backbone_addr, struct ethhdr *ethhdr,
				  unsigned short vid)
				  unsigned short vid)
{
{
	/* check for REQUEST frame */
	/* check for REQUEST frame */
	if (!batadv_compare_eth(backbone_addr, ethhdr->h_dest))
	if (!batadv_compare_eth(backbone_addr, ethhdr->h_dest))
		return 0;
		return false;


	/* sanity check, this should not happen on a normal switch,
	/* sanity check, this should not happen on a normal switch,
	 * we ignore it in this case.
	 * we ignore it in this case.
	 */
	 */
	if (!batadv_compare_eth(ethhdr->h_dest, primary_if->net_dev->dev_addr))
	if (!batadv_compare_eth(ethhdr->h_dest, primary_if->net_dev->dev_addr))
		return 1;
		return true;


	batadv_dbg(BATADV_DBG_BLA, bat_priv,
	batadv_dbg(BATADV_DBG_BLA, bat_priv,
		   "handle_request(): REQUEST vid %d (sent by %pM)...\n",
		   "handle_request(): REQUEST vid %d (sent by %pM)...\n",
		   BATADV_PRINT_VID(vid), ethhdr->h_source);
		   BATADV_PRINT_VID(vid), ethhdr->h_source);


	batadv_bla_answer_request(bat_priv, primary_if, vid);
	batadv_bla_answer_request(bat_priv, primary_if, vid);
	return 1;
	return true;
}
}


/**
/**
@@ -827,9 +867,9 @@ static int batadv_handle_request(struct batadv_priv *bat_priv,
 * @claim_addr: Client to be unclaimed (ARP sender HW MAC)
 * @claim_addr: Client to be unclaimed (ARP sender HW MAC)
 * @vid: the VLAN ID of the frame
 * @vid: the VLAN ID of the frame
 *
 *
 * Return: 1 if handled
 * Return: true if handled
 */
 */
static int batadv_handle_unclaim(struct batadv_priv *bat_priv,
static bool batadv_handle_unclaim(struct batadv_priv *bat_priv,
				  struct batadv_hard_iface *primary_if,
				  struct batadv_hard_iface *primary_if,
				  u8 *backbone_addr, u8 *claim_addr,
				  u8 *backbone_addr, u8 *claim_addr,
				  unsigned short vid)
				  unsigned short vid)
@@ -845,7 +885,7 @@ static int batadv_handle_unclaim(struct batadv_priv *bat_priv,
	backbone_gw = batadv_backbone_hash_find(bat_priv, backbone_addr, vid);
	backbone_gw = batadv_backbone_hash_find(bat_priv, backbone_addr, vid);


	if (!backbone_gw)
	if (!backbone_gw)
		return 1;
		return true;


	/* this must be an UNCLAIM frame */
	/* this must be an UNCLAIM frame */
	batadv_dbg(BATADV_DBG_BLA, bat_priv,
	batadv_dbg(BATADV_DBG_BLA, bat_priv,
@@ -854,7 +894,7 @@ static int batadv_handle_unclaim(struct batadv_priv *bat_priv,


	batadv_bla_del_claim(bat_priv, claim_addr, vid);
	batadv_bla_del_claim(bat_priv, claim_addr, vid);
	batadv_backbone_gw_put(backbone_gw);
	batadv_backbone_gw_put(backbone_gw);
	return 1;
	return true;
}
}


/**
/**
@@ -865,9 +905,9 @@ static int batadv_handle_unclaim(struct batadv_priv *bat_priv,
 * @claim_addr: client mac address to be claimed (ARP sender HW MAC)
 * @claim_addr: client mac address to be claimed (ARP sender HW MAC)
 * @vid: the VLAN ID of the frame
 * @vid: the VLAN ID of the frame
 *
 *
 * Return: 1 if handled
 * Return: true if handled
 */
 */
static int batadv_handle_claim(struct batadv_priv *bat_priv,
static bool batadv_handle_claim(struct batadv_priv *bat_priv,
				struct batadv_hard_iface *primary_if,
				struct batadv_hard_iface *primary_if,
				u8 *backbone_addr, u8 *claim_addr,
				u8 *backbone_addr, u8 *claim_addr,
				unsigned short vid)
				unsigned short vid)
@@ -880,7 +920,7 @@ static int batadv_handle_claim(struct batadv_priv *bat_priv,
						 false);
						 false);


	if (unlikely(!backbone_gw))
	if (unlikely(!backbone_gw))
		return 1;
		return true;


	/* this must be a CLAIM frame */
	/* this must be a CLAIM frame */
	batadv_bla_add_claim(bat_priv, claim_addr, vid, backbone_gw);
	batadv_bla_add_claim(bat_priv, claim_addr, vid, backbone_gw);
@@ -891,7 +931,7 @@ static int batadv_handle_claim(struct batadv_priv *bat_priv,
	/* TODO: we could call something like tt_local_del() here. */
	/* TODO: we could call something like tt_local_del() here. */


	batadv_backbone_gw_put(backbone_gw);
	batadv_backbone_gw_put(backbone_gw);
	return 1;
	return true;
}
}


/**
/**
@@ -975,10 +1015,10 @@ static int batadv_check_claim_group(struct batadv_priv *bat_priv,
 * @primary_if: the primary hard interface of this batman soft interface
 * @primary_if: the primary hard interface of this batman soft interface
 * @skb: the frame to be checked
 * @skb: the frame to be checked
 *
 *
 * Return: 1 if it was a claim frame, otherwise return 0 to
 * Return: true if it was a claim frame, otherwise return false to
 * tell the callee that it can use the frame on its own.
 * tell the callee that it can use the frame on its own.
 */
 */
static int batadv_bla_process_claim(struct batadv_priv *bat_priv,
static bool batadv_bla_process_claim(struct batadv_priv *bat_priv,
				     struct batadv_hard_iface *primary_if,
				     struct batadv_hard_iface *primary_if,
				     struct sk_buff *skb)
				     struct sk_buff *skb)
{
{
@@ -1011,7 +1051,7 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv,
			vhdr = skb_header_pointer(skb, headlen, VLAN_HLEN,
			vhdr = skb_header_pointer(skb, headlen, VLAN_HLEN,
						  &vhdr_buf);
						  &vhdr_buf);
			if (!vhdr)
			if (!vhdr)
				return 0;
				return false;


			proto = vhdr->h_vlan_encapsulated_proto;
			proto = vhdr->h_vlan_encapsulated_proto;
			headlen += VLAN_HLEN;
			headlen += VLAN_HLEN;
@@ -1020,12 +1060,12 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv,
	}
	}


	if (proto != htons(ETH_P_ARP))
	if (proto != htons(ETH_P_ARP))
		return 0; /* not a claim frame */
		return false; /* not a claim frame */


	/* this must be a ARP frame. check if it is a claim. */
	/* this must be a ARP frame. check if it is a claim. */


	if (unlikely(!pskb_may_pull(skb, headlen + arp_hdr_len(skb->dev))))
	if (unlikely(!pskb_may_pull(skb, headlen + arp_hdr_len(skb->dev))))
		return 0;
		return false;


	/* pskb_may_pull() may have modified the pointers, get ethhdr again */
	/* pskb_may_pull() may have modified the pointers, get ethhdr again */
	ethhdr = eth_hdr(skb);
	ethhdr = eth_hdr(skb);
@@ -1035,13 +1075,13 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv,
	 * IP information
	 * IP information
	 */
	 */
	if (arphdr->ar_hrd != htons(ARPHRD_ETHER))
	if (arphdr->ar_hrd != htons(ARPHRD_ETHER))
		return 0;
		return false;
	if (arphdr->ar_pro != htons(ETH_P_IP))
	if (arphdr->ar_pro != htons(ETH_P_IP))
		return 0;
		return false;
	if (arphdr->ar_hln != ETH_ALEN)
	if (arphdr->ar_hln != ETH_ALEN)
		return 0;
		return false;
	if (arphdr->ar_pln != 4)
	if (arphdr->ar_pln != 4)
		return 0;
		return false;


	hw_src = (u8 *)arphdr + sizeof(struct arphdr);
	hw_src = (u8 *)arphdr + sizeof(struct arphdr);
	hw_dst = hw_src + ETH_ALEN + 4;
	hw_dst = hw_src + ETH_ALEN + 4;
@@ -1051,14 +1091,18 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv,
	/* check if it is a claim frame in general */
	/* check if it is a claim frame in general */
	if (memcmp(bla_dst->magic, bla_dst_own->magic,
	if (memcmp(bla_dst->magic, bla_dst_own->magic,
		   sizeof(bla_dst->magic)) != 0)
		   sizeof(bla_dst->magic)) != 0)
		return 0;
		return false;


	/* check if there is a claim frame encapsulated deeper in (QinQ) and
	/* check if there is a claim frame encapsulated deeper in (QinQ) and
	 * drop that, as this is not supported by BLA but should also not be
	 * drop that, as this is not supported by BLA but should also not be
	 * sent via the mesh.
	 * sent via the mesh.
	 */
	 */
	if (vlan_depth > 1)
	if (vlan_depth > 1)
		return 1;
		return true;

	/* Let the loopdetect frames on the mesh in any case. */
	if (bla_dst->type == BATADV_CLAIM_TYPE_LOOPDETECT)
		return 0;


	/* check if it is a claim frame. */
	/* check if it is a claim frame. */
	ret = batadv_check_claim_group(bat_priv, primary_if, hw_src, hw_dst,
	ret = batadv_check_claim_group(bat_priv, primary_if, hw_src, hw_dst,
@@ -1070,7 +1114,7 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv,
			   hw_dst);
			   hw_dst);


	if (ret < 2)
	if (ret < 2)
		return ret;
		return !!ret;


	/* become a backbone gw ourselves on this vlan if not happened yet */
	/* become a backbone gw ourselves on this vlan if not happened yet */
	batadv_bla_update_own_backbone_gw(bat_priv, primary_if, vid);
	batadv_bla_update_own_backbone_gw(bat_priv, primary_if, vid);
@@ -1080,30 +1124,30 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv,
	case BATADV_CLAIM_TYPE_CLAIM:
	case BATADV_CLAIM_TYPE_CLAIM:
		if (batadv_handle_claim(bat_priv, primary_if, hw_src,
		if (batadv_handle_claim(bat_priv, primary_if, hw_src,
					ethhdr->h_source, vid))
					ethhdr->h_source, vid))
			return 1;
			return true;
		break;
		break;
	case BATADV_CLAIM_TYPE_UNCLAIM:
	case BATADV_CLAIM_TYPE_UNCLAIM:
		if (batadv_handle_unclaim(bat_priv, primary_if,
		if (batadv_handle_unclaim(bat_priv, primary_if,
					  ethhdr->h_source, hw_src, vid))
					  ethhdr->h_source, hw_src, vid))
			return 1;
			return true;
		break;
		break;


	case BATADV_CLAIM_TYPE_ANNOUNCE:
	case BATADV_CLAIM_TYPE_ANNOUNCE:
		if (batadv_handle_announce(bat_priv, hw_src, ethhdr->h_source,
		if (batadv_handle_announce(bat_priv, hw_src, ethhdr->h_source,
					   vid))
					   vid))
			return 1;
			return true;
		break;
		break;
	case BATADV_CLAIM_TYPE_REQUEST:
	case BATADV_CLAIM_TYPE_REQUEST:
		if (batadv_handle_request(bat_priv, primary_if, hw_src, ethhdr,
		if (batadv_handle_request(bat_priv, primary_if, hw_src, ethhdr,
					  vid))
					  vid))
			return 1;
			return true;
		break;
		break;
	}
	}


	batadv_dbg(BATADV_DBG_BLA, bat_priv,
	batadv_dbg(BATADV_DBG_BLA, bat_priv,
		   "bla_process_claim(): ERROR - this looks like a claim frame, but is useless. eth src %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n",
		   "bla_process_claim(): ERROR - this looks like a claim frame, but is useless. eth src %pM on vid %d ...(hw_src %pM, hw_dst %pM)\n",
		   ethhdr->h_source, BATADV_PRINT_VID(vid), hw_src, hw_dst);
		   ethhdr->h_source, BATADV_PRINT_VID(vid), hw_src, hw_dst);
	return 1;
	return true;
}
}


/**
/**
@@ -1264,6 +1308,26 @@ void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
	}
	}
}
}


/**
 * batadv_bla_send_loopdetect - send a loopdetect frame
 * @bat_priv: the bat priv with all the soft interface information
 * @backbone_gw: the backbone gateway for which a loop should be detected
 *
 * To detect loops that the bridge loop avoidance can't handle, send a loop
 * detection packet on the backbone. Unlike other BLA frames, this frame will
 * be allowed on the mesh by other nodes. If it is received on the mesh, this
 * indicates that there is a loop.
 */
static void
batadv_bla_send_loopdetect(struct batadv_priv *bat_priv,
			   struct batadv_bla_backbone_gw *backbone_gw)
{
	batadv_dbg(BATADV_DBG_BLA, bat_priv, "Send loopdetect frame for vid %d\n",
		   backbone_gw->vid);
	batadv_bla_send_claim(bat_priv, bat_priv->bla.loopdetect_addr,
			      backbone_gw->vid, BATADV_CLAIM_TYPE_LOOPDETECT);
}

/**
/**
 * batadv_bla_status_update - purge bla interfaces if necessary
 * batadv_bla_status_update - purge bla interfaces if necessary
 * @net_dev: the soft interface net device
 * @net_dev: the soft interface net device
@@ -1301,6 +1365,7 @@ static void batadv_bla_periodic_work(struct work_struct *work)
	struct batadv_bla_backbone_gw *backbone_gw;
	struct batadv_bla_backbone_gw *backbone_gw;
	struct batadv_hashtable *hash;
	struct batadv_hashtable *hash;
	struct batadv_hard_iface *primary_if;
	struct batadv_hard_iface *primary_if;
	bool send_loopdetect = false;
	int i;
	int i;


	delayed_work = to_delayed_work(work);
	delayed_work = to_delayed_work(work);
@@ -1316,6 +1381,22 @@ static void batadv_bla_periodic_work(struct work_struct *work)
	if (!atomic_read(&bat_priv->bridge_loop_avoidance))
	if (!atomic_read(&bat_priv->bridge_loop_avoidance))
		goto out;
		goto out;


	if (atomic_dec_and_test(&bat_priv->bla.loopdetect_next)) {
		/* set a new random mac address for the next bridge loop
		 * detection frames. Set the locally administered bit to avoid
		 * collisions with users mac addresses.
		 */
		random_ether_addr(bat_priv->bla.loopdetect_addr);
		bat_priv->bla.loopdetect_addr[0] = 0xba;
		bat_priv->bla.loopdetect_addr[1] = 0xbe;
		bat_priv->bla.loopdetect_lasttime = jiffies;
		atomic_set(&bat_priv->bla.loopdetect_next,
			   BATADV_BLA_LOOPDETECT_PERIODS);

		/* mark for sending loop detect on all VLANs */
		send_loopdetect = true;
	}

	hash = bat_priv->bla.backbone_hash;
	hash = bat_priv->bla.backbone_hash;
	if (!hash)
	if (!hash)
		goto out;
		goto out;
@@ -1332,6 +1413,9 @@ static void batadv_bla_periodic_work(struct work_struct *work)
			backbone_gw->lasttime = jiffies;
			backbone_gw->lasttime = jiffies;


			batadv_bla_send_announce(bat_priv, backbone_gw);
			batadv_bla_send_announce(bat_priv, backbone_gw);
			if (send_loopdetect)
				batadv_bla_send_loopdetect(bat_priv,
							   backbone_gw);


			/* request_sent is only set after creation to avoid
			/* request_sent is only set after creation to avoid
			 * problems when we are not yet known as backbone gw
			 * problems when we are not yet known as backbone gw
@@ -1405,6 +1489,9 @@ int batadv_bla_init(struct batadv_priv *bat_priv)
		bat_priv->bla.bcast_duplist[i].entrytime = entrytime;
		bat_priv->bla.bcast_duplist[i].entrytime = entrytime;
	bat_priv->bla.bcast_duplist_curr = 0;
	bat_priv->bla.bcast_duplist_curr = 0;


	atomic_set(&bat_priv->bla.loopdetect_next,
		   BATADV_BLA_LOOPDETECT_PERIODS);

	if (bat_priv->bla.claim_hash)
	if (bat_priv->bla.claim_hash)
		return 0;
		return 0;


@@ -1442,15 +1529,16 @@ int batadv_bla_init(struct batadv_priv *bat_priv)
 * sent by another host, drop it. We allow equal packets from
 * sent by another host, drop it. We allow equal packets from
 * the same host however as this might be intended.
 * the same host however as this might be intended.
 *
 *
 * Return: 1 if a packet is in the duplicate list, 0 otherwise.
 * Return: true if a packet is in the duplicate list, false otherwise.
 */
 */
int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
				    struct sk_buff *skb)
				    struct sk_buff *skb)
{
{
	int i, curr, ret = 0;
	int i, curr;
	__be32 crc;
	__be32 crc;
	struct batadv_bcast_packet *bcast_packet;
	struct batadv_bcast_packet *bcast_packet;
	struct batadv_bcast_duplist_entry *entry;
	struct batadv_bcast_duplist_entry *entry;
	bool ret = false;


	bcast_packet = (struct batadv_bcast_packet *)skb->data;
	bcast_packet = (struct batadv_bcast_packet *)skb->data;


@@ -1478,9 +1566,9 @@ int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
			continue;
			continue;


		/* this entry seems to match: same crc, not too old,
		/* this entry seems to match: same crc, not too old,
		 * and from another gw. therefore return 1 to forbid it.
		 * and from another gw. therefore return true to forbid it.
		 */
		 */
		ret = 1;
		ret = true;
		goto out;
		goto out;
	}
	}
	/* not found, add a new entry (overwrite the oldest entry)
	/* not found, add a new entry (overwrite the oldest entry)
@@ -1546,21 +1634,21 @@ bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, u8 *orig,
 * @orig_node: the orig_node of the frame
 * @orig_node: the orig_node of the frame
 * @hdr_size: maximum length of the frame
 * @hdr_size: maximum length of the frame
 *
 *
 * Return: 1 if the orig_node is also a gateway on the soft interface, otherwise
 * Return: true if the orig_node is also a gateway on the soft interface,
 * it returns 0.
 * otherwise it returns false.
 */
 */
int batadv_bla_is_backbone_gw(struct sk_buff *skb,
bool batadv_bla_is_backbone_gw(struct sk_buff *skb,
			       struct batadv_orig_node *orig_node, int hdr_size)
			       struct batadv_orig_node *orig_node, int hdr_size)
{
{
	struct batadv_bla_backbone_gw *backbone_gw;
	struct batadv_bla_backbone_gw *backbone_gw;
	unsigned short vid;
	unsigned short vid;


	if (!atomic_read(&orig_node->bat_priv->bridge_loop_avoidance))
	if (!atomic_read(&orig_node->bat_priv->bridge_loop_avoidance))
		return 0;
		return false;


	/* first, find out the vid. */
	/* first, find out the vid. */
	if (!pskb_may_pull(skb, hdr_size + ETH_HLEN))
	if (!pskb_may_pull(skb, hdr_size + ETH_HLEN))
		return 0;
		return false;


	vid = batadv_get_vid(skb, hdr_size);
	vid = batadv_get_vid(skb, hdr_size);


@@ -1568,10 +1656,10 @@ int batadv_bla_is_backbone_gw(struct sk_buff *skb,
	backbone_gw = batadv_backbone_hash_find(orig_node->bat_priv,
	backbone_gw = batadv_backbone_hash_find(orig_node->bat_priv,
						orig_node->orig, vid);
						orig_node->orig, vid);
	if (!backbone_gw)
	if (!backbone_gw)
		return 0;
		return false;


	batadv_backbone_gw_put(backbone_gw);
	batadv_backbone_gw_put(backbone_gw);
	return 1;
	return true;
}
}


/**
/**
@@ -1601,6 +1689,55 @@ void batadv_bla_free(struct batadv_priv *bat_priv)
		batadv_hardif_put(primary_if);
		batadv_hardif_put(primary_if);
}
}


/**
 * batadv_bla_loopdetect_check - check and handle a detected loop
 * @bat_priv: the bat priv with all the soft interface information
 * @skb: the packet to check
 * @primary_if: interface where the request came on
 * @vid: the VLAN ID of the frame
 *
 * Checks if this packet is a loop detect frame which has been sent by us,
 * throw an uevent and log the event if that is the case.
 *
 * Return: true if it is a loop detect frame which is to be dropped, false
 * otherwise.
 */
static bool
batadv_bla_loopdetect_check(struct batadv_priv *bat_priv, struct sk_buff *skb,
			    struct batadv_hard_iface *primary_if,
			    unsigned short vid)
{
	struct batadv_bla_backbone_gw *backbone_gw;
	struct ethhdr *ethhdr;

	ethhdr = eth_hdr(skb);

	/* Only check for the MAC address and skip more checks here for
	 * performance reasons - this function is on the hotpath, after all.
	 */
	if (!batadv_compare_eth(ethhdr->h_source,
				bat_priv->bla.loopdetect_addr))
		return false;

	/* If the packet came too late, don't forward it on the mesh
	 * but don't consider that as loop. It might be a coincidence.
	 */
	if (batadv_has_timed_out(bat_priv->bla.loopdetect_lasttime,
				 BATADV_BLA_LOOPDETECT_TIMEOUT))
		return true;

	backbone_gw = batadv_bla_get_backbone_gw(bat_priv,
						 primary_if->net_dev->dev_addr,
						 vid, true);
	if (unlikely(!backbone_gw))
		return true;

	queue_work(batadv_event_workqueue, &backbone_gw->report_work);
	/* backbone_gw is unreferenced in the report work function function */

	return true;
}

/**
/**
 * batadv_bla_rx - check packets coming from the mesh.
 * batadv_bla_rx - check packets coming from the mesh.
 * @bat_priv: the bat priv with all the soft interface information
 * @bat_priv: the bat priv with all the soft interface information
@@ -1614,16 +1751,16 @@ void batadv_bla_free(struct batadv_priv *bat_priv)
 *
 *
 * in these cases, the skb is further handled by this function
 * in these cases, the skb is further handled by this function
 *
 *
 * Return: 1 if handled, otherwise it returns 0 and the caller shall further
 * Return: true if handled, otherwise it returns false and the caller shall
 * process the skb.
 * further process the skb.
 */
 */
int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
		   unsigned short vid, bool is_bcast)
		   unsigned short vid, bool is_bcast)
{
{
	struct ethhdr *ethhdr;
	struct ethhdr *ethhdr;
	struct batadv_bla_claim search_claim, *claim = NULL;
	struct batadv_bla_claim search_claim, *claim = NULL;
	struct batadv_hard_iface *primary_if;
	struct batadv_hard_iface *primary_if;
	int ret;
	bool ret;


	ethhdr = eth_hdr(skb);
	ethhdr = eth_hdr(skb);


@@ -1634,6 +1771,9 @@ int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
	if (!atomic_read(&bat_priv->bridge_loop_avoidance))
	if (!atomic_read(&bat_priv->bridge_loop_avoidance))
		goto allow;
		goto allow;


	if (batadv_bla_loopdetect_check(bat_priv, skb, primary_if, vid))
		goto handled;

	if (unlikely(atomic_read(&bat_priv->bla.num_requests)))
	if (unlikely(atomic_read(&bat_priv->bla.num_requests)))
		/* don't allow broadcasts while requests are in flight */
		/* don't allow broadcasts while requests are in flight */
		if (is_multicast_ether_addr(ethhdr->h_dest) && is_bcast)
		if (is_multicast_ether_addr(ethhdr->h_dest) && is_bcast)
@@ -1682,12 +1822,12 @@ int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
	}
	}
allow:
allow:
	batadv_bla_update_own_backbone_gw(bat_priv, primary_if, vid);
	batadv_bla_update_own_backbone_gw(bat_priv, primary_if, vid);
	ret = 0;
	ret = false;
	goto out;
	goto out;


handled:
handled:
	kfree_skb(skb);
	kfree_skb(skb);
	ret = 1;
	ret = true;


out:
out:
	if (primary_if)
	if (primary_if)
@@ -1711,16 +1851,16 @@ int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
 *
 *
 * This call might reallocate skb data.
 * This call might reallocate skb data.
 *
 *
 * Return: 1 if handled, otherwise it returns 0 and the caller shall further
 * Return: true if handled, otherwise it returns false and the caller shall
 * process the skb.
 * further process the skb.
 */
 */
int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
bool batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
		   unsigned short vid)
		   unsigned short vid)
{
{
	struct ethhdr *ethhdr;
	struct ethhdr *ethhdr;
	struct batadv_bla_claim search_claim, *claim = NULL;
	struct batadv_bla_claim search_claim, *claim = NULL;
	struct batadv_hard_iface *primary_if;
	struct batadv_hard_iface *primary_if;
	int ret = 0;
	bool ret = false;


	primary_if = batadv_primary_if_get_selected(bat_priv);
	primary_if = batadv_primary_if_get_selected(bat_priv);
	if (!primary_if)
	if (!primary_if)
@@ -1774,10 +1914,10 @@ int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
	}
	}
allow:
allow:
	batadv_bla_update_own_backbone_gw(bat_priv, primary_if, vid);
	batadv_bla_update_own_backbone_gw(bat_priv, primary_if, vid);
	ret = 0;
	ret = false;
	goto out;
	goto out;
handled:
handled:
	ret = 1;
	ret = true;
out:
out:
	if (primary_if)
	if (primary_if)
		batadv_hardif_put(primary_if);
		batadv_hardif_put(primary_if);
Loading