[4/5] batman-adv: Make number of (re)broadcasts configurable via sysfs

Message ID 1286685001-15227-4-git-send-email-linus.luessing@web.de (mailing list archive)
State Superseded, archived
Headers

Commit Message

Linus Lüssing Oct. 10, 2010, 4:30 a.m. UTC
  Depending on the scenario, people might want to adjust the number of
(re)broadcast of data packets - usually higher values in sparse or lower
values in dense networks.

Signed-off-by: Linus Lüssing <linus.luessing@web.de>
---
 bat_sysfs.c |    2 ++
 send.c      |    3 ++-
 types.h     |    1 +
 3 files changed, 5 insertions(+), 1 deletions(-)
  

Comments

Marek Lindner Oct. 10, 2010, 12:53 p.m. UTC | #1
On Sunday 10 October 2010 06:30:00 Linus Lüssing wrote:
> Depending on the scenario, people might want to adjust the number of
> (re)broadcast of data packets - usually higher values in sparse or lower
> values in dense networks.

Is there a good reason to change this value at runtime or would a define be 
enough ? I just get scared when we add too many options that almost nobody 
cares about. 

In other words: What is the use case ? Can we handle it by some kind of auto-
detection ?

Regards,
Marek
  
Linus Lüssing Oct. 10, 2010, 2:49 p.m. UTC | #2
On Sun, Oct 10, 2010 at 02:53:51PM +0200, Marek Lindner wrote:
> On Sunday 10 October 2010 06:30:00 Linus Lüssing wrote:
> > Depending on the scenario, people might want to adjust the number of
> > (re)broadcast of data packets - usually higher values in sparse or lower
> > values in dense networks.
> 
> Is there a good reason to change this value at runtime or would a define be 
> enough ? I just get scared when we add too many options that almost nobody 
> cares about.
Well, as said before, in some cases the default value of 3 might
be too much, in other cases too less, depending on the topology.
However, you might know the kind of topology you have in advance
and would like to tweak that without having to know how to for
example rebuild a complete image and reflashing it on all
devices. You might want to test different values for your topology
for tweaking, without having to reflash / reload the kernel module
on all devices.

I also don't think too many configuration options in sysfs are
that much of a problem. There are also a dozen options for
tweaking IP in /proc/sys/net which nearly no one uses. But if
someone might need it, (s)he'll be very pleased to not having to
recompile and restart the whole kernel for that (or a kernel module
in our case).

The average user who might be scared of too many configuration
options will be using batctl anyway, won't (s)he? So I'd rather
plead to add tweaking options to the sysfs, but omitting them in
batctl. Or what do you think?
> 
> In other words: What is the use case ? Can we handle it by some kind of auto-
> detection ?
Sure we could, but then we'd need some more information about the
neighbourhood, i.e. with something like a seperate neighbor
discovery protocol giving 2-hop-neighbourhood information.
Otherwise a node would probably usually send the maximum amount of
rebroadcasts as there might be a node in the far distance with a
very low tq-value. But that'd require much more effort to
implement then these couple of lines :).

Thanks for reviewing

Cheers, Linus
> 
> Regards,
> Marek
>
  

Patch

diff --git a/bat_sysfs.c b/bat_sysfs.c
index 9fda75e..2f7f118 100644
--- a/bat_sysfs.c
+++ b/bat_sysfs.c
@@ -273,6 +273,7 @@  static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, show_vis_mode, store_vis_mode);
 static BAT_ATTR(gw_mode, S_IRUGO | S_IWUSR, show_gw_mode, store_gw_mode);
 BAT_ATTR_UINT(orig_interval, S_IRUGO | S_IWUSR, 2 * JITTER, INT_MAX, NULL);
 BAT_ATTR_UINT(hop_penalty, S_IRUGO | S_IWUSR, 0, TQ_MAX_VALUE, NULL);
+BAT_ATTR_UINT(num_bcasts, S_IRUGO | S_IWUSR, 0, INT_MAX, NULL);
 #ifdef CONFIG_BATMAN_ADV_DEBUG
 BAT_ATTR_UINT(log_level, S_IRUGO | S_IWUSR, 0, 3, NULL);
 #endif
@@ -285,6 +286,7 @@  static struct bat_attribute *mesh_attrs[] = {
 	&bat_attr_gw_mode,
 	&bat_attr_orig_interval,
 	&bat_attr_hop_penalty,
+	&bat_attr_num_bcasts,
 #ifdef CONFIG_BATMAN_ADV_DEBUG
 	&bat_attr_log_level,
 #endif
diff --git a/send.c b/send.c
index 943437b..2f18a0d 100644
--- a/send.c
+++ b/send.c
@@ -455,6 +455,7 @@  static void send_outstanding_bcast_packet(struct work_struct *work)
 	struct sk_buff *skb1;
 	struct net_device *soft_iface = forw_packet->if_incoming->soft_iface;
 	struct bat_priv *bat_priv = netdev_priv(soft_iface);
+	int num_bcasts = atomic_read(&bat_priv->num_bcasts);
 
 	spin_lock_irqsave(&bat_priv->forw_bcast_list_lock, flags);
 	hlist_del(&forw_packet->list);
@@ -479,7 +480,7 @@  static void send_outstanding_bcast_packet(struct work_struct *work)
 	forw_packet->num_packets++;
 
 	/* if we still have some more bcasts to send */
-	if (forw_packet->num_packets < 3) {
+	if (forw_packet->num_packets < num_bcasts) {
 		_add_bcast_packet_to_list(bat_priv, forw_packet,
 					  ((5 * HZ) / 1000));
 		return;
diff --git a/types.h b/types.h
index 75e0b71..0063ad7 100644
--- a/types.h
+++ b/types.h
@@ -132,6 +132,7 @@  struct bat_priv {
 	atomic_t gw_class;
 	atomic_t orig_interval;
 	atomic_t hop_penalty;
+	atomic_t num_bcasts;
 	atomic_t log_level;
 	atomic_t bcast_seqno;
 	atomic_t bcast_queue_left;