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

Add ffbs-debugbathosts #129

Merged
merged 1 commit into from
Aug 31, 2024

Conversation

SmithChart
Copy link
Contributor

This package provides /etc/bat-hosts.
his file can be used to map mac-addresses to names in batctl.

This file is empty by default and mainly serves as a reminder on how this can be used on the devices itself.

Copy link
Member

@maurerle maurerle left a comment

Choose a reason for hiding this comment

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

I would like this package to have a way to be set from the site.conf and overwrite this file in the upgrade process?

Very nice, i did not kbow about this behaviour before :)

@SmithChart
Copy link
Contributor Author

I would like this package to have a way to be set from the site.conf and overwrite this file in the upgrade process?

We have thought about a way to fill in the file during build process with information from e.g. meshviewer / yannic.
But overriding / appending data from site.conf during upgrade sounds like a good solution.

@maurerle
Copy link
Member

maurerle commented Aug 8, 2024

It would also be possible to have a small script which you call as:
download-bat-hosts https://map.aachen.freifunk.net/data/meshviewer.json which inserts all hosts into /etc/bat-hosts on demand, as this is anyway only useful if it is used manually to analyze something :)

That way, the site.conf config is not spoiled with many entries, and this package is a little mor useful than only being a placeholder :)

@T-X
Copy link

T-X commented Aug 12, 2024

Would love to have an automatic feature to populate /etc/bat-hosts (symlinked from /tmp/bat-hosts, to avoid flash writes). This would make debugging issues so much easier! Another, additional idea would be to populate at least from direct neighbors (via respondd?) as a solution that would work offline as well.

(As is, I don't see much value, it's something that is already documented in the batctl README. But of course wouldn't break anything either, so no reason to not merge this PR as is in the community repository.)

PS: spelling: contian -> contain

@maurerle
Copy link
Member

maurerle commented Aug 12, 2024

I just created a small script which does about this:

https://gist.github.com/maurerle/3586f2b8d825a69df0f523f60b731efa

One can install it using:

wget https://gist.githubusercontent.com/maurerle/3586f2b8d825a69df0f523f60b731efa/raw/1f32bd1c0bdc4156891cf2ea6058fade576fa664/update-bat-hosts.lua
chmod +x update-bat-hosts.lua

One can then call it using you communities nodes.json:
./update-bat-hosts.lua "https://map.aachen.freifunk.net/data/nodes.json"

Though this takes quite a few seconds on router cpus but is decent on x86.

Few notes:

  • batctl hostnames have to be unique so I added the iface and an index to the name
  • batctl has a host length limit of 50 - adding iface and idx and other chars, i used 30 real chars as maximum
  • batctl gives warnings if hosts are duplicated, so duplicates are removed (as some people just name their device "Freifunk")
  • it takes about 10 seconds to execute batctl commands on a D-Link COVR X1860 with the FFAC nodes.json loaded - on x86 it is less than one second

This is available under MIT license and can be integrated into this package if wanted :)

Update: I gave the script an option to show only the gateways int bat-hosts at least.

This package provides means to map MAC addresses to names for `batctl`.

This is done with two components:

* `/etc/bat-hosts` is a mapping file consumed by `batctl`.
  It is delivered empty and only contains help for the user.
  It is mostly intended as a reminder that this functions exists at all.
* `update-bat-hosts` is a lua-script that loads a `nodes.json` from a given URL
  and populates `/etc/bat-hosts` with the nodes found.

The script `update-bat-hosts` is only intended to be run by an
experienced user by hand to ease debugging. The result is directly written
into to `/etc/` and thus, usually, into flash memory. The
number of write/erase cycles caused by this should be negligible.
@SmithChart
Copy link
Contributor Author

SmithChart commented Aug 31, 2024

@maurerle your first review comments came in before my CI/CT had time for a turnaround :-D

I've integrated your script. Thanks for sharing! I have changed a few details:

  • The output is written to /etc/bat-hosts instead of /tmp and symlinking. A usual flash IC in a router should be capable of handling in the ballpark of 100k writes. Even with 20 writes a day for a year straight you do not exhaust 10% of that. And that does not take into account wear-leveling done by jffs2. This is plenty of headroom for a script an admin runs by hand. So no need to take extra rounds here.
  • I've added a command line switch for the gateway-only mode. And it's off by default. At least for Freifunk Braunschweig this mode does not make sense.

@SmithChart
Copy link
Contributor Author

PS: spelling: contian -> contain

Fixed.

@SmithChart
Copy link
Contributor Author

I've also thought about having the file populated at compile time. I would not favor such solution since it would make the build less reproducible: A changed nodes.json would affect the binary output.

@maurerle maurerle merged commit af58aa7 into freifunk-gluon:master Aug 31, 2024
2 checks passed
@SmithChart SmithChart deleted the ffbs-debugbathosts branch August 31, 2024 12:00
Copy link
Contributor

@grische grische left a comment

Choose a reason for hiding this comment

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

I know, I'm a bit late to the party, but I have some minor suggestions.

@@ -0,0 +1,95 @@
#!/usr/bin/lua
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be nice to have this in ffbs-debugbathosts/luasrc instead of ffbs-debugbathosts/files so that the Lua compressor can reduce the size of the script.

local url = arg[1]

local gateway_only = false
if #arg == 2 and arg[2] == '--gw' then
Copy link
Contributor

Choose a reason for hiding this comment

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

I propose to rename this to --gw-only. If I see the parameter --gw I would think it includes gws 🙂

@SmithChart
Copy link
Contributor Author

I know, I'm a bit late to the party, but I have some minor suggestions.

Thanks for the feedback. I'll pack those changes into a new PR in a few days.

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

Successfully merging this pull request may close these issues.

4 participants