From: Antonio Quartulli <a@unstable.cc>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Antonio Quartulli <a@unstable.cc>
Subject: [B.A.T.M.A.N.] [PATCH v4 6/6] batman-adv: disable sysfs knobs when GW-mode is not implemented
Date: Wed, 25 May 2016 23:27:36 +0800 [thread overview]
Message-ID: <20160525152736.9031-7-a@unstable.cc> (raw)
In-Reply-To: <20160525152736.9031-1-a@unstable.cc>
Now that the GW-mode code is algorithm specific, batman-adv expects the
routing algorithm to implement some APIs to make it work.
However, such APIs are not mandatory, therefore we might have algorithms
not providing them. In this case all the sysfs knobs related to GW-mode
should be deactivated to make sure that settings injected by the user
for this feature are rejected.
Signed-off-by: Antonio Quartulli <a@unstable.cc>
---
net/batman-adv/sysfs.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c
index bb43742..486fdd6 100644
--- a/net/batman-adv/sysfs.c
+++ b/net/batman-adv/sysfs.c
@@ -428,6 +428,13 @@ static ssize_t batadv_show_gw_mode(struct kobject *kobj, struct attribute *attr,
struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
int bytes_written;
+ /* GW mode is not available if the routing algorithm in use does not
+ * implement the GW API
+ */
+ if (!bat_priv->algo_ops->gw.get_best_gw_node ||
+ !bat_priv->algo_ops->gw.is_eligible)
+ return -ENOENT;
+
switch (atomic_read(&bat_priv->gw.mode)) {
case BATADV_GW_MODE_CLIENT:
bytes_written = sprintf(buff, "%s\n",
@@ -455,6 +462,13 @@ static ssize_t batadv_store_gw_mode(struct kobject *kobj,
char *curr_gw_mode_str;
int gw_mode_tmp = -1;
+ /* toggling GW mode is allowed only if the routing algorithm in use
+ * provides the GW API
+ */
+ if (!bat_priv->algo_ops->gw.get_best_gw_node ||
+ !bat_priv->algo_ops->gw.is_eligible)
+ return -EINVAL;
+
if (buff[count - 1] == '\n')
buff[count - 1] = '\0';
@@ -519,6 +533,13 @@ static ssize_t batadv_show_gw_sel_class(struct kobject *kobj,
{
struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
+ /* GW selection class is not available if the routing algorithm in use
+ * does not implement the GW API
+ */
+ if (!bat_priv->algo_ops->gw.get_best_gw_node ||
+ !bat_priv->algo_ops->gw.is_eligible)
+ return -ENOENT;
+
if (bat_priv->algo_ops->gw.show_sel_class)
return bat_priv->algo_ops->gw.show_sel_class(bat_priv, buff);
@@ -531,6 +552,13 @@ static ssize_t batadv_store_gw_sel_class(struct kobject *kobj,
{
struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj);
+ /* setting the GW selection class is allowed only if the routing
+ * algorithm in use implements the GW API
+ */
+ if (!bat_priv->algo_ops->gw.get_best_gw_node ||
+ !bat_priv->algo_ops->gw.is_eligible)
+ return -EINVAL;
+
if (buff[count - 1] == '\n')
buff[count - 1] = '\0';
--
2.8.3
prev parent reply other threads:[~2016-05-25 15:27 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-25 15:27 [B.A.T.M.A.N.] [PATCH v4 0/6] GW code: make it algorithm-agnostic and add B.A.T.M.A.N. V support Antonio Quartulli
2016-05-25 15:27 ` [B.A.T.M.A.N.] [PATCH v4 1/6] batman-adv: split routing API data structure in subobjects Antonio Quartulli
2016-05-31 18:25 ` Sven Eckelmann
2016-06-07 2:13 ` Marek Lindner
2016-05-25 15:27 ` [B.A.T.M.A.N.] [PATCH v4 2/6] batman-adv: make the GW selection class algorithm specific Antonio Quartulli
2016-05-25 15:27 ` [B.A.T.M.A.N.] [PATCH v4 3/6] batman-adv: statically print gateway table header Antonio Quartulli
2016-05-31 17:50 ` Sven Eckelmann
2016-06-07 6:22 ` Marek Lindner
2016-05-25 15:27 ` [B.A.T.M.A.N.] [PATCH v4 4/6] batman-adv: make GW election code protocol specific Antonio Quartulli
2016-05-25 15:27 ` [B.A.T.M.A.N.] [PATCH v4 5/6] batman-adv: B.A.T.M.A.N. V - implement GW selection logic Antonio Quartulli
2016-05-27 13:48 ` Sven Eckelmann
2016-05-27 13:57 ` Antonio Quartulli
2016-05-27 14:01 ` Sven Eckelmann
2016-05-25 15:27 ` Antonio Quartulli [this message]
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=20160525152736.9031-7-a@unstable.cc \
--to=a@unstable.cc \
--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