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

Commit c018ad3d authored by Antonio Quartulli's avatar Antonio Quartulli Committed by Antonio Quartulli
Browse files

batman-adv: add the VLAN ID attribute to the TT entry



To make the translation table code VLAN-aware, each entry
must carry the VLAN ID which it belongs to. This patch adds
such attribute to the related TT structures.

Signed-off-by: default avatarAntonio Quartulli <antonio@open-mesh.com>
Signed-off-by: default avatarMarek Lindner <lindner_marek@yahoo.de>
parent bc58eeef
Loading
Loading
Loading
Loading
+11 −24
Original line number Diff line number Diff line
@@ -858,27 +858,25 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv,
				    struct batadv_hard_iface *primary_if,
				    struct sk_buff *skb)
{
	struct ethhdr *ethhdr;
	struct batadv_bla_claim_dst *bla_dst;
	uint8_t *hw_src, *hw_dst;
	struct vlan_ethhdr *vhdr;
	struct ethhdr *ethhdr;
	struct arphdr *arphdr;
	uint8_t *hw_src, *hw_dst;
	struct batadv_bla_claim_dst *bla_dst;
	unsigned short vid;
	__be16 proto;
	int headlen;
	unsigned short vid = BATADV_NO_FLAGS;
	int ret;

	vid = batadv_get_vid(skb, 0);
	ethhdr = eth_hdr(skb);

	if (ethhdr->h_proto == htons(ETH_P_8021Q)) {
		vhdr = (struct vlan_ethhdr *)ethhdr;
		vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK;
		vid |= BATADV_VLAN_HAS_TAG;
		proto = vhdr->h_vlan_encapsulated_proto;
		headlen = sizeof(*vhdr);
	} else {
	proto = ethhdr->h_proto;
	headlen = ETH_HLEN;
	if (vid & BATADV_VLAN_HAS_TAG) {
		vhdr = (struct vlan_ethhdr *)ethhdr;
		proto = vhdr->h_vlan_encapsulated_proto;
		headlen += VLAN_HLEN;
	}

	if (proto != htons(ETH_P_ARP))
@@ -1365,10 +1363,8 @@ int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig)
int batadv_bla_is_backbone_gw(struct sk_buff *skb,
			      struct batadv_orig_node *orig_node, int hdr_size)
{
	struct ethhdr *ethhdr;
	struct vlan_ethhdr *vhdr;
	struct batadv_bla_backbone_gw *backbone_gw;
	unsigned short vid = BATADV_NO_FLAGS;
	unsigned short vid;

	if (!atomic_read(&orig_node->bat_priv->bridge_loop_avoidance))
		return 0;
@@ -1377,16 +1373,7 @@ int batadv_bla_is_backbone_gw(struct sk_buff *skb,
	if (!pskb_may_pull(skb, hdr_size + ETH_HLEN))
		return 0;

	ethhdr = (struct ethhdr *)(((uint8_t *)skb->data) + hdr_size);

	if (ethhdr->h_proto == htons(ETH_P_8021Q)) {
		if (!pskb_may_pull(skb, hdr_size + VLAN_ETH_HLEN))
			return 0;

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

	/* see if this originator is a backbone gw for this VLAN */
	backbone_gw = batadv_backbone_hash_find(orig_node->bat_priv,
+7 −4
Original line number Diff line number Diff line
@@ -905,7 +905,8 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
		 * additional DAT answer may trigger kernel warnings about
		 * a packet coming from the wrong port.
		 */
		if (batadv_is_my_client(bat_priv, dat_entry->mac_addr)) {
		if (batadv_is_my_client(bat_priv, dat_entry->mac_addr,
					BATADV_NO_FLAGS)) {
			ret = true;
			goto out;
		}
@@ -990,9 +991,11 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
	 */
	if (hdr_size == sizeof(struct batadv_unicast_4addr_packet))
		err = batadv_send_skb_unicast_4addr(bat_priv, skb_new,
						    BATADV_P_DAT_CACHE_REPLY);
						    BATADV_P_DAT_CACHE_REPLY,
						    BATADV_NO_FLAGS);
	else
		err = batadv_send_skb_unicast(bat_priv, skb_new);
		err = batadv_send_skb_unicast(bat_priv, skb_new,
					      BATADV_NO_FLAGS);

	if (!err) {
		batadv_inc_counter(bat_priv, BATADV_CNT_DAT_CACHED_REPLY_TX);
@@ -1080,7 +1083,7 @@ bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
	/* if this REPLY is directed to a client of mine, let's deliver the
	 * packet to the interface
	 */
	ret = !batadv_is_my_client(bat_priv, hw_dst);
	ret = !batadv_is_my_client(bat_priv, hw_dst, BATADV_NO_FLAGS);
out:
	if (ret)
		kfree_skb(skb);
+2 −1
Original line number Diff line number Diff line
@@ -744,7 +744,8 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,

	ethhdr = (struct ethhdr *)skb->data;
	orig_dst_node = batadv_transtable_search(bat_priv, ethhdr->h_source,
						 ethhdr->h_dest);
						 ethhdr->h_dest,
						 BATADV_NO_FLAGS);
	if (!orig_dst_node)
		goto out;

+28 −1
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ int batadv_mesh_init(struct net_device *soft_iface)
		goto err;

	batadv_tt_local_add(soft_iface, soft_iface->dev_addr,
			    BATADV_NULL_IFINDEX);
			    BATADV_NO_FLAGS, BATADV_NULL_IFINDEX);

	ret = batadv_bla_init(bat_priv);
	if (ret < 0)
@@ -1144,6 +1144,33 @@ out:
		batadv_orig_node_free_ref(orig_node);
}

/**
 * batadv_get_vid - extract the VLAN identifier from skb if any
 * @skb: the buffer containing the packet
 * @header_len: length of the batman header preceding the ethernet header
 *
 * If the packet embedded in the skb is vlan tagged this function returns the
 * VID with the BATADV_VLAN_HAS_TAG flag. Otherwise BATADV_NO_FLAGS is returned.
 */
unsigned short batadv_get_vid(struct sk_buff *skb, size_t header_len)
{
	struct ethhdr *ethhdr = (struct ethhdr *)(skb->data + header_len);
	struct vlan_ethhdr *vhdr;
	unsigned short vid;

	if (ethhdr->h_proto != htons(ETH_P_8021Q))
		return BATADV_NO_FLAGS;

	if (!pskb_may_pull(skb, header_len + VLAN_ETH_HLEN))
		return BATADV_NO_FLAGS;

	vhdr = (struct vlan_ethhdr *)(skb->data + header_len);
	vid = ntohs(vhdr->h_vlan_TCI) & VLAN_VID_MASK;
	vid |= BATADV_VLAN_HAS_TAG;

	return vid;
}

static int batadv_param_set_ra(const char *val, const struct kernel_param *kp)
{
	struct batadv_algo_ops *bat_algo_ops;
+1 −8
Original line number Diff line number Diff line
@@ -169,14 +169,6 @@ enum batadv_uev_type {
#include <linux/seq_file.h>
#include "types.h"

/**
 * batadv_vlan_flags - flags for the four MSB of any vlan ID field
 * @BATADV_VLAN_HAS_TAG: whether the field contains a valid vlan tag or not
 */
enum batadv_vlan_flags {
	BATADV_VLAN_HAS_TAG	= BIT(15),
};

#define BATADV_PRINT_VID(vid) (vid & BATADV_VLAN_HAS_TAG ? \
			       (int)(vid & VLAN_VID_MASK) : -1)

@@ -368,5 +360,6 @@ int batadv_tvlv_containers_process(struct batadv_priv *bat_priv,
void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, uint8_t *src,
			      uint8_t *dst, uint8_t type, uint8_t version,
			      void *tvlv_value, uint16_t tvlv_value_len);
unsigned short batadv_get_vid(struct sk_buff *skb, size_t header_len);

#endif /* _NET_BATMAN_ADV_MAIN_H_ */
Loading