b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Matthias Schiffer <mschiffer@universe-factory.net>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: [B.A.T.M.A.N.] [PATCHv4 2/2] batman-adv: send each broadcast only once on non-wireless interfaces
Date: Sat,  9 Mar 2013 22:18:22 +0100	[thread overview]
Message-ID: <6ef8d3c1fe5fa21893c780a8c0777c4fd322cd07.1362863832.git.mschiffer@universe-factory.net> (raw)
In-Reply-To: <b6b8ee26c56ef0c28d1efe1c54218c4d7090bd98.1362863832.git.mschiffer@universe-factory.net>
In-Reply-To: <b6b8ee26c56ef0c28d1efe1c54218c4d7090bd98.1362863832.git.mschiffer@universe-factory.net>

While it makes sense to send each broadcast thrice on 802.11 (WLAN) interfaces
as broadcasts are often unreliable on these, there is no reason to do so on
other interface types.

The increased the overhead can be harmful on low-bandwidth links like VPN
connections over slow internet lines, therefore it is better to reduce the
number of broadcast packets sent on non-wireless links to one.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
---
 hard-interface.c | 5 +++++
 main.h           | 5 +++++
 send.c           | 5 ++++-
 types.h          | 1 +
 4 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/hard-interface.c b/hard-interface.c
index 333a504..0eaf02c 100644
--- a/hard-interface.c
+++ b/hard-interface.c
@@ -556,6 +556,11 @@ batadv_hardif_add_interface(struct net_device *net_dev)
 	INIT_WORK(&hard_iface->cleanup_work,
 		  batadv_hardif_remove_interface_finish);
 
+	if (batadv_is_wifi_net_device(net_dev))
+		hard_iface->num_bcasts = BATADV_NUM_BCASTS_WIRELESS;
+	else
+		hard_iface->num_bcasts = BATADV_NUM_BCASTS_DEFAULT;
+
 	/* extra reference for return */
 	atomic_set(&hard_iface->refcount, 2);
 
diff --git a/main.h b/main.h
index e6eaf43..2c751c6 100644
--- a/main.h
+++ b/main.h
@@ -76,6 +76,11 @@
 
 #define BATADV_LOG_BUF_LEN 8192	  /* has to be a power of 2 */
 
+/* number of packets to send for broadcasts on different interface types */
+#define BATADV_NUM_BCASTS_DEFAULT 1
+#define BATADV_NUM_BCASTS_WIRELESS 3
+#define BATADV_NUM_BCASTS_MAX 3
+
 /* msecs after which an ARP_REQUEST is sent in broadcast as fallback */
 #define ARP_REQ_DELAY 250
 /* numbers of originator to contact for any PUT/GET DHT operation */
diff --git a/send.c b/send.c
index 0a0bb45..e21138f 100644
--- a/send.c
+++ b/send.c
@@ -260,6 +260,9 @@ static void batadv_send_outstanding_bcast_packet(struct work_struct *work)
 		if (hard_iface->soft_iface != soft_iface)
 			continue;
 
+		if (forw_packet->num_packets >= hard_iface->num_bcasts)
+			continue;
+
 		/* send a copy of the saved skb */
 		skb1 = skb_clone(forw_packet->skb, GFP_ATOMIC);
 		if (skb1)
@@ -271,7 +274,7 @@ static void batadv_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 < BATADV_NUM_BCASTS_MAX) {
 		_batadv_add_bcast_packet_to_list(bat_priv, forw_packet,
 						 msecs_to_jiffies(5));
 		return;
diff --git a/types.h b/types.h
index aba8364..0c5009f 100644
--- a/types.h
+++ b/types.h
@@ -76,6 +76,7 @@ struct batadv_hard_iface {
 	char if_status;
 	struct net_device *net_dev;
 	atomic_t frag_seqno;
+	uint8_t num_bcasts;
 	struct kobject *hardif_obj;
 	atomic_t refcount;
 	struct packet_type batman_adv_ptype;
-- 
1.8.1.5


  reply	other threads:[~2013-03-09 21:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-09 10:33 [B.A.T.M.A.N.] [PATCHv2] batman-adv: send each broadcast only once on non-wireless interfaces Matthias Schiffer
2013-03-09 10:40 ` [B.A.T.M.A.N.] [PATCHv3] " Matthias Schiffer
2013-03-09 20:17   ` Antonio Quartulli
2013-03-09 21:18     ` [B.A.T.M.A.N.] [PATCHv4 1/2] batman-adv: split batadv_is_wifi_iface() into two functions Matthias Schiffer
2013-03-09 21:18       ` Matthias Schiffer [this message]
2013-03-09 22:14       ` [B.A.T.M.A.N.] [PATCHv5 " Matthias Schiffer
2013-03-09 22:14         ` [B.A.T.M.A.N.] [PATCHv5 2/2] batman-adv: send each broadcast only once on non-wireless interfaces Matthias Schiffer
2013-03-16 10:31           ` Marek Lindner
2013-03-16 10:21         ` [B.A.T.M.A.N.] [PATCHv5 1/2] batman-adv: split batadv_is_wifi_iface() into two functions Marek Lindner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6ef8d3c1fe5fa21893c780a8c0777c4fd322cd07.1362863832.git.mschiffer@universe-factory.net \
    --to=mschiffer@universe-factory.net \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).