batman-adv: increase DAT DHT timeout
v8 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 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 v8 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.45.2
Sven Eckelmann
maintainerRe: [PATCH v8 1/3] batman-adv: netlink: reduce duplicate code by returning interfaces
net/batman-adv/originator.c batadv_neigh_node_get_or_create(struct batadv_orig_node *orig_node, · line 778
Quoted 6 lines · On Monday, 13 January 2025 20:31:39 CET Linus Lüssing wrote:
net/batman-adv/originator.c +6
-0+ hard_iface =batadv_netlink_get_hardif (bat_priv, cb); +if (IS_ERR (hard_iface) &&PTR_ERR (hard_iface) != -ENONET ) { + ret =PTR_ERR (hard_iface); + goto out_put_primary_if; + }else if (IS_ERR (hard_iface)) { +/* => PTR_ERR(hard_iface) == -ENOENT
No, this would mean that the error is "ENONET" (Machine is not on the network) and not ENOENT (No such file or directory). Is this a typo in the comment or did you actually wanted to use ENOENT in the rest of the code?
net/batman-adv/originator.c batadv_neigh_node_get_or_create(struct batadv_orig_node *orig_node, · line 782
Quoted 4 lines
net/batman-adv/originator.c +3
-0+* => no hard-iface given, ok +*/ + hard_iface =BATADV_IF_DEFAULT ; }
Kind regards,
Sven
Re: [PATCH v8 1/3] batman-adv: netlink: reduce duplicate code by returning interfaces
Quoted 11 lines · Sven Eckelmann
net/batman-adv/originator.c batadv_neigh_node_get_or_create(struct batadv_orig_node *orig_node, · line 778
Quoted 6 lines · On Monday, 13 January 2025 20:31:39 CET Linus Lüssing wrote:
net/batman-adv/originator.c +6
-0+ hard_iface =batadv_netlink_get_hardif (bat_priv, cb); +if (IS_ERR (hard_iface) &&PTR_ERR (hard_iface) != -ENONET ) { + ret =PTR_ERR (hard_iface); + goto out_put_primary_if; + }else if (IS_ERR (hard_iface)) { +/* => PTR_ERR(hard_iface) == -ENOENT No, this would mean that the error is "ENONET" (Machine is not on the network) and not ENOENT (No such file or directory). Is this a typo in the comment or did you actually wanted to use ENOENT in the rest of the code?
I wanted to use some less common error code, to reduce the risk that some future additions to batadv_netlink_get_hardif() might accidentally reuse this "soft error" case code for a real error case.
But in v8 seems like I forgot about that intention and then misread the ENONET as ENOENT :-). Leading to this typo. v9 should correct this.
Regards, Linus
PATCH v8 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.45.2
PATCH v8 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.45.2