Skip to content

Commit 2871734

Browse files
committed
batman-adv: fix DAT candidate selection (must use vid)
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: be1db4f ("batman-adv: make the Distributed ARP Table vlan aware") Signed-off-by: Antonio Quartulli <a@unstable.cc> [sven@narfation.org: fix conflicts with current version] Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
1 parent 1dfcd83 commit 2871734

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

net/batman-adv/distributed-arp-table.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ static void batadv_choose_next_candidate(struct batadv_priv *bat_priv,
568568
* be sent to
569569
* @bat_priv: the bat priv with all the soft interface information
570570
* @ip_dst: ipv4 to look up in the DHT
571+
* @vid: VLAN identifier
571572
*
572573
* An originator O is selected if and only if its DHT_ID value is one of three
573574
* closest values (from the LEFT, with wrap around if needed) then the hash
@@ -576,7 +577,8 @@ static void batadv_choose_next_candidate(struct batadv_priv *bat_priv,
576577
* Return: the candidate array of size BATADV_DAT_CANDIDATE_NUM.
577578
*/
578579
static struct batadv_dat_candidate *
579-
batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst)
580+
batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst,
581+
unsigned short vid)
580582
{
581583
int select;
582584
batadv_dat_addr_t last_max = BATADV_DAT_ADDR_MAX, ip_key;
@@ -592,7 +594,7 @@ batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst)
592594
return NULL;
593595

594596
dat.ip = ip_dst;
595-
dat.vid = 0;
597+
dat.vid = vid;
596598
ip_key = (batadv_dat_addr_t)batadv_hash_dat(&dat,
597599
BATADV_DAT_ADDR_MAX);
598600

@@ -612,6 +614,7 @@ batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst)
612614
* @bat_priv: the bat priv with all the soft interface information
613615
* @skb: payload to send
614616
* @ip: the DHT key
617+
* @vid: VLAN identifier
615618
* @packet_subtype: unicast4addr packet subtype to use
616619
*
617620
* This function copies the skb with pskb_copy() and is sent as unicast packet
@@ -622,7 +625,7 @@ batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst)
622625
*/
623626
static bool batadv_dat_send_data(struct batadv_priv *bat_priv,
624627
struct sk_buff *skb, __be32 ip,
625-
int packet_subtype)
628+
unsigned short vid, int packet_subtype)
626629
{
627630
int i;
628631
bool ret = false;
@@ -631,7 +634,7 @@ static bool batadv_dat_send_data(struct batadv_priv *bat_priv,
631634
struct sk_buff *tmp_skb;
632635
struct batadv_dat_candidate *cand;
633636

634-
cand = batadv_dat_select_candidates(bat_priv, ip);
637+
cand = batadv_dat_select_candidates(bat_priv, ip, vid);
635638
if (!cand)
636639
goto out;
637640

@@ -1022,7 +1025,7 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
10221025
ret = true;
10231026
} else {
10241027
/* Send the request to the DHT */
1025-
ret = batadv_dat_send_data(bat_priv, skb, ip_dst,
1028+
ret = batadv_dat_send_data(bat_priv, skb, ip_dst, vid,
10261029
BATADV_P_DAT_DHT_GET);
10271030
}
10281031
out:
@@ -1150,8 +1153,8 @@ void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,
11501153
/* Send the ARP reply to the candidates for both the IP addresses that
11511154
* the node obtained from the ARP reply
11521155
*/
1153-
batadv_dat_send_data(bat_priv, skb, ip_src, BATADV_P_DAT_DHT_PUT);
1154-
batadv_dat_send_data(bat_priv, skb, ip_dst, BATADV_P_DAT_DHT_PUT);
1156+
batadv_dat_send_data(bat_priv, skb, ip_src, vid, BATADV_P_DAT_DHT_PUT);
1157+
batadv_dat_send_data(bat_priv, skb, ip_dst, vid, BATADV_P_DAT_DHT_PUT);
11551158
}
11561159

11571160
/**

0 commit comments

Comments
 (0)