Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use own namespace #13

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Use own namespace #13

wants to merge 7 commits into from

Conversation

T-X
Copy link
Contributor

@T-X T-X commented Nov 27, 2018

This patchset allows loading and running the mainline batman-adv (compat 15) and the batman-adv-legacy (compat 14) fork simultaneously.

Together with the gluon-scheduled-domain-switch package (freifunk-gluon/gluon#1555) this should ease the migration from compat 14 to compat 15 and speed-up the deprecation of this fork.

(Changing the module name was first proposed in #3 three years ago.)

@ecsv
Copy link
Contributor

ecsv commented Nov 30, 2018

The build fails here against /usr/src/linux-headers-4.18.0-2-amd64 with

make[1]: Leaving directory '/usr/src/linux-headers-4.18.0-2-amd64'
objcopy: /home/sven/tmp/batman-adv-legacy/updated-syms.txt: Multiple redefinition of symbol "batadv_compare_eth"
make: *** [Makefile:61: updatesyms] Error 

This really seems to be the case:

$ grep -r batadv_compare_eth /home/sven/tmp/batman-adv-legacy/updated-syms.txt 
batadv_compare_eth batadv_legacy_compare_eth
batadv_compare_eth batadv_legacy_compare_eth

I've worked around it via

diff --git a/Makefile b/Makefile
index 657d4ee..4ee9ffa 100644
--- a/Makefile
+++ b/Makefile
@@ -60,8 +60,9 @@ build: config
 updatesyms:
 	@if ! $(OBJDUMP) -j .init.text -t batman-adv-legacy.ko| grep -q "batadv_legacy_init"; then \
 		$(OBJDUMP) -t batman-adv-legacy.ko | grep batadv_ | grep -v "batadv_legacy" | \
-			sed "s/.* \([^ ]*\)batadv_\([^ ]*\)$$/\1batadv_\2 \1batadv_legacy_\2/" \
-				>> $(PWD)/updated-syms.txt; \
+			sed "s/.* \([^ ]*\)batadv_\([^ ]*\)$$/\1batadv_\2 \1batadv_legacy_\2/" | \
+			sort | uniq \
+				> $(PWD)/updated-syms.txt; \
 		$(OBJCOPY) --redefine-syms=$(PWD)/updated-syms.txt $(PWD)/batman-adv-legacy.ko; \
 	fi

Copy link
Member

@neocturne neocturne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are some things that should be fixed if we decide to merge this.

Makefile Outdated
@@ -20,13 +20,13 @@

# read README.external for more information about the configuration
# B.A.T.M.A.N. debugging:
export CONFIG_BATMAN_ADV_DEBUG=n
export CONFIG_BATMAN_ADV_LEGACY_DEBUG=n
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is always built out-of-tree, I don't see a point in renaming these config symbols.

batman-adv-y += soft-interface.o
batman-adv-y += sysfs.o
batman-adv-y += translation-table.o
batman-adv-y += unicast.o
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not touch this file and generate a batman-adv.ko from this build step.

Makefile Outdated
$(OBJDUMP) -t batman-adv-legacy.ko | grep batadv_ | grep -v "batadv_legacy" | \
sed "s/.* \([^ ]*\)batadv_\([^ ]*\)$$/\1batadv_\2 \1batadv_legacy_\2/" \
>> $(PWD)/updated-syms.txt; \
$(OBJCOPY) --redefine-syms=$(PWD)/updated-syms.txt $(PWD)/batman-adv-legacy.ko; \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the same filename for input and output of the objcopy is making this more fragile than necessary. Just use batman-adv.ko as input, batman-adv-legacy.ko as output, and drop the whole if conditional.

We can use proper file targets then, which will also improve error handling:

  • rename build to batman-adv.ko
  • rename updatesyms to batman-adv-legacy.ko
  • create a proper target to updated-syms.txt
  • properly define dependencies between the different targets

main.h Outdated
@@ -22,8 +22,8 @@

#define BATADV_DRIVER_AUTHOR "Marek Lindner <[email protected]>, " \
"Simon Wunderlich <[email protected]>"
#define BATADV_DRIVER_DESC "B.A.T.M.A.N. advanced"
#define BATADV_DRIVER_DEVICE "batman-adv"
#define BATADV_DRIVER_DESC "B.A.T.M.A.N. advanced legacy (compat14)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a space between compat and 14?

@neocturne
Copy link
Member

I'm not really a fan of these changes. I don't see why it should be necessary to load both modules at the same time to allow a scheduled domain switch - shouldn't it be enough to be able to install both modules into the same image, and decide at runtime which one to load? That way we would need to adjust way less code to the "-legacy" namespace (batctl calls, netlink queries, ...).

@T-X
Copy link
Contributor Author

T-X commented Dec 8, 2018

Good point. You are right, the scheduled domain switcher will trigger a reboot anyway. And not making both loadable at the same time would indeed make this pull-request way simpler.

The one advantage to be able to load both modules simultaneously I can think of right now would to ease migration on the gateway side. Summing up the list in the wiki there are currently 39 site.conf/mk's of which 13 are still using batman-adv-legacy/compat-14 (counting Freifunk Rheinland as one).

With being able to load modules simultaneously it would probably just be a "git clone, run these dkms commands to build and install, update a few config lines". Compared to a setting up and integrating a new, additional system/OS somehow.

Depending on how active these 13 communities still are and how quick they'd be in setting up a new VM or root server we would need to maintain the batman-adv-legacy fork for a longer or shorter amount of time.

(anyone from these 13 communities having some opinion or strong preference?)

sed -i "s/^batman-adv-/batman-adv-legacy-/g" Makefile*
sed -i "s/ batman-adv.o/ batman-adv-legacy.o/g" Makefile.kbuild

Signed-off-by: Linus Lüssing <[email protected]>
This creates a new batman-adv-legacy.ko which has its symbols updated
accordingly.

Signed-off-by: Linus Lüssing <[email protected]>
sed -i "s/^#define BATADV_NL_NAME \"batadv\"/#define BATADV_NL_NAME \"batadv_legacy\"/" uapi/linux/batman_adv.h

Signed-off-by: Linus Lüssing <[email protected]>
@T-X
Copy link
Contributor Author

T-X commented Dec 25, 2018

Changelog v2:

  • "compat14" -> "compat 14" in main.h
  • Makefile: use file targets instead of PHONY ones (I could not remove the renaming of the object targets in Makefile.kbuild though, it seems that obj-m += <module_name>.ko determines the loaded modules name. when I tried to not rename that the loaded batman-adv-legacy module was still listed as "batman_adv" in lsmod.)
  • Added a "| sort | uniq >" to prevent duplicate symbol renaming lines with some compilers
  • Dumped the CONFIG_ renames ("batman-adv-legacy: Add "LEGACY" infix to CONFIG parameters")

Edit:

  • removed the unnecessary sysfs rename of /sys/class/net/bat0/mesh to mesh_legacy in "batman-adv-legacy: Changing batman-adv sysfs directory". There is no clash as bat0 always belongs to either batman-adv or batman-adv-legacy. This fixes some previously ignored parameters set in /etc/config/batman-adv and alfred init script start up issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants