b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Sven Eckelmann <sven@narfation.org>,
	Andreas Langer <an.langer@gmx.de>,
	Martin Hundeboll <martin@hundeboll.net>,
	Marek Lindner <mareklindner@neomailbox.ch>
Subject: [B.A.T.M.A.N.] [PATCH v5 17/20] batctl: Support generic netlink for fragmentation command
Date: Sat,  9 Feb 2019 14:42:19 +0100	[thread overview]
Message-ID: <20190209134222.15035-18-sven@narfation.org> (raw)
In-Reply-To: <20190209134222.15035-1-sven@narfation.org>

sysfs should be avoided for new settings of network interfaces. To still
provide a common configuration infrastructure, all the existing settings
subcommands also have to be reimplemented via generic netlink while still
using sysfs as fallback.

The fragmentation implementation is using the commands
BATADV_CMD_SET_MESH/BATADV_CMD_GET_MESH to set/get the configuration of
the u8 (boolean) BATADV_ATTR_FRAGMENTATION_ENABLED attribute.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
Cc: Andreas Langer <an.langer@gmx.de>
Cc: Martin Hundeboll <martin@hundeboll.net>
Cc: Marek Lindner <mareklindner@neomailbox.ch>
---
 fragmentation.c | 46 ++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 44 insertions(+), 2 deletions(-)

diff --git a/fragmentation.c b/fragmentation.c
index 6c3ece5..080de00 100644
--- a/fragmentation.c
+++ b/fragmentation.c
@@ -21,13 +21,55 @@
  */
 
 #include "main.h"
+
+#include <errno.h>
+#include <linux/genetlink.h>
+#include <netlink/genl/genl.h>
+
+#include "batman_adv.h"
+#include "netlink.h"
 #include "sys.h"
 
+static struct simple_boolean_data fragmentation;
+
+static int print_fragmentation(struct nl_msg *msg, void *arg)
+{
+	return sys_simple_print_boolean(msg, arg,
+					BATADV_ATTR_FRAGMENTATION_ENABLED);
+}
+
+static int get_fragmentation(struct state *state)
+{
+	return sys_simple_nlquery(state, BATADV_CMD_GET_MESH,
+				  NULL, print_fragmentation);
+}
+
+static int set_attrs_fragmentation(struct nl_msg *msg, void *arg)
+{
+	struct state *state = arg;
+	struct settings_data *settings = state->cmd->arg;
+	struct simple_boolean_data *data = settings->data;
+
+	nla_put_u8(msg, BATADV_ATTR_FRAGMENTATION_ENABLED, data->val);
+
+	return 0;
+}
+
+static int set_fragmentation(struct state *state)
+{
+	return sys_simple_nlquery(state, BATADV_CMD_SET_MESH,
+				  set_attrs_fragmentation, NULL);
+}
+
 static struct settings_data batctl_settings_fragmentation = {
 	.sysfs_name = "fragmentation",
-	.params = sysfs_param_enable,
+	.data = &fragmentation,
+	.parse = parse_simple_boolean,
+	.netlink_get = get_fragmentation,
+	.netlink_set = set_fragmentation,
 };
 
 COMMAND_NAMED(SUBCOMMAND, fragmentation, "f", handle_sys_setting,
-	      COMMAND_FLAG_MESH_IFACE, &batctl_settings_fragmentation,
+	      COMMAND_FLAG_MESH_IFACE | COMMAND_FLAG_NETLINK,
+	      &batctl_settings_fragmentation,
 	      "[0|1]             \tdisplay or modify fragmentation setting");
-- 
2.20.1


  parent reply	other threads:[~2019-02-09 13:42 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-09 13:42 [B.A.T.M.A.N.] [PATCH v5 00/20] batctl: netlink restructuring, part 3 Sven Eckelmann
2019-02-09 13:42 ` [B.A.T.M.A.N.] [PATCH v5 01/20] batctl: Add support for config mcast group in event monitor Sven Eckelmann
2019-02-09 13:42 ` [B.A.T.M.A.N.] [PATCH v5 02/20] batctl: Don't allocate new buffer for vlan parent device Sven Eckelmann
2019-02-09 13:42 ` [B.A.T.M.A.N.] [PATCH v5 03/20] batctl: Automatically translate vlan to mesh_iface Sven Eckelmann
2019-02-09 13:42 ` [B.A.T.M.A.N.] [PATCH v5 04/20] batctl: Add settings_data hooks for netlink integration Sven Eckelmann
2019-02-09 13:42 ` [B.A.T.M.A.N.] [PATCH v5 05/20] batctl: Parse the arguments for gw_mode Sven Eckelmann
2019-02-09 13:42 ` [B.A.T.M.A.N.] [PATCH v5 06/20] batctl: Add netlink simple query helper Sven Eckelmann
2019-02-09 13:42 ` [B.A.T.M.A.N.] [PATCH v5 07/20] batctl: Support generic netlink for gw_mode command Sven Eckelmann
2019-02-09 13:42 ` [B.A.T.M.A.N.] [PATCH v5 08/20] batctl: Support generic netlink for loglevel command Sven Eckelmann
2019-02-09 13:42 ` [B.A.T.M.A.N.] [PATCH v5 09/20] batctl: Support generic netlink for isolation_mark command Sven Eckelmann
2019-02-09 13:42 ` [B.A.T.M.A.N.] [PATCH v5 10/20] batctl: Support generic netlink for orig_interval command Sven Eckelmann
2019-02-09 13:42 ` [B.A.T.M.A.N.] [PATCH v5 11/20] batctl: Add helper to read/write boolean configuration values Sven Eckelmann
2019-02-09 13:42 ` [B.A.T.M.A.N.] [PATCH v5 12/20] batctl: Support generic netlink for aggregation command Sven Eckelmann
2019-02-09 13:42 ` [B.A.T.M.A.N.] [PATCH v5 13/20] batctl: Support generic netlink for ap_isolation command Sven Eckelmann
2019-02-09 13:42 ` [B.A.T.M.A.N.] [PATCH v5 14/20] batctl: Support generic netlink for bonding command Sven Eckelmann
2019-02-09 13:42 ` [B.A.T.M.A.N.] [PATCH v5 15/20] batctl: Support generic netlink for bridge_loop_avoidance command Sven Eckelmann
2019-02-09 13:42 ` [B.A.T.M.A.N.] [PATCH v5 16/20] batctl: Support generic netlink for distributed_arp_table command Sven Eckelmann
2019-02-09 13:42 ` Sven Eckelmann [this message]
2019-02-09 13:42 ` [B.A.T.M.A.N.] [PATCH v5 18/20] batctl: Support generic netlink for multicast_mode command Sven Eckelmann
2019-02-09 13:42 ` [B.A.T.M.A.N.] [PATCH v5 19/20] batctl: Support generic netlink for network_coding command Sven Eckelmann
2019-02-09 13:42 ` [B.A.T.M.A.N.] [PATCH v5 20/20] batctl: Drop settings_data param lists Sven Eckelmann

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=20190209134222.15035-18-sven@narfation.org \
    --to=sven@narfation.org \
    --cc=an.langer@gmx.de \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=mareklindner@neomailbox.ch \
    --cc=martin@hundeboll.net \
    /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).