From patchwork Sat Sep 26 08:12:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 18193 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id 9501B80824; Sat, 26 Sep 2020 10:22:07 +0200 (CEST) Received: from dvalin.narfation.org (dvalin.narfation.org [IPv6:2a00:17d8:100::8b1]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 73C1180599 for ; Sat, 26 Sep 2020 10:22:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=narfation.org; s=20121; t=1601107979; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=PiyNY7uUAXkphfVLKrVaoMUy9s/jcssrAt8TIVmT5I4=; b=bWSfplyJ6LHzOzIyoDSFXGBGJBae9uSnkJZrU82jDQrJwy2DuxnAgqqSESk9I4jNZvvtcO +YGDQ+SmLZBdUobphoS27pSnHlolf+OoB7m3ud5JKucOzOqDmHWvjh41C6FWlAq7fPrHo+ isJcm9N81BoovZTmZ1unU1v31rJiKnY= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Subject: [PATCH 1/2] batman-adv: Re-add compat-patches infrastructure Date: Sat, 26 Sep 2020 10:12:19 +0200 Message-Id: <20200926081220.40779-1-sven@narfation.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1601108524; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:dkim-signature; bh=PiyNY7uUAXkphfVLKrVaoMUy9s/jcssrAt8TIVmT5I4=; b=baldiHE+n0RkUW9KtVcQkRL4a1xUqDCLqujB5lhdFhaVct8UXmIerN4eEesf0X1BeqNKBU axtTU93/EqEWVlj39uzeABsALp5FD0NLi7a2QHamfZrN0IgqOoEEbm5KsvYYmyvaL4uJG7 s2yux8a8xk49v8d3eENC6UlSE8T9FnI= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1601108524; a=rsa-sha256; cv=none; b=maRXm/h3chIn44tX4OO35aFFu1ZkW9PQQtUwKbLJMmEuIcednzPRQPqP+ZaZiHknAdpVGy kQL+PjvC5Q0hdXnaUwMblzcvcO5XIth0Czc/1+i3nW95JDs2oJ49G3WAyn0zLfBdc980fu WbMKjH0Nch5+n0aUoI7f3TZ/lISjjek= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=pass header.d=narfation.org header.s=20121 header.b=bWSfplyJ; spf=pass (diktynna.open-mesh.org: domain of sven@narfation.org designates 2a00:17d8:100::8b1 as permitted sender) smtp.mailfrom=sven@narfation.org Message-ID-Hash: B4QOYO3UMUJGV5YMDUFX75DEIQLFC5EV X-Message-ID-Hash: B4QOYO3UMUJGV5YMDUFX75DEIQLFC5EV X-MailFrom: sven@narfation.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Nikolay Aleksandrov X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Some patches were added again in the mainline kernel which make it rather hard to allow building of the unmodified batman-adv sources against older kernel versions. Just switch again to the old build infrastructure again. It creates a copy of the sources in net/batman-adv which can be patched and then compiled+linked to create build/net/batman-adv/batman-adv.ko Signed-off-by: Sven Eckelmann --- .gitignore | 13 +----------- Makefile | 38 +++++++++++++++++++++++++++------- compat-patches/README | 27 ++++++++++++++++++++++++ compat-patches/replacements.sh | 5 +++++ 4 files changed, 64 insertions(+), 19 deletions(-) create mode 100644 compat-patches/README create mode 100755 compat-patches/replacements.sh diff --git a/.gitignore b/.gitignore index 4df7f60a..1a8dbc0d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,3 @@ -/.cache.mk /compat-autoconf.h /compat-autoconf.h.tmp -/compat-sources/**/.* -/compat-sources/**/*.o -/modules.order -/Module.symvers -/net/batman-adv/batman-adv.ko -/net/batman-adv/.batman-adv.ko.cmd -/net/batman-adv/batman-adv.mod.c -/net/batman-adv/modules.order -/net/batman-adv/*.o -/net/batman-adv/.*.o.cmd -/.tmp_versions +/build/ diff --git a/Makefile b/Makefile index afdbc03c..25c75f46 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,7 @@ export CONFIG_BATMAN_ADV_SYSFS=n export CONFIG_BATMAN_ADV_TRACING=n PWD:=$(shell pwd) +BUILD_DIR=$(PWD)/build KERNELPATH ?= /lib/modules/$(shell uname -r)/build # sanity check: does KERNELPATH exist? ifeq ($(shell cd $(KERNELPATH) && pwd),) @@ -32,17 +33,24 @@ endif export KERNELPATH RM ?= rm -f +MKDIR := mkdir -p +PATCH_FLAGS = --batch --fuzz=0 --forward --strip=1 --unified --version-control=never -g0 --remove-empty-files --no-backup-if-mismatch --reject-file=- +PATCH := patch $(PATCH_FLAGS) -i CP := cp -fpR LN := ln -sf DEPMOD := depmod -a +SOURCE = $(wildcard net/batman-adv/*.[ch]) net/batman-adv/Makefile +SOURCE_BUILD = $(wildcard $(BUILD_DIR)/net/batman-adv/*.[ch]) $(BUILD_DIR)/net/batman-adv/Makefile +SOURCE_STAMP = $(BUILD_DIR)/net/batman-adv/.compat-prepared + REVISION= $(shell if [ -d "$(PWD)/.git" ]; then \ echo $$(git --git-dir="$(PWD)/.git" describe --always --dirty --match "v*" |sed 's/^v//' 2> /dev/null || echo "[unknown]"); \ fi) NOSTDINC_FLAGS += \ - -I$(PWD)/compat-include/ \ - -I$(PWD)/include/ \ - -include $(PWD)/compat.h \ + -I$(PWD)/../compat-include/ \ + -I$(PWD)/../include/ \ + -include $(PWD)/../compat.h \ $(CFLAGS) ifneq ($(REVISION),) @@ -55,8 +63,8 @@ export batman-adv-y BUILD_FLAGS := \ - M=$(PWD) \ - PWD=$(PWD) \ + M=$(BUILD_DIR) \ + PWD=$(BUILD_DIR) \ REVISION=$(REVISION) \ CONFIG_BATMAN_ADV=m \ CONFIG_BATMAN_ADV_DEBUG=$(CONFIG_BATMAN_ADV_DEBUG) \ @@ -70,18 +78,34 @@ BUILD_FLAGS := \ CONFIG_BATMAN_ADV_BATMAN_V=$(CONFIG_BATMAN_ADV_BATMAN_V) \ INSTALL_MOD_DIR=updates/ -all: config +all: config $(SOURCE_STAMP) $(MAKE) -C $(KERNELPATH) $(BUILD_FLAGS) modules clean: $(RM) compat-autoconf.h* $(MAKE) -C $(KERNELPATH) $(BUILD_FLAGS) clean -install: config +install: config $(SOURCE_STAMP) $(MAKE) -C $(KERNELPATH) $(BUILD_FLAGS) modules_install $(DEPMOD) config: $(PWD)/gen-compat-autoconf.sh $(PWD)/compat-autoconf.h +$(SOURCE_STAMP): $(SOURCE) compat-patches/* compat-patches/replacements.sh + $(MKDIR) $(BUILD_DIR)/net/batman-adv/ + @$(LN) ../Makefile $(BUILD_DIR)/Makefile + @$(RM) $(SOURCE_BUILD) + @$(CP) $(SOURCE) $(BUILD_DIR)/net/batman-adv/ + @set -e; \ + patches="$$(ls -1 compat-patches/|grep '.patch$$'|sort)"; \ + for i in $${patches}; do \ + echo ' COMPAT_PATCH '$${i};\ + cd $(BUILD_DIR); \ + $(PATCH) ../compat-patches/$${i}; \ + cd - > /dev/null; \ + done + compat-patches/replacements.sh + touch $(SOURCE_STAMP) + .PHONY: all clean install config diff --git a/compat-patches/README b/compat-patches/README new file mode 100644 index 00000000..55cb0fe2 --- /dev/null +++ b/compat-patches/README @@ -0,0 +1,27 @@ +.. SPDX-License-Identifier: GPL-2.0 + +WARNING +======= + +Please avoid using the compat-patches/ to implement support for old kernels. +This should be the last resort. + + * it is nearly always possible to use compat-includes/ to do the same with a + lot less problems + + * maintaining these patches is *censored* + +GENERATING A PATCH +================== + +If it not possible to avoid a patch then please make the patch as small as +possible. Even refactor the code which has to be patched to reduce the +size/number of the changes. + +Please use git-format-patches to generate them and order them inside via the +XXXX- prefix before the patch name. + + git format-patch --no-stat --full-index --no-renames --binary \ + --diff-algorithm=histogram --no-signature \ + --format=format:'From: %an <%ae>%nDate: %aD%nSubject: %B' \ + -1 diff --git a/compat-patches/replacements.sh b/compat-patches/replacements.sh new file mode 100755 index 00000000..1b64e5c2 --- /dev/null +++ b/compat-patches/replacements.sh @@ -0,0 +1,5 @@ +#! /bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2007-2018 B.A.T.M.A.N. contributors + +set -e From patchwork Sat Sep 26 08:12:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 18192 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id DF8B18026B; Sat, 26 Sep 2020 10:22:06 +0200 (CEST) Received: from dvalin.narfation.org (dvalin.narfation.org [213.160.73.56]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 621F1800A1 for ; Sat, 26 Sep 2020 10:22:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=narfation.org; s=20121; t=1601107986; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E6TKCD2SmP0HbdLaY49M2V+pU+Q7FjyqTxkD6V+xbuQ=; b=2bbu8RAT+2ud7PQpkNBLy8xPJQ1he+VgGnocp/jIIk6mE6m3WGpett330NszJ1HBbH/gsA NN84W6Klthwbw7sL0QEXxDqooeQdfRxcCWGA01fVWzAPPNdPdP8WPHYLnMX00sWaGBUYCr qYI6/mxSLy7NgxNADwBDXGeSNO7IV5E= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Subject: [PATCH 2/2] batman-adv: mcast: rename br_ip's u member to dst Date: Sat, 26 Sep 2020 10:12:20 +0200 Message-Id: <20200926081220.40779-2-sven@narfation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200926081220.40779-1-sven@narfation.org> References: <20200926081220.40779-1-sven@narfation.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1601108524; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=E6TKCD2SmP0HbdLaY49M2V+pU+Q7FjyqTxkD6V+xbuQ=; b=JffKiaIGay9hnLu3rapWRrNBaJPOPxRKqH5hTuWCCbDgGa+B3cU2F1SwEVQtRRCuVp/LUz 9h48xmj97+1VdnCbd5kf+rm7VbnjF+9uEr2Ot1utVIkdzpB2YT6Hpl8PAzzZBI++t79A8H sXjwL/eVGLkyp0iCV2nlvdRiUR0Pddw= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1601108524; a=rsa-sha256; cv=none; b=3hrMV1X7ZodBGISp5qx4cO95dG9dKN7OeXSMPUwx6opi80ZMqHiUc7bmCTzCA0Z8tThlwe lS5thMj4LfX1tzbQpRkJt1XgKAavCAb/3yQN15lm715AyXOcdABP2zeOSKzHJSCDQlOFkg SIxhCQIieLPRRbYeh5QYPZOry/2AL6s= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=pass header.d=narfation.org header.s=20121 header.b=2bbu8RAT; spf=pass (diktynna.open-mesh.org: domain of sven@narfation.org designates 213.160.73.56 as permitted sender) smtp.mailfrom=sven@narfation.org Message-ID-Hash: 7H76PITJXELMORCMJ4JCGONBLKCGJIG4 X-Message-ID-Hash: 7H76PITJXELMORCMJ4JCGONBLKCGJIG4 X-MailFrom: sven@narfation.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Nikolay Aleksandrov X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Nikolay Aleksandrov Since now we have src in br_ip, u no longer makes sense so rename it to dst. No functional changes. Signed-off-by: Nikolay Aleksandrov Signed-off-by: David S. Miller [sven@narfation.org: Add compat code] Signed-off-by: Sven Eckelmann --- compat-include/linux/if_bridge.h | 26 ++++++++++++++++++++++++++ compat-patches/replacements.sh | 5 +++++ net/batman-adv/multicast.c | 14 +++++++------- 3 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 compat-include/linux/if_bridge.h diff --git a/compat-include/linux/if_bridge.h b/compat-include/linux/if_bridge.h new file mode 100644 index 00000000..7b6d5876 --- /dev/null +++ b/compat-include/linux/if_bridge.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2007-2020 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_IF_BRIDGE_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_IF_BRIDGE_H_ + +#include +#include_next + +#if LINUX_VERSION_IS_LESS(5, 10, 0) + +#define BATADV_BR_IP_UNION u + +#else + +#define BATADV_BR_IP_UNION dst + +#endif /* LINUX_VERSION_IS_LESS(5, 10, 0) */ + +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_IF_BRIDGE_H_ */ diff --git a/compat-patches/replacements.sh b/compat-patches/replacements.sh index 1b64e5c2..e72ec5ec 100755 --- a/compat-patches/replacements.sh +++ b/compat-patches/replacements.sh @@ -3,3 +3,8 @@ # Copyright (C) 2007-2018 B.A.T.M.A.N. contributors set -e + +# for kernel < 5.10 to enable br_ip compat code +sed -i \ + -e 's/\(->\|\.\)dst\.ip/\1BATADV_BR_IP_UNION.ip/' \ + build/net/batman-adv/multicast.c diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c index 0746fe2c..9af99c39 100644 --- a/net/batman-adv/multicast.c +++ b/net/batman-adv/multicast.c @@ -221,7 +221,7 @@ static u8 batadv_mcast_mla_rtr_flags_bridge_get(struct batadv_priv *bat_priv, * address here, only IPv6 ones */ if (br_ip_entry->addr.proto == htons(ETH_P_IPV6) && - ipv6_addr_is_ll_all_routers(&br_ip_entry->addr.u.ip6)) + ipv6_addr_is_ll_all_routers(&br_ip_entry->addr.dst.ip6)) flags &= ~BATADV_MCAST_WANT_NO_RTR6; list_del(&br_ip_entry->list); @@ -562,10 +562,10 @@ batadv_mcast_mla_softif_get(struct net_device *dev, static void batadv_mcast_mla_br_addr_cpy(char *dst, const struct br_ip *src) { if (src->proto == htons(ETH_P_IP)) - ip_eth_mc_map(src->u.ip4, dst); + ip_eth_mc_map(src->dst.ip4, dst); #if IS_ENABLED(CONFIG_IPV6) else if (src->proto == htons(ETH_P_IPV6)) - ipv6_eth_mc_map(&src->u.ip6, dst); + ipv6_eth_mc_map(&src->dst.ip6, dst); #endif else eth_zero_addr(dst); @@ -609,11 +609,11 @@ static int batadv_mcast_mla_bridge_get(struct net_device *dev, continue; if (tvlv_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES && - ipv4_is_local_multicast(br_ip_entry->addr.u.ip4)) + ipv4_is_local_multicast(br_ip_entry->addr.dst.ip4)) continue; if (!(tvlv_flags & BATADV_MCAST_WANT_NO_RTR4) && - !ipv4_is_local_multicast(br_ip_entry->addr.u.ip4)) + !ipv4_is_local_multicast(br_ip_entry->addr.dst.ip4)) continue; } @@ -623,11 +623,11 @@ static int batadv_mcast_mla_bridge_get(struct net_device *dev, continue; if (tvlv_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES && - ipv6_addr_is_ll_all_nodes(&br_ip_entry->addr.u.ip6)) + ipv6_addr_is_ll_all_nodes(&br_ip_entry->addr.dst.ip6)) continue; if (!(tvlv_flags & BATADV_MCAST_WANT_NO_RTR6) && - IPV6_ADDR_MC_SCOPE(&br_ip_entry->addr.u.ip6) > + IPV6_ADDR_MC_SCOPE(&br_ip_entry->addr.dst.ip6) > IPV6_ADDR_SCOPE_LINKLOCAL) continue; }