From: "Linus Lüssing" <linus.luessing@saxnet.de>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: "Linus Lüssing" <linus.luessing@saxnet.de>
Subject: [B.A.T.M.A.N.] [PATCH 01/18] batman-adv: Adding configurable variables for multicast optimizations
Date: Sun, 30 Jan 2011 05:39:09 +0100 [thread overview]
Message-ID: <1296362366-3852-2-git-send-email-linus.luessing@saxnet.de> (raw)
In-Reply-To: <1296362366-3852-1-git-send-email-linus.luessing@saxnet.de>
This commit adds the needed configurable variables in bat_priv and
according user interfaces in sysfs for the future multicast
optimizations.
Signed-off-by: Linus Lüssing <linus.luessing@saxnet.de>
---
Makefile.kbuild | 1 +
bat_sysfs.c | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
multicast.c | 121 +++++++++++++++++++++++++++++++++++++++++
multicast.h | 30 ++++++++++
packet.h | 4 ++
soft-interface.c | 4 ++
types.h | 4 ++
7 files changed, 324 insertions(+), 0 deletions(-)
create mode 100644 multicast.c
create mode 100644 multicast.h
diff --git a/batman-adv/Makefile.kbuild b/batman-adv/Makefile.kbuild
index 0a35006..1272d0d 100644
--- a/batman-adv/Makefile.kbuild
+++ b/batman-adv/Makefile.kbuild
@@ -49,5 +49,6 @@ batman-adv-y += send.o
batman-adv-y += soft-interface.o
batman-adv-y += translation-table.o
batman-adv-y += unicast.o
+batman-adv-y += multicast.o
batman-adv-y += vis.o
batman-adv-y += bat_printk.o
diff --git a/batman-adv/bat_sysfs.c b/batman-adv/bat_sysfs.c
index f7b93a0..67adb35 100644
--- a/batman-adv/bat_sysfs.c
+++ b/batman-adv/bat_sysfs.c
@@ -27,6 +27,7 @@
#include "gateway_common.h"
#include "gateway_client.h"
#include "vis.h"
+#include "multicast.h"
#define to_dev(obj) container_of(obj, struct device, kobj)
#define kobj_to_netdev(obj) to_net_dev(to_dev(obj->parent))
@@ -356,6 +357,153 @@ static ssize_t store_gw_bwidth(struct kobject *kobj, struct attribute *attr,
return gw_bandwidth_set(net_dev, buff, count);
}
+static ssize_t show_mcast_mode(struct kobject *kobj, struct attribute *attr,
+ char *buff)
+{
+ struct device *dev = to_dev(kobj->parent);
+ struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev));
+ int mcast_mode = atomic_read(&bat_priv->mcast_mode);
+ int ret;
+
+ switch (mcast_mode) {
+ case MCAST_MODE_CLASSIC_FLOODING:
+ ret = sprintf(buff, "classic_flooding\n");
+ break;
+ case MCAST_MODE_PROACT_TRACKING:
+ ret = sprintf(buff, "proactive_tracking\n");
+ break;
+ default:
+ ret = -1;
+ break;
+ }
+
+ return ret;
+}
+
+static ssize_t store_mcast_mode(struct kobject *kobj, struct attribute *attr,
+ char *buff, size_t count)
+{
+ struct device *dev = to_dev(kobj->parent);
+ struct net_device *net_dev = to_net_dev(dev);
+ struct bat_priv *bat_priv = netdev_priv(net_dev);
+ unsigned long val;
+ int ret, mcast_mode_tmp = -1;
+
+ ret = strict_strtoul(buff, 10, &val);
+
+ if (((count == 2) && (!ret) && (val == MCAST_MODE_CLASSIC_FLOODING)) ||
+ (strncmp(buff, "classic_flooding", 16) == 0))
+ mcast_mode_tmp = MCAST_MODE_CLASSIC_FLOODING;
+
+ if (((count == 2) && (!ret) && (val == MCAST_MODE_PROACT_TRACKING)) ||
+ (strncmp(buff, "proact_tracking", 15) == 0))
+ mcast_mode_tmp = MCAST_MODE_PROACT_TRACKING;
+
+ if (mcast_mode_tmp < 0) {
+ if (buff[count - 1] == '\n')
+ buff[count - 1] = '\0';
+
+ bat_info(net_dev,
+ "Invalid parameter for 'mcast mode' setting received: "
+ "%s\n", buff);
+ return -EINVAL;
+ }
+
+ if (atomic_read(&bat_priv->mcast_mode) == mcast_mode_tmp)
+ return count;
+
+ bat_info(net_dev, "Changing mcast mode from: %s to: %s\n",
+ atomic_read(&bat_priv->mcast_mode) ==
+ MCAST_MODE_CLASSIC_FLOODING ?
+ "classic_flooding" : "proact_tracking",
+ mcast_mode_tmp == MCAST_MODE_CLASSIC_FLOODING ?
+ "classic_flooding" : "proact_tracking");
+
+ atomic_set(&bat_priv->mcast_mode, (unsigned)mcast_mode_tmp);
+ return count;
+}
+
+static ssize_t show_mcast_tracker_interval(struct kobject *kobj,
+ struct attribute *attr, char *buff)
+{
+ struct device *dev = to_dev(kobj->parent);
+ struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev));
+ int tracker_interval = atomic_read(&bat_priv->mcast_tracker_interval);
+
+ if (!tracker_interval)
+ return sprintf(buff, "auto\n");
+ else
+ return sprintf(buff, "%i\n", tracker_interval);
+}
+
+static ssize_t store_mcast_tracker_interval(struct kobject *kobj,
+ struct attribute *attr, char *buff, size_t count)
+{
+ struct device *dev = to_dev(kobj->parent);
+ struct net_device *net_dev = to_net_dev(dev);
+
+ return mcast_tracker_interval_set(net_dev, buff, count);
+}
+
+static ssize_t show_mcast_tracker_timeout(struct kobject *kobj,
+ struct attribute *attr, char *buff)
+{
+ struct device *dev = to_dev(kobj->parent);
+ struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev));
+ int tracker_timeout = atomic_read(&bat_priv->mcast_tracker_timeout);
+
+ if (!tracker_timeout)
+ return sprintf(buff, "auto\n");
+ else
+ return sprintf(buff, "%i\n", tracker_timeout);
+}
+
+static ssize_t store_mcast_tracker_timeout(struct kobject *kobj,
+ struct attribute *attr, char *buff, size_t count)
+{
+ struct device *dev = to_dev(kobj->parent);
+ struct net_device *net_dev = to_net_dev(dev);
+
+ return mcast_tracker_timeout_set(net_dev, buff, count);
+}
+
+static ssize_t show_mcast_fanout(struct kobject *kobj,
+ struct attribute *attr, char *buff)
+{
+ struct device *dev = to_dev(kobj->parent);
+ struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev));
+
+ return sprintf(buff, "%i\n",
+ atomic_read(&bat_priv->mcast_fanout));
+}
+
+static ssize_t store_mcast_fanout(struct kobject *kobj,
+ struct attribute *attr, char *buff, size_t count)
+{
+ struct device *dev = to_dev(kobj->parent);
+ struct net_device *net_dev = to_net_dev(dev);
+ struct bat_priv *bat_priv = netdev_priv(net_dev);
+ unsigned long mcast_fanout_tmp;
+ int ret;
+
+ ret = strict_strtoul(buff, 10, &mcast_fanout_tmp);
+ if (ret) {
+ bat_info(net_dev, "Invalid parameter for 'mcast_fanout' "
+ "setting received: %s\n", buff);
+ return -EINVAL;
+ }
+
+ if (atomic_read(&bat_priv->mcast_fanout) == mcast_fanout_tmp)
+ return count;
+
+ bat_info(net_dev, "Changing mcast fanout interval from: %i to: %li\n",
+ atomic_read(&bat_priv->mcast_fanout),
+ mcast_fanout_tmp);
+
+ atomic_set(&bat_priv->mcast_fanout, mcast_fanout_tmp);
+ return count;
+}
+
BAT_ATTR_BOOL(aggregated_ogms, S_IRUGO | S_IWUSR, NULL);
BAT_ATTR_BOOL(bonding, S_IRUGO | S_IWUSR, NULL);
BAT_ATTR_BOOL(fragmentation, S_IRUGO | S_IWUSR, update_min_mtu);
@@ -367,6 +515,14 @@ BAT_ATTR_UINT(gw_sel_class, S_IRUGO | S_IWUSR, 1, TQ_MAX_VALUE,
post_gw_deselect);
static BAT_ATTR(gw_bandwidth, S_IRUGO | S_IWUSR, show_gw_bwidth,
store_gw_bwidth);
+static BAT_ATTR(mcast_mode, S_IRUGO | S_IWUSR,
+ show_mcast_mode, store_mcast_mode);
+static BAT_ATTR(mcast_tracker_interval, S_IRUGO | S_IWUSR,
+ show_mcast_tracker_interval, store_mcast_tracker_interval);
+static BAT_ATTR(mcast_tracker_timeout, S_IRUGO | S_IWUSR,
+ show_mcast_tracker_timeout, store_mcast_tracker_timeout);
+static BAT_ATTR(mcast_fanout, S_IRUGO | S_IWUSR,
+ show_mcast_fanout, store_mcast_fanout);
#ifdef CONFIG_BATMAN_ADV_DEBUG
BAT_ATTR_UINT(log_level, S_IRUGO | S_IWUSR, 0, 3, NULL);
#endif
@@ -381,6 +537,10 @@ static struct bat_attribute *mesh_attrs[] = {
&bat_attr_hop_penalty,
&bat_attr_gw_sel_class,
&bat_attr_gw_bandwidth,
+ &bat_attr_mcast_mode,
+ &bat_attr_mcast_tracker_interval,
+ &bat_attr_mcast_tracker_timeout,
+ &bat_attr_mcast_fanout,
#ifdef CONFIG_BATMAN_ADV_DEBUG
&bat_attr_log_level,
#endif
diff --git a/batman-adv/multicast.c b/batman-adv/multicast.c
new file mode 100644
index 0000000..0598873
--- /dev/null
+++ b/batman-adv/multicast.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2010 B.A.T.M.A.N. contributors:
+ *
+ * Linus Lüssing
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA
+ *
+ */
+
+#include "main.h"
+#include "multicast.h"
+
+int mcast_tracker_interval_set(struct net_device *net_dev, char *buff,
+ size_t count)
+{
+ struct bat_priv *bat_priv = netdev_priv(net_dev);
+ unsigned long new_tracker_interval;
+ int cur_tracker_interval;
+ int ret;
+
+ ret = strict_strtoul(buff, 10, &new_tracker_interval);
+
+ if (ret && !strncmp(buff, "auto", 4)) {
+ new_tracker_interval = 0;
+ goto ok;
+ }
+
+ else if (ret) {
+ bat_info(net_dev, "Invalid parameter for "
+ "'mcast_tracker_interval' setting received: %s\n",
+ buff);
+ return -EINVAL;
+ }
+
+ if (new_tracker_interval < JITTER) {
+ bat_info(net_dev, "New mcast tracker interval too small: %li "
+ "(min: %i or auto)\n", new_tracker_interval, JITTER);
+ return -EINVAL;
+ }
+
+ok:
+ cur_tracker_interval = atomic_read(&bat_priv->mcast_tracker_interval);
+
+ if (cur_tracker_interval == new_tracker_interval)
+ return count;
+
+ if (!cur_tracker_interval && new_tracker_interval)
+ bat_info(net_dev, "Tracker interval change from: %s to: %li\n",
+ "auto", new_tracker_interval);
+ else if (cur_tracker_interval && !new_tracker_interval)
+ bat_info(net_dev, "Tracker interval change from: %i to: %s\n",
+ cur_tracker_interval, "auto");
+ else
+ bat_info(net_dev, "Tracker interval change from: %i to: %li\n",
+ cur_tracker_interval, new_tracker_interval);
+
+ atomic_set(&bat_priv->mcast_tracker_interval, new_tracker_interval);
+
+ return count;
+}
+
+int mcast_tracker_timeout_set(struct net_device *net_dev, char *buff,
+ size_t count)
+{
+ struct bat_priv *bat_priv = netdev_priv(net_dev);
+ unsigned long new_tracker_timeout;
+ int cur_tracker_timeout;
+ int ret;
+
+ ret = strict_strtoul(buff, 10, &new_tracker_timeout);
+
+ if (ret && !strncmp(buff, "auto", 4)) {
+ new_tracker_timeout = 0;
+ goto ok;
+ }
+
+ else if (ret) {
+ bat_info(net_dev, "Invalid parameter for "
+ "'mcast_tracker_timeout' setting received: %s\n",
+ buff);
+ return -EINVAL;
+ }
+
+ if (new_tracker_timeout < JITTER) {
+ bat_info(net_dev, "New mcast tracker timeout too small: %li "
+ "(min: %i or auto)\n", new_tracker_timeout, JITTER);
+ return -EINVAL;
+ }
+
+ok:
+ cur_tracker_timeout = atomic_read(&bat_priv->mcast_tracker_timeout);
+
+ if (cur_tracker_timeout == new_tracker_timeout)
+ return count;
+
+ if (!cur_tracker_timeout && new_tracker_timeout)
+ bat_info(net_dev, "Tracker timeout change from: %s to: %li\n",
+ "auto", new_tracker_timeout);
+ else if (cur_tracker_timeout && !new_tracker_timeout)
+ bat_info(net_dev, "Tracker timeout change from: %i to: %s\n",
+ cur_tracker_timeout, "auto");
+ else
+ bat_info(net_dev, "Tracker timeout change from: %i to: %li\n",
+ cur_tracker_timeout, new_tracker_timeout);
+
+ atomic_set(&bat_priv->mcast_tracker_timeout, new_tracker_timeout);
+
+ return count;
+}
diff --git a/batman-adv/multicast.h b/batman-adv/multicast.h
new file mode 100644
index 0000000..12a3376
--- /dev/null
+++ b/batman-adv/multicast.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2010 B.A.T.M.A.N. contributors:
+ *
+ * Linus Lüssing
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA
+ *
+ */
+
+#ifndef _NET_BATMAN_ADV_MULTICAST_H_
+#define _NET_BATMAN_ADV_MULTICAST_H_
+
+int mcast_tracker_interval_set(struct net_device *net_dev, char *buff,
+ size_t count);
+int mcast_tracker_timeout_set(struct net_device *net_dev, char *buff,
+ size_t count);
+
+#endif /* _NET_BATMAN_ADV_MULTICAST_H_ */
diff --git a/batman-adv/packet.h b/batman-adv/packet.h
index e757187..eef5371 100644
--- a/batman-adv/packet.h
+++ b/batman-adv/packet.h
@@ -48,6 +48,10 @@
#define VIS_TYPE_SERVER_SYNC 0
#define VIS_TYPE_CLIENT_UPDATE 1
+/* mcast defines */
+#define MCAST_MODE_CLASSIC_FLOODING 0
+#define MCAST_MODE_PROACT_TRACKING 1
+
/* fragmentation defines */
#define UNI_FRAG_HEAD 0x01
#define UNI_FRAG_LARGETAIL 0x02
diff --git a/batman-adv/soft-interface.c b/batman-adv/soft-interface.c
index 145e0f7..f25fe9d 100644
--- a/batman-adv/soft-interface.c
+++ b/batman-adv/soft-interface.c
@@ -597,6 +597,10 @@ struct net_device *softif_create(char *name)
atomic_set(&bat_priv->gw_bandwidth, 41);
atomic_set(&bat_priv->orig_interval, 1000);
atomic_set(&bat_priv->hop_penalty, 10);
+ atomic_set(&bat_priv->mcast_mode, MCAST_MODE_CLASSIC_FLOODING);
+ atomic_set(&bat_priv->mcast_tracker_interval, 0); /* = auto */
+ atomic_set(&bat_priv->mcast_tracker_timeout, 0); /* = auto */
+ atomic_set(&bat_priv->mcast_fanout, 2);
atomic_set(&bat_priv->log_level, 0);
atomic_set(&bat_priv->fragmentation, 1);
atomic_set(&bat_priv->bcast_queue_left, BCAST_QUEUE_LEN);
diff --git a/batman-adv/types.h b/batman-adv/types.h
index e4a0462..47490fa 100644
--- a/batman-adv/types.h
+++ b/batman-adv/types.h
@@ -139,6 +139,10 @@ struct bat_priv {
atomic_t gw_bandwidth; /* gw bandwidth */
atomic_t orig_interval; /* uint */
atomic_t hop_penalty; /* uint */
+ atomic_t mcast_mode; /* MCAST_MODE_* */
+ atomic_t mcast_tracker_interval;/* uint, auto */
+ atomic_t mcast_tracker_timeout; /* uint, auto */
+ atomic_t mcast_fanout; /* uint */
atomic_t log_level; /* uint */
atomic_t bcast_seqno;
atomic_t bcast_queue_left;
--
1.7.2.3
next prev parent reply other threads:[~2011-01-30 4:39 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-30 4:39 [B.A.T.M.A.N.] B.A.T.M.A.N.-Advanced Multicast Optimizations, v3 Linus Lüssing
2011-01-30 4:39 ` Linus Lüssing [this message]
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 02/18] batman-adv: Attach local MCAs to OGMs Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 03/18] batman-adv: Add periodic multicast tracker timer Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 04/18] batman-adv: Buffer other originator's received MCA entries Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 05/18] batman-adv: Prepare and send own multicast tracker packets Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 06/18] batman-adv: Add length check for (received) " Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 07/18] batman-adv: Route multicast " Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 08/18] batman-adv: Add/refresh entries to/in mcast forwarding table Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 09/18] batman-adv: Output mcast forw table in debugfs Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 10/18] batman-adv: Purge timeouted entries in mcast forw table Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 11/18] batman-adv: Send own BAT_MCAST packets in proact_tracking multicast mode Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 12/18] batman-adv: Export broadcast packet ethernet header checks Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 13/18] batman-adv: Receive multicast data packets BAT_MCAST Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 14/18] batman-adv: Forward multicast data in proact_tracking mode Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 15/18] batman-adv: Add duplicate checks for multicast data Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 16/18] batman-adv: Still flood multicast packets we are not a receiver of Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 17/18] batman-adv: Make number of (re)broadcasts configurable via sysfs Linus Lüssing
2011-01-30 4:39 ` [B.A.T.M.A.N.] [PATCH 18/18] batman-adv: Use rcu-locking for multicast forwarding table Linus Lüssing
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=1296362366-3852-2-git-send-email-linus.luessing@saxnet.de \
--to=linus.luessing@saxnet.de \
--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).