batctl: Add support for hop_penalty settings command
authorSven Eckelmann <sven@narfation.org>
Fri, 22 Feb 2019 21:31:44 +0000 (22:31 +0100)
committerSven Eckelmann <sven@narfation.org>
Fri, 22 Feb 2019 21:49:56 +0000 (22:49 +0100)
The batman-adv scripts are still using sysfs for setting the hop_penalty.
Since the sysfs is deprecated, the batctl interface should be used to make
it independent of implementation details (sysfs vs. netlink).

Signed-off-by: Sven Eckelmann <sven@narfation.org>
batctl/Makefile
batctl/patches/0001-batctl-Add-hop_penalty-command.patch [new file with mode: 0644]

index 5c1c20e6bf82d608d97381c6fa7bf4d7f75fb71d..84a456c26f86fac01f3da3601d63b4d2aa54bd29 100644 (file)
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 PKG_NAME:=batctl
 
 PKG_VERSION:=2019.0
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 PKG_HASH:=997721096ff396644e8d697ea7651e9d38243faf317bcea2661d4139ff58b531
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
@@ -101,6 +101,7 @@ config-n := \
        fragmentation \
        gateways \
        gw_mode \
+       hop_penalty \
        interface \
        isolation_mark \
        log \
@@ -130,6 +131,7 @@ config-settings := \
        distributed_arp_table \
        fragmentation \
        gw_mode \
+       hop_penalty \
        interface \
        isolation_mark \
        loglevel \
diff --git a/batctl/patches/0001-batctl-Add-hop_penalty-command.patch b/batctl/patches/0001-batctl-Add-hop_penalty-command.patch
new file mode 100644 (file)
index 0000000..ae95f87
--- /dev/null
@@ -0,0 +1,59 @@
+From: Sven Eckelmann <sven@narfation.org>
+Date: Fri, 22 Feb 2019 22:19:59 +0100
+Subject: batctl: Add hop_penalty command
+
+Signed-off-by: Sven Eckelmann <sven@narfation.org>
+
+diff --git a/Makefile b/Makefile
+index 4d8b7095a1e307f0dde7660a718e4ad9c6b11102..55105cc754f546891ba2fcaf57dc8b3ac4c22f71 100755
+--- a/Makefile
++++ b/Makefile
+@@ -63,6 +63,7 @@ $(eval $(call add_command,event,y))
+ $(eval $(call add_command,fragmentation,y))
+ $(eval $(call add_command,gateways,y))
+ $(eval $(call add_command,gw_mode,y))
++$(eval $(call add_command,hop_penalty,y))
+ $(eval $(call add_command,interface,y))
+ $(eval $(call add_command,isolation_mark,y))
+ $(eval $(call add_command,log,y))
+diff --git a/hop_penalty.c b/hop_penalty.c
+new file mode 100644
+index 0000000000000000000000000000000000000000..6e6a06a661e2ffbb76793116fb214396523bbd8d
+--- /dev/null
++++ b/hop_penalty.c
+@@ -0,0 +1,35 @@
++// SPDX-License-Identifier: GPL-2.0
++/* Copyright (C) 2009-2019  B.A.T.M.A.N. contributors:
++ *
++ * Marek Lindner <mareklindner@neomailbox.ch>
++ *
++ * 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
++ *
++ * License-Filename: LICENSES/preferred/GPL-2.0
++ */
++
++#include <stddef.h>
++
++#include "main.h"
++#include "sys.h"
++
++static struct settings_data batctl_settings_hop_penalty = {
++      .sysfs_name = "hop_penalty",
++      .params = NULL,
++};
++
++COMMAND_NAMED(SUBCOMMAND, hop_penalty, "hp", handle_sys_setting,
++            COMMAND_FLAG_MESH_IFACE, &batctl_settings_hop_penalty,
++            "[penalty]        \tdisplay or modify hop_penalty setting");