Commit 29a56550 authored by Antonio Quartulli's avatar Antonio Quartulli Committed by Ben Hutchings

batman-adv: fix DAT candidate selection (must use vid)

commit 2871734e upstream.

Now that DAT is VLAN aware, it must use the VID when
computing the DHT address of the candidate nodes where
an entry is going to be stored/retrieved.

Fixes: be1db4f6 ("batman-adv: make the Distributed ARP Table vlan aware")
Signed-off-by: default avatarAntonio Quartulli <a@unstable.cc>
[sven@narfation.org: fix conflicts with current version]
Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
Signed-off-by: default avatarMarek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 19d8176d
...@@ -521,6 +521,7 @@ static void batadv_choose_next_candidate(struct batadv_priv *bat_priv, ...@@ -521,6 +521,7 @@ static void batadv_choose_next_candidate(struct batadv_priv *bat_priv,
* be sent to * be sent to
* @bat_priv: the bat priv with all the soft interface information * @bat_priv: the bat priv with all the soft interface information
* @ip_dst: ipv4 to look up in the DHT * @ip_dst: ipv4 to look up in the DHT
* @vid: VLAN identifier
* *
* An originator O is selected if and only if its DHT_ID value is one of three * An originator O is selected if and only if its DHT_ID value is one of three
* closest values (from the LEFT, with wrap around if needed) then the hash * closest values (from the LEFT, with wrap around if needed) then the hash
...@@ -529,7 +530,8 @@ static void batadv_choose_next_candidate(struct batadv_priv *bat_priv, ...@@ -529,7 +530,8 @@ static void batadv_choose_next_candidate(struct batadv_priv *bat_priv,
* Returns the candidate array of size BATADV_DAT_CANDIDATE_NUM. * Returns the candidate array of size BATADV_DAT_CANDIDATE_NUM.
*/ */
static struct batadv_dat_candidate * static struct batadv_dat_candidate *
batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst) batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst,
unsigned short vid)
{ {
int select; int select;
batadv_dat_addr_t last_max = BATADV_DAT_ADDR_MAX, ip_key; batadv_dat_addr_t last_max = BATADV_DAT_ADDR_MAX, ip_key;
...@@ -544,7 +546,7 @@ batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst) ...@@ -544,7 +546,7 @@ batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst)
return NULL; return NULL;
dat.ip = ip_dst; dat.ip = ip_dst;
dat.vid = 0; dat.vid = vid;
ip_key = (batadv_dat_addr_t)batadv_hash_dat(&dat, ip_key = (batadv_dat_addr_t)batadv_hash_dat(&dat,
BATADV_DAT_ADDR_MAX); BATADV_DAT_ADDR_MAX);
...@@ -564,6 +566,7 @@ batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst) ...@@ -564,6 +566,7 @@ batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst)
* @bat_priv: the bat priv with all the soft interface information * @bat_priv: the bat priv with all the soft interface information
* @skb: payload to send * @skb: payload to send
* @ip: the DHT key * @ip: the DHT key
* @vid: VLAN identifier
* @packet_subtype: unicast4addr packet subtype to use * @packet_subtype: unicast4addr packet subtype to use
* *
* This function copies the skb with pskb_copy() and is sent as unicast packet * This function copies the skb with pskb_copy() and is sent as unicast packet
...@@ -574,7 +577,7 @@ batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst) ...@@ -574,7 +577,7 @@ batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst)
*/ */
static bool batadv_dat_send_data(struct batadv_priv *bat_priv, static bool batadv_dat_send_data(struct batadv_priv *bat_priv,
struct sk_buff *skb, __be32 ip, struct sk_buff *skb, __be32 ip,
int packet_subtype) unsigned short vid, int packet_subtype)
{ {
int i; int i;
bool ret = false; bool ret = false;
...@@ -583,7 +586,7 @@ static bool batadv_dat_send_data(struct batadv_priv *bat_priv, ...@@ -583,7 +586,7 @@ static bool batadv_dat_send_data(struct batadv_priv *bat_priv,
struct sk_buff *tmp_skb; struct sk_buff *tmp_skb;
struct batadv_dat_candidate *cand; struct batadv_dat_candidate *cand;
cand = batadv_dat_select_candidates(bat_priv, ip); cand = batadv_dat_select_candidates(bat_priv, ip, vid);
if (!cand) if (!cand)
goto out; goto out;
...@@ -972,7 +975,7 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv, ...@@ -972,7 +975,7 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
ret = true; ret = true;
} else { } else {
/* Send the request to the DHT */ /* Send the request to the DHT */
ret = batadv_dat_send_data(bat_priv, skb, ip_dst, ret = batadv_dat_send_data(bat_priv, skb, ip_dst, vid,
BATADV_P_DAT_DHT_GET); BATADV_P_DAT_DHT_GET);
} }
out: out:
...@@ -1100,8 +1103,8 @@ void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv, ...@@ -1100,8 +1103,8 @@ void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,
/* Send the ARP reply to the candidates for both the IP addresses that /* Send the ARP reply to the candidates for both the IP addresses that
* the node obtained from the ARP reply * the node obtained from the ARP reply
*/ */
batadv_dat_send_data(bat_priv, skb, ip_src, BATADV_P_DAT_DHT_PUT); batadv_dat_send_data(bat_priv, skb, ip_src, vid, BATADV_P_DAT_DHT_PUT);
batadv_dat_send_data(bat_priv, skb, ip_dst, BATADV_P_DAT_DHT_PUT); batadv_dat_send_data(bat_priv, skb, ip_dst, vid, BATADV_P_DAT_DHT_PUT);
} }
/** /**
* batadv_dat_snoop_incoming_arp_reply - snoop the ARP reply and fill the local * batadv_dat_snoop_incoming_arp_reply - snoop the ARP reply and fill the local
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment