mirror of
https://git.openwrt.org/feed/routing.git
synced 2025-01-09 04:07:48 +08:00
batman-adv: Merge bugfixes from 2019.5
* fix DAT candidate selection on little endian systems Signed-off-by: Sven Eckelmann <sven@narfation.org>
This commit is contained in:
parent
f659697eff
commit
5cba01e37a
@ -22,10 +22,10 @@ Acked-by: Antonio Quartulli <a@unstable.cc>
|
||||
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/07b6051ebcfaa7ea89b4f278eca2ff4070d29e56
|
||||
|
||||
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
|
||||
index 7bfd0d7ef49df8e699f91e2b827b824aa3657c0d..5afc4e9646d622c6f924d4610ac58eb77404b37a 100644
|
||||
index 73ea771287fd8babc6c8858643e84c1d9cba3691..8967bc91423cd36b3a4dc240150ff2a694f5bed4 100644
|
||||
--- a/net/batman-adv/bat_iv_ogm.c
|
||||
+++ b/net/batman-adv/bat_iv_ogm.c
|
||||
@@ -450,17 +450,23 @@ static u8 batadv_hop_penalty(u8 tq, const struct batadv_priv *bat_priv)
|
||||
@@ -454,17 +454,23 @@ static u8 batadv_hop_penalty(u8 tq, const struct batadv_priv *bat_priv)
|
||||
* batadv_iv_ogm_aggr_packet - checks if there is another OGM attached
|
||||
* @buff_pos: current position in the skb
|
||||
* @packet_len: total length of the skb
|
||||
@ -54,7 +54,7 @@ index 7bfd0d7ef49df8e699f91e2b827b824aa3657c0d..5afc4e9646d622c6f924d4610ac58eb7
|
||||
|
||||
return (next_buff_pos <= packet_len) &&
|
||||
(next_buff_pos <= BATADV_MAX_AGGREGATION_BYTES);
|
||||
@@ -488,7 +494,7 @@ static void batadv_iv_ogm_send_to_if(struct batadv_forw_packet *forw_packet,
|
||||
@@ -492,7 +498,7 @@ static void batadv_iv_ogm_send_to_if(struct batadv_forw_packet *forw_packet,
|
||||
|
||||
/* adjust all flags and log packets */
|
||||
while (batadv_iv_ogm_aggr_packet(buff_pos, forw_packet->packet_len,
|
||||
@ -63,7 +63,7 @@ index 7bfd0d7ef49df8e699f91e2b827b824aa3657c0d..5afc4e9646d622c6f924d4610ac58eb7
|
||||
/* we might have aggregated direct link packets with an
|
||||
* ordinary base packet
|
||||
*/
|
||||
@@ -1838,7 +1844,7 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb,
|
||||
@@ -1842,7 +1848,7 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb,
|
||||
|
||||
/* unpack the aggregated packets and process them one by one */
|
||||
while (batadv_iv_ogm_aggr_packet(ogm_offset, skb_headlen(skb),
|
@ -101,10 +101,10 @@ index 5f4fe1889053d4ea7624e4500dcefe2601371024..f5feaa8c4fd228228fea519771e2c9e1
|
||||
ogm_buff = kzalloc(bat_priv->bat_v.ogm_buff_len, GFP_ATOMIC);
|
||||
if (!ogm_buff)
|
||||
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
|
||||
index 5137d859694c28f60cad33325127617c047412ff..bf33f04e055bbf288ce6800d0b93da1b4cd9b70d 100644
|
||||
index 5c5762f0f89c8b79b52288104d975dc3753bbf82..11ced015ab639f0d82f12ae533a92f356734cafa 100644
|
||||
--- a/net/batman-adv/types.h
|
||||
+++ b/net/batman-adv/types.h
|
||||
@@ -984,8 +984,8 @@ struct batadv_softif_vlan {
|
||||
@@ -990,8 +990,8 @@ struct batadv_softif_vlan {
|
||||
|
||||
/**
|
||||
* struct batadv_priv_bat_v - B.A.T.M.A.N. V per soft-interface private data
|
@ -21,7 +21,7 @@ Signed-off-by: Sven Eckelmann <sven@narfation.org>
|
||||
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/9b8ceef26c697d0c8319748428944c3339a498dc
|
||||
|
||||
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
|
||||
index 5afc4e9646d622c6f924d4610ac58eb77404b37a..54c5be029b7418bc97d87e7642e258bfed120874 100644
|
||||
index 8967bc91423cd36b3a4dc240150ff2a694f5bed4..ccb60591a01886ceef22408e9387a8a3fda05a36 100644
|
||||
--- a/net/batman-adv/bat_iv_ogm.c
|
||||
+++ b/net/batman-adv/bat_iv_ogm.c
|
||||
@@ -41,6 +41,7 @@
|
||||
@ -32,7 +32,7 @@ index 5afc4e9646d622c6f924d4610ac58eb77404b37a..54c5be029b7418bc97d87e7642e258bf
|
||||
#include <linux/seq_file.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/slab.h>
|
||||
@@ -366,6 +367,8 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
|
||||
@@ -370,6 +371,8 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
|
||||
unsigned char *ogm_buff;
|
||||
u32 random_seqno;
|
||||
|
||||
@ -41,7 +41,7 @@ index 5afc4e9646d622c6f924d4610ac58eb77404b37a..54c5be029b7418bc97d87e7642e258bf
|
||||
/* randomize initial seqno to avoid collision */
|
||||
get_random_bytes(&random_seqno, sizeof(random_seqno));
|
||||
atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
|
||||
@@ -390,6 +393,8 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
|
||||
@@ -394,6 +397,8 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
|
||||
|
||||
static void batadv_iv_ogm_iface_disable(struct batadv_hard_iface *hard_iface)
|
||||
{
|
||||
@ -50,7 +50,7 @@ index 5afc4e9646d622c6f924d4610ac58eb77404b37a..54c5be029b7418bc97d87e7642e258bf
|
||||
kfree(hard_iface->bat_iv.ogm_buff);
|
||||
hard_iface->bat_iv.ogm_buff = NULL;
|
||||
}
|
||||
@@ -399,6 +404,8 @@ static void batadv_iv_ogm_iface_update_mac(struct batadv_hard_iface *hard_iface)
|
||||
@@ -403,6 +408,8 @@ static void batadv_iv_ogm_iface_update_mac(struct batadv_hard_iface *hard_iface)
|
||||
struct batadv_ogm_packet *batadv_ogm_packet;
|
||||
unsigned char *ogm_buff = hard_iface->bat_iv.ogm_buff;
|
||||
|
||||
@ -59,7 +59,7 @@ index 5afc4e9646d622c6f924d4610ac58eb77404b37a..54c5be029b7418bc97d87e7642e258bf
|
||||
batadv_ogm_packet = (struct batadv_ogm_packet *)ogm_buff;
|
||||
ether_addr_copy(batadv_ogm_packet->orig,
|
||||
hard_iface->net_dev->dev_addr);
|
||||
@@ -412,6 +419,8 @@ batadv_iv_ogm_primary_iface_set(struct batadv_hard_iface *hard_iface)
|
||||
@@ -416,6 +423,8 @@ batadv_iv_ogm_primary_iface_set(struct batadv_hard_iface *hard_iface)
|
||||
struct batadv_ogm_packet *batadv_ogm_packet;
|
||||
unsigned char *ogm_buff = hard_iface->bat_iv.ogm_buff;
|
||||
|
||||
@ -68,7 +68,7 @@ index 5afc4e9646d622c6f924d4610ac58eb77404b37a..54c5be029b7418bc97d87e7642e258bf
|
||||
batadv_ogm_packet = (struct batadv_ogm_packet *)ogm_buff;
|
||||
batadv_ogm_packet->ttl = BATADV_TTL;
|
||||
}
|
||||
@@ -923,6 +932,8 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
|
||||
@@ -927,6 +936,8 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
|
||||
u16 tvlv_len = 0;
|
||||
unsigned long send_time;
|
||||
|
||||
@ -77,7 +77,7 @@ index 5afc4e9646d622c6f924d4610ac58eb77404b37a..54c5be029b7418bc97d87e7642e258bf
|
||||
if ((hard_iface->if_status == BATADV_IF_NOT_IN_USE) ||
|
||||
(hard_iface->if_status == BATADV_IF_TO_BE_REMOVED))
|
||||
return;
|
||||
@@ -1777,16 +1788,12 @@ static void batadv_iv_ogm_process(const struct sk_buff *skb, int ogm_offset,
|
||||
@@ -1781,16 +1792,12 @@ static void batadv_iv_ogm_process(const struct sk_buff *skb, int ogm_offset,
|
||||
batadv_orig_node_put(orig_node);
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ index 5afc4e9646d622c6f924d4610ac58eb77404b37a..54c5be029b7418bc97d87e7642e258bf
|
||||
bat_priv = netdev_priv(forw_packet->if_incoming->soft_iface);
|
||||
|
||||
if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_DEACTIVATING) {
|
||||
@@ -1815,6 +1822,20 @@ out:
|
||||
@@ -1819,6 +1826,20 @@ out:
|
||||
batadv_forw_packet_free(forw_packet, dropped);
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ index 5afc4e9646d622c6f924d4610ac58eb77404b37a..54c5be029b7418bc97d87e7642e258bf
|
||||
struct batadv_hard_iface *if_incoming)
|
||||
{
|
||||
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
|
||||
index bf33f04e055bbf288ce6800d0b93da1b4cd9b70d..8906e551c85991e6b085108cf6f2b734b48fc231 100644
|
||||
index 11ced015ab639f0d82f12ae533a92f356734cafa..2489d5e403c1bcbcc9008f51303f7b1ea4753ea2 100644
|
||||
--- a/net/batman-adv/types.h
|
||||
+++ b/net/batman-adv/types.h
|
||||
@@ -78,8 +78,8 @@ enum batadv_dhcp_recipient {
|
@ -104,7 +104,7 @@ index f5feaa8c4fd228228fea519771e2c9e123b10345..a9240a0bedad109aba58e30038fe91a4
|
||||
+ mutex_unlock(&bat_priv->bat_v.ogm_buff_mutex);
|
||||
}
|
||||
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
|
||||
index 8906e551c85991e6b085108cf6f2b734b48fc231..57df7c68dfee8d6bed72edbd044d95016a5dd75e 100644
|
||||
index 2489d5e403c1bcbcc9008f51303f7b1ea4753ea2..3d9704ce31b4a162c01a74021ef18d53d992d506 100644
|
||||
--- a/net/batman-adv/types.h
|
||||
+++ b/net/batman-adv/types.h
|
||||
@@ -27,6 +27,7 @@
|
||||
@ -115,7 +115,7 @@ index 8906e551c85991e6b085108cf6f2b734b48fc231..57df7c68dfee8d6bed72edbd044d9501
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/sched.h> /* for linux/wait.h */
|
||||
@@ -984,15 +985,17 @@ struct batadv_softif_vlan {
|
||||
@@ -990,15 +991,17 @@ struct batadv_softif_vlan {
|
||||
|
||||
/**
|
||||
* struct batadv_priv_bat_v - B.A.T.M.A.N. V per soft-interface private data
|
@ -25,7 +25,7 @@ Signed-off-by: Sven Eckelmann <sven@narfation.org>
|
||||
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/d3be478f1aa27b47f61c4a62e18eb063d47c9168
|
||||
|
||||
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
|
||||
index 54c5be029b7418bc97d87e7642e258bfed120874..3fb3feaf5e462f7263754b81a06fc877aae3f10d 100644
|
||||
index ccb60591a01886ceef22408e9387a8a3fda05a36..80fc960e656eb2f11f58fc8211235e033331bfd5 100644
|
||||
--- a/net/batman-adv/bat_iv_ogm.c
|
||||
+++ b/net/batman-adv/bat_iv_ogm.c
|
||||
@@ -34,6 +34,7 @@
|
||||
@ -44,7 +44,7 @@ index 54c5be029b7418bc97d87e7642e258bfed120874..3fb3feaf5e462f7263754b81a06fc877
|
||||
#include <linux/seq_file.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/slab.h>
|
||||
@@ -367,7 +367,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
|
||||
@@ -371,7 +371,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
|
||||
unsigned char *ogm_buff;
|
||||
u32 random_seqno;
|
||||
|
||||
@ -53,7 +53,7 @@ index 54c5be029b7418bc97d87e7642e258bfed120874..3fb3feaf5e462f7263754b81a06fc877
|
||||
|
||||
/* randomize initial seqno to avoid collision */
|
||||
get_random_bytes(&random_seqno, sizeof(random_seqno));
|
||||
@@ -375,8 +375,10 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
|
||||
@@ -379,8 +379,10 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
|
||||
|
||||
hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
|
||||
ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
|
||||
@ -65,7 +65,7 @@ index 54c5be029b7418bc97d87e7642e258bfed120874..3fb3feaf5e462f7263754b81a06fc877
|
||||
|
||||
hard_iface->bat_iv.ogm_buff = ogm_buff;
|
||||
|
||||
@@ -388,41 +390,59 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
|
||||
@@ -392,41 +394,59 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
|
||||
batadv_ogm_packet->reserved = 0;
|
||||
batadv_ogm_packet->tq = BATADV_TQ_MAX_VALUE;
|
||||
|
||||
@ -132,7 +132,7 @@ index 54c5be029b7418bc97d87e7642e258bfed120874..3fb3feaf5e462f7263754b81a06fc877
|
||||
}
|
||||
|
||||
/* when do we schedule our own ogm to be sent */
|
||||
@@ -921,7 +941,11 @@ batadv_iv_ogm_slide_own_bcast_window(struct batadv_hard_iface *hard_iface)
|
||||
@@ -925,7 +945,11 @@ batadv_iv_ogm_slide_own_bcast_window(struct batadv_hard_iface *hard_iface)
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ index 54c5be029b7418bc97d87e7642e258bfed120874..3fb3feaf5e462f7263754b81a06fc877
|
||||
{
|
||||
struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
|
||||
unsigned char **ogm_buff = &hard_iface->bat_iv.ogm_buff;
|
||||
@@ -932,11 +956,7 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
|
||||
@@ -936,11 +960,7 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
|
||||
u16 tvlv_len = 0;
|
||||
unsigned long send_time;
|
||||
|
||||
@ -158,7 +158,7 @@ index 54c5be029b7418bc97d87e7642e258bfed120874..3fb3feaf5e462f7263754b81a06fc877
|
||||
|
||||
/* the interface gets activated here to avoid race conditions between
|
||||
* the moment of activating the interface in
|
||||
@@ -1004,6 +1024,17 @@ out:
|
||||
@@ -1008,6 +1028,17 @@ out:
|
||||
batadv_hardif_put(primary_if);
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ index 54c5be029b7418bc97d87e7642e258bfed120874..3fb3feaf5e462f7263754b81a06fc877
|
||||
/**
|
||||
* batadv_iv_ogm_orig_update - use OGM to update corresponding data in an
|
||||
* originator
|
||||
@@ -1788,12 +1819,16 @@ static void batadv_iv_ogm_process(const struct sk_buff *skb, int ogm_offset,
|
||||
@@ -1792,12 +1823,16 @@ static void batadv_iv_ogm_process(const struct sk_buff *skb, int ogm_offset,
|
||||
batadv_orig_node_put(orig_node);
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ index 54c5be029b7418bc97d87e7642e258bfed120874..3fb3feaf5e462f7263754b81a06fc877
|
||||
bat_priv = netdev_priv(forw_packet->if_incoming->soft_iface);
|
||||
|
||||
if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_DEACTIVATING) {
|
||||
@@ -1822,20 +1857,6 @@ out:
|
||||
@@ -1826,20 +1861,6 @@ out:
|
||||
batadv_forw_packet_free(forw_packet, dropped);
|
||||
}
|
||||
|
||||
@ -217,10 +217,10 @@ index 54c5be029b7418bc97d87e7642e258bfed120874..3fb3feaf5e462f7263754b81a06fc877
|
||||
struct batadv_hard_iface *if_incoming)
|
||||
{
|
||||
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
|
||||
index 6969f580d0bfd0428f1c6985eaec8bbbf5a0d38b..72b63117fe47c4cb91eb8512b4f44d6b0bc670c9 100644
|
||||
index 6d96ecd14fb0881e3384850bc34063b999fe5c93..0060d3cf2cfcad24fb26c190e588689e768584d5 100644
|
||||
--- a/net/batman-adv/hard-interface.c
|
||||
+++ b/net/batman-adv/hard-interface.c
|
||||
@@ -29,6 +29,7 @@
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/kref.h>
|
||||
#include <linux/list.h>
|
||||
@ -228,7 +228,7 @@ index 6969f580d0bfd0428f1c6985eaec8bbbf5a0d38b..72b63117fe47c4cb91eb8512b4f44d6b
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/printk.h>
|
||||
#include <linux/rculist.h>
|
||||
@@ -896,6 +897,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
|
||||
@@ -905,6 +906,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
|
||||
INIT_LIST_HEAD(&hard_iface->list);
|
||||
INIT_HLIST_HEAD(&hard_iface->neigh_list);
|
||||
|
||||
@ -237,7 +237,7 @@ index 6969f580d0bfd0428f1c6985eaec8bbbf5a0d38b..72b63117fe47c4cb91eb8512b4f44d6b
|
||||
kref_init(&hard_iface->refcount);
|
||||
|
||||
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
|
||||
index 57df7c68dfee8d6bed72edbd044d95016a5dd75e..ee1a3243b160b5ca87e1a42654e579d7358aab6b 100644
|
||||
index 3d9704ce31b4a162c01a74021ef18d53d992d506..6854cb2b107024ad3588ac7eedd71339e529e4f8 100644
|
||||
--- a/net/batman-adv/types.h
|
||||
+++ b/net/batman-adv/types.h
|
||||
@@ -79,14 +79,16 @@ enum batadv_dhcp_recipient {
|
@ -0,0 +1,43 @@
|
||||
From: Sven Eckelmann <sven@narfation.org>
|
||||
Date: Thu, 28 Nov 2019 12:43:49 +0100
|
||||
Subject: batman-adv: Fix DAT candidate selection on little endian systems
|
||||
|
||||
The distributed arp table is using a DHT to store and retrieve MAC address
|
||||
information for an IP address. This is done using unicast messages to
|
||||
selected peers. The potential peers are looked up using the IP address and
|
||||
the VID.
|
||||
|
||||
While the IP address is always stored in big endian byte order, it is not
|
||||
the case of the VID. It can (depending on the host system) either be big
|
||||
endian or little endian. The host must therefore always convert it to big
|
||||
endian to ensure that all devices calculate the same peers for the same
|
||||
lookup data.
|
||||
|
||||
Fixes: 3e26722bc9f2 ("batman-adv: make the Distributed ARP Table vlan aware")
|
||||
Signed-off-by: Sven Eckelmann <sven@narfation.org>
|
||||
Acked-by: Antonio Quartulli <a@unstable.cc>
|
||||
|
||||
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/728aea06f38e0e4d70f4f7d43698187f7f7055c5
|
||||
|
||||
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
|
||||
index fcd38e48a6ea74bd91b0bdd874cb5e88e661e729..91e5bc6c99d40ec17b583dcb857b3c5a3a73453e 100644
|
||||
--- a/net/batman-adv/distributed-arp-table.c
|
||||
+++ b/net/batman-adv/distributed-arp-table.c
|
||||
@@ -243,6 +243,7 @@ static u32 batadv_hash_dat(const void *data, u32 size)
|
||||
u32 hash = 0;
|
||||
const struct batadv_dat_entry *dat = data;
|
||||
const unsigned char *key;
|
||||
+ __be16 vid;
|
||||
u32 i;
|
||||
|
||||
key = (const unsigned char *)&dat->ip;
|
||||
@@ -252,7 +253,8 @@ static u32 batadv_hash_dat(const void *data, u32 size)
|
||||
hash ^= (hash >> 6);
|
||||
}
|
||||
|
||||
- key = (const unsigned char *)&dat->vid;
|
||||
+ vid = htons(dat->vid);
|
||||
+ key = (__force const unsigned char *)&vid;
|
||||
for (i = 0; i < sizeof(dat->vid); i++) {
|
||||
hash += key[i];
|
||||
hash += (hash << 10);
|
Loading…
Reference in New Issue
Block a user