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

Commit e6e94e39 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:
- a set of codestyle rearrangements/fixes
- new feature to early detect new joining (mesh-unaware) clients
- a minor fix for the gw-feature
- substitution of shift operations with the BIT() macro
- reorganization of the main batman-adv structure (struct batadv_priv)
- some more (very) minor cleanups and fixes
===================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents f63c45e0 fa4f0afc
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -76,8 +76,9 @@ folder:
There is a special folder for debugging information:
There is a special folder for debugging information:


# ls /sys/kernel/debug/batman_adv/bat0/
# ls /sys/kernel/debug/batman_adv/bat0/
# bla_claim_table    log                socket             transtable_local
# bla_backbone_table  log                 transtable_global
# gateways           originators        transtable_global  vis_data
# bla_claim_table     originators         transtable_local
# gateways            socket              vis_data


Some of the files contain all sort of status information  regard-
Some of the files contain all sort of status information  regard-
ing  the  mesh  network.  For  example, you can view the table of
ing  the  mesh  network.  For  example, you can view the table of
+56 −40
Original line number Original line Diff line number Diff line
@@ -166,13 +166,15 @@ static void batadv_iv_ogm_send_to_if(struct batadv_forw_packet *forw_packet,
	int16_t buff_pos;
	int16_t buff_pos;
	struct batadv_ogm_packet *batadv_ogm_packet;
	struct batadv_ogm_packet *batadv_ogm_packet;
	struct sk_buff *skb;
	struct sk_buff *skb;
	uint8_t *packet_pos;


	if (hard_iface->if_status != BATADV_IF_ACTIVE)
	if (hard_iface->if_status != BATADV_IF_ACTIVE)
		return;
		return;


	packet_num = 0;
	packet_num = 0;
	buff_pos = 0;
	buff_pos = 0;
	batadv_ogm_packet = (struct batadv_ogm_packet *)forw_packet->skb->data;
	packet_pos = forw_packet->skb->data;
	batadv_ogm_packet = (struct batadv_ogm_packet *)packet_pos;


	/* adjust all flags and log packets */
	/* adjust all flags and log packets */
	while (batadv_iv_ogm_aggr_packet(buff_pos, forw_packet->packet_len,
	while (batadv_iv_ogm_aggr_packet(buff_pos, forw_packet->packet_len,
@@ -181,15 +183,17 @@ static void batadv_iv_ogm_send_to_if(struct batadv_forw_packet *forw_packet,
		/* we might have aggregated direct link packets with an
		/* we might have aggregated direct link packets with an
		 * ordinary base packet
		 * ordinary base packet
		 */
		 */
		if ((forw_packet->direct_link_flags & (1 << packet_num)) &&
		if (forw_packet->direct_link_flags & BIT(packet_num) &&
		    (forw_packet->if_incoming == hard_iface))
		    forw_packet->if_incoming == hard_iface)
			batadv_ogm_packet->flags |= BATADV_DIRECTLINK;
			batadv_ogm_packet->flags |= BATADV_DIRECTLINK;
		else
		else
			batadv_ogm_packet->flags &= ~BATADV_DIRECTLINK;
			batadv_ogm_packet->flags &= ~BATADV_DIRECTLINK;


		fwd_str = (packet_num > 0 ? "Forwarding" : (forw_packet->own ?
		if (packet_num > 0 || !forw_packet->own)
							    "Sending own" :
			fwd_str = "Forwarding";
							    "Forwarding"));
		else
			fwd_str = "Sending own";

		batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
		batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
			   "%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d, IDF %s, ttvn %d) on interface %s [%pM]\n",
			   "%s %spacket (originator %pM, seqno %u, TQ %d, TTL %d, IDF %s, ttvn %d) on interface %s [%pM]\n",
			   fwd_str, (packet_num > 0 ? "aggregated " : ""),
			   fwd_str, (packet_num > 0 ? "aggregated " : ""),
@@ -204,8 +208,8 @@ static void batadv_iv_ogm_send_to_if(struct batadv_forw_packet *forw_packet,
		buff_pos += BATADV_OGM_HLEN;
		buff_pos += BATADV_OGM_HLEN;
		buff_pos += batadv_tt_len(batadv_ogm_packet->tt_num_changes);
		buff_pos += batadv_tt_len(batadv_ogm_packet->tt_num_changes);
		packet_num++;
		packet_num++;
		batadv_ogm_packet = (struct batadv_ogm_packet *)
		packet_pos = forw_packet->skb->data + buff_pos;
					(forw_packet->skb->data + buff_pos);
		batadv_ogm_packet = (struct batadv_ogm_packet *)packet_pos;
	}
	}


	/* create clone because function is called more than once */
	/* create clone because function is called more than once */
@@ -227,9 +231,10 @@ static void batadv_iv_ogm_emit(struct batadv_forw_packet *forw_packet)
	struct batadv_hard_iface *primary_if = NULL;
	struct batadv_hard_iface *primary_if = NULL;
	struct batadv_ogm_packet *batadv_ogm_packet;
	struct batadv_ogm_packet *batadv_ogm_packet;
	unsigned char directlink;
	unsigned char directlink;
	uint8_t *packet_pos;


	batadv_ogm_packet = (struct batadv_ogm_packet *)
	packet_pos = forw_packet->skb->data;
						(forw_packet->skb->data);
	batadv_ogm_packet = (struct batadv_ogm_packet *)packet_pos;
	directlink = (batadv_ogm_packet->flags & BATADV_DIRECTLINK ? 1 : 0);
	directlink = (batadv_ogm_packet->flags & BATADV_DIRECTLINK ? 1 : 0);


	if (!forw_packet->if_incoming) {
	if (!forw_packet->if_incoming) {
@@ -454,6 +459,7 @@ static void batadv_iv_ogm_aggregate(struct batadv_forw_packet *forw_packet_aggr,
				    int packet_len, bool direct_link)
				    int packet_len, bool direct_link)
{
{
	unsigned char *skb_buff;
	unsigned char *skb_buff;
	unsigned long new_direct_link_flag;


	skb_buff = skb_put(forw_packet_aggr->skb, packet_len);
	skb_buff = skb_put(forw_packet_aggr->skb, packet_len);
	memcpy(skb_buff, packet_buff, packet_len);
	memcpy(skb_buff, packet_buff, packet_len);
@@ -461,9 +467,10 @@ static void batadv_iv_ogm_aggregate(struct batadv_forw_packet *forw_packet_aggr,
	forw_packet_aggr->num_packets++;
	forw_packet_aggr->num_packets++;


	/* save packet direct link flag status */
	/* save packet direct link flag status */
	if (direct_link)
	if (direct_link) {
		forw_packet_aggr->direct_link_flags |=
		new_direct_link_flag = BIT(forw_packet_aggr->num_packets);
			(1 << forw_packet_aggr->num_packets);
		forw_packet_aggr->direct_link_flags |= new_direct_link_flag;
	}
}
}


static void batadv_iv_ogm_queue_add(struct batadv_priv *bat_priv,
static void batadv_iv_ogm_queue_add(struct batadv_priv *bat_priv,
@@ -586,6 +593,8 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
	struct batadv_ogm_packet *batadv_ogm_packet;
	struct batadv_ogm_packet *batadv_ogm_packet;
	struct batadv_hard_iface *primary_if;
	struct batadv_hard_iface *primary_if;
	int vis_server, tt_num_changes = 0;
	int vis_server, tt_num_changes = 0;
	uint32_t seqno;
	uint8_t bandwidth;


	vis_server = atomic_read(&bat_priv->vis_mode);
	vis_server = atomic_read(&bat_priv->vis_mode);
	primary_if = batadv_primary_if_get_selected(bat_priv);
	primary_if = batadv_primary_if_get_selected(bat_priv);
@@ -599,12 +608,12 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
	batadv_ogm_packet = (struct batadv_ogm_packet *)hard_iface->packet_buff;
	batadv_ogm_packet = (struct batadv_ogm_packet *)hard_iface->packet_buff;


	/* change sequence number to network order */
	/* change sequence number to network order */
	batadv_ogm_packet->seqno =
	seqno = (uint32_t)atomic_read(&hard_iface->seqno);
			htonl((uint32_t)atomic_read(&hard_iface->seqno));
	batadv_ogm_packet->seqno = htonl(seqno);
	atomic_inc(&hard_iface->seqno);
	atomic_inc(&hard_iface->seqno);


	batadv_ogm_packet->ttvn = atomic_read(&bat_priv->ttvn);
	batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
	batadv_ogm_packet->tt_crc = htons(bat_priv->tt_crc);
	batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
	if (tt_num_changes >= 0)
	if (tt_num_changes >= 0)
		batadv_ogm_packet->tt_num_changes = tt_num_changes;
		batadv_ogm_packet->tt_num_changes = tt_num_changes;


@@ -613,12 +622,13 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
	else
	else
		batadv_ogm_packet->flags &= ~BATADV_VIS_SERVER;
		batadv_ogm_packet->flags &= ~BATADV_VIS_SERVER;


	if ((hard_iface == primary_if) &&
	if (hard_iface == primary_if &&
	    (atomic_read(&bat_priv->gw_mode) == BATADV_GW_MODE_SERVER))
	    atomic_read(&bat_priv->gw_mode) == BATADV_GW_MODE_SERVER) {
		batadv_ogm_packet->gw_flags =
		bandwidth = (uint8_t)atomic_read(&bat_priv->gw_bandwidth);
				(uint8_t)atomic_read(&bat_priv->gw_bandwidth);
		batadv_ogm_packet->gw_flags = bandwidth;
	else
	} else {
		batadv_ogm_packet->gw_flags = BATADV_NO_FLAGS;
		batadv_ogm_packet->gw_flags = BATADV_NO_FLAGS;
	}


	batadv_slide_own_bcast_window(hard_iface);
	batadv_slide_own_bcast_window(hard_iface);
	batadv_iv_ogm_queue_add(bat_priv, hard_iface->packet_buff,
	batadv_iv_ogm_queue_add(bat_priv, hard_iface->packet_buff,
@@ -642,8 +652,9 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
	struct batadv_neigh_node *router = NULL;
	struct batadv_neigh_node *router = NULL;
	struct batadv_orig_node *orig_node_tmp;
	struct batadv_orig_node *orig_node_tmp;
	struct hlist_node *node;
	struct hlist_node *node;
	uint8_t bcast_own_sum_orig, bcast_own_sum_neigh;
	uint8_t sum_orig, sum_neigh;
	uint8_t *neigh_addr;
	uint8_t *neigh_addr;
	uint8_t tq_avg;


	batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
	batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
		   "update_originator(): Searching and updating originator entry of received packet\n");
		   "update_originator(): Searching and updating originator entry of received packet\n");
@@ -667,8 +678,8 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
		spin_lock_bh(&tmp_neigh_node->lq_update_lock);
		spin_lock_bh(&tmp_neigh_node->lq_update_lock);
		batadv_ring_buffer_set(tmp_neigh_node->tq_recv,
		batadv_ring_buffer_set(tmp_neigh_node->tq_recv,
				       &tmp_neigh_node->tq_index, 0);
				       &tmp_neigh_node->tq_index, 0);
		tmp_neigh_node->tq_avg =
		tq_avg = batadv_ring_buffer_avg(tmp_neigh_node->tq_recv);
			batadv_ring_buffer_avg(tmp_neigh_node->tq_recv);
		tmp_neigh_node->tq_avg = tq_avg;
		spin_unlock_bh(&tmp_neigh_node->lq_update_lock);
		spin_unlock_bh(&tmp_neigh_node->lq_update_lock);
	}
	}


@@ -727,17 +738,15 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
	if (router && (neigh_node->tq_avg == router->tq_avg)) {
	if (router && (neigh_node->tq_avg == router->tq_avg)) {
		orig_node_tmp = router->orig_node;
		orig_node_tmp = router->orig_node;
		spin_lock_bh(&orig_node_tmp->ogm_cnt_lock);
		spin_lock_bh(&orig_node_tmp->ogm_cnt_lock);
		bcast_own_sum_orig =
		sum_orig = orig_node_tmp->bcast_own_sum[if_incoming->if_num];
			orig_node_tmp->bcast_own_sum[if_incoming->if_num];
		spin_unlock_bh(&orig_node_tmp->ogm_cnt_lock);
		spin_unlock_bh(&orig_node_tmp->ogm_cnt_lock);


		orig_node_tmp = neigh_node->orig_node;
		orig_node_tmp = neigh_node->orig_node;
		spin_lock_bh(&orig_node_tmp->ogm_cnt_lock);
		spin_lock_bh(&orig_node_tmp->ogm_cnt_lock);
		bcast_own_sum_neigh =
		sum_neigh = orig_node_tmp->bcast_own_sum[if_incoming->if_num];
			orig_node_tmp->bcast_own_sum[if_incoming->if_num];
		spin_unlock_bh(&orig_node_tmp->ogm_cnt_lock);
		spin_unlock_bh(&orig_node_tmp->ogm_cnt_lock);


		if (bcast_own_sum_orig >= bcast_own_sum_neigh)
		if (sum_orig >= sum_neigh)
			goto update_tt;
			goto update_tt;
	}
	}


@@ -835,8 +844,10 @@ static int batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node,
	spin_unlock_bh(&orig_node->ogm_cnt_lock);
	spin_unlock_bh(&orig_node->ogm_cnt_lock);


	/* pay attention to not get a value bigger than 100 % */
	/* pay attention to not get a value bigger than 100 % */
	total_count = (orig_eq_count > neigh_rq_count ?
	if (orig_eq_count > neigh_rq_count)
		       neigh_rq_count : orig_eq_count);
		total_count = neigh_rq_count;
	else
		total_count = orig_eq_count;


	/* if we have too few packets (too less data) we set tq_own to zero
	/* if we have too few packets (too less data) we set tq_own to zero
	 * if we receive too few packets it is not considered bidirectional
	 * if we receive too few packets it is not considered bidirectional
@@ -910,6 +921,7 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
	int set_mark, ret = -1;
	int set_mark, ret = -1;
	uint32_t seqno = ntohl(batadv_ogm_packet->seqno);
	uint32_t seqno = ntohl(batadv_ogm_packet->seqno);
	uint8_t *neigh_addr;
	uint8_t *neigh_addr;
	uint8_t packet_count;


	orig_node = batadv_get_orig_node(bat_priv, batadv_ogm_packet->orig);
	orig_node = batadv_get_orig_node(bat_priv, batadv_ogm_packet->orig);
	if (!orig_node)
	if (!orig_node)
@@ -944,9 +956,9 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
						     tmp_neigh_node->real_bits,
						     tmp_neigh_node->real_bits,
						     seq_diff, set_mark);
						     seq_diff, set_mark);


		tmp_neigh_node->real_packet_count =
		packet_count = bitmap_weight(tmp_neigh_node->real_bits,
			bitmap_weight(tmp_neigh_node->real_bits,
					     BATADV_TQ_LOCAL_WINDOW_SIZE);
					     BATADV_TQ_LOCAL_WINDOW_SIZE);
		tmp_neigh_node->real_packet_count = packet_count;
	}
	}
	rcu_read_unlock();
	rcu_read_unlock();


@@ -1163,9 +1175,12 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
	/* if sender is a direct neighbor the sender mac equals
	/* if sender is a direct neighbor the sender mac equals
	 * originator mac
	 * originator mac
	 */
	 */
	orig_neigh_node = (is_single_hop_neigh ?
	if (is_single_hop_neigh)
			   orig_node :
		orig_neigh_node = orig_node;
			   batadv_get_orig_node(bat_priv, ethhdr->h_source));
	else
		orig_neigh_node = batadv_get_orig_node(bat_priv,
						       ethhdr->h_source);

	if (!orig_neigh_node)
	if (!orig_neigh_node)
		goto out;
		goto out;


@@ -1251,6 +1266,7 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb,
	int buff_pos = 0, packet_len;
	int buff_pos = 0, packet_len;
	unsigned char *tt_buff, *packet_buff;
	unsigned char *tt_buff, *packet_buff;
	bool ret;
	bool ret;
	uint8_t *packet_pos;


	ret = batadv_check_management_packet(skb, if_incoming, BATADV_OGM_HLEN);
	ret = batadv_check_management_packet(skb, if_incoming, BATADV_OGM_HLEN);
	if (!ret)
	if (!ret)
@@ -1281,8 +1297,8 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb,
		buff_pos += BATADV_OGM_HLEN;
		buff_pos += BATADV_OGM_HLEN;
		buff_pos += batadv_tt_len(batadv_ogm_packet->tt_num_changes);
		buff_pos += batadv_tt_len(batadv_ogm_packet->tt_num_changes);


		batadv_ogm_packet = (struct batadv_ogm_packet *)
		packet_pos = packet_buff + buff_pos;
						(packet_buff + buff_pos);
		batadv_ogm_packet = (struct batadv_ogm_packet *)packet_pos;
	} while (batadv_iv_ogm_aggr_packet(buff_pos, packet_len,
	} while (batadv_iv_ogm_aggr_packet(buff_pos, packet_len,
					   batadv_ogm_packet->tt_num_changes));
					   batadv_ogm_packet->tt_num_changes));


+142 −72
Original line number Original line Diff line number Diff line
@@ -133,7 +133,7 @@ static void batadv_claim_free_ref(struct batadv_claim *claim)
static struct batadv_claim *batadv_claim_hash_find(struct batadv_priv *bat_priv,
static struct batadv_claim *batadv_claim_hash_find(struct batadv_priv *bat_priv,
						   struct batadv_claim *data)
						   struct batadv_claim *data)
{
{
	struct batadv_hashtable *hash = bat_priv->claim_hash;
	struct batadv_hashtable *hash = bat_priv->bla.claim_hash;
	struct hlist_head *head;
	struct hlist_head *head;
	struct hlist_node *node;
	struct hlist_node *node;
	struct batadv_claim *claim;
	struct batadv_claim *claim;
@@ -174,7 +174,7 @@ static struct batadv_backbone_gw *
batadv_backbone_hash_find(struct batadv_priv *bat_priv,
batadv_backbone_hash_find(struct batadv_priv *bat_priv,
			  uint8_t *addr, short vid)
			  uint8_t *addr, short vid)
{
{
	struct batadv_hashtable *hash = bat_priv->backbone_hash;
	struct batadv_hashtable *hash = bat_priv->bla.backbone_hash;
	struct hlist_head *head;
	struct hlist_head *head;
	struct hlist_node *node;
	struct hlist_node *node;
	struct batadv_backbone_gw search_entry, *backbone_gw;
	struct batadv_backbone_gw search_entry, *backbone_gw;
@@ -218,7 +218,7 @@ batadv_bla_del_backbone_claims(struct batadv_backbone_gw *backbone_gw)
	int i;
	int i;
	spinlock_t *list_lock;	/* protects write access to the hash lists */
	spinlock_t *list_lock;	/* protects write access to the hash lists */


	hash = backbone_gw->bat_priv->claim_hash;
	hash = backbone_gw->bat_priv->bla.claim_hash;
	if (!hash)
	if (!hash)
		return;
		return;


@@ -265,7 +265,7 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac,
	if (!primary_if)
	if (!primary_if)
		return;
		return;


	memcpy(&local_claim_dest, &bat_priv->claim_dest,
	memcpy(&local_claim_dest, &bat_priv->bla.claim_dest,
	       sizeof(local_claim_dest));
	       sizeof(local_claim_dest));
	local_claim_dest.type = claimtype;
	local_claim_dest.type = claimtype;


@@ -281,7 +281,7 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac,
			 NULL,
			 NULL,
			 /* Ethernet SRC/HW SRC:  originator mac */
			 /* Ethernet SRC/HW SRC:  originator mac */
			 primary_if->net_dev->dev_addr,
			 primary_if->net_dev->dev_addr,
			 /* HW DST: FF:43:05:XX:00:00
			 /* HW DST: FF:43:05:XX:YY:YY
			  * with XX   = claim type
			  * with XX   = claim type
			  * and YY:YY = group id
			  * and YY:YY = group id
			  */
			  */
@@ -295,7 +295,7 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac,


	/* now we pretend that the client would have sent this ... */
	/* now we pretend that the client would have sent this ... */
	switch (claimtype) {
	switch (claimtype) {
	case BATADV_CLAIM_TYPE_ADD:
	case BATADV_CLAIM_TYPE_CLAIM:
		/* normal claim frame
		/* normal claim frame
		 * set Ethernet SRC to the clients mac
		 * set Ethernet SRC to the clients mac
		 */
		 */
@@ -303,7 +303,7 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac,
		batadv_dbg(BATADV_DBG_BLA, bat_priv,
		batadv_dbg(BATADV_DBG_BLA, bat_priv,
			   "bla_send_claim(): CLAIM %pM on vid %d\n", mac, vid);
			   "bla_send_claim(): CLAIM %pM on vid %d\n", mac, vid);
		break;
		break;
	case BATADV_CLAIM_TYPE_DEL:
	case BATADV_CLAIM_TYPE_UNCLAIM:
		/* unclaim frame
		/* unclaim frame
		 * set HW SRC to the clients mac
		 * set HW SRC to the clients mac
		 */
		 */
@@ -323,7 +323,8 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac,
		break;
		break;
	case BATADV_CLAIM_TYPE_REQUEST:
	case BATADV_CLAIM_TYPE_REQUEST:
		/* request frame
		/* request frame
		 * set HW SRC to the special mac containg the crc
		 * set HW SRC and header destination to the receiving backbone
		 * gws mac
		 */
		 */
		memcpy(hw_src, mac, ETH_ALEN);
		memcpy(hw_src, mac, ETH_ALEN);
		memcpy(ethhdr->h_dest, mac, ETH_ALEN);
		memcpy(ethhdr->h_dest, mac, ETH_ALEN);
@@ -339,8 +340,9 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, uint8_t *mac,


	skb_reset_mac_header(skb);
	skb_reset_mac_header(skb);
	skb->protocol = eth_type_trans(skb, soft_iface);
	skb->protocol = eth_type_trans(skb, soft_iface);
	bat_priv->stats.rx_packets++;
	batadv_inc_counter(bat_priv, BATADV_CNT_RX);
	bat_priv->stats.rx_bytes += skb->len + ETH_HLEN;
	batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES,
			   skb->len + ETH_HLEN);
	soft_iface->last_rx = jiffies;
	soft_iface->last_rx = jiffies;


	netif_rx(skb);
	netif_rx(skb);
@@ -389,7 +391,7 @@ batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, uint8_t *orig,
	/* one for the hash, one for returning */
	/* one for the hash, one for returning */
	atomic_set(&entry->refcount, 2);
	atomic_set(&entry->refcount, 2);


	hash_added = batadv_hash_add(bat_priv->backbone_hash,
	hash_added = batadv_hash_add(bat_priv->bla.backbone_hash,
				     batadv_compare_backbone_gw,
				     batadv_compare_backbone_gw,
				     batadv_choose_backbone_gw, entry,
				     batadv_choose_backbone_gw, entry,
				     &entry->hash_entry);
				     &entry->hash_entry);
@@ -456,7 +458,7 @@ static void batadv_bla_answer_request(struct batadv_priv *bat_priv,
	if (!backbone_gw)
	if (!backbone_gw)
		return;
		return;


	hash = bat_priv->claim_hash;
	hash = bat_priv->bla.claim_hash;
	for (i = 0; i < hash->size; i++) {
	for (i = 0; i < hash->size; i++) {
		head = &hash->table[i];
		head = &hash->table[i];


@@ -467,7 +469,7 @@ static void batadv_bla_answer_request(struct batadv_priv *bat_priv,
				continue;
				continue;


			batadv_bla_send_claim(bat_priv, claim->addr, claim->vid,
			batadv_bla_send_claim(bat_priv, claim->addr, claim->vid,
					      BATADV_CLAIM_TYPE_ADD);
					      BATADV_CLAIM_TYPE_CLAIM);
		}
		}
		rcu_read_unlock();
		rcu_read_unlock();
	}
	}
@@ -497,7 +499,7 @@ static void batadv_bla_send_request(struct batadv_backbone_gw *backbone_gw)


	/* no local broadcasts should be sent or received, for now. */
	/* no local broadcasts should be sent or received, for now. */
	if (!atomic_read(&backbone_gw->request_sent)) {
	if (!atomic_read(&backbone_gw->request_sent)) {
		atomic_inc(&backbone_gw->bat_priv->bla_num_requests);
		atomic_inc(&backbone_gw->bat_priv->bla.num_requests);
		atomic_set(&backbone_gw->request_sent, 1);
		atomic_set(&backbone_gw->request_sent, 1);
	}
	}
}
}
@@ -557,7 +559,7 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
		batadv_dbg(BATADV_DBG_BLA, bat_priv,
		batadv_dbg(BATADV_DBG_BLA, bat_priv,
			   "bla_add_claim(): adding new entry %pM, vid %d to hash ...\n",
			   "bla_add_claim(): adding new entry %pM, vid %d to hash ...\n",
			   mac, vid);
			   mac, vid);
		hash_added = batadv_hash_add(bat_priv->claim_hash,
		hash_added = batadv_hash_add(bat_priv->bla.claim_hash,
					     batadv_compare_claim,
					     batadv_compare_claim,
					     batadv_choose_claim, claim,
					     batadv_choose_claim, claim,
					     &claim->hash_entry);
					     &claim->hash_entry);
@@ -577,8 +579,7 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
			   "bla_add_claim(): changing ownership for %pM, vid %d\n",
			   "bla_add_claim(): changing ownership for %pM, vid %d\n",
			   mac, vid);
			   mac, vid);


		claim->backbone_gw->crc ^=
		claim->backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
			crc16(0, claim->addr, ETH_ALEN);
		batadv_backbone_gw_free_ref(claim->backbone_gw);
		batadv_backbone_gw_free_ref(claim->backbone_gw);


	}
	}
@@ -610,7 +611,7 @@ static void batadv_bla_del_claim(struct batadv_priv *bat_priv,
	batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla_del_claim(): %pM, vid %d\n",
	batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla_del_claim(): %pM, vid %d\n",
		   mac, vid);
		   mac, vid);


	batadv_hash_remove(bat_priv->claim_hash, batadv_compare_claim,
	batadv_hash_remove(bat_priv->bla.claim_hash, batadv_compare_claim,
			   batadv_choose_claim, claim);
			   batadv_choose_claim, claim);
	batadv_claim_free_ref(claim); /* reference from the hash is gone */
	batadv_claim_free_ref(claim); /* reference from the hash is gone */


@@ -657,7 +658,7 @@ static int batadv_handle_announce(struct batadv_priv *bat_priv,
		 * we can allow traffic again.
		 * we can allow traffic again.
		 */
		 */
		if (atomic_read(&backbone_gw->request_sent)) {
		if (atomic_read(&backbone_gw->request_sent)) {
			atomic_dec(&backbone_gw->bat_priv->bla_num_requests);
			atomic_dec(&backbone_gw->bat_priv->bla.num_requests);
			atomic_set(&backbone_gw->request_sent, 0);
			atomic_set(&backbone_gw->request_sent, 0);
		}
		}
	}
	}
@@ -702,7 +703,7 @@ static int batadv_handle_unclaim(struct batadv_priv *bat_priv,
	if (primary_if && batadv_compare_eth(backbone_addr,
	if (primary_if && batadv_compare_eth(backbone_addr,
					     primary_if->net_dev->dev_addr))
					     primary_if->net_dev->dev_addr))
		batadv_bla_send_claim(bat_priv, claim_addr, vid,
		batadv_bla_send_claim(bat_priv, claim_addr, vid,
				      BATADV_CLAIM_TYPE_DEL);
				      BATADV_CLAIM_TYPE_UNCLAIM);


	backbone_gw = batadv_backbone_hash_find(bat_priv, backbone_addr, vid);
	backbone_gw = batadv_backbone_hash_find(bat_priv, backbone_addr, vid);


@@ -738,7 +739,7 @@ static int batadv_handle_claim(struct batadv_priv *bat_priv,
	batadv_bla_add_claim(bat_priv, claim_addr, vid, backbone_gw);
	batadv_bla_add_claim(bat_priv, claim_addr, vid, backbone_gw);
	if (batadv_compare_eth(backbone_addr, primary_if->net_dev->dev_addr))
	if (batadv_compare_eth(backbone_addr, primary_if->net_dev->dev_addr))
		batadv_bla_send_claim(bat_priv, claim_addr, vid,
		batadv_bla_send_claim(bat_priv, claim_addr, vid,
				      BATADV_CLAIM_TYPE_ADD);
				      BATADV_CLAIM_TYPE_CLAIM);


	/* TODO: we could call something like tt_local_del() here. */
	/* TODO: we could call something like tt_local_del() here. */


@@ -772,7 +773,7 @@ static int batadv_check_claim_group(struct batadv_priv *bat_priv,
	struct batadv_bla_claim_dst *bla_dst, *bla_dst_own;
	struct batadv_bla_claim_dst *bla_dst, *bla_dst_own;


	bla_dst = (struct batadv_bla_claim_dst *)hw_dst;
	bla_dst = (struct batadv_bla_claim_dst *)hw_dst;
	bla_dst_own = &bat_priv->claim_dest;
	bla_dst_own = &bat_priv->bla.claim_dest;


	/* check if it is a claim packet in general */
	/* check if it is a claim packet in general */
	if (memcmp(bla_dst->magic, bla_dst_own->magic,
	if (memcmp(bla_dst->magic, bla_dst_own->magic,
@@ -783,12 +784,12 @@ static int batadv_check_claim_group(struct batadv_priv *bat_priv,
	 * otherwise assume it is in the hw_src
	 * otherwise assume it is in the hw_src
	 */
	 */
	switch (bla_dst->type) {
	switch (bla_dst->type) {
	case BATADV_CLAIM_TYPE_ADD:
	case BATADV_CLAIM_TYPE_CLAIM:
		backbone_addr = hw_src;
		backbone_addr = hw_src;
		break;
		break;
	case BATADV_CLAIM_TYPE_REQUEST:
	case BATADV_CLAIM_TYPE_REQUEST:
	case BATADV_CLAIM_TYPE_ANNOUNCE:
	case BATADV_CLAIM_TYPE_ANNOUNCE:
	case BATADV_CLAIM_TYPE_DEL:
	case BATADV_CLAIM_TYPE_UNCLAIM:
		backbone_addr = ethhdr->h_source;
		backbone_addr = ethhdr->h_source;
		break;
		break;
	default:
	default:
@@ -904,12 +905,12 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv,


	/* check for the different types of claim frames ... */
	/* check for the different types of claim frames ... */
	switch (bla_dst->type) {
	switch (bla_dst->type) {
	case BATADV_CLAIM_TYPE_ADD:
	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 1;
		break;
		break;
	case BATADV_CLAIM_TYPE_DEL:
	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 1;
@@ -945,7 +946,7 @@ static void batadv_bla_purge_backbone_gw(struct batadv_priv *bat_priv, int now)
	spinlock_t *list_lock;	/* protects write access to the hash lists */
	spinlock_t *list_lock;	/* protects write access to the hash lists */
	int i;
	int i;


	hash = bat_priv->backbone_hash;
	hash = bat_priv->bla.backbone_hash;
	if (!hash)
	if (!hash)
		return;
		return;


@@ -969,7 +970,7 @@ static void batadv_bla_purge_backbone_gw(struct batadv_priv *bat_priv, int now)
purge_now:
purge_now:
			/* don't wait for the pending request anymore */
			/* don't wait for the pending request anymore */
			if (atomic_read(&backbone_gw->request_sent))
			if (atomic_read(&backbone_gw->request_sent))
				atomic_dec(&bat_priv->bla_num_requests);
				atomic_dec(&bat_priv->bla.num_requests);


			batadv_bla_del_backbone_claims(backbone_gw);
			batadv_bla_del_backbone_claims(backbone_gw);


@@ -999,7 +1000,7 @@ static void batadv_bla_purge_claims(struct batadv_priv *bat_priv,
	struct batadv_hashtable *hash;
	struct batadv_hashtable *hash;
	int i;
	int i;


	hash = bat_priv->claim_hash;
	hash = bat_priv->bla.claim_hash;
	if (!hash)
	if (!hash)
		return;
		return;


@@ -1046,11 +1047,12 @@ void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
	struct hlist_node *node;
	struct hlist_node *node;
	struct hlist_head *head;
	struct hlist_head *head;
	struct batadv_hashtable *hash;
	struct batadv_hashtable *hash;
	__be16 group;
	int i;
	int i;


	/* reset bridge loop avoidance group id */
	/* reset bridge loop avoidance group id */
	bat_priv->claim_dest.group =
	group = htons(crc16(0, primary_if->net_dev->dev_addr, ETH_ALEN));
		htons(crc16(0, primary_if->net_dev->dev_addr, ETH_ALEN));
	bat_priv->bla.claim_dest.group = group;


	if (!oldif) {
	if (!oldif) {
		batadv_bla_purge_claims(bat_priv, NULL, 1);
		batadv_bla_purge_claims(bat_priv, NULL, 1);
@@ -1058,7 +1060,7 @@ void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
		return;
		return;
	}
	}


	hash = bat_priv->backbone_hash;
	hash = bat_priv->bla.backbone_hash;
	if (!hash)
	if (!hash)
		return;
		return;


@@ -1088,8 +1090,8 @@ void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
/* (re)start the timer */
/* (re)start the timer */
static void batadv_bla_start_timer(struct batadv_priv *bat_priv)
static void batadv_bla_start_timer(struct batadv_priv *bat_priv)
{
{
	INIT_DELAYED_WORK(&bat_priv->bla_work, batadv_bla_periodic_work);
	INIT_DELAYED_WORK(&bat_priv->bla.work, batadv_bla_periodic_work);
	queue_delayed_work(batadv_event_workqueue, &bat_priv->bla_work,
	queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work,
			   msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH));
			   msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH));
}
}


@@ -1099,9 +1101,9 @@ static void batadv_bla_start_timer(struct batadv_priv *bat_priv)
 */
 */
static void batadv_bla_periodic_work(struct work_struct *work)
static void batadv_bla_periodic_work(struct work_struct *work)
{
{
	struct delayed_work *delayed_work =
	struct delayed_work *delayed_work;
		container_of(work, struct delayed_work, work);
	struct batadv_priv *bat_priv;
	struct batadv_priv *bat_priv;
	struct batadv_priv_bla *priv_bla;
	struct hlist_node *node;
	struct hlist_node *node;
	struct hlist_head *head;
	struct hlist_head *head;
	struct batadv_backbone_gw *backbone_gw;
	struct batadv_backbone_gw *backbone_gw;
@@ -1109,7 +1111,9 @@ static void batadv_bla_periodic_work(struct work_struct *work)
	struct batadv_hard_iface *primary_if;
	struct batadv_hard_iface *primary_if;
	int i;
	int i;


	bat_priv = container_of(delayed_work, struct batadv_priv, bla_work);
	delayed_work = container_of(work, struct delayed_work, work);
	priv_bla = container_of(delayed_work, struct batadv_priv_bla, work);
	bat_priv = container_of(priv_bla, struct batadv_priv, bla);
	primary_if = batadv_primary_if_get_selected(bat_priv);
	primary_if = batadv_primary_if_get_selected(bat_priv);
	if (!primary_if)
	if (!primary_if)
		goto out;
		goto out;
@@ -1120,7 +1124,7 @@ 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;


	hash = bat_priv->backbone_hash;
	hash = bat_priv->bla.backbone_hash;
	if (!hash)
	if (!hash)
		goto out;
		goto out;


@@ -1160,40 +1164,41 @@ int batadv_bla_init(struct batadv_priv *bat_priv)
	int i;
	int i;
	uint8_t claim_dest[ETH_ALEN] = {0xff, 0x43, 0x05, 0x00, 0x00, 0x00};
	uint8_t claim_dest[ETH_ALEN] = {0xff, 0x43, 0x05, 0x00, 0x00, 0x00};
	struct batadv_hard_iface *primary_if;
	struct batadv_hard_iface *primary_if;
	uint16_t crc;
	unsigned long entrytime;


	batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla hash registering\n");
	batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla hash registering\n");


	/* setting claim destination address */
	/* setting claim destination address */
	memcpy(&bat_priv->claim_dest.magic, claim_dest, 3);
	memcpy(&bat_priv->bla.claim_dest.magic, claim_dest, 3);
	bat_priv->claim_dest.type = 0;
	bat_priv->bla.claim_dest.type = 0;
	primary_if = batadv_primary_if_get_selected(bat_priv);
	primary_if = batadv_primary_if_get_selected(bat_priv);
	if (primary_if) {
	if (primary_if) {
		bat_priv->claim_dest.group =
		crc = crc16(0, primary_if->net_dev->dev_addr, ETH_ALEN);
			htons(crc16(0, primary_if->net_dev->dev_addr,
		bat_priv->bla.claim_dest.group = htons(crc);
				    ETH_ALEN));
		batadv_hardif_free_ref(primary_if);
		batadv_hardif_free_ref(primary_if);
	} else {
	} else {
		bat_priv->claim_dest.group = 0; /* will be set later */
		bat_priv->bla.claim_dest.group = 0; /* will be set later */
	}
	}


	/* initialize the duplicate list */
	/* initialize the duplicate list */
	entrytime = jiffies - msecs_to_jiffies(BATADV_DUPLIST_TIMEOUT);
	for (i = 0; i < BATADV_DUPLIST_SIZE; i++)
	for (i = 0; i < BATADV_DUPLIST_SIZE; i++)
		bat_priv->bcast_duplist[i].entrytime =
		bat_priv->bla.bcast_duplist[i].entrytime = entrytime;
			jiffies - msecs_to_jiffies(BATADV_DUPLIST_TIMEOUT);
	bat_priv->bla.bcast_duplist_curr = 0;
	bat_priv->bcast_duplist_curr = 0;


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


	bat_priv->claim_hash = batadv_hash_new(128);
	bat_priv->bla.claim_hash = batadv_hash_new(128);
	bat_priv->backbone_hash = batadv_hash_new(32);
	bat_priv->bla.backbone_hash = batadv_hash_new(32);


	if (!bat_priv->claim_hash || !bat_priv->backbone_hash)
	if (!bat_priv->bla.claim_hash || !bat_priv->bla.backbone_hash)
		return -ENOMEM;
		return -ENOMEM;


	batadv_hash_set_lock_class(bat_priv->claim_hash,
	batadv_hash_set_lock_class(bat_priv->bla.claim_hash,
				   &batadv_claim_hash_lock_class_key);
				   &batadv_claim_hash_lock_class_key);
	batadv_hash_set_lock_class(bat_priv->backbone_hash,
	batadv_hash_set_lock_class(bat_priv->bla.backbone_hash,
				   &batadv_backbone_hash_lock_class_key);
				   &batadv_backbone_hash_lock_class_key);


	batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla hashes initialized\n");
	batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla hashes initialized\n");
@@ -1234,8 +1239,9 @@ int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
	crc = crc16(0, content, length);
	crc = crc16(0, content, length);


	for (i = 0; i < BATADV_DUPLIST_SIZE; i++) {
	for (i = 0; i < BATADV_DUPLIST_SIZE; i++) {
		curr = (bat_priv->bcast_duplist_curr + i) % BATADV_DUPLIST_SIZE;
		curr = (bat_priv->bla.bcast_duplist_curr + i);
		entry = &bat_priv->bcast_duplist[curr];
		curr %= BATADV_DUPLIST_SIZE;
		entry = &bat_priv->bla.bcast_duplist[curr];


		/* we can stop searching if the entry is too old ;
		/* we can stop searching if the entry is too old ;
		 * later entries will be even older
		 * later entries will be even older
@@ -1256,13 +1262,13 @@ int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
		return 1;
		return 1;
	}
	}
	/* not found, add a new entry (overwrite the oldest entry) */
	/* not found, add a new entry (overwrite the oldest entry) */
	curr = (bat_priv->bcast_duplist_curr + BATADV_DUPLIST_SIZE - 1);
	curr = (bat_priv->bla.bcast_duplist_curr + BATADV_DUPLIST_SIZE - 1);
	curr %= BATADV_DUPLIST_SIZE;
	curr %= BATADV_DUPLIST_SIZE;
	entry = &bat_priv->bcast_duplist[curr];
	entry = &bat_priv->bla.bcast_duplist[curr];
	entry->crc = crc;
	entry->crc = crc;
	entry->entrytime = jiffies;
	entry->entrytime = jiffies;
	memcpy(entry->orig, bcast_packet->orig, ETH_ALEN);
	memcpy(entry->orig, bcast_packet->orig, ETH_ALEN);
	bat_priv->bcast_duplist_curr = curr;
	bat_priv->bla.bcast_duplist_curr = curr;


	/* allow it, its the first occurence. */
	/* allow it, its the first occurence. */
	return 0;
	return 0;
@@ -1279,7 +1285,7 @@ int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
 */
 */
int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig)
int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig)
{
{
	struct batadv_hashtable *hash = bat_priv->backbone_hash;
	struct batadv_hashtable *hash = bat_priv->bla.backbone_hash;
	struct hlist_head *head;
	struct hlist_head *head;
	struct hlist_node *node;
	struct hlist_node *node;
	struct batadv_backbone_gw *backbone_gw;
	struct batadv_backbone_gw *backbone_gw;
@@ -1339,8 +1345,7 @@ int batadv_bla_is_backbone_gw(struct sk_buff *skb,
		if (!pskb_may_pull(skb, hdr_size + sizeof(struct vlan_ethhdr)))
		if (!pskb_may_pull(skb, hdr_size + sizeof(struct vlan_ethhdr)))
			return 0;
			return 0;


		vhdr = (struct vlan_ethhdr *)(((uint8_t *)skb->data) +
		vhdr = (struct vlan_ethhdr *)(skb->data + hdr_size);
					      hdr_size);
		vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK;
		vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK;
	}
	}


@@ -1359,18 +1364,18 @@ void batadv_bla_free(struct batadv_priv *bat_priv)
{
{
	struct batadv_hard_iface *primary_if;
	struct batadv_hard_iface *primary_if;


	cancel_delayed_work_sync(&bat_priv->bla_work);
	cancel_delayed_work_sync(&bat_priv->bla.work);
	primary_if = batadv_primary_if_get_selected(bat_priv);
	primary_if = batadv_primary_if_get_selected(bat_priv);


	if (bat_priv->claim_hash) {
	if (bat_priv->bla.claim_hash) {
		batadv_bla_purge_claims(bat_priv, primary_if, 1);
		batadv_bla_purge_claims(bat_priv, primary_if, 1);
		batadv_hash_destroy(bat_priv->claim_hash);
		batadv_hash_destroy(bat_priv->bla.claim_hash);
		bat_priv->claim_hash = NULL;
		bat_priv->bla.claim_hash = NULL;
	}
	}
	if (bat_priv->backbone_hash) {
	if (bat_priv->bla.backbone_hash) {
		batadv_bla_purge_backbone_gw(bat_priv, 1);
		batadv_bla_purge_backbone_gw(bat_priv, 1);
		batadv_hash_destroy(bat_priv->backbone_hash);
		batadv_hash_destroy(bat_priv->bla.backbone_hash);
		bat_priv->backbone_hash = NULL;
		bat_priv->bla.backbone_hash = NULL;
	}
	}
	if (primary_if)
	if (primary_if)
		batadv_hardif_free_ref(primary_if);
		batadv_hardif_free_ref(primary_if);
@@ -1409,7 +1414,7 @@ int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid,
		goto allow;
		goto allow;




	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)
			goto handled;
			goto handled;
@@ -1508,7 +1513,7 @@ int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid)


	ethhdr = (struct ethhdr *)skb_mac_header(skb);
	ethhdr = (struct ethhdr *)skb_mac_header(skb);


	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))
		if (is_multicast_ether_addr(ethhdr->h_dest))
			goto handled;
			goto handled;
@@ -1564,7 +1569,7 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
{
{
	struct net_device *net_dev = (struct net_device *)seq->private;
	struct net_device *net_dev = (struct net_device *)seq->private;
	struct batadv_priv *bat_priv = netdev_priv(net_dev);
	struct batadv_priv *bat_priv = netdev_priv(net_dev);
	struct batadv_hashtable *hash = bat_priv->claim_hash;
	struct batadv_hashtable *hash = bat_priv->bla.claim_hash;
	struct batadv_claim *claim;
	struct batadv_claim *claim;
	struct batadv_hard_iface *primary_if;
	struct batadv_hard_iface *primary_if;
	struct hlist_node *node;
	struct hlist_node *node;
@@ -1593,7 +1598,7 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
	seq_printf(seq,
	seq_printf(seq,
		   "Claims announced for the mesh %s (orig %pM, group id %04x)\n",
		   "Claims announced for the mesh %s (orig %pM, group id %04x)\n",
		   net_dev->name, primary_addr,
		   net_dev->name, primary_addr,
		   ntohs(bat_priv->claim_dest.group));
		   ntohs(bat_priv->bla.claim_dest.group));
	seq_printf(seq, "   %-17s    %-5s    %-17s [o] (%-4s)\n",
	seq_printf(seq, "   %-17s    %-5s    %-17s [o] (%-4s)\n",
		   "Client", "VID", "Originator", "CRC");
		   "Client", "VID", "Originator", "CRC");
	for (i = 0; i < hash->size; i++) {
	for (i = 0; i < hash->size; i++) {
@@ -1616,3 +1621,68 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
		batadv_hardif_free_ref(primary_if);
		batadv_hardif_free_ref(primary_if);
	return ret;
	return ret;
}
}

int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, void *offset)
{
	struct net_device *net_dev = (struct net_device *)seq->private;
	struct batadv_priv *bat_priv = netdev_priv(net_dev);
	struct batadv_hashtable *hash = bat_priv->bla.backbone_hash;
	struct batadv_backbone_gw *backbone_gw;
	struct batadv_hard_iface *primary_if;
	struct hlist_node *node;
	struct hlist_head *head;
	int secs, msecs;
	uint32_t i;
	bool is_own;
	int ret = 0;
	uint8_t *primary_addr;

	primary_if = batadv_primary_if_get_selected(bat_priv);
	if (!primary_if) {
		ret = seq_printf(seq,
				 "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
				 net_dev->name);
		goto out;
	}

	if (primary_if->if_status != BATADV_IF_ACTIVE) {
		ret = seq_printf(seq,
				 "BATMAN mesh %s disabled - primary interface not active\n",
				 net_dev->name);
		goto out;
	}

	primary_addr = primary_if->net_dev->dev_addr;
	seq_printf(seq,
		   "Backbones announced for the mesh %s (orig %pM, group id %04x)\n",
		   net_dev->name, primary_addr,
		   ntohs(bat_priv->bla.claim_dest.group));
	seq_printf(seq, "   %-17s    %-5s %-9s (%-4s)\n",
		   "Originator", "VID", "last seen", "CRC");
	for (i = 0; i < hash->size; i++) {
		head = &hash->table[i];

		rcu_read_lock();
		hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) {
			msecs = jiffies_to_msecs(jiffies -
						 backbone_gw->lasttime);
			secs = msecs / 1000;
			msecs = msecs % 1000;

			is_own = batadv_compare_eth(backbone_gw->orig,
						    primary_addr);
			if (is_own)
				continue;

			seq_printf(seq,
				   " * %pM on % 5d % 4i.%03is (%04x)\n",
				   backbone_gw->orig, backbone_gw->vid,
				   secs, msecs, backbone_gw->crc);
		}
		rcu_read_unlock();
	}
out:
	if (primary_if)
		batadv_hardif_free_ref(primary_if);
	return ret;
}
+9 −2

File changed.

Preview size limit exceeded, changes collapsed.

+12 −0
Original line number Original line Diff line number Diff line
@@ -267,6 +267,15 @@ static int batadv_bla_claim_table_open(struct inode *inode, struct file *file)
	return single_open(file, batadv_bla_claim_table_seq_print_text,
	return single_open(file, batadv_bla_claim_table_seq_print_text,
			   net_dev);
			   net_dev);
}
}

static int batadv_bla_backbone_table_open(struct inode *inode,
					  struct file *file)
{
	struct net_device *net_dev = (struct net_device *)inode->i_private;
	return single_open(file, batadv_bla_backbone_table_seq_print_text,
			   net_dev);
}

#endif
#endif


static int batadv_transtable_local_open(struct inode *inode, struct file *file)
static int batadv_transtable_local_open(struct inode *inode, struct file *file)
@@ -305,6 +314,8 @@ static BATADV_DEBUGINFO(transtable_global, S_IRUGO,
			batadv_transtable_global_open);
			batadv_transtable_global_open);
#ifdef CONFIG_BATMAN_ADV_BLA
#ifdef CONFIG_BATMAN_ADV_BLA
static BATADV_DEBUGINFO(bla_claim_table, S_IRUGO, batadv_bla_claim_table_open);
static BATADV_DEBUGINFO(bla_claim_table, S_IRUGO, batadv_bla_claim_table_open);
static BATADV_DEBUGINFO(bla_backbone_table, S_IRUGO,
			batadv_bla_backbone_table_open);
#endif
#endif
static BATADV_DEBUGINFO(transtable_local, S_IRUGO,
static BATADV_DEBUGINFO(transtable_local, S_IRUGO,
			batadv_transtable_local_open);
			batadv_transtable_local_open);
@@ -316,6 +327,7 @@ static struct batadv_debuginfo *batadv_mesh_debuginfos[] = {
	&batadv_debuginfo_transtable_global,
	&batadv_debuginfo_transtable_global,
#ifdef CONFIG_BATMAN_ADV_BLA
#ifdef CONFIG_BATMAN_ADV_BLA
	&batadv_debuginfo_bla_claim_table,
	&batadv_debuginfo_bla_claim_table,
	&batadv_debuginfo_bla_backbone_table,
#endif
#endif
	&batadv_debuginfo_transtable_local,
	&batadv_debuginfo_transtable_local,
	&batadv_debuginfo_vis_data,
	&batadv_debuginfo_vis_data,
Loading