Skip to content

Commit cbebd36

Browse files
T-Xsimonwunderlich
authored andcommitted
batman-adv: Use own timer for multicast TT and TVLV updates
Instead of latching onto the OGM period, this patch introduces a worker dedicated to multicast TT and TVLV updates. The reasoning is, that upon roaming especially the translation table should be updated timely to minimize connectivity issues. With BATMAN V, the idea is to greatly increase the OGM interval to reduce overhead. Unfortunately, right now this could lead to a bad user experience if multicast traffic is involved. Therefore this patch introduces a fixed 500ms update interval for multicast TT entries and the multicast TVLV. Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue> Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
1 parent eb6915e commit cbebd36

5 files changed

Lines changed: 60 additions & 17 deletions

File tree

‎net/batman-adv/main.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#define BATADV_TT_CLIENT_TEMP_TIMEOUT 600000 /* in milliseconds */
4949
#define BATADV_TT_WORK_PERIOD 5000 /* 5 seconds */
5050
#define BATADV_ORIG_WORK_PERIOD 1000 /* 1 second */
51+
#define BATADV_MCAST_WORK_PERIOD 500 /* 0.5 seconds */
5152
#define BATADV_DAT_ENTRY_TIMEOUT (5 * 60000) /* 5 mins in milliseconds */
5253
/* sliding packet range of received originator messages in sequence numbers
5354
* (should be a multiple of our word size)

‎net/batman-adv/multicast.c‎

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <linux/in6.h>
3434
#include <linux/ip.h>
3535
#include <linux/ipv6.h>
36+
#include <linux/jiffies.h>
3637
#include <linux/kernel.h>
3738
#include <linux/kref.h>
3839
#include <linux/list.h>
@@ -48,6 +49,7 @@
4849
#include <linux/stddef.h>
4950
#include <linux/string.h>
5051
#include <linux/types.h>
52+
#include <linux/workqueue.h>
5153
#include <net/addrconf.h>
5254
#include <net/if_inet6.h>
5355
#include <net/ip.h>
@@ -60,6 +62,18 @@
6062
#include "translation-table.h"
6163
#include "tvlv.h"
6264

65+
static void batadv_mcast_mla_update(struct work_struct *work);
66+
67+
/**
68+
* batadv_mcast_start_timer - schedule the multicast periodic worker
69+
* @bat_priv: the bat priv with all the soft interface information
70+
*/
71+
static void batadv_mcast_start_timer(struct batadv_priv *bat_priv)
72+
{
73+
queue_delayed_work(batadv_event_workqueue, &bat_priv->mcast.work,
74+
msecs_to_jiffies(BATADV_MCAST_WORK_PERIOD));
75+
}
76+
6377
/**
6478
* batadv_mcast_get_bridge - get the bridge on top of the softif if it exists
6579
* @soft_iface: netdev struct of the mesh interface
@@ -255,14 +269,16 @@ static void batadv_mcast_mla_list_free(struct hlist_head *mcast_list)
255269
* translation table except the ones listed in the given mcast_list.
256270
*
257271
* If mcast_list is NULL then all are retracted.
272+
*
273+
* Do not call outside of the mcast worker! (or cancel mcast worker first)
258274
*/
259275
static void batadv_mcast_mla_tt_retract(struct batadv_priv *bat_priv,
260276
struct hlist_head *mcast_list)
261277
{
262278
struct batadv_hw_addr *mcast_entry;
263279
struct hlist_node *tmp;
264280

265-
lockdep_assert_held(&bat_priv->tt.commit_lock);
281+
WARN_ON(delayed_work_pending(&bat_priv->mcast.work));
266282

267283
hlist_for_each_entry_safe(mcast_entry, tmp, &bat_priv->mcast.mla_list,
268284
list) {
@@ -287,14 +303,16 @@ static void batadv_mcast_mla_tt_retract(struct batadv_priv *bat_priv,
287303
*
288304
* Adds multicast listener announcements from the given mcast_list to the
289305
* translation table if they have not been added yet.
306+
*
307+
* Do not call outside of the mcast worker! (or cancel mcast worker first)
290308
*/
291309
static void batadv_mcast_mla_tt_add(struct batadv_priv *bat_priv,
292310
struct hlist_head *mcast_list)
293311
{
294312
struct batadv_hw_addr *mcast_entry;
295313
struct hlist_node *tmp;
296314

297-
lockdep_assert_held(&bat_priv->tt.commit_lock);
315+
WARN_ON(delayed_work_pending(&bat_priv->mcast.work));
298316

299317
if (!mcast_list)
300318
return;
@@ -528,13 +546,18 @@ static bool batadv_mcast_mla_tvlv_update(struct batadv_priv *bat_priv)
528546
}
529547

530548
/**
531-
* batadv_mcast_mla_update - update the own MLAs
549+
* __batadv_mcast_mla_update - update the own MLAs
532550
* @bat_priv: the bat priv with all the soft interface information
533551
*
534552
* Updates the own multicast listener announcements in the translation
535553
* table as well as the own, announced multicast tvlv container.
554+
*
555+
* Note that non-conflicting reads and writes to bat_priv->mcast.mla_list
556+
* in batadv_mcast_mla_tt_retract() and batadv_mcast_mla_tt_add() are
557+
* ensured by the non-parallel execution of the worker this function
558+
* belongs to.
536559
*/
537-
void batadv_mcast_mla_update(struct batadv_priv *bat_priv)
560+
static void __batadv_mcast_mla_update(struct batadv_priv *bat_priv)
538561
{
539562
struct net_device *soft_iface = bat_priv->soft_iface;
540563
struct hlist_head mcast_list = HLIST_HEAD_INIT;
@@ -559,6 +582,29 @@ void batadv_mcast_mla_update(struct batadv_priv *bat_priv)
559582
batadv_mcast_mla_list_free(&mcast_list);
560583
}
561584

585+
/**
586+
* batadv_mcast_mla_update - update the own MLAs
587+
* @work: kernel work struct
588+
*
589+
* Updates the own multicast listener announcements in the translation
590+
* table as well as the own, announced multicast tvlv container.
591+
*
592+
* In the end, reschedules the work timer.
593+
*/
594+
static void batadv_mcast_mla_update(struct work_struct *work)
595+
{
596+
struct delayed_work *delayed_work;
597+
struct batadv_priv_mcast *priv_mcast;
598+
struct batadv_priv *bat_priv;
599+
600+
delayed_work = to_delayed_work(work);
601+
priv_mcast = container_of(delayed_work, struct batadv_priv_mcast, work);
602+
bat_priv = container_of(priv_mcast, struct batadv_priv, mcast);
603+
604+
__batadv_mcast_mla_update(bat_priv);
605+
batadv_mcast_start_timer(bat_priv);
606+
}
607+
562608
/**
563609
* batadv_mcast_is_report_ipv4 - check for IGMP reports
564610
* @skb: the ethernet frame destined for the mesh
@@ -1128,6 +1174,9 @@ void batadv_mcast_init(struct batadv_priv *bat_priv)
11281174
batadv_tvlv_handler_register(bat_priv, batadv_mcast_tvlv_ogm_handler,
11291175
NULL, BATADV_TVLV_MCAST, 2,
11301176
BATADV_TVLV_HANDLER_OGM_CIFNOTFND);
1177+
1178+
INIT_DELAYED_WORK(&bat_priv->mcast.work, batadv_mcast_mla_update);
1179+
batadv_mcast_start_timer(bat_priv);
11311180
}
11321181

11331182
#ifdef CONFIG_BATMAN_ADV_DEBUGFS
@@ -1239,12 +1288,13 @@ int batadv_mcast_flags_seq_print_text(struct seq_file *seq, void *offset)
12391288
*/
12401289
void batadv_mcast_free(struct batadv_priv *bat_priv)
12411290
{
1291+
cancel_delayed_work_sync(&bat_priv->mcast.work);
1292+
12421293
batadv_tvlv_container_unregister(bat_priv, BATADV_TVLV_MCAST, 2);
12431294
batadv_tvlv_handler_unregister(bat_priv, BATADV_TVLV_MCAST, 2);
12441295

1245-
spin_lock_bh(&bat_priv->tt.commit_lock);
1296+
/* safely calling outside of worker, as worker was canceled above */
12461297
batadv_mcast_mla_tt_retract(bat_priv, NULL);
1247-
spin_unlock_bh(&bat_priv->tt.commit_lock);
12481298
}
12491299

12501300
/**

‎net/batman-adv/multicast.h‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ enum batadv_forw_mode {
3939

4040
#ifdef CONFIG_BATMAN_ADV_MCAST
4141

42-
void batadv_mcast_mla_update(struct batadv_priv *bat_priv);
43-
4442
enum batadv_forw_mode
4543
batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
4644
struct batadv_orig_node **mcast_single_orig);
@@ -55,10 +53,6 @@ void batadv_mcast_purge_orig(struct batadv_orig_node *orig_node);
5553

5654
#else
5755

58-
static inline void batadv_mcast_mla_update(struct batadv_priv *bat_priv)
59-
{
60-
}
61-
6256
static inline enum batadv_forw_mode
6357
batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
6458
struct batadv_orig_node **mcast_single_orig)

‎net/batman-adv/translation-table.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
#include "hard-interface.h"
5757
#include "hash.h"
5858
#include "log.h"
59-
#include "multicast.h"
6059
#include "netlink.h"
6160
#include "originator.h"
6261
#include "packet.h"
@@ -3795,9 +3794,6 @@ static void batadv_tt_local_commit_changes_nolock(struct batadv_priv *bat_priv)
37953794
{
37963795
lockdep_assert_held(&bat_priv->tt.commit_lock);
37973796

3798-
/* Update multicast addresses in local translation table */
3799-
batadv_mcast_mla_update(bat_priv);
3800-
38013797
if (atomic_read(&bat_priv->tt.local_changes) < 1) {
38023798
if (!batadv_atomic_dec_not_zero(&bat_priv->tt.ogm_append_cnt))
38033799
batadv_tt_tvlv_container_update(bat_priv);

‎net/batman-adv/types.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,9 +785,10 @@ struct batadv_mcast_querier_state {
785785
* @num_want_all_ipv6: counter for items in want_all_ipv6_list
786786
* @want_lists_lock: lock for protecting modifications to mcast want lists
787787
* (traversals are rcu-locked)
788+
* @work: work queue callback item for multicast TT and TVLV updates
788789
*/
789790
struct batadv_priv_mcast {
790-
struct hlist_head mla_list;
791+
struct hlist_head mla_list; /* see __batadv_mcast_mla_update() */
791792
struct hlist_head want_all_unsnoopables_list;
792793
struct hlist_head want_all_ipv4_list;
793794
struct hlist_head want_all_ipv6_list;
@@ -802,6 +803,7 @@ struct batadv_priv_mcast {
802803
atomic_t num_want_all_ipv6;
803804
/* protects want_all_{unsnoopables,ipv4,ipv6}_list */
804805
spinlock_t want_lists_lock;
806+
struct delayed_work work;
805807
};
806808
#endif
807809

0 commit comments

Comments
 (0)