Skip to content

batman-adv: add new package - #30164

Merged
BKPepe merged 4 commits into
openwrt:masterfrom
BKPepe:add-batman-adv
Aug 18, 2026
Merged

batman-adv: add new package#30164
BKPepe merged 4 commits into
openwrt:masterfrom
BKPepe:add-batman-adv

Conversation

@BKPepe

@BKPepe BKPepe commented Aug 6, 2026

Copy link
Copy Markdown
Member

Adds batman-adv from the openwrt/routing feed — the routing packages are being moved into openwrt/packages one by one, as discussed in openwrt/routing#184.

Note: this is a kernel module package; it builds against the mac80211 backport, the same way it does in the routing feed.

The content matches the current routing feed master. Once this is merged, the package will be removed from the routing feed (a coordinated removal PR is prepared there).

Maintainer: @simonwunderlich

Copilot AI lite review requested due to automatic review settings August 6, 2026 08:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ecsv

ecsv commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

@simonwunderlich is the maintainer, not me. (see makefile)

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed 1 new commit.

Nothing here looks like a build breaker — the one thing that initially read as one is fine: NOSTDINC_FLAGS points at $(PKG_BUILD_DIR)/compat-hacks.h while the file lives in src/, but Build/Prepare/Default copies ./src/. into $(PKG_BUILD_DIR) unconditionally, so that resolves. LINUX_6_12 is likewise a real symbol (generated by scripts/target-metadata.pl), and 6.12 / 6.18 are the only KERNEL_PATCHVER values in openwrt master today, so the conditional kmod-lib-crc32c dependency lines up with the LINUX_VERSION_IS_LESS(6, 16, 0) || !defined(CONFIG_NET_CRC32C) fallback in compat-hacks.h.

Three findings inline. The +batctl one is the only one I'd consider merge-blocking, and it is really a sequencing question for the feed move rather than a defect in this diff. Note I could not diff this against the routing feed directly (only openwrt/packages is reachable from this session), so I reviewed it on its own merits rather than verifying the "content matches the current routing feed master" claim — if some of this is verbatim, the continue finding is pre-existing and might be better fixed in routing first.

Indentation conventions all check out: two spaces for the KernelPackage metadata block, tabs for Build/Compile and /install, no indent for the conffiles body. The migration script uses four spaces where tabs dominate for uci-defaults scripts in this feed, but that is not worth churn on a file being moved wholesale.

CI was still queued at review time, so none of this is grounded in build logs.


Generated by Claude Code

Comment thread net/batman-adv/Makefile Outdated
Comment on lines +54 to +57

define Package/kmod-batman-adv/conffiles
/etc/config/batman-adv
endef

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This registers /etc/config/batman-adv as a conffile, but the package never installs that file — files/ only ships etc/uci-defaults/99-migrate-batadv_hardif and lib/netifd/proto/*.sh, and KernelPackage/batman-adv/install just does $(CP) ./files/. $(1)/.

Worse, the migration script this package ships actively deletes that file as the last step of moving the settings into /etc/config/network (rm -f /etc/config/batman-adv).`` So the entry is vestigial from the pre-batadv_hardif layout and should go.

Two secondary points if you decide to keep it anyway: the canonical spelling inside a KernelPackage is KernelPackage/batman-adv/conffiles (kernel.mk expands that into Package/kmod-.../conffiles — see include/kernel.mk:222-226), and it would be the only Package/kmod-batman-adv/* block in a file that otherwise uses KernelPackage/batman-adv/* throughout.

Suggested change
define Package/kmod-batman-adv/conffiles
/etc/config/batman-adv
endef

Generated by Claude Code

Comment thread net/batman-adv/Makefile
SUBMENU:=Network Support
TITLE:=B.A.T.M.A.N. Adv
URL:=https://www.open-mesh.org/
DEPENDS:=+BATMAN_ADV_BLA:kmod-lib-crc16 +LINUX_6_12:kmod-lib-crc32c +kmod-cfg80211 +batctl

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

+batctl is a hard dependency on a package that does not exist in this feed — there is no net/batctl in openwrt/packages, and no other Makefile here references it. It is still in openwrt/routing.

This is not only a metadata concern: all three netifd proto scripts shell out to batctl for every operation (batctl meshif "$iface" interface create in batadv.sh:71, batctl hardif ... in batadv_hardif.sh, batctl vlan ... in batadv_vlan.sh), so the package is non-functional without it.

The SDK used by the package CI has all official feeds enabled, which is why this still resolves in the build jobs — but anyone building with only base + packages gets an unsatisfied dependency. Since openwrt/routing#184 is about moving these packages over one by one, is batctl planned as a follow-up PR, and should batman-adv wait for it so the two land together?


Generated by Claude Code

config_get routing_algo "${section}" routing_algo

if [ -z "$mesh" -o "${proto}" != "batadv" ]; then
continue

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

continue is used here to bail out of a function, not a loop. POSIX leaves continue with no enclosing loop in the current function unspecified; ash/dash/bash happen to walk the dynamic call stack, so it lands on the for section in ${CONFIG_SECTIONS} loop inside config_foreach and the net effect is the intended "skip this section".

That makes it work today by accident. return expresses the intent directly and does not depend on how config_foreach is implemented.

Suggested change
continue
return

Generated by Claude Code

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed 2 new commits (cf6a264, 0512012). Both do exactly what their messages say, and both resolve findings from the previous round — the vestigial conffiles block is gone and the migration script now uses return instead of continue.

One new finding, and it is a build breaker rather than a metadata point: CI has now run, and batman-adv fails to compile on every kernel-6.12 target because the kmalloc_obj family in compat-hacks.h is redefined against include/linux/slab.h. Details and a suggested guard are inline. This is inherited content rather than something these two commits introduced, but it does mean the package as it stands builds on 6.18 targets only.

Still open from the previous review: +batctl is a hard dependency on a package that does not exist in this feed yet. Not repeating it here beyond the pointer — it is a sequencing question for the feed move rather than a defect in the diff.


Generated by Claude Code

Comment thread net/batman-adv/src/compat-hacks.h Outdated
Comment on lines +49 to +61
#if LINUX_VERSION_IS_LESS(7, 0, 0) && \
!(LINUX_VERSION_IS_GEQ(6, 18, 33) && LINUX_VERSION_IS_LESS(6, 19, 0))

#define kzalloc_obj(P, GFP) \
kzalloc(sizeof(P), GFP)

#define kmalloc_obj(P, GFP) \
kmalloc(sizeof(P), GFP)

#define kmalloc_objs(P, COUNT, GFP) \
kmalloc_array((COUNT), sizeof(P), GFP)

#endif /* < KERNEL_VERSION(7, 0, 0) */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This guard only carves out the 6.18.33+ stable backport, but kzalloc_obj / kmalloc_obj / kmalloc_objs have also landed in 6.12.y stable, so on a 6.12 kernel these collide with the definitions in include/linux/slab.h.

CI is unambiguous — from Test mips_24kc (target lantiq_xrx200, linux-6.12.100):

compat-hacks.h:58:9: error: "kmalloc_objs" redefined [-Werror]
./include/linux/slab.h:944:9: note: this is the location of the previous definition
cc1: all warnings being treated as errors
make[5]: *** [scripts/Makefile.build:229: .../net/batman-adv/bat_algo.o] Error 1
    ERROR: package/feeds/packages_ci/batman-adv failed to build.

The four failed jobs — mips_24kc, powerpc_8548, arm_cortex-a15_neon-vfpv4, arm_cortex-a9_vfpv3-d16 — are exactly the arches whose SDK target sits on KERNEL_PATCHVER:=6.12 (lantiq, mpc85xx, ipq806x, bcm53xx); the six that passed are all on 6.18. So this is not a flaky matrix entry — the kmod does not build for any 6.12 target as it stands.

All three are plain object-like/function-like macros upstream, so guarding on the macro name fixes it without having to track which point release of every LTS series picks the backport up:

Suggested change
#if LINUX_VERSION_IS_LESS(7, 0, 0) && \
!(LINUX_VERSION_IS_GEQ(6, 18, 33) && LINUX_VERSION_IS_LESS(6, 19, 0))
#define kzalloc_obj(P, GFP) \
kzalloc(sizeof(P), GFP)
#define kmalloc_obj(P, GFP) \
kmalloc(sizeof(P), GFP)
#define kmalloc_objs(P, COUNT, GFP) \
kmalloc_array((COUNT), sizeof(P), GFP)
#endif /* < KERNEL_VERSION(7, 0, 0) */
#ifndef kzalloc_obj
#define kzalloc_obj(P, GFP) \
kzalloc(sizeof(P), GFP)
#endif
#ifndef kmalloc_obj
#define kmalloc_obj(P, GFP) \
kmalloc(sizeof(P), GFP)
#endif
#ifndef kmalloc_objs
#define kmalloc_objs(P, COUNT, GFP) \
kmalloc_array((COUNT), sizeof(P), GFP)
#endif

A version-range fix works as well, but then the exact 6.12.y that carries the backport has to be pinned down too, and repeated for the next series that gets it. Given the header's own opening line, whichever form you pick is probably worth sending to batman-adv upstream rather than carrying only here.


Generated by Claude Code

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@simonwunderlich Are you ok with this one?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@BKPepe yes looks good, thank you!

config_get routing_algo "${section}" routing_algo

if [ -z "$mesh" -o "${proto}" != "batadv" ]; then
return

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: this line, and the conffiles removal in cf6a264, are fixups to a file the same series introduces two commits earlier. Since net/batman-adv/ does not exist before this PR, folding cf6a264 and 0512012 back into 8beec4f ("batman-adv: add new package") leaves a single self-consistent add-package commit instead of an introduce-then-fix trio in the history.

Two knock-on details if you do rebase:

  • The PR body says "The content matches the current routing feed master." That is no longer true after these two commits — worth either adjusting the sentence or noting that the two deltas are deliberate improvements over the feed version.
  • The Reported-by: openwrt-ai[bot] trailers become moot once squashed; feel free to drop them.

Generated by Claude Code

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed 1 new commit (f07112c). The message matches the diff, and the fix is the right shape — guarding on the macro name rather than on a version range is what keeps this from needing a re-audit each time another stable series picks the backport up. The #endif /* kzalloc_obj */ comments also match the file's own style for #ifdef DECLARE_EWMA further down.

One follow-up inline: the #ifndef guards only work if <linux/slab.h> has already been preprocessed when they are reached, and this header does not include it. Today it works out, but only because of an unrelated conditional above. Nothing merge-blocking — a one-line include makes it self-contained.

CI on this head is queued rather than finished, so I could not confirm the four 6.12 targets now pass; nothing is red at review time.

Still open from earlier rounds, not repeated here: +batctl depends on a package that is not in this feed yet (a sequencing question for the feed move), and the squash suggestion — which now covers three fixups to a file this same series introduces, and makes the PR body's "content matches the current routing feed master" a bit less accurate than when it was written.


Generated by Claude Code


#endif /* LINUX_VERSION_IS_LESS(6, 16, 0) || !defined(CONFIG_NET_CRC32C) */

#ifndef kzalloc_obj

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Switching to #ifndef is the right call — the macro-name test is the only guard that does not have to be re-audited every time a stable series picks the backport up. One thing that makes it fragile as written, though: #ifndef kzalloc_obj is only meaningful if <linux/slab.h> has already been preprocessed at this point, and this header never includes it.

Today that happens to hold. The block above at compat-hacks.h:19-47 pulls in <linux/skbuff.h>, and CONFIG_NET_CRC32C appears nowhere in openwrt master (grep -rn NET_CRC32C over openwrt@f4a7ae1 returns nothing), so !defined(CONFIG_NET_CRC32C) is true on 6.18 as well as on 6.12 and the include always fires. But that is an accident of an unrelated conditional: the moment CONFIG_NET_CRC32C gets selected on a ≥6.16 kernel, the #include <linux/skbuff.h> disappears and these three guards evaluate before slab.h is seen. The compat macros then get defined, and slab.h collides with them later — the same redefinition error as before, just with the two sides swapped.

Making it explicit costs one line and removes the dependency on the block above:

Suggested change
#ifndef kzalloc_obj
#include <linux/slab.h>
#ifndef kzalloc_obj

Caveat on my evidence: NOSTDINC_FLAGS also force-includes backport/backport.h ahead of this file, and I cannot see the mac80211-backport headers from here. If that already drags in slab.h unconditionally, the guards are safe as they stand and this is redundant — do you know whether it does?


Generated by Claude Code

@BKPepe
BKPepe force-pushed the add-batman-adv branch 2 times, most recently from feb7dbf to cd6dd0e Compare August 6, 2026 18:33
BKPepe and others added 4 commits August 7, 2026 07:19
B.A.T.M.A.N. Advanced is a routing protocol for multi-hop
ad-hoc mesh networks implemented as a kernel module. It builds
against the mac80211 backport like in the routing feed.

Moved from the openwrt/routing feed, as discussed in
openwrt/routing#184.

Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
/etc/config/batman-adv is registered as a conffile although the
package never installs it: files/ only ships the uci-defaults
migration script and the netifd proto handlers. The migration script
itself removes /etc/config/batman-adv as its last step once the
settings have been moved into /etc/config/network, so the entry is
left over from the layout that predates batadv_hardif.

Reported-by: openwrt-ai[bot]
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
proto_batadv_to_batadv_hardif() uses continue to skip a section, but
there is no loop in the function itself. POSIX leaves continue
without an enclosing loop in the current function unspecified; ash
walks the dynamic call stack and lands on the loop inside
config_foreach, which happens to produce the intended behaviour.

Use return, which expresses the intent directly and does not depend
on how config_foreach is implemented.

Reported-by: openwrt-ai[bot]
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
The compat definitions of kzalloc_obj(), kmalloc_obj() and
kmalloc_objs() were guarded by a version range which carves out only
specific stable backports. These helpers are backported on demand to
stable kernel branches, so on a newer stable kernel they collide
with the definitions in include/linux/slab.h and the module fails to
build:

    compat-hacks.h:52:9: error: "kzalloc_obj" redefined [-Werror]
    ./include/linux/slab.h:963:9: note: this is the location of the
    previous definition

CI showed this on exactly the four targets sitting on
KERNEL_PATCHVER 6.12 - mips_24kc, powerpc_8548, arm_cortex-a15 and
arm_cortex-a9 - while the six 6.18 targets passed.

Guard each definition on the macro name instead, so the compat code
steps aside whenever the kernel provides the helper, without having
to track which point release of which stable series picked up the
backport.

This mirrors what batman-adv carries in compat-include/linux/slab.h.
That file is not used by this package, which force-includes its own
compat-hacks.h instead, so the same fix has to be applied here as
well. slab.h is included explicitly, because unlike the upstream
file this header does not otherwise pull it in.

Upstream-Status: Backport [96a26bababe5e9c9b9f9226e7cdbe60f49f57b71]

Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed 1 amended commit. The branch was rebased onto current master and the last commit was reworked in place (f07112c6862bac), so the only new content in net/batman-adv/ since the previous round is six lines in src/compat-hacks.h; nothing else in the package changed.

The #include <linux/slab.h> resolves the previous round's finding — the #ifndef kzalloc_obj guards no longer depend on an unrelated conditional above having pulled slab.h in first, so the header is self-contained now. The expanded commit message is also a better description of the problem than the one it replaces: "specific stable backports" rather than naming 6.18.33 is what the #ifndef approach actually buys.

One inline question about the other half of that hunk, the new #if LINUX_VERSION_IS_LESS(7, 0, 0) wrapper, plus a one-click nit on its #endif comment. Neither blocks a merge.

I could not verify the Upstream-Status: Backport [96a26ba...] reference or the "mirrors compat-include/linux/slab.h" claim — this session is restricted to openwrt/packages and cannot reach open-mesh's repository. Same caveat as earlier rounds applies to "content matches the current routing feed master".

CI on this head was still in progress at review time (ten build targets in flight, FormalityCheck green), so I cannot confirm the four 6.12 targets that failed two rounds ago now pass. Nothing is red.

Still open from earlier rounds, not repeated inline: +batctl is a hard dependency on a package that is still absent from this feed (net/batctl does not exist on master as of 91a6967) — a sequencing question for the feed move rather than a defect in this diff — and the squash suggestion, which now covers three fixups to files this same series introduces.


Generated by Claude Code

kmalloc_array((COUNT), sizeof(P), GFP)
#endif /* kmalloc_objs */

#endif /* < KERNEL_VERSION(7, 0, 0) */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The commit message frames the fix as dropping a version range in favour of guarding on the macro name ("without having to track which point release of which stable series picked up the backport"), but this hunk wraps the three #ifndef blocks in a new version range. With the #ifndefs already in place, < 7.0.0 cannot change the outcome for any kernel that exists — and if a 7.x kernel ever did ship without these helpers, the guard would break the build rather than protect it. Is it here to mirror upstream's compat-include/linux/slab.h (this session only reaches openwrt/packages, so I could not check open-mesh's tree or the 96a26ba reference in the commit message), or can it go?

nit, and independent of the above: the closing comment names KERNEL_VERSION(7, 0, 0) while the condition it closes is LINUX_VERSION_IS_LESS(7, 0, 0). Every other guard in this file repeats its condition verbatim — line 47 #endif /* LINUX_VERSION_IS_LESS(6, 16, 0) || !defined(CONFIG_NET_CRC32C) */, and the three #endif /* kzalloc_obj */-style comments this same commit added.

Suggested change
#endif /* < KERNEL_VERSION(7, 0, 0) */
#endif /* LINUX_VERSION_IS_LESS(7, 0, 0) */

Generated by Claude Code

BKPepe added a commit to BKPepe/openwrt-routing that referenced this pull request Aug 11, 2026
The package has been moved to the openwrt/packages feed, as
discussed in openwrt#184.

See openwrt/packages#30164.

Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@DamisDorgon

Copy link
Copy Markdown

Why was the routing feed package removed before this was merged?

@geldot

geldot commented Aug 16, 2026

Copy link
Copy Markdown

Adds batman-adv from the openwrt/routing feed — the routing packages are being moved into openwrt/packages one by one, as discussed in openwrt/routing#184.

Wouldn't it be better to merge unrelated histories to maintain the commit log? It would appear as an ordinary merge commit here (no rewrite needed) but git log --follow/blame etc. would work.

@simonwunderlich

Copy link
Copy Markdown

@BKPepe we (@ecsv and myself) reviewed the changes, including the compat changes, and think this is good to be merged. batctl and alfred, which are connected to batman-adv were already merged (#30161, #30163), so by merging this pull request we should be able to mesh again with batman-adv. :)

@BKPepe
BKPepe merged commit 53bafc0 into openwrt:master Aug 18, 2026
14 checks passed
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.

7 participants