batman-adv: increase DAT DHT timeout
v9 cover batman-adv: increase DAT DHT timeout
This patchset increases the DAT DHT timeout to reduce the amount of broadcasted ARP Replies.
To increase the timeout only for DAT DHT entries added via DHT-PUT but not for any other entry in the DAT cache the DAT cache and DAT DHT concepts are split into two separate hash tables (PATCH 2/3).
PATCH 3/3 then increases the timeout for DAT DHT entries from 5 to 30 minutes.
The motivation for this patchset is based on the observations made here:
https://www.open-mesh.org/projects/batman-adv/wiki/DAT_DHCP_Snooping
In
tests this year at Freifunk Lübeck with ~180 mesh nodes and Gluon
this reduced the ARP broadcast overhead, measured over 7 days, as
follows:
- Total: 6677.66 bits/s -> 677.26 bits/s => -89.86%
11.92 pkts/s -> 1.21 pkts/s => -89.85%
- from gateways: 5618.02 bits/s -> 212.28 => -96.22%
10.03 pkts/s -> 0.38 pkts/s => -96.21%
Also see graphics and a few more test details here:
- https://www.open-mesh.org/projects/batman-adv/wiki/DAT_DHCP_Snooping#Result-2
These patches (v5) have been applied in this mesh network without issues for 3 months now.
Regards,
Linus
---
Changelog v9:
- PATCH 1/3:
- fixed typo in a comment: ENOENT -> ENONET
Changelog v8:
- PATCH 1/3:
- fixing / cleaning up includes
- fixing function kernel doc titles
- fixing bugs introduced in v7 in the error handling of batadv_orig_dump() and batadv_neigh_dump(), using a goto pattern with more explicit labels
Changelog v7:
- adding PATCH 1/3 to add the batadv_netlink_get_softif() wrapper to reduce the amount of duplicate code, both in the current code base but also for the next PATCH 2/3
Changelog v6:
- removed renaming+deprecation of BATADV_P_DAT_CACHE_REPLY in PATCH 1/2
- small commit message rewording in PATCH 1/2
Changelog v5:
- rebased to current main branch
-> removed now obsolete debugfs code
Changelog v4:
- rebased to: acfc9a214d01695
("batman-adv: genetlink: make policy common to family")
Changelog v3:
formerly:
"batman-adv: Increase purge timeout on DAT DHT candidates"
https://patchwork.open-mesh.org/patch/17728/
- fixed the potential jiffies overflow and jiffies initialization issues by replacing the last_dht_update timeout variable with a split of DAT cache and DAT DHT into two separate hash tables -> instead of maintaining two timeouts in one DAT entry two DAT entries are created and maintained in their respective DAT cache and DAT DHT hash tables
Changelog v2:
formerly:
"batman-adv: Increase DHCP snooped DAT entry purge timeout in DHT"
(https://patchwork.open-mesh.org/patch/17364/)
- removed the extended timeouts flag in the DHT-PUT messages introduced in v1 again
- removed DHCP dependency
PATCH v9 1/3 batman-adv: netlink: reduce duplicate code by returning interfaces
Reduce duplicate code by using netlink helpers which return the soft/hard interface directly. Instead of returning an interface index which we are typically not interested in.
--- net/batman-adv/bridge_loop_avoidance.c | 33 ++---- net/batman-adv/distributed-arp-table.c | 18 +-- net/batman-adv/gateway_client.c | 18 +-- net/batman-adv/multicast.c | 17 +-- net/batman-adv/netlink.c | 146 +++++++++++++++++-------- net/batman-adv/netlink.h | 5 +- net/batman-adv/originator.c | 116 +++++++------------- net/batman-adv/translation-table.c | 30 ++--- 8 files changed, 174 insertions(+), 209 deletions(-)
net/batman-adv/bridge_loop_avoidance.c +7 -26
@@ -12,6 +12,7 @@#include <linux/compiler.h> #include <linux/container_of.h> #include <linux/crc16.h> +#include <linux/err.h> #include <linux/errno.h> #include <linux/etherdevice.h> #include <linux/gfp.h>
@@ -38,7 +39,6 @@#include <net/arp.h> #include <net/genetlink.h> #include <net/netlink.h> -#include <net/sock.h> #include <uapi/linux/batadv_packet.h> #include <uapi/linux/batman_adv.h>
@@ -47,7 +47,6 @@#include "log.h" #include "netlink.h" #include "originator.h" -#include "soft-interface.h" #include "translation-table.h" static const u8 batadv_announce_mac[4 ] = {0x43 ,0x05 ,0x43 ,0x05 };
@@ -2233,25 +2232,16 @@ int batadv_bla_claim_dump(struct sk_buff *msg, struct netlink_callback *cb) {struct batadv_hard_iface *primary_if =NULL ;int portid =NETLINK_CB (cb->skb).portid; -struct net *net =sock_net (cb->skb->sk);struct net_device *soft_iface;struct batadv_hashtable *hash;struct batadv_priv *bat_priv;int bucket = cb->args[0 ];int idx = cb->args[1 ]; -int ifindex;int ret =0 ; - ifindex =batadv_netlink_get_ifindex (cb->nlh, -BATADV_ATTR_MESH_IFINDEX ); -if (!ifindex) -return -EINVAL ; - - soft_iface =dev_get_by_index (net, ifindex); -if (!soft_iface || !batadv_softif_is_valid (soft_iface)) { - ret = -ENODEV ; - goto out; - } + soft_iface =batadv_netlink_get_softif (cb); +if (IS_ERR (soft_iface)) +return PTR_ERR (soft_iface); bat_priv =netdev_priv (soft_iface); hash = bat_priv->bla.claim_hash;
@@ -2403,25 +2393,16 @@ int batadv_bla_backbone_dump(struct sk_buff *msg, struct netlink_callback *cb) {struct batadv_hard_iface *primary_if =NULL ;int portid =NETLINK_CB (cb->skb).portid; -struct net *net =sock_net (cb->skb->sk);struct net_device *soft_iface;struct batadv_hashtable *hash;struct batadv_priv *bat_priv;int bucket = cb->args[0 ];int idx = cb->args[1 ]; -int ifindex;int ret =0 ; - ifindex =batadv_netlink_get_ifindex (cb->nlh, -BATADV_ATTR_MESH_IFINDEX ); -if (!ifindex) -return -EINVAL ; - - soft_iface =dev_get_by_index (net, ifindex); -if (!soft_iface || !batadv_softif_is_valid (soft_iface)) { - ret = -ENODEV ; - goto out; - } + soft_iface =batadv_netlink_get_softif (cb); +if (IS_ERR (soft_iface)) +return PTR_ERR (soft_iface); bat_priv =netdev_priv (soft_iface); hash = bat_priv->bla.backbone_hash;
net/batman-adv/distributed-arp-table.c +4 -14
@@ -11,6 +11,7 @@#include <linux/bitops.h> #include <linux/byteorder/generic.h> #include <linux/container_of.h> +#include <linux/err.h> #include <linux/errno.h> #include <linux/etherdevice.h> #include <linux/gfp.h>
@@ -36,7 +37,6 @@#include <net/arp.h> #include <net/genetlink.h> #include <net/netlink.h> -#include <net/sock.h> #include <uapi/linux/batman_adv.h> #include "bridge_loop_avoidance.h"
@@ -46,7 +46,6 @@#include "netlink.h" #include "originator.h" #include "send.h" -#include "soft-interface.h" #include "translation-table.h" #include "tvlv.h"
@@ -937,25 +936,16 @@ int batadv_dat_cache_dump(struct sk_buff *msg, struct netlink_callback *cb) {struct batadv_hard_iface *primary_if =NULL ;int portid =NETLINK_CB (cb->skb).portid; -struct net *net =sock_net (cb->skb->sk);struct net_device *soft_iface;struct batadv_hashtable *hash;struct batadv_priv *bat_priv;int bucket = cb->args[0 ];int idx = cb->args[1 ]; -int ifindex;int ret =0 ; - ifindex =batadv_netlink_get_ifindex (cb->nlh, -BATADV_ATTR_MESH_IFINDEX ); -if (!ifindex) -return -EINVAL ; - - soft_iface =dev_get_by_index (net, ifindex); -if (!soft_iface || !batadv_softif_is_valid (soft_iface)) { - ret = -ENODEV ; - goto out; - } + soft_iface =batadv_netlink_get_softif (cb); +if (IS_ERR (soft_iface)) +return PTR_ERR (soft_iface); bat_priv =netdev_priv (soft_iface); hash = bat_priv->dat.hash;
net/batman-adv/gateway_client.c +4 -14
@@ -10,6 +10,7 @@#include <linux/atomic.h> #include <linux/byteorder/generic.h> #include <linux/container_of.h> +#include <linux/err.h> #include <linux/errno.h> #include <linux/etherdevice.h> #include <linux/gfp.h>
@@ -31,7 +32,6 @@#include <linux/sprintf.h> #include <linux/stddef.h> #include <linux/udp.h> -#include <net/sock.h> #include <uapi/linux/batadv_packet.h> #include <uapi/linux/batman_adv.h>
@@ -40,7 +40,6 @@#include "netlink.h" #include "originator.h" #include "routing.h" -#include "soft-interface.h" #include "translation-table.h" /* These are the offsets of the "hw type" and "hw address length" in the dhcp
@@ -502,22 +501,13 @@ void batadv_gw_node_free(struct batadv_priv *bat_priv)int batadv_gw_dump (struct sk_buff *msg,struct netlink_callback *cb) {struct batadv_hard_iface *primary_if =NULL ; -struct net *net =sock_net (cb->skb->sk);struct net_device *soft_iface;struct batadv_priv *bat_priv; -int ifindex;int ret; - ifindex =batadv_netlink_get_ifindex (cb->nlh, -BATADV_ATTR_MESH_IFINDEX ); -if (!ifindex) -return -EINVAL ; - - soft_iface =dev_get_by_index (net, ifindex); -if (!soft_iface || !batadv_softif_is_valid (soft_iface)) { - ret = -ENODEV ; - goto out; - } + soft_iface =batadv_netlink_get_softif (cb); +if (IS_ERR (soft_iface)) +return PTR_ERR (soft_iface); bat_priv =netdev_priv (soft_iface);
net/batman-adv/multicast.c +4 -13
@@ -12,6 +12,7 @@#include <linux/bug.h> #include <linux/byteorder/generic.h> #include <linux/container_of.h> +#include <linux/err.h> #include <linux/errno.h> #include <linux/etherdevice.h> #include <linux/gfp.h>
@@ -46,7 +47,6 @@#include <net/ip.h> #include <net/ipv6.h> #include <net/netlink.h> -#include <net/sock.h> #include <uapi/linux/batadv_packet.h> #include <uapi/linux/batman_adv.h>
@@ -56,7 +56,6 @@#include "log.h" #include "netlink.h" #include "send.h" -#include "soft-interface.h" #include "translation-table.h" #include "tvlv.h"
@@ -2112,21 +2111,13 @@ batadv_mcast_netlink_get_primary(struct netlink_callback *cb, struct batadv_hard_iface **primary_if) {struct batadv_hard_iface *hard_iface =NULL ; -struct net *net =sock_net (cb->skb->sk);struct net_device *soft_iface;struct batadv_priv *bat_priv; -int ifindex;int ret =0 ; - ifindex =batadv_netlink_get_ifindex (cb->nlh,BATADV_ATTR_MESH_IFINDEX ); -if (!ifindex) -return -EINVAL ; - - soft_iface =dev_get_by_index (net, ifindex); -if (!soft_iface || !batadv_softif_is_valid (soft_iface)) { - ret = -ENODEV ; - goto out; - } + soft_iface =batadv_netlink_get_softif (cb); +if (IS_ERR (soft_iface)) +return PTR_ERR (soft_iface); bat_priv =netdev_priv (soft_iface);
net/batman-adv/netlink.c +103 -43
231 lines not on this page · raw message
net/batman-adv/netlink.h +4 -1
@@ -15,7 +15,10 @@void batadv_netlink_register (void );void batadv_netlink_unregister (void ); -int batadv_netlink_get_ifindex (const struct nlmsghdr *nlh,int attrtype); +struct net_device *batadv_netlink_get_softif (struct netlink_callback *cb); +struct batadv_hard_iface * +batadv_netlink_get_hardif (struct batadv_priv *bat_priv, +struct netlink_callback *cb); int batadv_netlink_tpmeter_notify(struct batadv_priv *bat_priv, const u8 *dst, u8 result, u32 test_time, u64 total_bytes,
net/batman-adv/originator.c +41 -75
191 lines not on this page · raw message
net/batman-adv/translation-table.c +7 -23
@@ -15,6 +15,7 @@#include <linux/compiler.h> #include <linux/container_of.h> #include <linux/crc32c.h> +#include <linux/err.h> #include <linux/errno.h> #include <linux/etherdevice.h> #include <linux/gfp.h>
@@ -39,7 +40,6 @@#include <linux/workqueue.h> #include <net/genetlink.h> #include <net/netlink.h> -#include <net/sock.h> #include <uapi/linux/batadv_packet.h> #include <uapi/linux/batman_adv.h>
@@ -1170,26 +1170,18 @@ batadv_tt_local_dump_bucket(struct sk_buff *msg, u32 portid,*/ int batadv_tt_local_dump (struct sk_buff *msg,struct netlink_callback *cb) { -struct net *net =sock_net (cb->skb->sk);struct net_device *soft_iface;struct batadv_priv *bat_priv;struct batadv_hard_iface *primary_if =NULL ;struct batadv_hashtable *hash;int ret; -int ifindex;int bucket = cb->args[0 ];int idx = cb->args[1 ];int portid =NETLINK_CB (cb->skb).portid; - ifindex =batadv_netlink_get_ifindex (cb->nlh,BATADV_ATTR_MESH_IFINDEX ); -if (!ifindex) -return -EINVAL ; - - soft_iface =dev_get_by_index (net, ifindex); -if (!soft_iface || !batadv_softif_is_valid (soft_iface)) { - ret = -ENODEV ; - goto out; - } + soft_iface =batadv_netlink_get_softif (cb); +if (IS_ERR (soft_iface)) +return PTR_ERR (soft_iface); bat_priv =netdev_priv (soft_iface);
@@ -1945,28 +1937,20 @@ batadv_tt_global_dump_bucket(struct sk_buff *msg, u32 portid, u32 seq,*/ int batadv_tt_global_dump (struct sk_buff *msg,struct netlink_callback *cb) { -struct net *net =sock_net (cb->skb->sk);struct net_device *soft_iface;struct batadv_priv *bat_priv;struct batadv_hard_iface *primary_if =NULL ;struct batadv_hashtable *hash;struct hlist_head *head;int ret; -int ifindex;int bucket = cb->args[0 ];int idx = cb->args[1 ];int sub = cb->args[2 ];int portid =NETLINK_CB (cb->skb).portid; - ifindex =batadv_netlink_get_ifindex (cb->nlh,BATADV_ATTR_MESH_IFINDEX ); -if (!ifindex) -return -EINVAL ; - - soft_iface =dev_get_by_index (net, ifindex); -if (!soft_iface || !batadv_softif_is_valid (soft_iface)) { - ret = -ENODEV ; - goto out; - } + soft_iface =batadv_netlink_get_softif (cb); +if (IS_ERR (soft_iface)) +return PTR_ERR (soft_iface); bat_priv =netdev_priv (soft_iface);
Signature · 1 line
2.47.1
PATCH v9 2/3 batman-adv: split DAT cache into DAT cache and DAT DHT
In reply to Linus LüssingSimilar to the translation table split the (mostly) locally maintained DAT cache and the DAT DHT concepts into two separate tables.
This eases the monitoring and debugging regarding the origin of DAT entries. And allows to apply differing properties to entries in the DAT cache and DAT DHT in the future, like distinct timeouts.
--- include/uapi/linux/batman_adv.h | 5 + net/batman-adv/distributed-arp-table.c | 316 +++++++++++++++++++------ net/batman-adv/distributed-arp-table.h | 13 +- net/batman-adv/netlink.c | 5 + net/batman-adv/routing.c | 8 +- net/batman-adv/types.h | 7 +- 6 files changed, 269 insertions(+), 85 deletions(-)
include/uapi/linux/batman_adv.h +5 -0
@@ -613,6 +613,11 @@ enum batadv_nl_commands {*/ BATADV_CMD_SET_VLAN , +/** +* @BATADV_CMD_GET_DAT_DHT: Query list of DAT DHT entries +*/ + BATADV_CMD_GET_DAT_DHT, +/* add new commands above here */ /**
net/batman-adv/distributed-arp-table.c +238 -78
557 lines not on this page · raw message
net/batman-adv/distributed-arp-table.h +11 -2
@@ -31,7 +31,8 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,void batadv_dat_snoop_outgoing_arp_reply (struct batadv_priv *bat_priv,struct sk_buff *skb);bool batadv_dat_snoop_incoming_arp_reply (struct batadv_priv *bat_priv, -struct sk_buff *skb,int hdr_size); +struct sk_buff *skb,int hdr_size, +bool is_dht_put); void batadv_dat_snoop_outgoing_dhcp_ack(struct batadv_priv *bat_priv, struct sk_buff *skb, __be16 proto,
@@ -74,6 +75,7 @@ batadv_dat_init_own_addr(struct batadv_priv *bat_priv,int batadv_dat_init (struct batadv_priv *bat_priv);void batadv_dat_free (struct batadv_priv *bat_priv);int batadv_dat_cache_dump (struct sk_buff *msg,struct netlink_callback *cb); +int batadv_dat_dht_dump (struct sk_buff *msg,struct netlink_callback *cb);/** * batadv_dat_inc_counter() - increment the correct DAT packet counter
@@ -126,7 +128,8 @@ batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,static inline bool batadv_dat_snoop_incoming_arp_reply (struct batadv_priv *bat_priv, -struct sk_buff *skb,int hdr_size) +struct sk_buff *skb,int hdr_size, +bool is_dht_put) {return false; }
@@ -176,6 +179,12 @@ batadv_dat_cache_dump(struct sk_buff *msg, struct netlink_callback *cb)return -EOPNOTSUPP ; } +static inline int +batadv_dat_dht_dump (struct sk_buff *msg,struct netlink_callback *cb) +{ +return -EOPNOTSUPP ; +} +static inline void batadv_dat_inc_counter (struct batadv_priv *bat_priv,u8 subtype) {
net/batman-adv/netlink.c +5 -0
@@ -1502,6 +1502,11 @@ static const struct genl_small_ops batadv_netlink_ops[] = { .flags = GENL_UNS_ADMIN_PERM, .dumpit = batadv_dat_cache_dump, }, + { + .cmd = BATADV_CMD_GET_DAT_DHT, + .flags = GENL_ADMIN_PERM, + .dumpit = batadv_dat_dht_dump, + }, { .cmd = BATADV_CMD_GET_MCAST_FLAGS, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
net/batman-adv/routing.c +5 -3
@@ -943,10 +943,10 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,struct batadv_unicast_4addr_packet *unicast_4addr_packet;u8 *orig_addr, *orig_addr_gw;struct batadv_orig_node *orig_node =NULL , *orig_node_gw =NULL ; +bool is4addr, is_gw, is_dht_put = false;int check, hdr_size =sizeof (*unicast_packet);enum batadv_subtype subtype;int ret =NET_RX_DROP ; -bool is4addr, is_gw; unicast_packet = (struct batadv_unicast_packet *)skb->data; is4addr = unicast_packet->packet_type ==BATADV_UNICAST_4ADDR ;
@@ -1005,6 +1005,8 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, orig_addr = unicast_4addr_packet->src; orig_node =batadv_orig_hash_find (bat_priv, orig_addr); + }else if (subtype ==BATADV_P_DAT_DHT_PUT ) { + is_dht_put = true; } }
@@ -1012,7 +1014,7 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, hdr_size)) goto rx_success;if (batadv_dat_snoop_incoming_arp_reply (bat_priv, skb, - hdr_size)) + hdr_size, is_dht_put)) goto rx_success;batadv_dat_snoop_incoming_dhcp_ack (bat_priv, skb, hdr_size);
@@ -1249,7 +1251,7 @@ int batadv_recv_bcast_packet(struct sk_buff *skb,if (batadv_dat_snoop_incoming_arp_request (bat_priv, skb, hdr_size)) goto rx_success; -if (batadv_dat_snoop_incoming_arp_reply (bat_priv, skb, hdr_size)) +if (batadv_dat_snoop_incoming_arp_reply (bat_priv, skb, hdr_size, false)) goto rx_success;batadv_dat_snoop_incoming_dhcp_ack (bat_priv, skb, hdr_size);
net/batman-adv/types.h +5 -2
@@ -1231,8 +1231,11 @@ struct batadv_priv_dat {/** @addr: node DAT address */ batadv_dat_addr_t addr; -/** @hash: hashtable representing the local ARP cache */ -struct batadv_hashtable *hash; +/** @cache_hash: hashtable representing the local ARP cache */ +struct batadv_hashtable *cache_hash; + +/** @dht_hash: hashtable representing the local DAT DHT */ +struct batadv_hashtable *dht_hash;/** @work: work queue callback item for cache purging */ struct delayed_work work;
Signature · 1 line
2.47.1
Sven Eckelmann
maintainerRe: [PATCH v9 2/3] batman-adv: split DAT cache into DAT cache and DAT DHT
Quoted 8 lines · Linus Lüssing
Similar to the translation table split the (mostly) locally maintained DAT cache and the DAT DHT concepts into two separate tables.
This eases the monitoring and debugging regarding the origin of DAT entries. And allows to apply differing properties to entries in the DAT cache and DAT DHT in the future, like distinct timeouts.
Signed-off-by Linus Lüssing <[email protected]>
It applies find on 2cff5b1c6bba ("batman-adv: Use mailmap to fix old e-mail addresses") but not anymore on the current main. This patch has various minor conflicts with the rename of softif to meshif. It looks like the conflict has to be solved like this
net/batman-adv/distributed-arp-table.c +12 -52
@@ -144,13 +144,8 @@ }/** -<<<<<<< * __batadv_dat_purge() - delete entries from a DAT hash table * @hash: the hash table to delete from -======= -* __batadv_dat_purge() - delete entries from the DAT local storage -* @bat_priv: the bat priv with all the mesh interface information ->>>>>>> * @to_purge: function in charge to decide whether an entry has to be purged or * not. This function takes the dat_entry as argument and has to * returns a boolean value: true is the entry has to be deleted,
@@ -319,14 +314,8 @@ }/** -<<<<<<< * batadv_dat_entry_hash_find() - look for a given dat_entry in a hash table * @hash: the hash table to search in -======= -* batadv_dat_entry_hash_find() - look for a given dat_entry in the local hash -* table -* @bat_priv: the bat priv with all the mesh interface information ->>>>>>> * @ip: search key * @vid: VLAN identifier *
@@ -397,12 +386,8 @@/** * batadv_dat_entry_add() - add a new dat entry or update it if already exists -<<<<<<< * @bat_priv: the bat priv with all the mesh interface information -======= -* @bat_priv: the bat priv with all the soft interface information * @hash: the hash table to add to ->>>>>>> * @ip: ipv4 to add/edit * @mac_addr: mac address to assign to the given ipv4 * @vid: VLAN identifier
@@ -865,13 +850,8 @@ }/** -<<<<<<< * batadv_dat_hash_free() - free a DAT hash table -* @bat_priv: the bat priv with all the soft interface information -======= -* batadv_dat_hash_free() - free the local DAT hash table * @bat_priv: the bat priv with all the mesh interface information ->>>>>>> */ static void batadv_dat_hash_free (struct batadv_hashtable **hash) {
@@ -1068,27 +1048,11 @@ u8 cmd) {int portid =NETLINK_CB (cb->skb).portid; -<<<<<<<struct batadv_hard_iface *primary_if; -======= -struct net_device *mesh_iface; -struct batadv_hashtable *hash; -struct batadv_priv *bat_priv; ->>>>>>>int bucket = cb->args[0 ];int idx = cb->args[1 ];int ret =0 ; -<<<<<<< -======= - mesh_iface =batadv_netlink_get_meshif (cb); -if (IS_ERR (mesh_iface)) -return PTR_ERR (mesh_iface); - - bat_priv =netdev_priv (mesh_iface); - hash = bat_priv->dat.hash; - ->>>>>>> primary_if =batadv_primary_if_get_selected (bat_priv);if (!primary_if || primary_if->if_status !=BATADV_IF_ACTIVE ) { ret = -ENOENT ;
@@ -1112,12 +1076,8 @@ out:batadv_hardif_put (primary_if); -<<<<<<< -dev_put (mesh_iface); -=======return ret; } ->>>>>>>/** * batadv_dat_cache_dump() - dump the DAT cache table to a netlink socket
@@ -1128,20 +1088,20 @@*/ int batadv_dat_cache_dump (struct sk_buff *msg,struct netlink_callback *cb) { -struct net_device *soft_iface; +struct net_device *mesh_iface;struct batadv_priv *bat_priv;int ret; - soft_iface =batadv_netlink_get_softif (cb); -if (IS_ERR (soft_iface)) -return PTR_ERR (soft_iface); + mesh_iface =batadv_netlink_get_meshif (cb); +if (IS_ERR (mesh_iface)) +return PTR_ERR (mesh_iface); - bat_priv =netdev_priv (soft_iface); + bat_priv =netdev_priv (mesh_iface); ret =batadv_dat_dump (bat_priv, msg, cb, bat_priv->dat.cache_hash,BATADV_CMD_GET_DAT_CACHE ); -dev_put (soft_iface); +dev_put (mesh_iface);return ret; }
@@ -1154,20 +1114,20 @@*/ int batadv_dat_dht_dump (struct sk_buff *msg,struct netlink_callback *cb) { -struct net_device *soft_iface; +struct net_device *mesh_iface;struct batadv_priv *bat_priv;int ret; - soft_iface =batadv_netlink_get_softif (cb); -if (IS_ERR (soft_iface)) -return PTR_ERR (soft_iface); + mesh_iface =batadv_netlink_get_meshif (cb); +if (IS_ERR (mesh_iface)) +return PTR_ERR (mesh_iface); - bat_priv =netdev_priv (soft_iface); + bat_priv =netdev_priv (mesh_iface); ret =batadv_dat_dump (bat_priv, msg, cb, bat_priv->dat.dht_hash,BATADV_CMD_GET_DAT_DHT ); -dev_put (soft_iface); +dev_put (mesh_iface);return ret; }
Quoted 7 lines
net/batman-adv/distributed-arp-table.c +0
-0
net/batman-adv/distributed-arp-table.c static void batadv_dat_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv, · line 857
Quoted 9 lines
net/batman-adv/distributed-arp-table.c +2
-2@@ -785,19 +851,57 @@ static void batadv_dat_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv, }/** -* batadv_dat_hash_free() - free the local DAT hash table +* batadv_dat_hash_free() - free a DAT hash table * @bat_priv: the bat priv with all the soft interface information */ -static void batadv_dat_hash_free (struct batadv_priv *bat_priv) +static void batadv_dat_hash_free (struct batadv_hashtable **hash)
function parameter 'hash' not described in 'batadv_dat_hash_free'
net/batman-adv/distributed-arp-table.c void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv, · line 1490
Quoted 7 lines
net/batman-adv/distributed-arp-table.c +2
-1@@ -1332,7 +1486,8 @@ void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,* packet has to be delivered to the interface */ bool batadv_dat_snoop_incoming_arp_reply (struct batadv_priv *bat_priv, -struct sk_buff *skb,int hdr_size) +struct sk_buff *skb,int hdr_size, +bool is_dht_put)
function parameter 'is_dht_put' not described in 'batadv_dat_snoop_incoming_arp_reply'
Signature · 1 line
Sven Eckelmann <[email protected]>
PATCH v9 3/3 batman-adv: increase DAT DHT timeout
In reply to Linus LüssingCurrently, the DHT_GET messages of the DAT will likely be left unanswered due to the following issues:
When a node has a matching DAT Cache entry for a local ARP Request then this node will answer it directly with the information provided by the cache. This however, will likely lead to missing ARP Replies from the original host. Which in turn leads to the DAT DHT not being updated.
Then the local DAT cache entry will time out, triggering a unicasted DHT_GET. However, as the 5min. timeout has passed, the DAT DHT candidates will likely have purged their entry, too.
So basically this results in an ARP Request broadcast fallback every five minutes.
A second issue is that it is quite common that a host which has long gone offline will be tried to be contacted by another one at some remote period larger than the current 5min. timeout. This too leads to flooded ARP Requests.
With this patch the purge timeout for DAT DHT entries is increased to 30min to reduce the number of DAT ARP broadcast fallbacks.
--- net/batman-adv/distributed-arp-table.c | 22 +++++++++++++++++----- net/batman-adv/main.h | 3 ++- 2 files changed, 19 insertions(+), 6 deletions(-)
net/batman-adv/distributed-arp-table.c +17 -5
@@ -132,15 +132,27 @@ static void batadv_dat_entry_put(struct batadv_dat_entry *dat_entry) }/** -* batadv_dat_to_purge() - check whether a dat_entry has to be purged or not +* batadv_dat_cache_to_purge() - check if a cache entry has to be purged or not * @dat_entry: the entry to check * * Return: true if the entry has to be purged now, false otherwise. */ -static bool batadv_dat_to_purge (struct batadv_dat_entry *dat_entry) +static bool batadv_dat_cache_to_purge (struct batadv_dat_entry *dat_entry) {return batadv_has_timed_out (dat_entry->last_update, -BATADV_DAT_ENTRY_TIMEOUT ); +BATADV_DAT_CACHE_ENTRY_TIMEOUT ); +} + +/** +* batadv_dat_dht_to_purge() - check if a DHT entry has to be purged or not +* @dat_entry: the entry to check +* +* Return: true if the entry has to be purged now, false otherwise. +*/ +static bool batadv_dat_dht_to_purge (struct batadv_dat_entry *dat_entry) +{ +return batadv_has_timed_out (dat_entry->last_update, +BATADV_DAT_DHT_ENTRY_TIMEOUT ); }/**
@@ -201,8 +213,8 @@ static void batadv_dat_purge(struct work_struct *work) priv_dat = container_of(delayed_work, struct batadv_priv_dat, work); bat_priv = container_of(priv_dat, struct batadv_priv, dat); -__batadv_dat_purge (bat_priv->dat.cache_hash, batadv_dat_to_purge); -__batadv_dat_purge (bat_priv->dat.dht_hash, batadv_dat_to_purge); +__batadv_dat_purge (bat_priv->dat.cache_hash, batadv_dat_cache_to_purge); +__batadv_dat_purge (bat_priv->dat.dht_hash, batadv_dat_dht_to_purge);batadv_dat_start_timer (bat_priv); }
net/batman-adv/main.h +2 -1
@@ -38,7 +38,8 @@#define BATADV_TT_WORK_PERIOD 5000/* 5 seconds */ #define BATADV_ORIG_WORK_PERIOD 1000/* 1 second */ #define BATADV_MCAST_WORK_PERIOD 500/* 0.5 seconds */ -#define BATADV_DAT_ENTRY_TIMEOUT (5 * 60000)/* 5 mins in milliseconds */ +#define BATADV_DAT_CACHE_ENTRY_TIMEOUT (5 * 60000)/* 5 mins in milliseconds */ +#define BATADV_DAT_DHT_ENTRY_TIMEOUT (30 * 60000)/* 30 mins in milliseconds */ /* sliding packet range of received originator messages in sequence numbers * (should be a multiple of our word size) */
Signature · 1 line
2.47.1