mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-29 09:32:34 +00:00
batman-adv: drop v4.4 backport
Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
@@ -1,88 +0,0 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# Copyright (C) 2007-2019 B.A.T.M.A.N. contributors:
|
||||
#
|
||||
# Marek Lindner, Simon Wunderlich
|
||||
|
||||
#
|
||||
# B.A.T.M.A.N meshing protocol
|
||||
#
|
||||
|
||||
config BATMAN_ADV_BATMAN_V
|
||||
bool "B.A.T.M.A.N. V protocol"
|
||||
depends on PACKAGE_kmod-batman-adv
|
||||
default y
|
||||
help
|
||||
This option enables the B.A.T.M.A.N. V protocol, the successor
|
||||
of the currently used B.A.T.M.A.N. IV protocol. The main
|
||||
changes include splitting of the OGM protocol into a neighbor
|
||||
discovery protocol (Echo Location Protocol, ELP) and a new OGM
|
||||
Protocol OGMv2 for flooding protocol information through the
|
||||
network, as well as a throughput based metric.
|
||||
B.A.T.M.A.N. V is currently considered experimental and not
|
||||
compatible to B.A.T.M.A.N. IV networks.
|
||||
|
||||
config BATMAN_ADV_BLA
|
||||
bool "Bridge Loop Avoidance"
|
||||
depends on PACKAGE_kmod-batman-adv
|
||||
select PACKAGE_kmod-lib-crc16
|
||||
default y
|
||||
help
|
||||
This option enables BLA (Bridge Loop Avoidance), a mechanism
|
||||
to avoid Ethernet frames looping when mesh nodes are connected
|
||||
to both the same LAN and the same mesh. If you will never use
|
||||
more than one mesh node in the same LAN, you can safely remove
|
||||
this feature and save some space.
|
||||
|
||||
config BATMAN_ADV_DAT
|
||||
bool "Distributed ARP Table"
|
||||
depends on PACKAGE_kmod-batman-adv
|
||||
default y
|
||||
help
|
||||
This option enables DAT (Distributed ARP Table), a DHT based
|
||||
mechanism that increases ARP reliability on sparse wireless
|
||||
mesh networks. If you think that your network does not need
|
||||
this option you can safely remove it and save some space.
|
||||
|
||||
config BATMAN_ADV_NC
|
||||
bool "Network Coding"
|
||||
depends on PACKAGE_kmod-batman-adv
|
||||
help
|
||||
This option enables network coding, a mechanism that aims to
|
||||
increase the overall network throughput by fusing multiple
|
||||
packets in one transmission.
|
||||
Note that interfaces controlled by batman-adv must be manually
|
||||
configured to have promiscuous mode enabled in order to make
|
||||
network coding work.
|
||||
If you think that your network does not need this feature you
|
||||
can safely disable it and save some space.
|
||||
|
||||
config BATMAN_ADV_MCAST
|
||||
bool "Multicast optimisation"
|
||||
depends on PACKAGE_kmod-batman-adv
|
||||
default y
|
||||
help
|
||||
This option enables the multicast optimisation which aims to
|
||||
reduce the air overhead while improving the reliability of
|
||||
multicast messages.
|
||||
|
||||
config BATMAN_ADV_DEBUG
|
||||
bool "B.A.T.M.A.N. debugging"
|
||||
depends on PACKAGE_kmod-batman-adv
|
||||
help
|
||||
This is an option for use by developers; most people should
|
||||
say N here. This enables compilation of support for
|
||||
outputting debugging information to the debugfs log or tracing
|
||||
buffer. The output is controlled via the batadv netdev specific
|
||||
log_level setting.
|
||||
|
||||
config BATMAN_ADV_TRACING
|
||||
bool "B.A.T.M.A.N. tracing support"
|
||||
depends on PACKAGE_kmod-batman-adv
|
||||
select KERNEL_FTRACE
|
||||
select KERNEL_ENABLE_DEFAULT_TRACERS
|
||||
help
|
||||
This is an option for use by developers; most people should
|
||||
say N here. Select this option to gather traces like the debug
|
||||
messages using the generic tracing infrastructure of the kernel.
|
||||
BATMAN_ADV_DEBUG must also be selected to get trace events for
|
||||
batadv_dbg.
|
||||
@@ -1,91 +0,0 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=batman-adv
|
||||
PKG_VERSION:=2021.1
|
||||
PKG_RELEASE:=$(AUTORELEASE)
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
|
||||
PKG_HASH:=bf77843d8dead75342d673ce7021e4ad037447ce18c64056ae1e3202039934d0
|
||||
PKG_EXTMOD_SUBDIRS:=net/batman-adv
|
||||
|
||||
PKG_MAINTAINER:=Simon Wunderlich <sw@simonwunderlich.de>
|
||||
PKG_LICENSE:=GPL-2.0-only MIT
|
||||
PKG_LICENSE_FILES:=LICENSES/preferred/GPL-2.0 LICENSES/preferred/MIT
|
||||
|
||||
STAMP_CONFIGURED_DEPENDS := $(STAGING_DIR)/usr/include/mac80211-backport/backport/autoconf.h
|
||||
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define KernelPackage/batman-adv
|
||||
SUBMENU:=Network Support
|
||||
TITLE:=B.A.T.M.A.N. Adv
|
||||
URL:=https://www.open-mesh.org/
|
||||
DEPENDS:=+BATMAN_ADV_BLA:kmod-lib-crc16 +kmod-lib-crc32c +kmod-cfg80211 +batctl
|
||||
FILES:=$(PKG_BUILD_DIR)/net/batman-adv/batman-adv.$(LINUX_KMOD_SUFFIX)
|
||||
AUTOLOAD:=$(call AutoProbe,batman-adv)
|
||||
endef
|
||||
|
||||
define KernelPackage/batman-adv/description
|
||||
B.A.T.M.A.N. (better approach to mobile ad-hoc networking) is
|
||||
a routing protocol for multi-hop ad-hoc mesh networks. The
|
||||
networks may be wired or wireless. See
|
||||
https://www.open-mesh.org/ for more information and user space
|
||||
tools. This package builds version $(PKG_VERSION) of the kernel
|
||||
module.
|
||||
endef
|
||||
|
||||
define KernelPackage/batman-adv/config
|
||||
source "$(SOURCE)/Config.in"
|
||||
endef
|
||||
|
||||
define Package/kmod-batman-adv/conffiles
|
||||
/etc/config/batman-adv
|
||||
endef
|
||||
|
||||
PKG_EXTRA_KCONFIG:= \
|
||||
CONFIG_BATMAN_ADV=m \
|
||||
CONFIG_BATMAN_ADV_DEBUG=$(if $(CONFIG_BATMAN_ADV_DEBUG),y,n) \
|
||||
CONFIG_BATMAN_ADV_BLA=$(if $(CONFIG_BATMAN_ADV_BLA),y,n) \
|
||||
CONFIG_BATMAN_ADV_DAT=$(if $(CONFIG_BATMAN_ADV_DAT),y,n) \
|
||||
CONFIG_BATMAN_ADV_MCAST=$(if $(CONFIG_BATMAN_ADV_MCAST),y,n) \
|
||||
CONFIG_BATMAN_ADV_NC=$(if $(CONFIG_BATMAN_ADV_NC),y,n) \
|
||||
CONFIG_BATMAN_ADV_BATMAN_V=$(if $(CONFIG_BATMAN_ADV_BATMAN_V),y,n) \
|
||||
CONFIG_BATMAN_ADV_TRACING=$(if $(CONFIG_BATMAN_ADV_TRACING),y,n) \
|
||||
|
||||
PKG_EXTRA_CFLAGS:= \
|
||||
$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(PKG_EXTRA_KCONFIG)))) \
|
||||
$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(PKG_EXTRA_KCONFIG)))) \
|
||||
|
||||
NOSTDINC_FLAGS = \
|
||||
$(KERNEL_NOSTDINC_FLAGS) \
|
||||
-I$(PKG_BUILD_DIR)/net/batman-adv \
|
||||
-I$(STAGING_DIR)/usr/include/mac80211-backport \
|
||||
-I$(STAGING_DIR)/usr/include/mac80211-backport/uapi \
|
||||
-I$(STAGING_DIR)/usr/include/mac80211 \
|
||||
-I$(STAGING_DIR)/usr/include/mac80211/uapi \
|
||||
-I$(PKG_BUILD_DIR)/include/ \
|
||||
-include backport/autoconf.h \
|
||||
-include backport/backport.h \
|
||||
-include $(PKG_BUILD_DIR)/compat-hacks.h \
|
||||
-include $(PKG_BUILD_DIR)/compat-qca.h \
|
||||
-DBATADV_SOURCE_VERSION=\\\"$(PKG_VERSION)-openwrt-$(PKG_RELEASE)\\\"
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \
|
||||
$(KERNEL_MAKE_FLAGS) \
|
||||
M="$(PKG_BUILD_DIR)/net/batman-adv" \
|
||||
$(PKG_EXTRA_KCONFIG) \
|
||||
EXTRA_CFLAGS="$(PKG_EXTRA_CFLAGS)" \
|
||||
NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \
|
||||
modules
|
||||
endef
|
||||
|
||||
define KernelPackage/batman-adv/install
|
||||
$(CP) ./files/. $(1)/
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,batman-adv))
|
||||
@@ -1,97 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This UCI-Defaults script will split the batadv proto network interfaces
|
||||
# in batadv_hardif and batadv proto. The configuration options from
|
||||
# /etc/config/batman-adv will be moved to the latter.
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
proto_batadv_to_batadv_hardif() {
|
||||
local section="$1"
|
||||
local proto
|
||||
local mesh
|
||||
local routing_algo
|
||||
|
||||
config_get proto "${section}" proto
|
||||
config_get mesh "${section}" mesh
|
||||
config_get routing_algo "${section}" routing_algo
|
||||
|
||||
if [ -z "$mesh" -o "${proto}" != "batadv" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
uci set network."${section}".proto="batadv_hardif"
|
||||
uci rename network."${section}".mesh="master"
|
||||
uci delete network."${section}".routing_algo
|
||||
|
||||
# create new section or adjust existing one
|
||||
uci set network."${mesh}"=interface
|
||||
uci set network."${mesh}".proto=batadv
|
||||
[ -n "${routing_algo}" ] && uci set network."${mesh}".routing_algo="${routing_algo}"
|
||||
}
|
||||
|
||||
mv_batadv_config_section() {
|
||||
local section="$1"
|
||||
local aggregated_ogms
|
||||
local ap_isolation
|
||||
local bonding
|
||||
local bridge_loop_avoidance
|
||||
local distributed_arp_table
|
||||
local fragmentation
|
||||
local gw_bandwidth
|
||||
local gw_mode
|
||||
local gw_sel_class
|
||||
local hop_penalty
|
||||
local isolation_mark
|
||||
local log_level
|
||||
local multicast_mode
|
||||
local network_coding
|
||||
local orig_interval
|
||||
|
||||
config_get aggregated_ogms "${section}" aggregated_ogms
|
||||
config_get ap_isolation "${section}" ap_isolation
|
||||
config_get bonding "${section}" bonding
|
||||
config_get bridge_loop_avoidance "${section}" bridge_loop_avoidance
|
||||
config_get distributed_arp_table "${section}" distributed_arp_table
|
||||
config_get fragmentation "${section}" fragmentation
|
||||
config_get gw_bandwidth "${section}" gw_bandwidth
|
||||
config_get gw_mode "${section}" gw_mode
|
||||
config_get gw_sel_class "${section}" gw_sel_class
|
||||
config_get hop_penalty "${section}" hop_penalty
|
||||
config_get isolation_mark "${section}" isolation_mark
|
||||
config_get log_level "${section}" log_level
|
||||
config_get multicast_mode "${section}" multicast_mode
|
||||
config_get network_coding "${section}" network_coding
|
||||
config_get orig_interval "${section}" orig_interval
|
||||
|
||||
# update section in case it exists
|
||||
[ -n "${aggregated_ogms}" ] && uci set network."${section}".aggregated_ogms="${aggregated_ogms}"
|
||||
[ -n "${ap_isolation}" ] && uci set network."${section}".ap_isolation="${ap_isolation}"
|
||||
[ -n "${bonding}" ] && uci set network."${section}".bonding="${bonding}"
|
||||
[ -n "${bridge_loop_avoidance}" ] && uci set network."${section}".bridge_loop_avoidance="${bridge_loop_avoidance}"
|
||||
[ -n "${distributed_arp_table}" ] && uci set network."${section}".distributed_arp_table="${distributed_arp_table}"
|
||||
[ -n "${fragmentation}" ] && uci set network."${section}".fragmentation="${fragmentation}"
|
||||
[ -n "${gw_bandwidth}" ] && uci set network."${section}".gw_bandwidth="${gw_bandwidth}"
|
||||
[ -n "${gw_mode}" ] && uci set network."${section}".gw_mode="${gw_mode}"
|
||||
[ -n "${gw_sel_class}" ] && uci set network."${section}".gw_sel_class="${gw_sel_class}"
|
||||
[ -n "${hop_penalty}" ] && uci set network."${section}".hop_penalty="${hop_penalty}"
|
||||
[ -n "${isolation_mark}" ] && uci set network."${section}".isolation_mark="${isolation_mark}"
|
||||
[ -n "${log_level}" ] && uci set network."${section}".log_level="${log_level}"
|
||||
[ -n "${multicast_mode}" ] && uci set network."${section}".multicast_mode="${multicast_mode}"
|
||||
[ -n "${network_coding}" ] && uci set network."${section}".network_coding="${network_coding}"
|
||||
[ -n "${orig_interval}" ] && uci set network."${section}".orig_interval="${orig_interval}"
|
||||
}
|
||||
|
||||
if [ -f /etc/config/batman-adv ]; then
|
||||
config_load network
|
||||
config_foreach proto_batadv_to_batadv_hardif 'interface'
|
||||
uci commit network
|
||||
|
||||
config_load batman-adv
|
||||
config_foreach mv_batadv_config_section 'mesh'
|
||||
uci commit network
|
||||
|
||||
rm -f /etc/config/batman-adv
|
||||
fi
|
||||
|
||||
exit 0
|
||||
@@ -1,123 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
[ -n "$INCLUDE_ONLY" ] || {
|
||||
. /lib/functions.sh
|
||||
. ../netifd-proto.sh
|
||||
init_proto "$@"
|
||||
}
|
||||
|
||||
proto_batadv_init_config() {
|
||||
no_device=1
|
||||
available=1
|
||||
|
||||
proto_config_add_boolean 'aggregated_ogms:bool'
|
||||
proto_config_add_boolean 'ap_isolation:bool'
|
||||
proto_config_add_boolean 'bonding:bool'
|
||||
proto_config_add_boolean 'bridge_loop_avoidance:bool'
|
||||
proto_config_add_boolean 'distributed_arp_table:bool'
|
||||
proto_config_add_boolean 'fragmentation:bool'
|
||||
proto_config_add_string 'gw_bandwidth'
|
||||
proto_config_add_string 'gw_mode'
|
||||
proto_config_add_int 'gw_sel_class'
|
||||
proto_config_add_int 'hop_penalty'
|
||||
proto_config_add_string 'isolation_mark'
|
||||
proto_config_add_string 'log_level'
|
||||
proto_config_add_int 'multicast_fanout'
|
||||
proto_config_add_boolean 'multicast_mode:bool'
|
||||
proto_config_add_boolean 'network_coding:bool'
|
||||
proto_config_add_int 'orig_interval'
|
||||
proto_config_add_string 'routing_algo'
|
||||
}
|
||||
|
||||
proto_batadv_setup() {
|
||||
local config="$1"
|
||||
local iface="$config"
|
||||
|
||||
local aggregated_ogms
|
||||
local ap_isolation
|
||||
local bonding
|
||||
local bridge_loop_avoidance
|
||||
local distributed_arp_table
|
||||
local fragmentation
|
||||
local gw_bandwidth
|
||||
local gw_mode
|
||||
local gw_sel_class
|
||||
local hop_penalty
|
||||
local isolation_mark
|
||||
local log_level
|
||||
local multicast_fanout
|
||||
local multicast_mode
|
||||
local network_coding
|
||||
local orig_interval
|
||||
local routing_algo
|
||||
|
||||
json_get_vars aggregated_ogms
|
||||
json_get_vars ap_isolation
|
||||
json_get_vars bonding
|
||||
json_get_vars bridge_loop_avoidance
|
||||
json_get_vars distributed_arp_table
|
||||
json_get_vars fragmentation
|
||||
json_get_vars gw_bandwidth
|
||||
json_get_vars gw_mode
|
||||
json_get_vars gw_sel_class
|
||||
json_get_vars hop_penalty
|
||||
json_get_vars isolation_mark
|
||||
json_get_vars log_level
|
||||
json_get_vars multicast_fanout
|
||||
json_get_vars multicast_mode
|
||||
json_get_vars network_coding
|
||||
json_get_vars orig_interval
|
||||
json_get_vars routing_algo
|
||||
|
||||
set_default routing_algo 'BATMAN_IV'
|
||||
|
||||
batctl routing_algo "$routing_algo"
|
||||
batctl meshif "$iface" interface create
|
||||
|
||||
[ -n "$aggregated_ogms" ] && batctl meshif "$iface" aggregation "$aggregated_ogms"
|
||||
[ -n "$ap_isolation" ] && batctl meshif "$iface" ap_isolation "$ap_isolation"
|
||||
[ -n "$bonding" ] && batctl meshif "$iface" bonding "$bonding"
|
||||
[ -n "$bridge_loop_avoidance" ] && batctl meshif "$iface" bridge_loop_avoidance "$bridge_loop_avoidance" 2>&-
|
||||
[ -n "$distributed_arp_table" ] && batctl meshif "$iface" distributed_arp_table "$distributed_arp_table" 2>&-
|
||||
[ -n "$fragmentation" ] && batctl meshif "$iface" fragmentation "$fragmentation"
|
||||
|
||||
case "$gw_mode" in
|
||||
server)
|
||||
if [ -n "$gw_bandwidth" ]; then
|
||||
batctl meshif "$iface" gw_mode "server" "$gw_bandwidth"
|
||||
else
|
||||
batctl meshif "$iface" gw_mode "server"
|
||||
fi
|
||||
;;
|
||||
client)
|
||||
if [ -n "$gw_sel_class" ]; then
|
||||
batctl meshif "$iface" gw_mode "client" "$gw_sel_class"
|
||||
else
|
||||
batctl meshif "$iface" gw_mode "client"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
batctl meshif "$iface" gw_mode "off"
|
||||
;;
|
||||
esac
|
||||
|
||||
[ -n "$hop_penalty" ] && batctl meshif "$iface" hop_penalty "$hop_penalty"
|
||||
[ -n "$isolation_mark" ] && batctl meshif "$iface" isolation_mark "$isolation_mark"
|
||||
[ -n "$multicast_fanout" ] && batctl meshif "$iface" multicast_fanout "$multicast_fanout"
|
||||
[ -n "$multicast_mode" ] && batctl meshif "$iface" multicast_mode "$multicast_mode" 2>&-
|
||||
[ -n "$network_coding" ] && batctl meshif "$iface" network_coding "$network_coding" 2>&-
|
||||
[ -n "$log_level" ] && batctl meshif "$iface" loglevel "$log_level" 2>&-
|
||||
[ -n "$orig_interval" ] && batctl meshif "$iface" orig_interval "$orig_interval"
|
||||
|
||||
proto_init_update "$iface" 1
|
||||
proto_send_update "$config"
|
||||
}
|
||||
|
||||
proto_batadv_teardown() {
|
||||
local config="$1"
|
||||
local iface="$config"
|
||||
|
||||
batctl meshif "$iface" interface destroy
|
||||
}
|
||||
|
||||
add_protocol batadv
|
||||
@@ -1,53 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
[ -n "$INCLUDE_ONLY" ] || {
|
||||
. /lib/functions.sh
|
||||
. ../netifd-proto.sh
|
||||
init_proto "$@"
|
||||
}
|
||||
|
||||
proto_batadv_hardif_init_config() {
|
||||
proto_config_add_int 'elp_interval'
|
||||
proto_config_add_int 'hop_penalty'
|
||||
proto_config_add_string "master"
|
||||
proto_config_add_string 'throughput_override'
|
||||
}
|
||||
|
||||
proto_batadv_hardif_setup() {
|
||||
local config="$1"
|
||||
local iface="$2"
|
||||
|
||||
local elp_interval
|
||||
local hop_penalty
|
||||
local master
|
||||
local throughput_override
|
||||
|
||||
json_get_vars elp_interval
|
||||
json_get_vars hop_penalty
|
||||
json_get_vars master
|
||||
json_get_vars throughput_override
|
||||
|
||||
( proto_add_host_dependency "$config" '' "$master" )
|
||||
|
||||
batctl meshif "$master" interface -M add "$iface"
|
||||
|
||||
[ -n "$elp_interval" ] && batctl hardif "$iface" elp_interval "$elp_interval"
|
||||
[ -n "$hop_penalty" ] && batctl hardif "$iface" hop_penalty "$hop_penalty"
|
||||
[ -n "$throughput_override" ] && batctl hardif "$iface" throughput_override "$throughput_override"
|
||||
|
||||
proto_init_update "$iface" 1
|
||||
proto_send_update "$config"
|
||||
}
|
||||
|
||||
proto_batadv_hardif_teardown() {
|
||||
local config="$1"
|
||||
local iface="$2"
|
||||
|
||||
local master
|
||||
|
||||
json_get_vars master
|
||||
|
||||
batctl meshif "$master" interface -M del "$iface" || true
|
||||
}
|
||||
|
||||
add_protocol batadv_hardif
|
||||
@@ -1,25 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
. ../netifd-proto.sh
|
||||
init_proto "$@"
|
||||
|
||||
proto_batadv_vlan_init_config() {
|
||||
proto_config_add_boolean 'ap_isolation:bool'
|
||||
}
|
||||
|
||||
proto_batadv_vlan_setup() {
|
||||
local config="$1"
|
||||
local iface="$2"
|
||||
|
||||
# batadv_vlan options
|
||||
local ap_isolation
|
||||
|
||||
json_get_vars ap_isolation
|
||||
|
||||
[ -n "$ap_isolation" ] && batctl vlan "$iface" ap_isolation "$ap_isolation"
|
||||
proto_init_update "$iface" 1
|
||||
proto_send_update "$config"
|
||||
}
|
||||
|
||||
add_protocol batadv_vlan
|
||||
@@ -1,128 +0,0 @@
|
||||
From: Sven Eckelmann <sven@narfation.org>
|
||||
Date: Sat, 24 Oct 2020 22:51:23 +0200
|
||||
Subject: Revert "batman-adv: genetlink: move to smaller ops wherever possible"
|
||||
|
||||
The netlink genl_ops interface was splitted into two parts for Linux 5.10.
|
||||
The batman-adv code changed to the new one because it doesn't use the more
|
||||
complex policy handling of genl_ops. But the backports-5.8-1 version in
|
||||
OpenWrt doesn't yet support the new genl_small_ops.
|
||||
|
||||
This patch must be dropped directly when OpenWrt switches to backports-5.10
|
||||
or newer - otherwise it will not work as expected.
|
||||
|
||||
This reverts commit 725b4ef5be840cfcd0ca33b9393c14dee40c10f7.
|
||||
|
||||
--- a/compat-include/net/genetlink.h
|
||||
+++ b/compat-include/net/genetlink.h
|
||||
@@ -31,17 +31,15 @@ void batadv_genl_dump_check_consistent(s
|
||||
#endif /* LINUX_VERSION_IS_LESS(4, 15, 0) */
|
||||
|
||||
|
||||
-#if LINUX_VERSION_IS_LESS(5, 10, 0)
|
||||
-
|
||||
#if LINUX_VERSION_IS_LESS(5, 2, 0)
|
||||
+
|
||||
enum genl_validate_flags {
|
||||
GENL_DONT_VALIDATE_STRICT = BIT(0),
|
||||
GENL_DONT_VALIDATE_DUMP = BIT(1),
|
||||
GENL_DONT_VALIDATE_DUMP_STRICT = BIT(2),
|
||||
};
|
||||
-#endif /* LINUX_VERSION_IS_LESS(5, 2, 0) */
|
||||
|
||||
-struct batadv_genl_small_ops {
|
||||
+struct batadv_genl_ops {
|
||||
int (*doit)(struct sk_buff *skb,
|
||||
struct genl_info *info);
|
||||
int (*dumpit)(struct sk_buff *skb,
|
||||
@@ -70,9 +68,9 @@ struct batadv_genl_family {
|
||||
struct genl_info *info);
|
||||
void (*post_doit)(const struct genl_ops *ops, struct sk_buff *skb,
|
||||
struct genl_info *info);
|
||||
- const struct batadv_genl_small_ops *small_ops;
|
||||
+ const struct batadv_genl_ops *ops;
|
||||
const struct genl_multicast_group *mcgrps;
|
||||
- unsigned int n_small_ops;
|
||||
+ unsigned int n_ops;
|
||||
unsigned int n_mcgrps;
|
||||
struct module *module;
|
||||
|
||||
@@ -96,32 +94,24 @@ static inline int batadv_genl_register_f
|
||||
family->family.pre_doit = family->pre_doit;
|
||||
family->family.post_doit = family->post_doit;
|
||||
family->family.mcgrps = family->mcgrps;
|
||||
- family->family.n_ops = family->n_small_ops;
|
||||
+ family->family.n_ops = family->n_ops;
|
||||
family->family.n_mcgrps = family->n_mcgrps;
|
||||
family->family.module = family->module;
|
||||
|
||||
- ops = kzalloc(sizeof(*ops) * family->n_small_ops, GFP_KERNEL);
|
||||
+ ops = kzalloc(sizeof(*ops) * family->n_ops, GFP_KERNEL);
|
||||
if (!ops)
|
||||
return -ENOMEM;
|
||||
|
||||
for (i = 0; i < family->family.n_ops; i++) {
|
||||
- ops[i].doit = family->small_ops[i].doit;
|
||||
- ops[i].dumpit = family->small_ops[i].dumpit;
|
||||
- ops[i].done = family->small_ops[i].done;
|
||||
- ops[i].cmd = family->small_ops[i].cmd;
|
||||
- ops[i].internal_flags = family->small_ops[i].internal_flags;
|
||||
- ops[i].flags = family->small_ops[i].flags;
|
||||
-#if LINUX_VERSION_IS_GEQ(5, 2, 0)
|
||||
- ops[i].validate = family->small_ops[i].validate;
|
||||
-#else
|
||||
+ ops[i].doit = family->ops[i].doit;
|
||||
+ ops[i].dumpit = family->ops[i].dumpit;
|
||||
+ ops[i].done = family->ops[i].done;
|
||||
+ ops[i].cmd = family->ops[i].cmd;
|
||||
+ ops[i].internal_flags = family->ops[i].internal_flags;
|
||||
+ ops[i].flags = family->ops[i].flags;
|
||||
ops[i].policy = family->policy;
|
||||
-#endif
|
||||
}
|
||||
|
||||
-#if LINUX_VERSION_IS_GEQ(5, 2, 0)
|
||||
- family->family.policy = family->policy;
|
||||
-#endif
|
||||
-
|
||||
family->family.ops = ops;
|
||||
family->copy_ops = ops;
|
||||
|
||||
@@ -136,7 +126,7 @@ typedef struct genl_ops batadv_genl_ops_
|
||||
#define batadv_post_doit(__x, __y, __z) \
|
||||
batadv_post_doit(const batadv_genl_ops_old *ops, __y, __z)
|
||||
|
||||
-#define genl_small_ops batadv_genl_small_ops
|
||||
+#define genl_ops batadv_genl_ops
|
||||
#define genl_family batadv_genl_family
|
||||
|
||||
#define genl_register_family(family) \
|
||||
@@ -160,6 +150,6 @@ batadv_genl_unregister_family(struct bat
|
||||
genlmsg_multicast_netns(&(_family)->family, _net, _skb, _portid, \
|
||||
_group, _flags)
|
||||
|
||||
-#endif /* LINUX_VERSION_IS_LESS(5, 10, 0) */
|
||||
+#endif /* LINUX_VERSION_IS_LESS(5, 2, 0) */
|
||||
|
||||
#endif /* _NET_BATMAN_ADV_COMPAT_NET_GENETLINK_H_ */
|
||||
--- a/net/batman-adv/netlink.c
|
||||
+++ b/net/batman-adv/netlink.c
|
||||
@@ -1351,7 +1351,7 @@ static void batadv_post_doit(const struc
|
||||
}
|
||||
}
|
||||
|
||||
-static const struct genl_small_ops batadv_netlink_ops[] = {
|
||||
+static const struct genl_ops batadv_netlink_ops[] = {
|
||||
{
|
||||
.cmd = BATADV_CMD_GET_MESH,
|
||||
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
|
||||
@@ -1485,8 +1485,8 @@ struct genl_family batadv_netlink_family
|
||||
.pre_doit = batadv_pre_doit,
|
||||
.post_doit = batadv_post_doit,
|
||||
.module = THIS_MODULE,
|
||||
- .small_ops = batadv_netlink_ops,
|
||||
- .n_small_ops = ARRAY_SIZE(batadv_netlink_ops),
|
||||
+ .ops = batadv_netlink_ops,
|
||||
+ .n_ops = ARRAY_SIZE(batadv_netlink_ops),
|
||||
.mcgrps = batadv_netlink_mcgrps,
|
||||
.n_mcgrps = ARRAY_SIZE(batadv_netlink_mcgrps),
|
||||
};
|
||||
@@ -1,116 +0,0 @@
|
||||
From: Sven Eckelmann <sven@narfation.org>
|
||||
Date: Thu, 28 Jan 2021 21:06:51 +0100
|
||||
Subject: Revert "batman-adv: Add new include for min/max helpers"
|
||||
|
||||
The OpenWrt kernel sources and backports sources are currently missing this
|
||||
header.
|
||||
|
||||
This reverts commit 1810de05310d5c5e9140f870ac21052f38bc06b8.
|
||||
|
||||
Signed-off-by: Sven Eckelmann <sven@narfation.org>
|
||||
|
||||
--- a/compat-include/linux/minmax.h
|
||||
+++ /dev/null
|
||||
@@ -1,20 +0,0 @@
|
||||
-/* SPDX-License-Identifier: GPL-2.0 */
|
||||
-/* Copyright (C) B.A.T.M.A.N. contributors:
|
||||
- *
|
||||
- * Marek Lindner, Simon Wunderlich
|
||||
- *
|
||||
- * This file contains macros for maintaining compatibility with older versions
|
||||
- * of the Linux kernel.
|
||||
- */
|
||||
-
|
||||
-#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_MINMAX_H_
|
||||
-#define _NET_BATMAN_ADV_COMPAT_LINUX_MINMAX_H_
|
||||
-
|
||||
-#include <linux/version.h>
|
||||
-#if LINUX_VERSION_IS_GEQ(5, 10, 0)
|
||||
-#include_next <linux/minmax.h>
|
||||
-#else
|
||||
-#include <linux/kernel.h>
|
||||
-#endif
|
||||
-
|
||||
-#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_MINMAX_H_ */
|
||||
--- a/net/batman-adv/bat_v.c
|
||||
+++ b/net/batman-adv/bat_v.c
|
||||
@@ -15,7 +15,6 @@
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/kref.h>
|
||||
#include <linux/list.h>
|
||||
-#include <linux/minmax.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/rculist.h>
|
||||
--- a/net/batman-adv/bat_v_elp.c
|
||||
+++ b/net/batman-adv/bat_v_elp.c
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/kref.h>
|
||||
-#include <linux/minmax.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/nl80211.h>
|
||||
#include <linux/prandom.h>
|
||||
--- a/net/batman-adv/bat_v_ogm.c
|
||||
+++ b/net/batman-adv/bat_v_ogm.c
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <linux/kref.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/lockdep.h>
|
||||
-#include <linux/minmax.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/prandom.h>
|
||||
--- a/net/batman-adv/fragmentation.c
|
||||
+++ b/net/batman-adv/fragmentation.c
|
||||
@@ -14,8 +14,8 @@
|
||||
#include <linux/gfp.h>
|
||||
#include <linux/if_ether.h>
|
||||
#include <linux/jiffies.h>
|
||||
+#include <linux/kernel.h>
|
||||
#include <linux/lockdep.h>
|
||||
-#include <linux/minmax.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/slab.h>
|
||||
--- a/net/batman-adv/hard-interface.c
|
||||
+++ b/net/batman-adv/hard-interface.c
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <linux/kref.h>
|
||||
#include <linux/limits.h>
|
||||
#include <linux/list.h>
|
||||
-#include <linux/minmax.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/printk.h>
|
||||
--- a/net/batman-adv/main.c
|
||||
+++ b/net/batman-adv/main.c
|
||||
@@ -23,7 +23,6 @@
|
||||
#include <linux/kobject.h>
|
||||
#include <linux/kref.h>
|
||||
#include <linux/list.h>
|
||||
-#include <linux/minmax.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/printk.h>
|
||||
--- a/net/batman-adv/netlink.c
|
||||
+++ b/net/batman-adv/netlink.c
|
||||
@@ -23,7 +23,6 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/limits.h>
|
||||
#include <linux/list.h>
|
||||
-#include <linux/minmax.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/printk.h>
|
||||
--- a/net/batman-adv/tp_meter.c
|
||||
+++ b/net/batman-adv/tp_meter.c
|
||||
@@ -23,7 +23,6 @@
|
||||
#include <linux/kthread.h>
|
||||
#include <linux/limits.h>
|
||||
#include <linux/list.h>
|
||||
-#include <linux/minmax.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/param.h>
|
||||
#include <linux/printk.h>
|
||||
@@ -1,34 +0,0 @@
|
||||
From: Sven Eckelmann <sven@narfation.org>
|
||||
Date: Fri, 14 May 2021 19:34:35 +0200
|
||||
Subject: batman-adv: Fix build of multicast code against Linux < 5.13
|
||||
|
||||
Fixes: 007b4c4b031f ("batman-adv: convert ifmcaddr6 to RCU")
|
||||
Signed-off-by: Sven Eckelmann <sven@narfation.org>
|
||||
|
||||
--- a/net/batman-adv/multicast.c
|
||||
+++ b/net/batman-adv/multicast.c
|
||||
@@ -454,9 +454,14 @@ batadv_mcast_mla_softif_get_ipv6(struct
|
||||
return 0;
|
||||
}
|
||||
|
||||
+#if LINUX_VERSION_IS_LESS(5, 13, 0)
|
||||
+ read_lock_bh(&in6_dev->lock);
|
||||
+ for (pmc6 = in6_dev->mc_list; pmc6; pmc6 = pmc6->next) {
|
||||
+#else
|
||||
for (pmc6 = rcu_dereference(in6_dev->mc_list);
|
||||
pmc6;
|
||||
pmc6 = rcu_dereference(pmc6->next)) {
|
||||
+#endif
|
||||
if (IPV6_ADDR_MC_SCOPE(&pmc6->mca_addr) <
|
||||
IPV6_ADDR_SCOPE_LINKLOCAL)
|
||||
continue;
|
||||
@@ -485,6 +490,9 @@ batadv_mcast_mla_softif_get_ipv6(struct
|
||||
hlist_add_head(&new->list, mcast_list);
|
||||
ret++;
|
||||
}
|
||||
+#if LINUX_VERSION_IS_LESS(5, 13, 0)
|
||||
+ read_unlock_bh(&in6_dev->lock);
|
||||
+#endif
|
||||
rcu_read_unlock();
|
||||
|
||||
return ret;
|
||||
@@ -1,111 +0,0 @@
|
||||
From: Sven Eckelmann <sven@narfation.org>
|
||||
Date: Mon, 10 May 2021 15:05:42 +0200
|
||||
Subject: batman-adv: Always send iface index+name in genlmsg
|
||||
|
||||
The batman-adv netlink messages often contain the interface index and
|
||||
interface name in the same message. This makes it easy for the receiver to
|
||||
operate on the incoming data when it either needs to print something or
|
||||
needs to operate on the interface index.
|
||||
|
||||
But one of the attributes was missing for:
|
||||
|
||||
* neighbor table dumps
|
||||
* originator table dumps
|
||||
* gateway list dumps
|
||||
* query of hardif information
|
||||
* query of vid information
|
||||
|
||||
The userspace therefore had to implement special workarounds using
|
||||
SIOCGIFNAME or SIOCGIFINDEX depending on what was actually provided.
|
||||
Providing both information simplifies the userspace code massively without
|
||||
adding a lot of extra overhead in the kernel portion.
|
||||
|
||||
Signed-off-by: Sven Eckelmann <sven@narfation.org>
|
||||
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/77c7d62618259f22f36427eaa62668e6e1c43090
|
||||
|
||||
--- a/net/batman-adv/bat_iv_ogm.c
|
||||
+++ b/net/batman-adv/bat_iv_ogm.c
|
||||
@@ -1849,6 +1849,8 @@ batadv_iv_ogm_orig_dump_subentry(struct
|
||||
orig_node->orig) ||
|
||||
nla_put(msg, BATADV_ATTR_NEIGH_ADDRESS, ETH_ALEN,
|
||||
neigh_node->addr) ||
|
||||
+ nla_put_string(msg, BATADV_ATTR_HARD_IFNAME,
|
||||
+ neigh_node->if_incoming->net_dev->name) ||
|
||||
nla_put_u32(msg, BATADV_ATTR_HARD_IFINDEX,
|
||||
neigh_node->if_incoming->net_dev->ifindex) ||
|
||||
nla_put_u8(msg, BATADV_ATTR_TQ, tq_avg) ||
|
||||
@@ -2078,6 +2080,8 @@ batadv_iv_ogm_neigh_dump_neigh(struct sk
|
||||
|
||||
if (nla_put(msg, BATADV_ATTR_NEIGH_ADDRESS, ETH_ALEN,
|
||||
hardif_neigh->addr) ||
|
||||
+ nla_put_string(msg, BATADV_ATTR_HARD_IFNAME,
|
||||
+ hardif_neigh->if_incoming->net_dev->name) ||
|
||||
nla_put_u32(msg, BATADV_ATTR_HARD_IFINDEX,
|
||||
hardif_neigh->if_incoming->net_dev->ifindex) ||
|
||||
nla_put_u32(msg, BATADV_ATTR_LAST_SEEN_MSECS,
|
||||
@@ -2459,6 +2463,8 @@ static int batadv_iv_gw_dump_entry(struc
|
||||
router->addr) ||
|
||||
nla_put_string(msg, BATADV_ATTR_HARD_IFNAME,
|
||||
router->if_incoming->net_dev->name) ||
|
||||
+ nla_put_u32(msg, BATADV_ATTR_HARD_IFINDEX,
|
||||
+ router->if_incoming->net_dev->ifindex) ||
|
||||
nla_put_u32(msg, BATADV_ATTR_BANDWIDTH_DOWN,
|
||||
gw_node->bandwidth_down) ||
|
||||
nla_put_u32(msg, BATADV_ATTR_BANDWIDTH_UP,
|
||||
--- a/net/batman-adv/bat_v.c
|
||||
+++ b/net/batman-adv/bat_v.c
|
||||
@@ -145,6 +145,8 @@ batadv_v_neigh_dump_neigh(struct sk_buff
|
||||
|
||||
if (nla_put(msg, BATADV_ATTR_NEIGH_ADDRESS, ETH_ALEN,
|
||||
hardif_neigh->addr) ||
|
||||
+ nla_put_string(msg, BATADV_ATTR_HARD_IFNAME,
|
||||
+ hardif_neigh->if_incoming->net_dev->name) ||
|
||||
nla_put_u32(msg, BATADV_ATTR_HARD_IFINDEX,
|
||||
hardif_neigh->if_incoming->net_dev->ifindex) ||
|
||||
nla_put_u32(msg, BATADV_ATTR_LAST_SEEN_MSECS,
|
||||
@@ -297,6 +299,8 @@ batadv_v_orig_dump_subentry(struct sk_bu
|
||||
if (nla_put(msg, BATADV_ATTR_ORIG_ADDRESS, ETH_ALEN, orig_node->orig) ||
|
||||
nla_put(msg, BATADV_ATTR_NEIGH_ADDRESS, ETH_ALEN,
|
||||
neigh_node->addr) ||
|
||||
+ nla_put_string(msg, BATADV_ATTR_HARD_IFNAME,
|
||||
+ neigh_node->if_incoming->net_dev->name) ||
|
||||
nla_put_u32(msg, BATADV_ATTR_HARD_IFINDEX,
|
||||
neigh_node->if_incoming->net_dev->ifindex) ||
|
||||
nla_put_u32(msg, BATADV_ATTR_THROUGHPUT, throughput) ||
|
||||
@@ -737,6 +741,12 @@ static int batadv_v_gw_dump_entry(struct
|
||||
genlmsg_cancel(msg, hdr);
|
||||
goto out;
|
||||
}
|
||||
+
|
||||
+ if (nla_put_u32(msg, BATADV_ATTR_HARD_IFINDEX,
|
||||
+ router->if_incoming->net_dev->ifindex)) {
|
||||
+ genlmsg_cancel(msg, hdr);
|
||||
+ goto out;
|
||||
+ }
|
||||
|
||||
if (nla_put_u32(msg, BATADV_ATTR_BANDWIDTH_DOWN,
|
||||
gw_node->bandwidth_down)) {
|
||||
--- a/net/batman-adv/netlink.c
|
||||
+++ b/net/batman-adv/netlink.c
|
||||
@@ -813,6 +813,10 @@ static int batadv_netlink_hardif_fill(st
|
||||
bat_priv->soft_iface->ifindex))
|
||||
goto nla_put_failure;
|
||||
|
||||
+ if (nla_put_string(msg, BATADV_ATTR_MESH_IFNAME,
|
||||
+ bat_priv->soft_iface->name))
|
||||
+ goto nla_put_failure;
|
||||
+
|
||||
if (nla_put_u32(msg, BATADV_ATTR_HARD_IFINDEX,
|
||||
net_dev->ifindex) ||
|
||||
nla_put_string(msg, BATADV_ATTR_HARD_IFNAME,
|
||||
@@ -1044,6 +1048,10 @@ static int batadv_netlink_vlan_fill(stru
|
||||
bat_priv->soft_iface->ifindex))
|
||||
goto nla_put_failure;
|
||||
|
||||
+ if (nla_put_string(msg, BATADV_ATTR_MESH_IFNAME,
|
||||
+ bat_priv->soft_iface->name))
|
||||
+ goto nla_put_failure;
|
||||
+
|
||||
if (nla_put_u32(msg, BATADV_ATTR_VLANID, vlan->vid & VLAN_VID_MASK))
|
||||
goto nla_put_failure;
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
From: Sven Eckelmann <sven@narfation.org>
|
||||
Date: Tue, 18 May 2021 21:00:27 +0200
|
||||
Subject: batman-adv: Avoid WARN_ON timing related checks
|
||||
|
||||
The soft/batadv interface for a queued OGM can be changed during the time
|
||||
the OGM was queued for transmission and when the OGM is actually
|
||||
transmitted by the worker.
|
||||
|
||||
But WARN_ON must be used to denote kernel bugs and not to print simple
|
||||
warnings. A warning can simply be printed using pr_warn.
|
||||
|
||||
Reported-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
|
||||
Reported-by: syzbot+c0b807de416427ff3dd1@syzkaller.appspotmail.com
|
||||
Fixes: 29b9256e6631 ("batman-adv: consider outgoing interface in OGM sending")
|
||||
Signed-off-by: Sven Eckelmann <sven@narfation.org>
|
||||
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/5061f9c502d7101912089d8f4a7866e0a926a49a
|
||||
|
||||
--- a/net/batman-adv/bat_iv_ogm.c
|
||||
+++ b/net/batman-adv/bat_iv_ogm.c
|
||||
@@ -409,8 +409,10 @@ static void batadv_iv_ogm_emit(struct ba
|
||||
if (WARN_ON(!forw_packet->if_outgoing))
|
||||
return;
|
||||
|
||||
- if (WARN_ON(forw_packet->if_outgoing->soft_iface != soft_iface))
|
||||
+ if (forw_packet->if_outgoing->soft_iface != soft_iface) {
|
||||
+ pr_warn("%s: soft interface switch for queued OGM\n", __func__);
|
||||
return;
|
||||
+ }
|
||||
|
||||
if (forw_packet->if_incoming->if_status != BATADV_IF_ACTIVE)
|
||||
return;
|
||||
@@ -1,162 +0,0 @@
|
||||
From: Pavel Skripkin <paskripkin@gmail.com>
|
||||
Date: Sun, 24 Oct 2021 16:13:56 +0300
|
||||
Subject: batman-adv: fix error handling
|
||||
|
||||
Syzbot reported ODEBUG warning in batadv_nc_mesh_free(). The problem was
|
||||
in wrong error handling in batadv_mesh_init().
|
||||
|
||||
Before this patch batadv_mesh_init() was calling batadv_mesh_free() in case
|
||||
of any batadv_*_init() calls failure. This approach may work well, when
|
||||
there is some kind of indicator, which can tell which parts of batadv are
|
||||
initialized; but there isn't any.
|
||||
|
||||
All written above lead to cleaning up uninitialized fields. Even if we hide
|
||||
ODEBUG warning by initializing bat_priv->nc.work, syzbot was able to hit
|
||||
GPF in batadv_nc_purge_paths(), because hash pointer in still NULL. [1]
|
||||
|
||||
To fix these bugs we can unwind batadv_*_init() calls one by one.
|
||||
It is good approach for 2 reasons: 1) It fixes bugs on error handling
|
||||
path 2) It improves the performance, since we won't call unneeded
|
||||
batadv_*_free() functions.
|
||||
|
||||
So, this patch makes all batadv_*_init() clean up all allocated memory
|
||||
before returning with an error to no call correspoing batadv_*_free()
|
||||
and open-codes batadv_mesh_free() with proper order to avoid touching
|
||||
uninitialized fields.
|
||||
|
||||
Link: https://lore.kernel.org/netdev/000000000000c87fbd05cef6bcb0@google.com/ [1]
|
||||
Reported-and-tested-by: syzbot+28b0702ada0bf7381f58@syzkaller.appspotmail.com
|
||||
Fixes: 21e838760727 ("[batman-adv] fix various race conditions during startup & shutdown")
|
||||
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
Signed-off-by: Sven Eckelmann <sven@narfation.org>
|
||||
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/0631e0825c8129cd3896926da62a09ac00bf13a0
|
||||
|
||||
--- a/net/batman-adv/bridge_loop_avoidance.c
|
||||
+++ b/net/batman-adv/bridge_loop_avoidance.c
|
||||
@@ -1556,10 +1556,14 @@ int batadv_bla_init(struct batadv_priv *
|
||||
return 0;
|
||||
|
||||
bat_priv->bla.claim_hash = batadv_hash_new(128);
|
||||
- bat_priv->bla.backbone_hash = batadv_hash_new(32);
|
||||
+ if (!bat_priv->bla.claim_hash)
|
||||
+ return -ENOMEM;
|
||||
|
||||
- if (!bat_priv->bla.claim_hash || !bat_priv->bla.backbone_hash)
|
||||
+ bat_priv->bla.backbone_hash = batadv_hash_new(32);
|
||||
+ if (!bat_priv->bla.backbone_hash) {
|
||||
+ batadv_hash_destroy(bat_priv->bla.claim_hash);
|
||||
return -ENOMEM;
|
||||
+ }
|
||||
|
||||
batadv_hash_set_lock_class(bat_priv->bla.claim_hash,
|
||||
&batadv_claim_hash_lock_class_key);
|
||||
--- a/net/batman-adv/main.c
|
||||
+++ b/net/batman-adv/main.c
|
||||
@@ -189,29 +189,41 @@ int batadv_mesh_init(struct net_device *
|
||||
|
||||
bat_priv->gw.generation = 0;
|
||||
|
||||
- ret = batadv_v_mesh_init(bat_priv);
|
||||
- if (ret < 0)
|
||||
- goto err;
|
||||
-
|
||||
ret = batadv_originator_init(bat_priv);
|
||||
- if (ret < 0)
|
||||
- goto err;
|
||||
+ if (ret < 0) {
|
||||
+ atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
|
||||
+ goto err_orig;
|
||||
+ }
|
||||
|
||||
ret = batadv_tt_init(bat_priv);
|
||||
- if (ret < 0)
|
||||
- goto err;
|
||||
+ if (ret < 0) {
|
||||
+ atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
|
||||
+ goto err_tt;
|
||||
+ }
|
||||
+
|
||||
+ ret = batadv_v_mesh_init(bat_priv);
|
||||
+ if (ret < 0) {
|
||||
+ atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
|
||||
+ goto err_v;
|
||||
+ }
|
||||
|
||||
ret = batadv_bla_init(bat_priv);
|
||||
- if (ret < 0)
|
||||
- goto err;
|
||||
+ if (ret < 0) {
|
||||
+ atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
|
||||
+ goto err_bla;
|
||||
+ }
|
||||
|
||||
ret = batadv_dat_init(bat_priv);
|
||||
- if (ret < 0)
|
||||
- goto err;
|
||||
+ if (ret < 0) {
|
||||
+ atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
|
||||
+ goto err_dat;
|
||||
+ }
|
||||
|
||||
ret = batadv_nc_mesh_init(bat_priv);
|
||||
- if (ret < 0)
|
||||
- goto err;
|
||||
+ if (ret < 0) {
|
||||
+ atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
|
||||
+ goto err_nc;
|
||||
+ }
|
||||
|
||||
batadv_gw_init(bat_priv);
|
||||
batadv_mcast_init(bat_priv);
|
||||
@@ -221,8 +233,20 @@ int batadv_mesh_init(struct net_device *
|
||||
|
||||
return 0;
|
||||
|
||||
-err:
|
||||
- batadv_mesh_free(soft_iface);
|
||||
+err_nc:
|
||||
+ batadv_dat_free(bat_priv);
|
||||
+err_dat:
|
||||
+ batadv_bla_free(bat_priv);
|
||||
+err_bla:
|
||||
+ batadv_v_mesh_free(bat_priv);
|
||||
+err_v:
|
||||
+ batadv_tt_free(bat_priv);
|
||||
+err_tt:
|
||||
+ batadv_originator_free(bat_priv);
|
||||
+err_orig:
|
||||
+ batadv_purge_outstanding_packets(bat_priv, NULL);
|
||||
+ atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
|
||||
+
|
||||
return ret;
|
||||
}
|
||||
|
||||
--- a/net/batman-adv/network-coding.c
|
||||
+++ b/net/batman-adv/network-coding.c
|
||||
@@ -152,8 +152,10 @@ int batadv_nc_mesh_init(struct batadv_pr
|
||||
&batadv_nc_coding_hash_lock_class_key);
|
||||
|
||||
bat_priv->nc.decoding_hash = batadv_hash_new(128);
|
||||
- if (!bat_priv->nc.decoding_hash)
|
||||
+ if (!bat_priv->nc.decoding_hash) {
|
||||
+ batadv_hash_destroy(bat_priv->nc.coding_hash);
|
||||
goto err;
|
||||
+ }
|
||||
|
||||
batadv_hash_set_lock_class(bat_priv->nc.decoding_hash,
|
||||
&batadv_nc_decoding_hash_lock_class_key);
|
||||
--- a/net/batman-adv/translation-table.c
|
||||
+++ b/net/batman-adv/translation-table.c
|
||||
@@ -4193,8 +4193,10 @@ int batadv_tt_init(struct batadv_priv *b
|
||||
return ret;
|
||||
|
||||
ret = batadv_tt_global_init(bat_priv);
|
||||
- if (ret < 0)
|
||||
+ if (ret < 0) {
|
||||
+ batadv_tt_local_table_free(bat_priv);
|
||||
return ret;
|
||||
+ }
|
||||
|
||||
batadv_tvlv_handler_register(bat_priv, batadv_tt_tvlv_ogm_handler_v1,
|
||||
batadv_tt_tvlv_unicast_handler_v1,
|
||||
@@ -1,182 +0,0 @@
|
||||
From: Linus Lüssing <linus.luessing@c0d3.blue>
|
||||
Date: Mon, 1 Nov 2021 21:46:17 +0100
|
||||
Subject: batman-adv: allow netlink usage in unprivileged containers
|
||||
|
||||
Currently, creating a batman-adv interface in an unprivileged LXD
|
||||
container and attaching secondary interfaces to it with "ip" or "batctl"
|
||||
works fine. However all batctl debug and configuration commands
|
||||
fail:
|
||||
|
||||
root@container:~# batctl originators
|
||||
Error received: Operation not permitted
|
||||
root@container:~# batctl orig_interval
|
||||
1000
|
||||
root@container:~# batctl orig_interval 2000
|
||||
root@container:~# batctl orig_interval
|
||||
1000
|
||||
|
||||
To fix this change the generic netlink permissions from GENL_ADMIN_PERM
|
||||
to GENL_UNS_ADMIN_PERM. This way a batman-adv interface is fully
|
||||
maintainable as root from within a user namespace, from an unprivileged
|
||||
container.
|
||||
|
||||
All except one batman-adv netlink setting are per interface and do not
|
||||
leak information or change settings from the host system and are
|
||||
therefore save to retrieve or modify as root from within an unprivileged
|
||||
container.
|
||||
|
||||
"batctl routing_algo" / BATADV_CMD_GET_ROUTING_ALGOS is the only
|
||||
exception: It provides the batman-adv kernel module wide default routing
|
||||
algorithm. However it is read-only from netlink and an unprivileged
|
||||
container is still not allowed to modify
|
||||
/sys/module/batman_adv/parameters/routing_algo. Instead it is advised to
|
||||
use the newly introduced "batctl if create routing_algo RA_NAME" /
|
||||
IFLA_BATADV_ALGO_NAME to set the routing algorithm on interface
|
||||
creation, which already works fine in an unprivileged container.
|
||||
|
||||
Cc: Tycho Andersen <tycho@tycho.pizza>
|
||||
Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
|
||||
Signed-off-by: Sven Eckelmann <sven@narfation.org>
|
||||
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/055fa41b73ca8dae1c1ed41777e32a8f02e80c82
|
||||
|
||||
--- /dev/null
|
||||
+++ b/compat-include/uapi/linux/genetlink.h
|
||||
@@ -0,0 +1,22 @@
|
||||
+/* SPDX-License-Identifier: GPL-2.0 */
|
||||
+/* Copyright (C) B.A.T.M.A.N. contributors:
|
||||
+ *
|
||||
+ * Marek Lindner, Simon Wunderlich
|
||||
+ *
|
||||
+ * This file contains macros for maintaining compatibility with older versions
|
||||
+ * of the Linux kernel.
|
||||
+ */
|
||||
+
|
||||
+#ifndef _NET_BATMAN_ADV_COMPAT_UAPI_LINUX_GENETLINK_H_
|
||||
+#define _NET_BATMAN_ADV_COMPAT_UAPI_LINUX_GENETLINK_H_
|
||||
+
|
||||
+#include <linux/version.h>
|
||||
+#include_next <uapi/linux/genetlink.h>
|
||||
+
|
||||
+#if LINUX_VERSION_IS_LESS(4, 6, 0)
|
||||
+
|
||||
+#define GENL_UNS_ADMIN_PERM GENL_ADMIN_PERM
|
||||
+
|
||||
+#endif /* LINUX_VERSION_IS_LESS(4, 6, 0) */
|
||||
+
|
||||
+#endif /* _NET_BATMAN_ADV_COMPAT_UAPI_LINUX_GENETLINK_H_ */
|
||||
--- a/net/batman-adv/netlink.c
|
||||
+++ b/net/batman-adv/netlink.c
|
||||
@@ -1369,21 +1369,21 @@ static const struct genl_ops batadv_netl
|
||||
{
|
||||
.cmd = BATADV_CMD_TP_METER,
|
||||
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
|
||||
- .flags = GENL_ADMIN_PERM,
|
||||
+ .flags = GENL_UNS_ADMIN_PERM,
|
||||
.doit = batadv_netlink_tp_meter_start,
|
||||
.internal_flags = BATADV_FLAG_NEED_MESH,
|
||||
},
|
||||
{
|
||||
.cmd = BATADV_CMD_TP_METER_CANCEL,
|
||||
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
|
||||
- .flags = GENL_ADMIN_PERM,
|
||||
+ .flags = GENL_UNS_ADMIN_PERM,
|
||||
.doit = batadv_netlink_tp_meter_cancel,
|
||||
.internal_flags = BATADV_FLAG_NEED_MESH,
|
||||
},
|
||||
{
|
||||
.cmd = BATADV_CMD_GET_ROUTING_ALGOS,
|
||||
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
|
||||
- .flags = GENL_ADMIN_PERM,
|
||||
+ .flags = GENL_UNS_ADMIN_PERM,
|
||||
.dumpit = batadv_algo_dump,
|
||||
},
|
||||
{
|
||||
@@ -1398,68 +1398,68 @@ static const struct genl_ops batadv_netl
|
||||
{
|
||||
.cmd = BATADV_CMD_GET_TRANSTABLE_LOCAL,
|
||||
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
|
||||
- .flags = GENL_ADMIN_PERM,
|
||||
+ .flags = GENL_UNS_ADMIN_PERM,
|
||||
.dumpit = batadv_tt_local_dump,
|
||||
},
|
||||
{
|
||||
.cmd = BATADV_CMD_GET_TRANSTABLE_GLOBAL,
|
||||
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
|
||||
- .flags = GENL_ADMIN_PERM,
|
||||
+ .flags = GENL_UNS_ADMIN_PERM,
|
||||
.dumpit = batadv_tt_global_dump,
|
||||
},
|
||||
{
|
||||
.cmd = BATADV_CMD_GET_ORIGINATORS,
|
||||
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
|
||||
- .flags = GENL_ADMIN_PERM,
|
||||
+ .flags = GENL_UNS_ADMIN_PERM,
|
||||
.dumpit = batadv_orig_dump,
|
||||
},
|
||||
{
|
||||
.cmd = BATADV_CMD_GET_NEIGHBORS,
|
||||
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
|
||||
- .flags = GENL_ADMIN_PERM,
|
||||
+ .flags = GENL_UNS_ADMIN_PERM,
|
||||
.dumpit = batadv_hardif_neigh_dump,
|
||||
},
|
||||
{
|
||||
.cmd = BATADV_CMD_GET_GATEWAYS,
|
||||
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
|
||||
- .flags = GENL_ADMIN_PERM,
|
||||
+ .flags = GENL_UNS_ADMIN_PERM,
|
||||
.dumpit = batadv_gw_dump,
|
||||
},
|
||||
{
|
||||
.cmd = BATADV_CMD_GET_BLA_CLAIM,
|
||||
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
|
||||
- .flags = GENL_ADMIN_PERM,
|
||||
+ .flags = GENL_UNS_ADMIN_PERM,
|
||||
.dumpit = batadv_bla_claim_dump,
|
||||
},
|
||||
{
|
||||
.cmd = BATADV_CMD_GET_BLA_BACKBONE,
|
||||
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
|
||||
- .flags = GENL_ADMIN_PERM,
|
||||
+ .flags = GENL_UNS_ADMIN_PERM,
|
||||
.dumpit = batadv_bla_backbone_dump,
|
||||
},
|
||||
{
|
||||
.cmd = BATADV_CMD_GET_DAT_CACHE,
|
||||
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
|
||||
- .flags = GENL_ADMIN_PERM,
|
||||
+ .flags = GENL_UNS_ADMIN_PERM,
|
||||
.dumpit = batadv_dat_cache_dump,
|
||||
},
|
||||
{
|
||||
.cmd = BATADV_CMD_GET_MCAST_FLAGS,
|
||||
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
|
||||
- .flags = GENL_ADMIN_PERM,
|
||||
+ .flags = GENL_UNS_ADMIN_PERM,
|
||||
.dumpit = batadv_mcast_flags_dump,
|
||||
},
|
||||
{
|
||||
.cmd = BATADV_CMD_SET_MESH,
|
||||
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
|
||||
- .flags = GENL_ADMIN_PERM,
|
||||
+ .flags = GENL_UNS_ADMIN_PERM,
|
||||
.doit = batadv_netlink_set_mesh,
|
||||
.internal_flags = BATADV_FLAG_NEED_MESH,
|
||||
},
|
||||
{
|
||||
.cmd = BATADV_CMD_SET_HARDIF,
|
||||
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
|
||||
- .flags = GENL_ADMIN_PERM,
|
||||
+ .flags = GENL_UNS_ADMIN_PERM,
|
||||
.doit = batadv_netlink_set_hardif,
|
||||
.internal_flags = BATADV_FLAG_NEED_MESH |
|
||||
BATADV_FLAG_NEED_HARDIF,
|
||||
@@ -1475,7 +1475,7 @@ static const struct genl_ops batadv_netl
|
||||
{
|
||||
.cmd = BATADV_CMD_SET_VLAN,
|
||||
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
|
||||
- .flags = GENL_ADMIN_PERM,
|
||||
+ .flags = GENL_UNS_ADMIN_PERM,
|
||||
.doit = batadv_netlink_set_vlan,
|
||||
.internal_flags = BATADV_FLAG_NEED_MESH |
|
||||
BATADV_FLAG_NEED_VLAN,
|
||||
@@ -1,165 +0,0 @@
|
||||
From: Linus Lüssing <linus.luessing@c0d3.blue>
|
||||
Date: Sat, 1 Jan 2022 06:27:13 +0100
|
||||
Subject: batman-adv: mcast: don't send link-local multicast to mcast routers
|
||||
|
||||
The addition of routable multicast TX handling introduced a
|
||||
bug/regression for packets with a link-local multicast destination:
|
||||
These packets would be sent to all batman-adv nodes with a multicast
|
||||
router and to all batman-adv nodes with an old version without multicast
|
||||
router detection.
|
||||
|
||||
This even disregards the batman-adv multicast fanout setting, which can
|
||||
potentially lead to an unwanted, high number of unicast transmissions or
|
||||
even congestion.
|
||||
|
||||
Fixing this by avoiding to send link-local multicast packets to nodes in
|
||||
the multicast router list.
|
||||
|
||||
Fixes: 3a8df00cd969 ("batman-adv: mcast: apply optimizations for routable packets, too")
|
||||
Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
|
||||
Signed-off-by: Sven Eckelmann <sven@narfation.org>
|
||||
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/ee013870947b9175847aa46a0686ca01dd480af4
|
||||
|
||||
--- a/net/batman-adv/multicast.c
|
||||
+++ b/net/batman-adv/multicast.c
|
||||
@@ -1380,6 +1380,7 @@ batadv_mcast_forw_rtr_node_get(struct ba
|
||||
* @bat_priv: the bat priv with all the soft interface information
|
||||
* @skb: The multicast packet to check
|
||||
* @orig: an originator to be set to forward the skb to
|
||||
+ * @is_routable: stores whether the destination is routable
|
||||
*
|
||||
* Return: the forwarding mode as enum batadv_forw_mode and in case of
|
||||
* BATADV_FORW_SINGLE set the orig to the single originator the skb
|
||||
@@ -1387,17 +1388,16 @@ batadv_mcast_forw_rtr_node_get(struct ba
|
||||
*/
|
||||
enum batadv_forw_mode
|
||||
batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
|
||||
- struct batadv_orig_node **orig)
|
||||
+ struct batadv_orig_node **orig, int *is_routable)
|
||||
{
|
||||
int ret, tt_count, ip_count, unsnoop_count, total_count;
|
||||
bool is_unsnoopable = false;
|
||||
unsigned int mcast_fanout;
|
||||
struct ethhdr *ethhdr;
|
||||
- int is_routable = 0;
|
||||
int rtr_count = 0;
|
||||
|
||||
ret = batadv_mcast_forw_mode_check(bat_priv, skb, &is_unsnoopable,
|
||||
- &is_routable);
|
||||
+ is_routable);
|
||||
if (ret == -ENOMEM)
|
||||
return BATADV_FORW_NONE;
|
||||
else if (ret < 0)
|
||||
@@ -1410,7 +1410,7 @@ batadv_mcast_forw_mode(struct batadv_pri
|
||||
ip_count = batadv_mcast_forw_want_all_ip_count(bat_priv, ethhdr);
|
||||
unsnoop_count = !is_unsnoopable ? 0 :
|
||||
atomic_read(&bat_priv->mcast.num_want_all_unsnoopables);
|
||||
- rtr_count = batadv_mcast_forw_rtr_count(bat_priv, is_routable);
|
||||
+ rtr_count = batadv_mcast_forw_rtr_count(bat_priv, *is_routable);
|
||||
|
||||
total_count = tt_count + ip_count + unsnoop_count + rtr_count;
|
||||
|
||||
@@ -1730,6 +1730,7 @@ batadv_mcast_forw_want_rtr(struct batadv
|
||||
* @bat_priv: the bat priv with all the soft interface information
|
||||
* @skb: the multicast packet to transmit
|
||||
* @vid: the vlan identifier
|
||||
+ * @is_routable: stores whether the destination is routable
|
||||
*
|
||||
* Sends copies of a frame with multicast destination to any node that signaled
|
||||
* interest in it, that is either via the translation table or the according
|
||||
@@ -1742,7 +1743,7 @@ batadv_mcast_forw_want_rtr(struct batadv
|
||||
* is neither IPv4 nor IPv6. NET_XMIT_SUCCESS otherwise.
|
||||
*/
|
||||
int batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb,
|
||||
- unsigned short vid)
|
||||
+ unsigned short vid, int is_routable)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -1758,12 +1759,16 @@ int batadv_mcast_forw_send(struct batadv
|
||||
return ret;
|
||||
}
|
||||
|
||||
+ if (!is_routable)
|
||||
+ goto skip_mc_router;
|
||||
+
|
||||
ret = batadv_mcast_forw_want_rtr(bat_priv, skb, vid);
|
||||
if (ret != NET_XMIT_SUCCESS) {
|
||||
kfree_skb(skb);
|
||||
return ret;
|
||||
}
|
||||
|
||||
+skip_mc_router:
|
||||
consume_skb(skb);
|
||||
return ret;
|
||||
}
|
||||
--- a/net/batman-adv/multicast.h
|
||||
+++ b/net/batman-adv/multicast.h
|
||||
@@ -43,7 +43,8 @@ enum batadv_forw_mode {
|
||||
|
||||
enum batadv_forw_mode
|
||||
batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
|
||||
- struct batadv_orig_node **mcast_single_orig);
|
||||
+ struct batadv_orig_node **mcast_single_orig,
|
||||
+ int *is_routable);
|
||||
|
||||
int batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv,
|
||||
struct sk_buff *skb,
|
||||
@@ -51,7 +52,7 @@ int batadv_mcast_forw_send_orig(struct b
|
||||
struct batadv_orig_node *orig_node);
|
||||
|
||||
int batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb,
|
||||
- unsigned short vid);
|
||||
+ unsigned short vid, int is_routable);
|
||||
|
||||
void batadv_mcast_init(struct batadv_priv *bat_priv);
|
||||
|
||||
@@ -68,7 +69,8 @@ void batadv_mcast_purge_orig(struct bata
|
||||
|
||||
static inline enum batadv_forw_mode
|
||||
batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
|
||||
- struct batadv_orig_node **mcast_single_orig)
|
||||
+ struct batadv_orig_node **mcast_single_orig,
|
||||
+ int *is_routable)
|
||||
{
|
||||
return BATADV_FORW_ALL;
|
||||
}
|
||||
@@ -85,7 +87,7 @@ batadv_mcast_forw_send_orig(struct batad
|
||||
|
||||
static inline int
|
||||
batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb,
|
||||
- unsigned short vid)
|
||||
+ unsigned short vid, int is_routable)
|
||||
{
|
||||
kfree_skb(skb);
|
||||
return NET_XMIT_DROP;
|
||||
--- a/net/batman-adv/soft-interface.c
|
||||
+++ b/net/batman-adv/soft-interface.c
|
||||
@@ -198,6 +198,7 @@ static netdev_tx_t batadv_interface_tx(s
|
||||
int gw_mode;
|
||||
enum batadv_forw_mode forw_mode = BATADV_FORW_SINGLE;
|
||||
struct batadv_orig_node *mcast_single_orig = NULL;
|
||||
+ int mcast_is_routable = 0;
|
||||
int network_offset = ETH_HLEN;
|
||||
__be16 proto;
|
||||
|
||||
@@ -300,7 +301,8 @@ static netdev_tx_t batadv_interface_tx(s
|
||||
send:
|
||||
if (do_bcast && !is_broadcast_ether_addr(ethhdr->h_dest)) {
|
||||
forw_mode = batadv_mcast_forw_mode(bat_priv, skb,
|
||||
- &mcast_single_orig);
|
||||
+ &mcast_single_orig,
|
||||
+ &mcast_is_routable);
|
||||
if (forw_mode == BATADV_FORW_NONE)
|
||||
goto dropped;
|
||||
|
||||
@@ -365,7 +367,8 @@ send:
|
||||
ret = batadv_mcast_forw_send_orig(bat_priv, skb, vid,
|
||||
mcast_single_orig);
|
||||
} else if (forw_mode == BATADV_FORW_SOME) {
|
||||
- ret = batadv_mcast_forw_send(bat_priv, skb, vid);
|
||||
+ ret = batadv_mcast_forw_send(bat_priv, skb, vid,
|
||||
+ mcast_is_routable);
|
||||
} else {
|
||||
if (batadv_dat_snoop_outgoing_arp_request(bat_priv,
|
||||
skb))
|
||||
@@ -1,56 +0,0 @@
|
||||
From: Sven Eckelmann <sven@narfation.org>
|
||||
Date: Tue, 18 May 2021 19:47:14 +0200
|
||||
Subject: Revert "batman-adv: Migrate to linux/prandom.h"
|
||||
|
||||
This reverts commit fe773e9e389a763f38539de3d4782b628676ac99.
|
||||
|
||||
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
|
||||
index 680def809838097a9949de1dc9861923911f3d04..97000fe0ae2cebd9dc2fdf02c30faa1caa36a6c8 100644
|
||||
--- a/net/batman-adv/bat_iv_ogm.c
|
||||
+++ b/net/batman-adv/bat_iv_ogm.c
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/pkt_sched.h>
|
||||
-#include <linux/prandom.h>
|
||||
#include <linux/printk.h>
|
||||
#include <linux/random.h>
|
||||
#include <linux/rculist.h>
|
||||
diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c
|
||||
index 4d8e3fdb4427a431cab903bc8a20edb816079fd7..3b3c890870ee6941c337ce820f661f216a819161 100644
|
||||
--- a/net/batman-adv/bat_v_elp.c
|
||||
+++ b/net/batman-adv/bat_v_elp.c
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <linux/kref.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/nl80211.h>
|
||||
-#include <linux/prandom.h>
|
||||
#include <linux/random.h>
|
||||
#include <linux/rculist.h>
|
||||
#include <linux/rcupdate.h>
|
||||
diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c
|
||||
index 89ba88322c9c11acc49a9dcd9877ad8767fe713b..cb0bce3774898884b399dd0eb5ba4e03364a2fdd 100644
|
||||
--- a/net/batman-adv/bat_v_ogm.c
|
||||
+++ b/net/batman-adv/bat_v_ogm.c
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <linux/lockdep.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/netdevice.h>
|
||||
-#include <linux/prandom.h>
|
||||
#include <linux/random.h>
|
||||
#include <linux/rculist.h>
|
||||
#include <linux/rcupdate.h>
|
||||
diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c
|
||||
index 4bb76b434d0711dd67b8521e05c64772b4c48434..aceb1b2bb04db385f40deb94dd78901312150a17 100644
|
||||
--- a/net/batman-adv/network-coding.c
|
||||
+++ b/net/batman-adv/network-coding.c
|
||||
@@ -25,8 +25,8 @@
|
||||
#include <linux/lockdep.h>
|
||||
#include <linux/net.h>
|
||||
#include <linux/netdevice.h>
|
||||
-#include <linux/prandom.h>
|
||||
#include <linux/printk.h>
|
||||
+#include <linux/random.h>
|
||||
#include <linux/rculist.h>
|
||||
#include <linux/rcupdate.h>
|
||||
#include <linux/skbuff.h>
|
||||
@@ -1,125 +0,0 @@
|
||||
/* Please avoid adding hacks here - instead add it to mac80211/backports.git */
|
||||
|
||||
#undef CONFIG_MODULE_STRIPPED
|
||||
|
||||
#include <linux/version.h> /* LINUX_VERSION_CODE */
|
||||
#include <linux/types.h>
|
||||
|
||||
#if LINUX_VERSION_IS_LESS(5, 10, 0)
|
||||
|
||||
#include <linux/if_bridge.h>
|
||||
|
||||
struct batadv_br_ip {
|
||||
union {
|
||||
__be32 ip4;
|
||||
#if IS_ENABLED(CONFIG_IPV6)
|
||||
struct in6_addr ip6;
|
||||
#endif
|
||||
} dst;
|
||||
__be16 proto;
|
||||
__u16 vid;
|
||||
};
|
||||
|
||||
struct batadv_br_ip_list {
|
||||
struct list_head list;
|
||||
struct batadv_br_ip addr;
|
||||
};
|
||||
|
||||
#if 0
|
||||
/* "static" dropped to force compiler to evaluate it as part of multicast.c
|
||||
* might need to be added again and then called in some kind of dummy
|
||||
* compat.c in case this header is included in multiple files.
|
||||
*/
|
||||
inline void __batadv_br_ip_list_check(void)
|
||||
{
|
||||
BUILD_BUG_ON(sizeof(struct batadv_br_ip_list) != sizeof(struct br_ip_list));
|
||||
BUILD_BUG_ON(offsetof(struct batadv_br_ip_list, list) != offsetof(struct br_ip_list, list));
|
||||
BUILD_BUG_ON(offsetof(struct batadv_br_ip_list, addr) != offsetof(struct br_ip_list, addr));
|
||||
|
||||
BUILD_BUG_ON(sizeof(struct batadv_br_ip) != sizeof(struct br_ip));
|
||||
BUILD_BUG_ON(offsetof(struct batadv_br_ip, dst.ip4) != offsetof(struct br_ip, u.ip4));
|
||||
BUILD_BUG_ON(offsetof(struct batadv_br_ip, dst.ip6) != offsetof(struct br_ip, u.ip6));
|
||||
BUILD_BUG_ON(offsetof(struct batadv_br_ip, proto) != offsetof(struct br_ip, proto));
|
||||
BUILD_BUG_ON(offsetof(struct batadv_br_ip, vid) != offsetof(struct br_ip, vid));
|
||||
}
|
||||
#endif
|
||||
|
||||
#define br_ip batadv_br_ip
|
||||
#define br_ip_list batadv_br_ip_list
|
||||
|
||||
#endif /* LINUX_VERSION_IS_LESS(5, 10, 0) */
|
||||
|
||||
/* <DECLARE_EWMA> */
|
||||
|
||||
#include <linux/version.h>
|
||||
#include_next <linux/average.h>
|
||||
|
||||
#include <linux/bug.h>
|
||||
|
||||
#ifdef DECLARE_EWMA
|
||||
#undef DECLARE_EWMA
|
||||
#endif /* DECLARE_EWMA */
|
||||
|
||||
/*
|
||||
* Exponentially weighted moving average (EWMA)
|
||||
*
|
||||
* This implements a fixed-precision EWMA algorithm, with both the
|
||||
* precision and fall-off coefficient determined at compile-time
|
||||
* and built into the generated helper funtions.
|
||||
*
|
||||
* The first argument to the macro is the name that will be used
|
||||
* for the struct and helper functions.
|
||||
*
|
||||
* The second argument, the precision, expresses how many bits are
|
||||
* used for the fractional part of the fixed-precision values.
|
||||
*
|
||||
* The third argument, the weight reciprocal, determines how the
|
||||
* new values will be weighed vs. the old state, new values will
|
||||
* get weight 1/weight_rcp and old values 1-1/weight_rcp. Note
|
||||
* that this parameter must be a power of two for efficiency.
|
||||
*/
|
||||
|
||||
#define DECLARE_EWMA(name, _precision, _weight_rcp) \
|
||||
struct ewma_##name { \
|
||||
unsigned long internal; \
|
||||
}; \
|
||||
static inline void ewma_##name##_init(struct ewma_##name *e) \
|
||||
{ \
|
||||
BUILD_BUG_ON(!__builtin_constant_p(_precision)); \
|
||||
BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \
|
||||
/* \
|
||||
* Even if you want to feed it just 0/1 you should have \
|
||||
* some bits for the non-fractional part... \
|
||||
*/ \
|
||||
BUILD_BUG_ON((_precision) > 30); \
|
||||
BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \
|
||||
e->internal = 0; \
|
||||
} \
|
||||
static inline unsigned long \
|
||||
ewma_##name##_read(struct ewma_##name *e) \
|
||||
{ \
|
||||
BUILD_BUG_ON(!__builtin_constant_p(_precision)); \
|
||||
BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \
|
||||
BUILD_BUG_ON((_precision) > 30); \
|
||||
BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \
|
||||
return e->internal >> (_precision); \
|
||||
} \
|
||||
static inline void ewma_##name##_add(struct ewma_##name *e, \
|
||||
unsigned long val) \
|
||||
{ \
|
||||
unsigned long internal = READ_ONCE(e->internal); \
|
||||
unsigned long weight_rcp = ilog2(_weight_rcp); \
|
||||
unsigned long precision = _precision; \
|
||||
\
|
||||
BUILD_BUG_ON(!__builtin_constant_p(_precision)); \
|
||||
BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \
|
||||
BUILD_BUG_ON((_precision) > 30); \
|
||||
BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \
|
||||
\
|
||||
WRITE_ONCE(e->internal, internal ? \
|
||||
(((internal << weight_rcp) - internal) + \
|
||||
(val << precision)) >> weight_rcp : \
|
||||
(val << precision)); \
|
||||
}
|
||||
|
||||
/* </DECLARE_EWMA> */
|
||||
@@ -1,216 +0,0 @@
|
||||
#include <linux/version.h> /* LINUX_VERSION_CODE */
|
||||
#include <linux/types.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
|
||||
|
||||
#define dev_get_iflink(_net_dev) ((_net_dev)->iflink)
|
||||
|
||||
#endif /* < KERNEL_VERSION(4, 1, 0) */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)
|
||||
|
||||
#include <linux/netdevice.h>
|
||||
|
||||
#define netdev_master_upper_dev_link(dev, upper_dev, upper_priv, upper_info, extack) ({\
|
||||
BUILD_BUG_ON(upper_priv != NULL); \
|
||||
BUILD_BUG_ON(upper_info != NULL); \
|
||||
BUILD_BUG_ON(extack != NULL); \
|
||||
netdev_master_upper_dev_link(dev, upper_dev); \
|
||||
})
|
||||
|
||||
#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
|
||||
|
||||
#include <linux/netdevice.h>
|
||||
|
||||
#define netdev_master_upper_dev_link(dev, upper_dev, upper_priv, upper_info, extack) ({\
|
||||
BUILD_BUG_ON(extack != NULL); \
|
||||
netdev_master_upper_dev_link(dev, upper_dev, upper_priv, upper_info); \
|
||||
})
|
||||
|
||||
#endif /* < KERNEL_VERSION(4, 5, 0) */
|
||||
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
|
||||
|
||||
/* wild hack for batadv_getlink_net only */
|
||||
#define get_link_net get_xstats_size || 1 ? fallback_net : (struct net*)netdev->rtnl_link_ops->get_xstats_size
|
||||
|
||||
#endif /* < KERNEL_VERSION(4, 0, 0) */
|
||||
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0)
|
||||
|
||||
struct sk_buff *skb_checksum_trimmed(struct sk_buff *skb,
|
||||
unsigned int transport_len,
|
||||
__sum16(*skb_chkf)(struct sk_buff *skb));
|
||||
|
||||
int ip_mc_check_igmp(struct sk_buff *skb);
|
||||
int ipv6_mc_check_mld(struct sk_buff *skb);
|
||||
|
||||
#elif LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0)
|
||||
|
||||
#include_next <linux/igmp.h>
|
||||
#include_next <net/addrconf.h>
|
||||
|
||||
static inline int batadv_ip_mc_check_igmp1(struct sk_buff *skb)
|
||||
{
|
||||
return ip_mc_check_igmp(skb, NULL);
|
||||
}
|
||||
|
||||
static inline int batadv_ip_mc_check_igmp2(struct sk_buff *skb,
|
||||
struct sk_buff **skb_trimmed)
|
||||
{
|
||||
return ip_mc_check_igmp(skb, skb_trimmed);
|
||||
}
|
||||
|
||||
#define ip_mc_check_igmp_get(_1, _2, ip_mc_check_igmp_name, ...) ip_mc_check_igmp_name
|
||||
#define ip_mc_check_igmp(...) \
|
||||
ip_mc_check_igmp_get(__VA_ARGS__, batadv_ip_mc_check_igmp2, batadv_ip_mc_check_igmp1)(__VA_ARGS__)
|
||||
|
||||
#endif /* < KERNEL_VERSION(4, 2, 0) */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
|
||||
|
||||
#define IFF_NO_QUEUE 0; dev->tx_queue_len = 0
|
||||
|
||||
static inline bool hlist_fake(struct hlist_node *h)
|
||||
{
|
||||
return h->pprev == &h->next;
|
||||
}
|
||||
|
||||
#endif /* < KERNEL_VERSION(4, 3, 0) */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)
|
||||
|
||||
#include <linux/ethtool.h>
|
||||
|
||||
#define ethtool_link_ksettings batadv_ethtool_link_ksettings
|
||||
|
||||
struct batadv_ethtool_link_ksettings {
|
||||
struct {
|
||||
__u32 speed;
|
||||
__u8 duplex;
|
||||
__u8 autoneg;
|
||||
} base;
|
||||
};
|
||||
|
||||
#define __ethtool_get_link_ksettings(__dev, __link_settings) \
|
||||
batadv_ethtool_get_link_ksettings(__dev, __link_settings)
|
||||
|
||||
static inline int
|
||||
batadv_ethtool_get_link_ksettings(struct net_device *dev,
|
||||
struct ethtool_link_ksettings *link_ksettings)
|
||||
{
|
||||
struct ethtool_cmd cmd;
|
||||
int ret;
|
||||
|
||||
memset(&cmd, 0, sizeof(cmd));
|
||||
ret = __ethtool_get_settings(dev, &cmd);
|
||||
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
link_ksettings->base.duplex = cmd.duplex;
|
||||
link_ksettings->base.speed = ethtool_cmd_speed(&cmd);
|
||||
link_ksettings->base.autoneg = cmd.autoneg;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* < KERNEL_VERSION(4, 6, 0) */
|
||||
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)
|
||||
|
||||
#include_next <linux/cache.h>
|
||||
|
||||
/* hack for netlink.c which marked the family ops as ro */
|
||||
#ifdef __ro_after_init
|
||||
#undef __ro_after_init
|
||||
#endif
|
||||
#define __ro_after_init
|
||||
|
||||
#endif /* < KERNEL_VERSION(4, 10, 0) */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 9)
|
||||
|
||||
#include <linux/netdevice.h>
|
||||
|
||||
/* work around missing attribute needs_free_netdev and priv_destructor in
|
||||
* net_device
|
||||
*/
|
||||
#define ether_setup(dev) \
|
||||
void batadv_softif_free2(struct net_device *dev) \
|
||||
{ \
|
||||
batadv_softif_free(dev); \
|
||||
free_netdev(dev); \
|
||||
} \
|
||||
void (*t1)(struct net_device *dev) __attribute__((unused)); \
|
||||
bool t2 __attribute__((unused)); \
|
||||
ether_setup(dev)
|
||||
#define needs_free_netdev destructor = batadv_softif_free2; t2
|
||||
#define priv_destructor destructor = batadv_softif_free2; t1
|
||||
|
||||
#endif /* < KERNEL_VERSION(4, 11, 9) */
|
||||
|
||||
|
||||
#if LINUX_VERSION_IS_LESS(4, 13, 0)
|
||||
|
||||
#define batadv_softif_validate(__tb, __data, __extack) \
|
||||
batadv_softif_validate(__tb, __data)
|
||||
|
||||
#define batadv_softif_newlink(__src_net, __dev, __tb, __data, __extack) \
|
||||
batadv_softif_newlink(__src_net, __dev, __tb, __data)
|
||||
|
||||
#endif /* LINUX_VERSION_IS_LESS(4, 13, 0) */
|
||||
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
|
||||
|
||||
#define batadv_softif_slave_add(__dev, __slave_dev, __extack) \
|
||||
batadv_softif_slave_add(__dev, __slave_dev)
|
||||
|
||||
#endif /* < KERNEL_VERSION(4, 15, 0) */
|
||||
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)
|
||||
|
||||
#ifndef sizeof_field
|
||||
#define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER))
|
||||
#endif
|
||||
|
||||
#endif /* < KERNEL_VERSION(4, 16, 0) */
|
||||
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
|
||||
|
||||
static inline int batadv_access_ok(int type, const void __user *p,
|
||||
unsigned long size)
|
||||
{
|
||||
return access_ok(type, p, size);
|
||||
}
|
||||
|
||||
#ifdef access_ok
|
||||
#undef access_ok
|
||||
#endif
|
||||
|
||||
#define access_ok_get(_1, _2, _3 , access_ok_name, ...) access_ok_name
|
||||
#define access_ok(...) \
|
||||
access_ok_get(__VA_ARGS__, access_ok3, access_ok2)(__VA_ARGS__)
|
||||
|
||||
#define access_ok2(addr, size) batadv_access_ok(VERIFY_WRITE, (addr), (size))
|
||||
#define access_ok3(type, addr, size) batadv_access_ok((type), (addr), (size))
|
||||
|
||||
#endif /* < KERNEL_VERSION(5, 0, 0) */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)
|
||||
|
||||
#ifndef fallthrough
|
||||
#if __GNUC__ > 7 && !defined(__CHECKER__)
|
||||
# define fallthrough __attribute__((__fallthrough__))
|
||||
#else
|
||||
# define fallthrough do {} while (0) /* fallthrough */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* < KERNEL_VERSION(5, 4, 0) */
|
||||
Reference in New Issue
Block a user