Compare commits

...

91 commits

Author SHA1 Message Date
Toke Høiland-Jørgensen
820bb60ac2
Merge pull request #898 from mbargo23/bird19.07
bird2: bump to version 2.0.10
2022-06-29 15:10:52 +02:00
Jan Betik
790bffb57a
bird2: bump to version 2.0.10
Signed-off-by: Jan Betik <jan.betik@nic.cz>
(cherry picked from commit 1fa9fa339c)
2022-06-29 14:37:35 +02:00
Petr Štetiar
33254957df ci: use openwrt/gh-action-sdk@v4
In order to use feeds from GH mirror for GH actions, thus saving a lot
of resources being wasted. While at it fix whitespace issue.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
[applied to routing feed]
[whitespace issue not existing in routing feed]
Signed-off-by: Nick Hainke <vincent@systemli.org>
(cherry picked from commit 5702d2e40b)
2022-03-30 23:31:07 +02:00
Paul Spooren
6c7306602a CI: update SDK action to v3
No also check mirror hashes and badly formated init files

Signed-off-by: Paul Spooren <mail@aparcar.org>
[applied to routing feed]
Signed-off-by: Nick Hainke <vincent@systemli.org>
(cherry picked from commit 2134c56d12)
2022-03-30 23:31:07 +02:00
Josef Schlehofer
8f23999365 ahcpd: use SHA256 hash and use HTTPS everywhere
- The old page redirects to a new one and it uses HTTPS.
Let's skip that redirect in PKG_SOURCE_URL and URL.
- Reorder some things to be sync with Makefiles in packages feed
- Add PKG_LICENSE_FILES

Fixes: 47edf2d275 (ahcpd: Replace
PKG_MD5SUM with PKG_HASH)
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
(cherry picked from commit 6debd2f564)
2022-02-28 20:07:53 +01:00
Rosen Penev
04e7f66aa7 mcproxy: Fix compilation with uClibc-ng
uClibc-ng also defines __GLIBC__, which messes up the check.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
(cherry picked from commit b3ebe49dab)
2022-02-28 12:43:08 +01:00
Rosen Penev
bf77e5f0e0 cjdns-tests: Don't build on ARC (#487)
Not supported.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
(cherry picked from commit 9f5d42692e)
2022-02-28 12:43:08 +01:00
Rosen Penev
01417ad681 cjdns: Do not build on ARC
Is not supported by node.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
(cherry picked from commit ac8fc386fc)
2022-02-28 12:43:08 +01:00
Josef Schlehofer
653ec59929 olsrd: remove empty .gitignore file
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
2022-02-28 12:43:08 +01:00
Josef Schlehofer
3f095f7f7e pimbd: add PKG_MIRROR_HASH
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
2022-02-28 12:43:08 +01:00
Josef Schlehofer
c1a2f7a252 oonf-olsrd2: add PKG_MIRROR_HASH
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
2022-02-28 12:43:08 +01:00
Josef Schlehofer
2f9236d864 oonf-dlep-radio: add PKG_MIRROR_HASH
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
2022-02-28 12:43:08 +01:00
Josef Schlehofer
20f3e51710 oonf-dlep-proxy: add PKG_MIRROR_HASH
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
2022-02-28 12:43:08 +01:00
Josef Schlehofer
e05cb068c4 olsrd: add PKG_MIRROR_HASH
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
2022-02-28 12:43:08 +01:00
Josef Schlehofer
e37cf04da4 ohybridproxy: add PKG_MIRROR_HASH, refresh patch
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
2022-02-28 12:43:08 +01:00
Josef Schlehofer
95cd0ce4b5 mrd6: add PKG_MIRROR_HASH
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
2022-02-28 12:43:08 +01:00
Josef Schlehofer
00eacef47b minimalist-pcproxy: add PKG_MIRROR_HASH
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
2022-02-28 12:43:08 +01:00
Josef Schlehofer
84b7b3c553 mcproxy: add PKG_MIRROR_HASH
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
2022-02-28 12:43:08 +01:00
Josef Schlehofer
f17815946a hnetd: add PKG_MIRROR_HASH, refresh patch
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
2022-02-28 12:43:08 +01:00
Josef Schlehofer
372ec62886 cjdns: add PKG_MIRROR_HASH
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
2022-02-28 12:43:08 +01:00
Nick Hainke
ce5adaab95 CI: fix multi-arch-test-build for 19.07 branch
The "i386_pentium-mmx" does not exist in 19.07.

Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-02-26 17:23:43 +01:00
Paul Spooren
2ed5a04ab8 CI: fix runtime testing for non master branch
The runtime testing always ran on master branch aka snapshots since the
branch wasn't passed over to the container execution!

Signed-off-by: Paul Spooren <mail@aparcar.org>
(cherry picked from commit 817240b07c)
2022-02-26 17:23:43 +01:00
Sven Roederer
c755ab8dce issuetemplate: reference foreign repos
As we are the routing-feed, we don't care for packages of the base-, luci- and packages-feed.

Signed-off-by: Sven Roederer <devel-sven@geroedel.de>
(cherry picked from commit b81e9c8bab)
2022-02-26 17:23:43 +01:00
Nick Hainke
cccff55a62 CI: fix building multi-arch-test-build
The sed is adding the package name as "PKGNAME/" and does not remove
the "/". That is why the buildchain currently fails.

Signed-off-by: Nick Hainke <vincent@systemli.org>
(cherry picked from commit b65879895a)
2022-02-26 17:23:43 +01:00
Nick Hainke
63625f7e19 CI: copy .github from openwrt-packages
Just copy .github from openwrt enabling:
- checking of formalities
- checking of build
- issue template
- pr template

Signed-off-by: Nick Hainke <vincent@systemli.org>
(cherry picked from commit d1ab87b7db)
2022-02-26 17:23:43 +01:00
Simon Wunderlich
a30ac2558e
Merge pull request #783 from ecsv/batadv-for-19.07
openwrt-19.07: batman-adv: Merge bugfixes from 2022.0
2022-02-03 21:21:57 +01:00
Sven Eckelmann
df9f33c522 batman-adv: Merge bugfixes from 2022.0
* allow netlink usage in unprivileged containers

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2022-02-03 20:19:34 +01:00
Simon Wunderlich
ee0fbac610
Merge pull request #752 from ecsv/batadv-for-19.07
openwrt-19.07: batman-adv: Merge bugfixes from 2021.4
2021-11-19 17:54:51 +01:00
Sven Eckelmann
7a3e63fd45 batman-adv: Merge bugfixes from 2021.4
* fix error handling during interface initialization

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2021-11-19 17:20:13 +01:00
Sven Eckelmann
c8734df677 batman-adv: Refresh patches with quilt
The test builds are now requiring quilt refreshed patches instead of git
patches. Otherwise the build check will not even try to build something.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2021-11-19 17:17:04 +01:00
Simon Wunderlich
ef3e03a367
Merge pull request #718 from ecsv/batadv-for-19.07
openwrt-19.07: batman-adv: Merge bugfixes from 2021.2
2021-08-20 22:46:55 +02:00
Sven Eckelmann
3c10076826 batman-adv: Merge bugfixes from 2021.2
* Avoid WARN_ON timing related checks

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2021-08-20 11:59:36 +02:00
Simon Wunderlich
101632e153
Merge pull request #658 from ecsv/batadv-for-19.07
openwrt-19.07: batman-adv: Merge bugfixes from 2021.1
2021-05-18 19:09:21 +02:00
Sven Eckelmann
a995b62043 batman-adv: Merge bugfixes from 2021.1
* initialize "struct batadv_tvlv_tt_vlan_data"->reserved field

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2021-05-14 20:59:43 +02:00
Josef Schlehofer
118536cfb0 bird2: Makefile polishing
- Just small reodering of some rows to be more consistent with packages feed
- Fix deprecated SPDX License Identifier

Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
(cherry picked from commit b38a46acd5)
2021-04-02 10:33:16 +02:00
Josef Schlehofer
9d6ef13203 bird2: update to version 2.0.8
- Removed patch as it is now included in upstream release
- Removed --with-linux-headers option
(Fixes: configure: WARNING: unrecognized options: --with-linux-headers)

Changelog:
https://bird.network.cz/pipermail/bird-users/2021-March/015281.html

Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
2021-04-02 10:33:16 +02:00
Simon Wunderlich
e26b474520
Merge pull request #644 from ecsv/batadv-for-19.07
openwrt-19.07: alfred: Fix state handling for startup and restart/reload of alfred
2021-02-16 08:45:44 +01:00
Sven Eckelmann
369908cb0a alfred: Start up alfred without valid interfaces
The alfred server always needs interfaces to operate on. But these
interfaces might not exist at the moment when the daemon process is
started. This situation stopped the startup process after the init scripts
waited for a longer period of polling the system state.

But alfred is able to deal with interfaces which disappeared at runtime but
existed at startup. To force a similar behavior for the alfred startup, the
parameter "--force" or "-f" is used. The extra polling code is therefore no
longer needed in the init scripts.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2021-02-15 21:33:27 +01:00
Sven Eckelmann
97e7600955 alfred: Fix procd process handling for disable state
Alfred can be stopped during a (re)start or reload when:

* disabled = 1
* batman-adv interface is missing
* MAC based EUI64 IPv6 link-local address not set

It is assumed that procd detects that the procd instance definition
disappeared and the currently running instance must be stopped. But all
these checks were triggering an "exit" which then stopped the alfred init
script and the wrapper from /lib/functions/procd.sh. And thus procd was
never informed about the instances which should be changed.

The correct handling is to return the result of the function instead of
directly killing the init scripts.

Fixes: 45db0e60d2 ("alfred: use procd")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2021-02-15 21:28:09 +01:00
Simon Wunderlich
0a3432d633
Merge pull request #636 from ecsv/batadv-for-19.07
openwrt-19.07: batman-adv: Merge bugfixes from 2021.0
2021-01-28 22:26:11 +01:00
Sven Eckelmann
596dc84b65 batman-adv: Merge bugfixes from 2021.0
* set .owner to THIS_MODULE
* Consider fragmentation for needed_headroom
* Reserve needed_*room for fragments
* Don't always reallocate the fragmentation skb head

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2021-01-28 21:44:03 +01:00
Sven Eckelmann
862a2dfb5f batctl: Merge bugfixes from 2021.0
* Don't stop when create_interface detected existing interface
* Fix retrieval of meshif ap_isolation

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2021-01-28 21:34:50 +01:00
Simon Wunderlich
02b4dbfcb7
Merge pull request #620 from ecsv/batadv-for-19.07
openwrt-19.07: batman-adv: Merge bugfixes from 2020.4
2020-10-27 15:03:08 +01:00
Sven Eckelmann
59e8d5fa8c batctl: Merge bugfixes from 2020.4
* tcpdump: Fix endianness in ICMPv6 Echo Request/Reply parsing

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2020-10-24 21:45:15 +02:00
Sven Eckelmann
685968996f batman-adv: Merge bugfixes from 2020.4
* bla: fix type misuse for backbone_gw hash indexing
* mcast/TT: fix wrongly dropped or rerouted packets
* Add missing include for in_interrupt()
* mcast: fix duplicate mcast packets in BLA backbone from LAN
* mcast: fix duplicate mcast packets in BLA backbone from mesh
* mcast: fix duplicate mcast packets from BLA backbone to mesh

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2020-10-24 21:40:40 +02:00
Simon Wunderlich
b77498bd56
Merge pull request #603 from ecsv/batadv-for-19.07
openwrt-19.07: batman-adv: Merge bugfixes from 2020.3
2020-08-27 10:27:20 +02:00
Sven Eckelmann
6dea537c07 batman-adv: Merge bugfixes from 2020.3
* Avoid uninitialized chaddr when handling DHCP
* Fix own OGM check in aggregated OGMs
* bla: use netif_rx_ni when not in interrupt context

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2020-08-25 20:36:05 +02:00
Moritz Warning
0e5c75f536
Merge pull request #601 from bluewavenet/openwrt-19.07
openwrt-19.07: opennds: Backport v5.2.0
2020-08-25 08:51:18 +02:00
Rob White
ad8f02a4aa opennds: Backport v5.2.0
Designed to replace the old NoDogsplash v4.0.3
NoDogSplash v4.0.3 still contains the FAS API but has numerous bugs,
some serious, but is no longer supported as the decision was made to
split into two projects - openNDS with FAS and NoDoGSplash optimised for
devices with minimal resources.

This version of openNDS is functionally the same as v6.0.0, but supports
libmicrohttpd (MHD) versions up to 0.9.70 that use the old MHD API.

There are many additions and bugfixes over NoDogSplash v4.0.3.
eg support for HTTPS remote FAS and support for upload/download quotas.

From the Changelog:
openNDS (5.2.0)

  * This version - for backport to Openwrt 19.07 - for compatibility with old MHD API
  * Fix - Failure of MHD with some operating systems eg Debian [bluewavenet]
  * Fix - potential buffer truncation in ndsctl
  * Set - use_outdated_mhd to 1 (enabled) as default [bluewavenet]
  * Set - maximum permissible version of MHD to 0.9.70 to ensure old MHD API is used [bluewavenet]

openNDS (5.1.0)

  * Add - Generic Linux - install opennds.service [bluewavenet]
  * Add - Documentation updates [bluewavenet]
  * Add - config file updates [bluewavenet]
  * Add - Install sitewide username/password splash support files [bluewavenet]
  * Add - quotas to binauth_sitewide [bluewavenet]
  * Add - Splash page updates [bluewavenet]
  * Add - Implement Rate Quotas [bluewavenet]
  * Fix - check if idle preauthenticated [bluewavenet]
  * Add - support for rate quotas [bluewavenet]
  * Fix - Correctly compare client counters and clean up debuglevel messages [bluewavenet]
  * Add - Implement upload/download quotas Update fas-aes-https to support quotas [bluewavenet]
  * Add - Rename demo-preauth scripts and install all scripts [bluewavenet]
  * Add - fas-aes-https layout update [bluewavenet]
  * Add - Set some defaults in fas-aes-https [bluewavenet]
  * Add - custom data string to ndsctl auth [bluewavenet]
  * Add - custom data string to fas-hid.php [bluewavenet]
  * Add - Send custom data field to BinAuth via auth_client method [bluewavenet]
  * Fix - missing token value in auth_client [bluewavenet]
  * Add - upload/download quota and rate configuration values [bluewavenet]
  * Add - Send client token to binauth [bluewavenet]
  * Add - Rename upload_limit and download_limit to upload_rate and download_rate [bluewavenet]
  * Fix - Pass correct session end time to binauth [bluewavenet]
  * Add - some debuglevel 3 messages [bluewavenet]
  * Add - description of the favicon and page footer images [bluewavenet]
  * Add - Authmon collect authentication parameters from fas-aes-https [bluewavenet]
  * Add - sessionlength to ndsctl auth [bluewavenet]
  * Fix - Page fault when ndsctl auth is called and client not found [bluewavenet]
  * Add - Enable BinAuth / fas_secure_enabled level 3 compatibility [bluewavenet]
  * Fix - Correctly set BinAuth session_end [bluewavenet]
  * Add - Updates to Templated Splash pages [bluewavenet]
  * Add - Community Testing files [bluewavenet]
  * Fix - BinAuth error passing client session times [bluewavenet]
  * Fix - PHP notice - undefined constant [bluewavenet]
  * Fix - OpenWrt CONFLICTS variable in Makefile [bluewavenet]

openNDS (5.0.1)

  * Fix - Path Traversal Attack vulnerability allowed by libmicrohttpd's built in unescape functionality [bluewavenet] [lynxis]

openNDS (5.0.0)

  * Import - from NoDogSplash 4.5.0 allowing development without compromising NoDogSplash optimisation for minimum resource utilisation [bluewavenet]
  * Rename - from NoDogSplash to openNDS [bluewavenet]
  * Create - openNDS avatar and splash image [bluewavenet]
  * Move - wait_for_interface to opennds C code ensuring consistent start at boot time for all hardware, OpenWrt and Debian [bluewavenet]
  * Add - Enable https protocol for remote FAS [bluewavenet]
  * Add - trusted devices list to ndsctl json output [bluewavenet]
  * Add - option unescape_callback_enabled [bluewavenet]
  * Add - get_client_token library utility [bluewavenet]
  * Add - utf-8 to PreAuth header [bluewavenet]
  * Add - PreAuth Support for hashed id (hid) if sent by NDS [bluewavenet]
  * Add - library script shebang warning for systems not running Busybox [bluewavenet]
  * Add - htmlentityencode function, encode gatewayname in templated splash page [bluewavenet]
  * Add - htmlentity encode gatewayname on login page (PreAuth) [bluewavenet]
  * Add - Simple customisation of log file location for PreAuth and BinAuth [bluewavenet]
  * Add - option use_outdated_mhd [bluewavenet]
  * Add - url-encode and htmlentity-encode gatewayname on startup [bluewavenet]
  * Add - Allow special characters in username (PreAuth) [bluewavenet]
  * Add - Documentation updates [bluewavenet]
  * Add - Various style and cosmetic updates  [bluewavenet]
  * Fix - Change library script shebang to bash in Debian [bluewavenet]
  * Fix - Remove unnecessary characters causing script execution failure in Debian [bluewavenet]
  * Fix - Add missing NULL parameter in MHD_OPTION_UNESCAPE_CALLBACK [skra72] [bluewavenet]
  * Fix - Script failures running on Openwrt 19.07.0 [bluewavenet]
  * Fix - Preauth, status=authenticated [bluewavenet]
  * Fix - Prevent ndsctl from running if called from a Binauth script. [bluewavenet]
  * Fix - Minor changes in Library scripts for better portability [bluewavenet]
  * Fix - Prevent php notices on pedantic php servers [bluewavenet]
  * Fix - broken remote image retrieval (PreAuth) [bluewavenet]
  * Fix - Allow use of "#" in gatewayname [bluewavenet]

Tested on mips_24kc, mipsel_24kc, arm_cortex-a7_neon-vfpv4 and x86_64 platforms.

Signed-off-by: Rob White <rob@blue-wave.net>
2020-08-24 13:08:37 +01:00
Sven Eckelmann
017d89d569 batctl: Enable build of mcast_flags subcommand
The mcast_flags subcommand allows to query the mcast_flags of the current
device and of the seen originators. It should be enabled for the default
and full variants. But the configuration string wasn't correctly included
in the list when the variants were prepared and thus disabled in all
variants.

Reported-by: Linus Lüssing <linus.luessing@c0d3.blue>
Fixes: 1299868252 ("batctl: Provide different variants")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2020-07-21 22:38:40 +02:00
Simon Wunderlich
ad79a0f065
Merge pull request #584 from ecsv/batadv-for-19.07
openwrt-19.07: batman-adv: Merge bugfixes from 2020.1
2020-07-07 09:20:00 +02:00
Sven Eckelmann
4c05fe97d9 batman-adv: Merge bugfixes from 2020.2
* Revert "disable ethtool link speed detection when auto negotiation off"

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2020-07-06 20:08:55 +02:00
Sven Eckelmann
822b55ff7d batctl: Merge bugfixes from 2020.2
* fix endianness when reading radiotap header
* Only remove batadv interface on hardif reduction

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2020-07-06 20:04:33 +02:00
Alexander Couzens
3f8571194c nodogsplash: update to 4.0.3
Fix a traversal path attack.

Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
2020-05-06 13:24:58 +02:00
Simon Wunderlich
9b42e24a54
Merge pull request #563 from ecsv/batadv-for-19.07
openwrt-19.07: batman-adv: Merge bugfixes from 2020.1
2020-04-27 10:25:41 +02:00
Sven Eckelmann
5dd2f44a5b batman-adv: Merge bugfixes from 2020.1
* fix batadv_nc_random_weight_tq
* Fix refcnt leak in batadv_show_throughput_override
* Fix refcnt leak in batadv_store_throughput_override
* Fix refcnt leak in batadv_v_ogm_process

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2020-04-24 21:06:04 +02:00
Sven Eckelmann
8b25c90ed6 batctl: Merge bugfixes from 2020.1
* Return EXIT_FAILURE when throughputmeter failed

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2020-04-24 20:46:29 +02:00
Sven Eckelmann
094e9b0f94 batctl: Fix upstream reference in backported patch
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2020-04-24 20:46:00 +02:00
zorun
20b98f094e
Merge pull request #560 from fblaese/babeld
[19.07] babeld: Update to version 1.9.2
2020-04-22 14:32:50 +02:00
Fabian Bläse
bd25cae2c4 babeld: Update to version 1.9.2
21 April 2020: babeld-1.9.2

  * Fixed two issues that could cause IPv4 routes to be represented
    incorrectly, with a range of confusing symptoms.  Thanks to
    Fabian Bläse.
  * Fixed incorrect parsing of TLVs with an unknown Address Encoding.
    Thanks to Théophile Bastian.
  * Fixed access to mis-aligned data structure.  Thanks to Antonin Décimo.

Signed-off-by: Fabian Bläse <fabian@blaese.de>
2020-04-22 14:08:05 +02:00
Moritz Warning
9f21b212ef
Merge pull request #558 from BKPepe/bird2-19.07-bump
[19.07] bird2: backport from master update to version 2.0.7 + fix restart&reload
2020-04-02 20:54:16 +02:00
Yuxiang Zhu
dc81e506ca
bird2: fix service restart and reload (#546)
`/etc/init.d/bird restart` or `/etc/init.d/bird reload` has no effects.

This PR fixes this issue by:

- running the service in the foreground to meet the requirements of procd
- sending SIGHUP signal to reload the service
2020-03-28 21:55:55 +01:00
Toke Høiland-Jørgensen
6e51cca4ea
bird2: Update to v2.0.7 (#516)
Bump release to upstream v2.0.7

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
2020-03-28 21:53:54 +01:00
Josef Schlehofer
3a800853d6
bird2: Update to version 2.0.6
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
2020-03-28 21:53:49 +01:00
Toke Høiland-Jørgensen
38f2ed9466
bird2: Bump to v2.0.5
Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
2020-03-28 21:53:33 +01:00
Simon Wunderlich
b8fd8c8b9f
Merge pull request #554 from ecsv/batadv-for-19.07
openwrt-19.07: batman-adv: Merge bugfixes from 2020.0
2020-03-10 17:08:52 +01:00
Sven Eckelmann
18a724e154 batman-adv: Merge bugfixes from 2020.0
* Don't schedule OGM for disabled interface

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2020-03-06 20:51:17 +01:00
Pedro hates github.com
efa6e5445a luci-app-bmx6: bugfix querying bmx6-info (p2)
see 51b370e1ce and #550
2020-02-26 15:21:25 +01:00
pedrolab
f1b0476edc luci-app-bmx6: bugfix format to query bmx6-info
- affected three tab luci templates (even with luci-compat installed)
- fixes #548
- as jow said in #548:
  - it might be that modern LuCI escapes it as %24 while old versions passed it
    on as-is
  - bmx6-info removes it anyway
    https://github.com/openwrt-routing/packages/blob/master/luci-app-bmx6/bmx6/www/cgi-bin/bmx6-info#L22
you can probably just remove it in all three tab templates

(cherry picked from commit b92f82ad1f)
2020-02-21 12:55:11 +01:00
Josef Schlehofer
839ea37939 quagga: update to version 1.1.1 (#541)
Makefile changes:
- Use HTTPS everywhere
- Reorder some things to have it in sync with other packages
- Fixed SPDX License Identifier
- Added PKG_LICENSE_FILES
- For checksum use SHA256

Refreshed patches

Fixes CVEs:
- CVE-2017-5495
- CVE-2017-16227

Fixes security issues:
- Quagga-2018-0543: attr_endp used for NOTIFY data
https://gogs.quagga.net/Quagga/quagga/src/master/doc/security/Quagga-2018-0543.txt
- Quagga-2018-1114: bgpd double free
https://gogs.quagga.net/Quagga/quagga/src/master/doc/security/Quagga-2018-1114.txt
- Quagga-2018-1550: debug overrun in notify lookup tables
https://gogs.quagga.net/Quagga/quagga/src/master/doc/security/Quagga-2018-1550.txt
- Quagga-2018-1975: BGP capability inf. loop
https://gogs.quagga.net/Quagga/quagga/src/master/doc/security/Quagga-2018-1975.txt

Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
2020-01-27 23:58:39 +01:00
Simon Wunderlich
c82ce8d095
Merge pull request #536 from ecsv/batadv-for-19.07
openwrt-19.07: batman-adv: Merge bugfixes from 2019.5
2019-12-14 16:59:11 +01:00
Sven Eckelmann
242185e386 batman-adv: Merge bugfixes from 2019.5
* fix DAT candidate selection on little endian systems

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2019-12-13 22:16:19 +01:00
Simon Wunderlich
8d5ee29f08
Merge pull request #519 from ecsv/batadv-for-19.07
openwrt-19.07: batman-adv: Merge bugfixes from 2019.4
2019-10-26 10:30:30 +02:00
Sven Eckelmann
a2f2a13386 batman-adv: Merge bugfixes from 2019.4
* fix uninit-value in batadv_netlink_get_ifindex()
* Only read OGM tvlv_len after buffer len check
* Only read OGM2 tvlv_len after buffer len check
* Avoid free/alloc race when handling OGM2 buffer
* Avoid free/alloc race when handling OGM buffer
* Introduce own OGM2 buffer mutex
* Avoid OGM workqueue synchronous cancel deadlock

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2019-10-25 22:25:10 +02:00
zorun
931f947dd6
Merge pull request #505 from zorun/babeld-1.9-openwrt-19.07
[openwrt-19.07] babeld: Update to 1.9.1 and assorted fixes
2019-08-26 21:06:38 +02:00
Baptiste Jonglez
56878ac500 babeld: Update example configuration file
More example filters are provided, and new options such as "type" or
"pref_src" are given as example.

Signed-off-by: Baptiste Jonglez <git@bitsofnetworks.org>
2019-08-26 20:54:56 +02:00
Baptiste Jonglez
e53bb5eed6 babeld: Update description in Makefile and fix license path
Signed-off-by: Baptiste Jonglez <git@bitsofnetworks.org>
2019-08-26 19:31:54 +02:00
Adrian Schmutzler
774b7c60d7 babeld: Update to version 1.9.1
20 August 2019: babeld-1.9.1

  * Fixed a crash that could happen when unicast and RTT estimation are
    both enabled on an interface.  Thanks to Dave Taht.
  * Fixed compilation under BSD.  Thanks to Dave Taht.

4 August 2019: babeld-1.9.0

  * Reworked buffering of unicast packets to use a per-neighbour buffer
    rather than a single buffer per interface.  This makes unicast as
    efficient as multicast, at the cost of slightly higher memory usage.
  * Added option "unicast" that allows sending most TLVs over unicast.
    This is necessary for the DTLS extension.
  * Implemented parsing of unicast Hellos.  This makes it possible to
    interoperate with neighbours that only speak unicast (e.g. over some
    kinds of tunnels that only do unicast).
  * Implemented sending of unscheduled unicast Hellos.  This makes the
    RTT extension work over unicast too.
  * Reworked the xroute data structures to use binary search and
    linear-time comparison.
  * Don't attempt to modify the rp_filter sysctl if it already has the
    desired value; this makes it possible to run babeld in an
    unpriviledged container.  Thanks to Christof Schulze.
  * Reinstated logging of late hellos.  Thanks to Dave Taht.
  * Don't send wildcard requests or Hellos to newish nodes.  This makes
    acquisition of new neighbours slower, but drastically reduces noise at
    startup.  Thanks to Teco Boot.
  * Remove an arbitrary limit on the number of interfaces.  Thanks to
    Christof Schulze.
  * Removed class E from martian filter.  Thanks to Dave Taht.
  * Added the ability to set the preferred source address in install filters.
    Thanks to Killian Lufau.
  * Fixed a number of read-only buffer overflows.  Thanks to Leo Stefanesco.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-08-26 19:31:50 +02:00
Adrian Schmutzler
953cd03492 babeld: Improve Makefile formatting
This applies some style improvements to make this ready for
migration to openwrt/packages.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-08-26 19:31:46 +02:00
Adrian Schmutzler
e0787e950d babeld: Update to version 1.8.5
Changes:

  * Fixed a bug that caused confustion between learned routes and
    imported routes (thanks to Fabian Bläse).
  * Fixed a bug that prevented install filters from being evaluated
    (thanks to Killian Lufau).

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-08-26 19:31:43 +02:00
Baptiste Jonglez
e0b319cb9f babeld: Don't kill -9 on stop
Killing anything with -9 is a bad idea.  When killed this way, babeld
won't be able to properly disassociate from its neighbours, withdraw its
announced routes or remove routes from the kernel.

This got introduced in bab933d4ca ("babeld: Update to version 1.8.3 +
fix init") with an unrelated change.  The purpose of the change is unclear
because stopping and restarting babeld worked fine without this change.

Signed-off-by: Baptiste Jonglez <git@bitsofnetworks.org>
2019-08-26 19:29:08 +02:00
Simon Wunderlich
66c20292c6
Merge pull request #498 from ecsv/batadv-for-19.07
batman-adv: Readd Linux 4.19.x compat patches
2019-08-04 13:33:29 +02:00
Sven Eckelmann
b04d24313d batman-adv: Readd Linux 4.19.x compat patches
The patches were accidentally deleted while testing the batman-adv 2019.3
bugfixes with various OpenWrt versions. But OpenWrt 19.07 will be released
with a mac80211 package which still uses the Linux 4.19 API. And thus the
OpenWrt 19.07 openwrt-routing branch still has to retain these compat
patches.

Fixes: a93e68447a ("alfred: Merge bugfixes from 2019.3")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2019-08-04 08:16:01 +02:00
Simon Wunderlich
784ae0e42d
Merge pull request #496 from ecsv/batadv-for-19.07
openwrt-19.07: batman-adv: Merge bugfixes from 2019.3
2019-08-02 09:53:13 +02:00
Sven Eckelmann
9d559fdae9 batman-adv: Merge bugfixes from 2019.3
* Fix netlink dumping of all mcast_flags buckets

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2019-08-01 19:47:11 +02:00
Sven Eckelmann
d65d6f1ea3 batctl: Merge bugfixes from 2019.3
* Prefer netlink hardif status retrieval over sysfs

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2019-08-01 19:47:11 +02:00
Sven Eckelmann
6ea9e9b093 batctl: Upgrade hardif settings patches to upstream version
The hardif patches were added to OpenWrt before they were accepted in the
upstream repository. This seemed necessary at that time because OpenWrt
19.07 was alreadu branched of (to be released soon).

But the upstream merged patches contain more cleanups. Having the actual
upstream version in OpenWrt make it easier to integrate potential bugfixes.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2019-08-01 19:47:11 +02:00
Sven Eckelmann
a93e68447a alfred: Merge bugfixes from 2019.3
* vis: Use rtnl to query list of hardifs of meshif
* vis: Retrieve hardif status via generic netlink

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2019-08-01 19:47:11 +02:00
Rob White
830440d25a nodogsplash: Backport Version 4.0.1. (#494)
This version has numerous fixes and enhancements.
It is compatible with the previous v3.2.1 release and onwards.

Important fixes in this version:
 * Fix coding error in fas-aes.php [bluewavenet]
 * Make debuglevel platform independent [mwarning]
 * Fix memory handling bug, issue nodogsplash/nodogsplash#341 [mwarning] [stevo01]
 * ndsctl_thread - ignore interupts when returning from epoll [lynxis]
 * auth.c - use correct types to prevent cast and comparement of uint and int [lynxis]
 * openwrt/init.d - prevent start of the daemon if configuration generation fails [lynxis]
 * Generate Error 403 Forbidden, if Gateway Port is accessed directly [bluewavenet]
 * Validate fasremoteip as a valid dotted format IPv4 address [bluewavenet] [mwarning]
 * Prevent client CPD "Too Many Redirects" error. [bluewavenet]

Maintainer: Moritz Warning <moritzwarning@web.de>

Signed-off-by: Rob White <rob@blue-wave.net>
2019-07-30 16:21:40 +02:00
Toke Høiland-Jørgensen
bef6617141 bird2: Bump to v2.0.4
Bird 2.0.4 was released on March 1st. Remove upstreamed patches.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
(cherry picked from commit 37f8c509e0)
2019-06-26 19:28:58 +02:00
Josef Schlehofer
18ec6d717b bird1: update to version 1.6.6
Signed-off-by: Josef Schlehofer <josef.schlehofer@nic.cz>
(cherry picked from commit 6141d5d182)
2019-06-26 19:24:56 +02:00
111 changed files with 4809 additions and 735 deletions

16
.github/issue_template vendored Normal file
View file

@ -0,0 +1,16 @@
Please make sure that the issue subject starts with `<package-name>: `
Also make sure that the package is maintained in this repository and not in OpenWrt-base, OpenWrt-packages or OpenWrt-LuCI.
Issues related to releases below 18.06 and forks are not supported or maintained and will be closed.
# Issue template (remove lines from top till here)
Maintainer: @\<github-user> (find it by checking history of the package Makefile)
Environment: (put here arch, model, OpenWrt version)
Description:
```
Formating code blocks by wrapping them with pairs of ```
```

5
.github/pull_request_template vendored Normal file
View file

@ -0,0 +1,5 @@
Maintainer: me / @\<github-user> (find it by checking history of the package Makefile)
Compile tested: (put here arch, model, OpenWrt version)
Run tested: (put here arch, model, OpenWrt version, tests done)
Description:

6
.github/workflows/Dockerfile vendored Normal file
View file

@ -0,0 +1,6 @@
ARG ARCH=x86-64
FROM openwrt/rootfs:$ARCH
ADD entrypoint.sh /entrypoint.sh
CMD ["/entrypoint.sh"]

26
.github/workflows/ci_helpers.sh vendored Normal file
View file

@ -0,0 +1,26 @@
#!/bin/sh
color_out() {
printf "\e[0;$1m$PKG_NAME: %s\e[0;0m\n" "$2"
}
success() {
color_out 32 "$1"
}
info() {
color_out 36 "$1"
}
err() {
color_out 31 "$1"
}
warn() {
color_out 33 "$1"
}
err_die() {
err "$1"
exit 1
}

39
.github/workflows/entrypoint.sh vendored Executable file
View file

@ -0,0 +1,39 @@
#!/bin/sh
mkdir -p /var/lock/
opkg update
[ -n "$CI_HELPER" ] || CI_HELPER="/ci/.github/workflows/ci_helpers.sh"
for PKG in /ci/*.ipk; do
tar -xzOf "$PKG" ./control.tar.gz | tar xzf - ./control
# package name including variant
PKG_NAME=$(sed -ne 's#^Package: \(.*\)$#\1#p' ./control)
# package version without release
PKG_VERSION=$(sed -ne 's#^Version: \(.*\)-[0-9]*$#\1#p' ./control)
# package source contianing test.sh script
PKG_SOURCE=$(sed -ne 's#^Source: .*/\(.*\)$#\1#p' ./control)
echo "Testing package $PKG_NAME in version $PKG_VERSION from $PKG_SOURCE"
opkg install "$PKG"
export PKG_NAME PKG_VERSION CI_HELPER
TEST_SCRIPT=$(find /ci/ -name "$PKG_SOURCE" -type d)/test.sh
if [ -f "$TEST_SCRIPT" ]; then
echo "Use package specific test.sh"
if sh "$TEST_SCRIPT" "$PKG_NAME" "$PKG_VERSION"; then
echo "Test succesful"
else
echo "Test failed"
exit 1
fi
else
echo "No test.sh script available"
fi
opkg remove "$PKG_NAME" --force-removal-of-dependent-packages --force-remove
done

63
.github/workflows/formal.yml vendored Normal file
View file

@ -0,0 +1,63 @@
name: Test Formalities
on:
pull_request:
jobs:
build:
name: Test Formalities
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Determine branch name
run: |
BRANCH="${GITHUB_BASE_REF#refs/heads/}"
echo "Building for $BRANCH"
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
- name: Test formalities
run: |
source .github/workflows/ci_helpers.sh
RET=0
for commit in $(git rev-list HEAD ^origin/$BRANCH); do
info "=== Checking commit '$commit'"
if git show --format='%P' -s $commit | grep -qF ' '; then
err "Pull request should not include merge commits"
RET=1
fi
author="$(git show -s --format=%aN $commit)"
if echo $author | grep -q '\S\+\s\+\S\+'; then
success "Author name ($author) seems ok"
else
err "Author name ($author) need to be your real name 'firstname lastname'"
RET=1
fi
subject="$(git show -s --format=%s $commit)"
if echo "$subject" | grep -q -e '^[0-9A-Za-z,+/_-]\+: ' -e '^Revert '; then
success "Commit subject line seems ok ($subject)"
else
err "Commit subject line MUST start with '<package name>: ' ($subject)"
RET=1
fi
body="$(git show -s --format=%b $commit)"
sob="$(git show -s --format='Signed-off-by: %aN <%aE>' $commit)"
if echo "$body" | grep -qF "$sob"; then
success "Signed-off-by match author"
else
err "Signed-off-by is missing or doesn't match author (should be '$sob')"
RET=1
fi
done
exit $RET

View file

@ -0,0 +1,120 @@
name: Test Build
on:
pull_request:
jobs:
build:
name: Test ${{ matrix.arch }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- arch: arc_archs
target: archs38-generic
runtime_test: false
- arch: arm_cortex-a9_vfpv3-d16
target: mvebu-cortexa9
runtime_test: false
- arch: mips_24kc
target: ath79-generic
runtime_test: false
- arch: powerpc_464fp
target: apm821xx-nand
runtime_test: false
- arch: powerpc_8540
target: mpc85xx-p1010
runtime_test: false
- arch: aarch64_cortex-a53
target: mvebu-cortexa53
runtime_test: true
- arch: arm_cortex-a15_neon-vfpv4
target: armvirt-32
runtime_test: true
- arch: x86_64
target: x86-64
runtime_test: true
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Determine branch name
run: |
BRANCH="${GITHUB_BASE_REF#refs/heads/}"
echo "Building for $BRANCH"
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
- name: Determine changed packages
run: |
# only detect packages with changes
PKG_ROOTS=$(find . -name Makefile | \
grep -v ".*/src/Makefile" | \
sed -e 's@./\(.*\)/Makefile@\1/@')
CHANGES=$(git diff --diff-filter=d --name-only origin/$BRANCH)
for ROOT in $PKG_ROOTS; do
for CHANGE in $CHANGES; do
if [[ "$CHANGE" == "$ROOT"* ]]; then
PACKAGES+=$(echo "$ROOT" | sed -e 's@\(.*\)/@\1 @')
break
fi
done
done
# fallback to test packages if nothing explicitly changes this is
# should run if other mechanics in packages.git changed
PACKAGES="${PACKAGES:-vim attendedsysupgrade-common bmon}"
echo "Building $PACKAGES"
echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV
- name: Build
uses: openwrt/gh-action-sdk@v4
env:
ARCH: ${{ matrix.arch }}-${{ env.BRANCH }}
FEEDNAME: packages_ci
- name: Move created packages to project dir
run: cp bin/packages/${{ matrix.arch }}/packages_ci/*.ipk . || true
- name: Store packages
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.arch}}-packages
path: "*.ipk"
- name: Store logs
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.arch}}-logs
path: logs/
- name: Remove logs
run: sudo rm -rf logs/ || true
- name: Register QEMU
if: ${{ matrix.runtime_test }}
run: |
sudo docker run --rm --privileged aptman/qus -s -- -p
- name: Build Docker container
if: ${{ matrix.runtime_test }}
run: |
docker build -t test-container --build-arg ARCH .github/workflows/
env:
ARCH: ${{ matrix.arch }}-${{ env.BRANCH }}
- name: Test via Docker container
if: ${{ matrix.runtime_test }}
run: |
docker run --rm -v $GITHUB_WORKSPACE:/ci test-container

View file

@ -9,13 +9,15 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=ahcpd PKG_NAME:=ahcpd
PKG_VERSION:=0.53 PKG_VERSION:=0.53
PKG_RELEASE:=2 PKG_RELEASE:=3
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.pps.univ-paris-diderot.fr/~jch/software/files/ PKG_SOURCE_URL:=https://www.irif.fr/~jch/software/files/
PKG_MD5SUM:=a1a610bf20965aa522cd766bf3d5829a PKG_HASH:=a4622e817d2b2a9b878653f085585bd57f3838cc546cca6028d3b73ffcac0d52
PKG_LICENSE:=MIT
PKG_MAINTAINER:=Gabriel Kerneis <gabriel@kerneis.info>
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENCE
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
@ -23,8 +25,7 @@ define Package/ahcpd
SECTION:=net SECTION:=net
CATEGORY:=Network CATEGORY:=Network
TITLE:=Ad-Hoc Configuration Protocol daemon TITLE:=Ad-Hoc Configuration Protocol daemon
URL:=http://www.pps.univ-paris-diderot.fr/~jch/software/ahcp/ URL:=https://www.irif.fr/~jch/software/ahcp/
MAINTAINER:=Gabriel Kerneis <gabriel@kerneis.info>
DEPENDS:=@IPV6 +ip +librt DEPENDS:=@IPV6 +ip +librt
endef endef

View file

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=alfred PKG_NAME:=alfred
PKG_VERSION:=2019.2 PKG_VERSION:=2019.2
PKG_RELEASE:=0 PKG_RELEASE:=3
PKG_HASH:=b656f0e9a97a99c7531b6d49ebfd663451c16cdd275bbf7d48ff8daed3880bf2 PKG_HASH:=b656f0e9a97a99c7531b6d49ebfd663451c16cdd275bbf7d48ff8daed3880bf2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz

View file

@ -13,47 +13,6 @@ facters_dir="/etc/alfred"
enable=0 enable=0
vis_enable=0 vis_enable=0
wait_for_dir() {
local ifce="$1" dir="$2"
if ! [ -d "$dir" ] ; then
timeout=30
echo "waiting $timeout secs for $ifce interface..."
for i in $(seq $timeout); do
sleep 1
[ -d "$dir" ] && break
if [ $i = $timeout ] ; then
echo "$ifce not detected, alfred not starting."
exit 1
fi
done
fi
}
wait_for_ll_address() {
local iface="$1"
local timeout=30
echo "waiting $timeout secs for $iface address..."
for i in $(seq $timeout); do
# We look for
# - the link-local address (starts with fe80)
# - without tentative flag (bit 0x40 in the flags field; the first char of the fifth field is evaluated)
# - on interface $iface
if awk '
BEGIN { RET=1 }
$1 ~ /^fe80/ && $5 ~ /^[012389ab]/ && $6 == "'"$iface"'" { RET=0 }
END { exit RET }
' /proc/net/if_inet6; then
return
fi
sleep 1
done
echo "$iface address not detected, alfred not starting."
exit 1
}
alfred_start() { alfred_start() {
local args="" local args=""
local section="$1" local section="$1"
@ -63,7 +22,7 @@ alfred_start() {
config_get_bool disabled "$section" disabled 0 config_get_bool disabled "$section" disabled 0
[ $disabled = 0 ] || return 1 [ $disabled = 0 ] || return 1
args="" args="-f"
config_get interface "$section" interface config_get interface "$section" interface
append args "-i $interface" append args "-i $interface"
@ -74,12 +33,6 @@ alfred_start() {
config_get batmanif "$section" batmanif config_get batmanif "$section" batmanif
append args "-b $batmanif" append args "-b $batmanif"
if [ "$batmanif" != "none" ]; then
wait_for_dir "$batmanif" "/sys/class/net/$batmanif/mesh"
fi
wait_for_ll_address "$interface"
append alfred_args "$args" append alfred_args "$args"
enable=1 enable=1
@ -98,7 +51,7 @@ start_service() {
config_load "alfred" config_load "alfred"
config_foreach alfred_start alfred config_foreach alfred_start alfred
[ "$enable" = "0" ] && exit 0 [ "$enable" = "0" ] && return 0
procd_open_instance "alfred" procd_open_instance "alfred"
procd_set_param command /usr/sbin/alfred procd_set_param command /usr/sbin/alfred

View file

@ -0,0 +1,242 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Wed, 19 Jun 2019 21:38:09 +0200
Subject: alfred: vis: Use rtnl to query list of hardifs of meshif
The normal way of network related programs to query the state of interfaces
is to use the rtnetlink. Most of these data can also be queried via sysfs
but it is better to use the same way for both retrieving the list of
interfaces and modifying the list of interfaces.
Also the sysfs files are deprecated and cause warnings when access:
batman_adv: [Deprecated]: batadv-vis (pid 832) Use of sysfs file "mesh_iface".
Use batadv genl family instead
In worst case, the file doesn't even exist when batman-adv was compiled
without sysfs support.
Reported-by: Linus Lüssing <linus.luessing@c0d3.blue>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/alfred.git/commit/a34f044de561ce90f67b5760059f818bfb35b449
diff --git a/vis/vis.c b/vis/vis.c
index beaeca150bcac583e9506b9504fa026131f50d5d..37956b100fad72257f5bab2b9f49908da59520cc 100644
--- a/vis/vis.c
+++ b/vis/vis.c
@@ -372,70 +372,146 @@ static void clear_lists(struct globals *globals)
}
}
+static int query_rtnl_link(int ifindex, nl_recvmsg_msg_cb_t func, void *arg)
+{
+ struct ifinfomsg rt_hdr = {
+ .ifi_family = IFLA_UNSPEC,
+ };
+ struct nl_sock *sock;
+ struct nl_msg *msg;
+ struct nl_cb *cb;
+ int err = 0;
+ int ret;
+
+ sock = nl_socket_alloc();
+ if (!sock)
+ return -ENOMEM;
+
+ ret = nl_connect(sock, NETLINK_ROUTE);
+ if (ret < 0) {
+ err = -ENOMEM;
+ goto err_free_sock;
+ }
+
+ cb = nl_cb_alloc(NL_CB_DEFAULT);
+ if (!cb) {
+ err = -ENOMEM;
+ goto err_free_sock;
+ }
+
+ nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, func, arg);
+
+ msg = nlmsg_alloc_simple(RTM_GETLINK, NLM_F_REQUEST | NLM_F_DUMP);
+ if (!msg) {
+ err = -ENOMEM;
+ goto err_free_cb;
+ }
+
+ ret = nlmsg_append(msg, &rt_hdr, sizeof(rt_hdr), NLMSG_ALIGNTO);
+ if (ret < 0) {
+ err = -ENOMEM;
+ goto err_free_msg;
+ }
+
+ ret = nla_put_u32(msg, IFLA_MASTER, ifindex);
+ if (ret < 0) {
+ err = -ENOMEM;
+ goto err_free_msg;
+ }
+
+ ret = nl_send_auto_complete(sock, msg);
+ if (ret < 0)
+ goto err_free_msg;
+
+ nl_recvmsgs(sock, cb);
+
+err_free_msg:
+ nlmsg_free(msg);
+err_free_cb:
+ nl_cb_put(cb);
+err_free_sock:
+ nl_socket_free(sock);
+
+ return err;
+}
+
+struct register_interfaces_rtnl_arg {
+ struct globals *globals;
+ int ifindex;
+};
+
+static struct nla_policy link_policy[IFLA_MAX + 1] = {
+ [IFLA_IFNAME] = { .type = NLA_STRING, .maxlen = IFNAMSIZ },
+ [IFLA_MASTER] = { .type = NLA_U32 },
+};
+
+static int register_interfaces_rtnl_parse(struct nl_msg *msg, void *arg)
+{
+ struct register_interfaces_rtnl_arg *register_arg = arg;
+ struct nlattr *attrs[IFLA_MAX + 1];
+ char path_buff[PATH_BUFF_LEN];
+ struct ifinfomsg *ifm;
+ char *content_newline;
+ char *file_content;
+ char *ifname;
+ int master;
+ int ret;
+
+ ifm = nlmsg_data(nlmsg_hdr(msg));
+ ret = nlmsg_parse(nlmsg_hdr(msg), sizeof(*ifm), attrs, IFLA_MAX,
+ link_policy);
+ if (ret < 0)
+ goto err;
+
+ if (!attrs[IFLA_IFNAME])
+ goto err;
+
+ if (!attrs[IFLA_MASTER])
+ goto err;
+
+ ifname = nla_get_string(attrs[IFLA_IFNAME]);
+ master = nla_get_u32(attrs[IFLA_MASTER]);
+
+ /* required on older kernels which don't prefilter the results */
+ if (master != register_arg->ifindex)
+ goto err;
+
+ snprintf(path_buff, PATH_BUFF_LEN, SYS_IFACE_STATUS_FMT, ifname);
+ file_content = read_file(path_buff);
+ if (!file_content)
+ goto free_file;
+
+ content_newline = strstr(file_content, "\n");
+ if (content_newline)
+ *content_newline = '\0';
+
+ if (strcmp(file_content, "active") != 0)
+ goto err;
+
+ get_if_index_byname(register_arg->globals, ifname);
+
+free_file:
+ free(file_content);
+ file_content = NULL;
+err:
+ return NL_OK;
+}
+
static int register_interfaces(struct globals *globals)
{
- DIR *iface_base_dir;
- struct dirent *iface_dir;
- char *path_buff, *file_content;
- char *content_newline;
+ struct register_interfaces_rtnl_arg register_arg = {
+ .globals = globals,
+ };
- path_buff = malloc(PATH_BUFF_LEN);
- if (!path_buff) {
- perror("Error - could not allocate path buffer");
- goto err;
- }
+ register_arg.ifindex = if_nametoindex(globals->interface);
+ if (!globals->interface)
+ return EXIT_FAILURE;
- iface_base_dir = opendir(SYS_IFACE_PATH);
- if (!iface_base_dir) {
- fprintf(stderr, "Error - the directory '%s' could not be read: %s\n",
- SYS_IFACE_PATH, strerror(errno));
- fprintf(stderr, "Is the batman-adv module loaded and sysfs mounted ?\n");
- goto err_buff;
- }
- while ((iface_dir = readdir(iface_base_dir)) != NULL) {
- snprintf(path_buff, PATH_BUFF_LEN, SYS_MESH_IFACE_FMT, iface_dir->d_name);
- file_content = read_file(path_buff);
- if (!file_content)
- continue;
+ query_rtnl_link(register_arg.ifindex, register_interfaces_rtnl_parse,
+ &register_arg);
- if (file_content[strlen(file_content) - 1] == '\n')
- file_content[strlen(file_content) - 1] = '\0';
-
- if (strcmp(file_content, "none") == 0)
- goto free_line;
-
- if (strcmp(file_content, globals->interface) != 0)
- goto free_line;
-
- free(file_content);
- file_content = NULL;
-
- snprintf(path_buff, PATH_BUFF_LEN, SYS_IFACE_STATUS_FMT, iface_dir->d_name);
- file_content = read_file(path_buff);
- if (!file_content)
- continue;
-
- content_newline = strstr(file_content, "\n");
- if (content_newline)
- *content_newline = '\0';
-
- if (strcmp(file_content, "active") == 0)
- get_if_index_byname(globals, iface_dir->d_name);
-
-free_line:
- free(file_content);
- file_content = NULL;
- }
-
- free(path_buff);
- closedir(iface_base_dir);
return EXIT_SUCCESS;
-
-err_buff:
- free(path_buff);
-err:
- return EXIT_FAILURE;
}
static const int parse_orig_list_mandatory[] = {
diff --git a/vis/vis.h b/vis/vis.h
index 6870dd4ad8570135f4ab2edf0219d74778b7d061..b04a89351778806e84acae88ff3869cf68bcb1a3 100644
--- a/vis/vis.h
+++ b/vis/vis.h
@@ -25,7 +25,6 @@
#define SYS_IFACE_PATH "/sys/class/net"
#define DEBUG_BATIF_PATH_FMT "%s/batman_adv/%s"
-#define SYS_MESH_IFACE_FMT SYS_IFACE_PATH"/%s/batman_adv/mesh_iface"
#define SYS_IFACE_STATUS_FMT SYS_IFACE_PATH"/%s/batman_adv/iface_status"

View file

@ -0,0 +1,201 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Wed, 19 Jun 2019 21:38:10 +0200
Subject: alfred: vis: Retrieve hardif status via generic netlink
The batman-adv kernel module can now be compiled without support for sysfs.
But the batadv-vis interface retriever can only get the status via the per
hardif sysfs file iface_status. To still have some information, use
BATADV_CMD_GET_HARDIF to retrieve the status and fall back to sysfs when
the status could not retrieved via generic netlink.
This also solved the warning about deprecated sysfs file access
batman_adv: [Deprecated]: batadv-vis (pid 1365) Use of sysfs file "iface_status".
Use batadv genl family instead
Reported-by: Linus Lüssing <linus.luessing@c0d3.blue>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/alfred.git/commit/0fc6e6674428ce7085b07645895ef837604e18b5
diff --git a/vis/vis.c b/vis/vis.c
index 37956b100fad72257f5bab2b9f49908da59520cc..947456343125458845f26dc38b53f18d6fd42d75 100644
--- a/vis/vis.c
+++ b/vis/vis.c
@@ -27,6 +27,8 @@
#include "netlink.h"
#include "debugfs.h"
+#define IFACE_STATUS_LEN 256
+
static struct globals vis_globals;
struct vis_netlink_opts {
@@ -435,6 +437,131 @@ err_free_sock:
return err;
}
+static int get_iface_status_netlink_parse(struct nl_msg *msg, void *arg)
+{
+ struct nlattr *attrs[NUM_BATADV_ATTR];
+ struct nlmsghdr *nlh = nlmsg_hdr(msg);
+ char *iface_status = arg;
+ struct genlmsghdr *ghdr;
+
+ if (!genlmsg_valid_hdr(nlh, 0))
+ return NL_OK;
+
+ ghdr = nlmsg_data(nlh);
+ if (ghdr->cmd != BATADV_CMD_GET_HARDIF)
+ return NL_OK;
+
+ if (nla_parse(attrs, BATADV_ATTR_MAX, genlmsg_attrdata(ghdr, 0),
+ genlmsg_len(ghdr), batadv_netlink_policy))
+ return NL_OK;
+
+ if (attrs[BATADV_ATTR_ACTIVE])
+ strncpy(iface_status, "active\n", IFACE_STATUS_LEN);
+ else
+ strncpy(iface_status, "inactive\n", IFACE_STATUS_LEN);
+
+ iface_status[IFACE_STATUS_LEN - 1] = '\0';
+
+ return NL_STOP;
+}
+
+static char *get_iface_status_netlink(unsigned int meshif, unsigned int hardif,
+ char *iface_status)
+{
+ char *ret_status = NULL;
+ struct nl_sock *sock;
+ struct nl_msg *msg;
+ int batadv_family;
+ struct nl_cb *cb;
+ int ret;
+
+ iface_status[0] = '\0';
+
+ sock = nl_socket_alloc();
+ if (!sock)
+ return NULL;
+
+ ret = genl_connect(sock);
+ if (ret < 0)
+ goto err_free_sock;
+
+ batadv_family = genl_ctrl_resolve(sock, BATADV_NL_NAME);
+ if (batadv_family < 0)
+ goto err_free_sock;
+
+ cb = nl_cb_alloc(NL_CB_DEFAULT);
+ if (!cb)
+ goto err_free_sock;
+
+ nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, get_iface_status_netlink_parse,
+ iface_status);
+
+ msg = nlmsg_alloc();
+ if (!msg)
+ goto err_free_cb;
+
+ genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, batadv_family,
+ 0, 0, BATADV_CMD_GET_HARDIF, 1);
+
+ nla_put_u32(msg, BATADV_ATTR_MESH_IFINDEX, meshif);
+ nla_put_u32(msg, BATADV_ATTR_HARD_IFINDEX, hardif);
+
+ ret = nl_send_auto_complete(sock, msg);
+ if (ret < 0)
+ goto err_free_msg;
+
+ nl_recvmsgs(sock, cb);
+
+ if (strlen(iface_status) > 0)
+ ret_status = iface_status;
+
+err_free_msg:
+ nlmsg_free(msg);
+err_free_cb:
+ nl_cb_put(cb);
+err_free_sock:
+ nl_socket_free(sock);
+
+ return ret_status;
+}
+
+static bool interface_active(unsigned int meshif, unsigned int hardif,
+ const char *ifname)
+{
+ char iface_status[IFACE_STATUS_LEN];
+ char path_buff[PATH_BUFF_LEN];
+ char *file_content = NULL;
+ char *content_newline;
+ bool active = false;
+ char *status;
+
+ status = get_iface_status_netlink(meshif, hardif, iface_status);
+ if (!status) {
+ snprintf(path_buff, sizeof(path_buff), SYS_IFACE_STATUS_FMT,
+ ifname);
+ file_content = read_file(path_buff);
+ if (!file_content)
+ return false;
+
+ status = file_content;
+ }
+
+ content_newline = strstr(status, "\n");
+ if (content_newline)
+ *content_newline = '\0';
+
+ if (strcmp(status, "active") != 0)
+ goto free_file;
+
+ active = true;
+
+free_file:
+ free(file_content);
+ file_content = NULL;
+
+ return active;
+}
+
struct register_interfaces_rtnl_arg {
struct globals *globals;
int ifindex;
@@ -449,10 +576,7 @@ static int register_interfaces_rtnl_parse(struct nl_msg *msg, void *arg)
{
struct register_interfaces_rtnl_arg *register_arg = arg;
struct nlattr *attrs[IFLA_MAX + 1];
- char path_buff[PATH_BUFF_LEN];
struct ifinfomsg *ifm;
- char *content_newline;
- char *file_content;
char *ifname;
int master;
int ret;
@@ -476,23 +600,11 @@ static int register_interfaces_rtnl_parse(struct nl_msg *msg, void *arg)
if (master != register_arg->ifindex)
goto err;
- snprintf(path_buff, PATH_BUFF_LEN, SYS_IFACE_STATUS_FMT, ifname);
- file_content = read_file(path_buff);
- if (!file_content)
- goto free_file;
-
- content_newline = strstr(file_content, "\n");
- if (content_newline)
- *content_newline = '\0';
-
- if (strcmp(file_content, "active") != 0)
+ if (!interface_active(master, ifm->ifi_index, ifname))
goto err;
get_if_index_byname(register_arg->globals, ifname);
-free_file:
- free(file_content);
- file_content = NULL;
err:
return NL_OK;
}

View file

@ -0,0 +1,21 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Thu, 1 Aug 2019 15:54:32 +0200
Subject: alfred: vis: Add missing include for ifinfomsg
Fixes: 0fc6e6674428 ("alfred: vis: Retrieve hardif status via generic netlink")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/alfred.git/commit/ce26453bd72829ac9561acd8d3a06a3937341687
diff --git a/vis/vis.c b/vis/vis.c
index 947456343125458845f26dc38b53f18d6fd42d75..8df3056612d5da3678603a6e6430923c0c86cde0 100644
--- a/vis/vis.c
+++ b/vis/vis.c
@@ -10,6 +10,7 @@
#include <dirent.h>
#include <errno.h>
#include <getopt.h>
+#include <linux/rtnetlink.h>
#include <net/if.h>
#include <netinet/in.h>
#include <signal.h>

View file

@ -0,0 +1,29 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Mon, 15 Feb 2021 19:56:22 +0100
Subject: alfred: Show error message for invalid batadv interface
The alfred server process always stopped without any informational message
when the provided batman-adv was not "none" and was not accessible. This
made it extremely hard to debug the reason why alfred directly stopped
after launching it.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Forwarded: https://patchwork.open-mesh.org/project/b.a.t.m.a.n./patch/20210215200126.140253-1-sven@narfation.org/
diff --git a/server.c b/server.c
index 18109cc76283484a67f54fbc34f88039b9602531..47e9ae28b703da23fb930756d2971161ab332bc1 100644
--- a/server.c
+++ b/server.c
@@ -385,8 +385,11 @@ int alfred_server(struct globals *globals)
}
if (strcmp(globals->mesh_iface, "none") != 0 &&
- batadv_interface_check(globals->mesh_iface) < 0)
+ batadv_interface_check(globals->mesh_iface) < 0) {
+ fprintf(stderr, "Can't start server: batman-adv interface %s not found\n",
+ globals->mesh_iface);
return -1;
+ }
num_socks = netsock_open_all(globals);
if (num_socks <= 0) {

View file

@ -0,0 +1,72 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Mon, 15 Feb 2021 20:16:15 +0100
Subject: alfred: Allow exactly one interface for secondary mode
A primary alfred daemon allows syncing over more than one interface. But
the secondary alfred daemon needs exactly one interface. But the check for
this property was insufficient because it allowed paramters like
"-i wlan0,asd" when wlan0 is valid and asd is not valid.
The better solution is to really use the number of interfaces given to
alfred instead of the number of interfaces evaluated as "valid".
Fixes: 67ae5f57eedd ("alfred: Add support for multiple interfaces per master")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Forwarded: https://patchwork.open-mesh.org/project/b.a.t.m.a.n./patch/20210215200126.140253-2-sven@narfation.org/
diff --git a/alfred.h b/alfred.h
index c7ee518eb9dc02c10fe1b19cea5c928915048d97..24f48fde3fdac1a8a80fae3b4f93dc2e16ddec0f 100644
--- a/alfred.h
+++ b/alfred.h
@@ -182,6 +182,7 @@ int unix_sock_req_data_finish(struct globals *globals,
int vis_update_data(struct globals *globals);
/* netsock.c */
int netsock_open_all(struct globals *globals);
+size_t netsocket_count_interfaces(struct globals *globals);
void netsock_close_all(struct globals *globals);
int netsock_set_interfaces(struct globals *globals, char *interfaces);
struct interface *netsock_first_interface(struct globals *globals);
diff --git a/netsock.c b/netsock.c
index fcbc20be34504e271187fa9e0a120f271e622140..418b378e43144a24d4ff53544b387b1a6e7642e9 100644
--- a/netsock.c
+++ b/netsock.c
@@ -471,6 +471,17 @@ int netsock_open_all(struct globals *globals)
return num_socks;
}
+size_t netsocket_count_interfaces(struct globals *globals)
+{
+ struct interface *interface;
+ size_t count = 0;
+
+ list_for_each_entry(interface, &globals->interfaces, list)
+ count++;
+
+ return count;
+}
+
void netsock_reopen(struct globals *globals)
{
struct interface *interface;
diff --git a/server.c b/server.c
index 47e9ae28b703da23fb930756d2971161ab332bc1..95fc3bc895bf46eb775bf64d963a6eec77399dba 100644
--- a/server.c
+++ b/server.c
@@ -371,6 +371,7 @@ int alfred_server(struct globals *globals)
int maxsock, ret, recvs;
struct timespec last_check, now, tv;
fd_set fds, errfds;
+ size_t num_interfaces;
int num_socks;
if (create_hashes(globals))
@@ -397,7 +398,8 @@ int alfred_server(struct globals *globals)
return -1;
}
- if (num_socks > 1 && globals->opmode == OPMODE_SLAVE) {
+ num_interfaces = netsocket_count_interfaces(globals);
+ if (num_interfaces > 1 && globals->opmode == OPMODE_SLAVE) {
fprintf(stderr, "More than one interface specified in slave mode\n");
return -1;
}

View file

@ -0,0 +1,67 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Mon, 15 Feb 2021 20:34:54 +0100
Subject: alfred: Save global mode flags in bitfield
The verbose and ipv4mode entries in the globals structure is only used to
save a boolean information. So just use a bit in a bitfield to store this
information instead of a full int.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Forwarded: https://patchwork.open-mesh.org/project/b.a.t.m.a.n./patch/20210215200126.140253-3-sven@narfation.org/
diff --git a/alfred.h b/alfred.h
index 24f48fde3fdac1a8a80fae3b4f93dc2e16ddec0f..f09eb497a6efe62d38891dcac2149a6473f9215a 100644
--- a/alfred.h
+++ b/alfred.h
@@ -115,8 +115,8 @@ struct globals {
enum clientmode clientmode;
int clientmode_arg;
int clientmode_version;
- int verbose;
- int ipv4mode;
+ uint8_t verbose:1;
+ uint8_t ipv4mode:1;
int unix_sock;
const char *unix_path;
diff --git a/main.c b/main.c
index f633462bcc55b1ae3369c42ccf8f030e671ab268..c7588505fb0a277de3a0c0ac08bb4365b9a9a2a1 100644
--- a/main.c
+++ b/main.c
@@ -9,6 +9,7 @@
#include <arpa/inet.h>
#include <getopt.h>
#include <signal.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -184,8 +185,8 @@ static struct globals *alfred_init(int argc, char *argv[])
globals->clientmode_version = 0;
globals->mesh_iface = "bat0";
globals->unix_path = ALFRED_SOCK_PATH_DEFAULT;
- globals->verbose = 0;
- globals->ipv4mode = 0;
+ globals->verbose = false;
+ globals->ipv4mode = false;
globals->update_command = NULL;
globals->sync_period.tv_sec = ALFRED_INTERVAL;
globals->sync_period.tv_nsec = 0;
@@ -253,7 +254,7 @@ static struct globals *alfred_init(int argc, char *argv[])
globals->unix_path = optarg;
break;
case 'd':
- globals->verbose++;
+ globals->verbose = true;
break;
case 'c':
globals->update_command = optarg;
@@ -269,7 +270,7 @@ static struct globals *alfred_init(int argc, char *argv[])
printf(" ** Setting sync interval to: %.9f seconds (%ld.%09ld)\n", sync_period, globals->sync_period.tv_sec, globals->sync_period.tv_nsec);
break;
case '4':
- globals->ipv4mode = 1;
+ globals->ipv4mode = true;
inet_pton(AF_INET, optarg, &alfred_mcast.ipv4);
printf(" ** IPv4 Multicast Mode: %x\n", alfred_mcast.ipv4.s_addr);
break;

View file

@ -0,0 +1,102 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Mon, 15 Feb 2021 20:52:17 +0100
Subject: alfred: Allow start of server without valid interface
The alfred server always needs interfaces to operate on. But these
interfaces might not exist at the moment when the daemon process is
started. This caused an error and stopped the process.
But alfred is able to deal with interfaces which disappeared at runtime but
existed at startup. To force a similar behavior for the alfred startup, the
parameter "--force" or "-f" is introduced.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Forwarded: https://patchwork.open-mesh.org/project/b.a.t.m.a.n./patch/20210215200126.140253-4-sven@narfation.org/
diff --git a/alfred.h b/alfred.h
index f09eb497a6efe62d38891dcac2149a6473f9215a..5bd118cbc6052932cfad9f3eb258ceb4ce06cdc3 100644
--- a/alfred.h
+++ b/alfred.h
@@ -117,6 +117,7 @@ struct globals {
int clientmode_version;
uint8_t verbose:1;
uint8_t ipv4mode:1;
+ uint8_t force:1;
int unix_sock;
const char *unix_path;
diff --git a/main.c b/main.c
index c7588505fb0a277de3a0c0ac08bb4365b9a9a2a1..2f77e1eb524f621391bf8ea7d56335e927e5197e 100644
--- a/main.c
+++ b/main.c
@@ -164,6 +164,7 @@ static struct globals *alfred_init(int argc, char *argv[])
{"version", no_argument, NULL, 'v'},
{"verbose", no_argument, NULL, 'd'},
{"sync-period", required_argument, NULL, 'p'},
+ {"force", no_argument, NULL, 'f'},
{NULL, 0, NULL, 0},
};
@@ -187,6 +188,7 @@ static struct globals *alfred_init(int argc, char *argv[])
globals->unix_path = ALFRED_SOCK_PATH_DEFAULT;
globals->verbose = false;
globals->ipv4mode = false;
+ globals->force = false;
globals->update_command = NULL;
globals->sync_period.tv_sec = ALFRED_INTERVAL;
globals->sync_period.tv_nsec = 0;
@@ -194,7 +196,7 @@ static struct globals *alfred_init(int argc, char *argv[])
time_random_seed();
- while ((opt = getopt_long(argc, argv, "ms:r:hi:b:vV:M:I:u:dc:p:4:", long_options,
+ while ((opt = getopt_long(argc, argv, "ms:r:hi:b:vV:M:I:u:dc:p:4:f", long_options,
&opt_ind)) != -1) {
switch (opt) {
case 'r':
@@ -274,6 +276,9 @@ static struct globals *alfred_init(int argc, char *argv[])
inet_pton(AF_INET, optarg, &alfred_mcast.ipv4);
printf(" ** IPv4 Multicast Mode: %x\n", alfred_mcast.ipv4.s_addr);
break;
+ case 'f':
+ globals->force = true;
+ break;
case 'h':
default:
alfred_usage();
diff --git a/man/alfred.8 b/man/alfred.8
index 7e31e12df0b7254e517001be5964d8c5088881e6..424633d4bdb16d25ce7b1a573cc58ab9f0dd1371 100644
--- a/man/alfred.8
+++ b/man/alfred.8
@@ -72,6 +72,9 @@ Collect data from the network and prints it on the network
\fB\-d\fP, \fB\-\-verbose\fP
Show extra information in the data output
.TP
+\fB\-d\fP, \fB\-\-force\fP
+Start server even when batman-adv or interface(s) are not yet available.
+.TP
\fB\-V\fP, \fB\-\-req\-version\fP \fIversion\fP
Specify the data version set for \fB\-s\fP
diff --git a/server.c b/server.c
index 95fc3bc895bf46eb775bf64d963a6eec77399dba..de7ddcff2de8163457bd377c8da99ab3c66ff00e 100644
--- a/server.c
+++ b/server.c
@@ -386,14 +386,15 @@ int alfred_server(struct globals *globals)
}
if (strcmp(globals->mesh_iface, "none") != 0 &&
- batadv_interface_check(globals->mesh_iface) < 0) {
+ batadv_interface_check(globals->mesh_iface) < 0 &&
+ !globals->force) {
fprintf(stderr, "Can't start server: batman-adv interface %s not found\n",
globals->mesh_iface);
return -1;
}
num_socks = netsock_open_all(globals);
- if (num_socks <= 0) {
+ if (num_socks <= 0 && !globals->force) {
fprintf(stderr, "Failed to open interfaces\n");
return -1;
}

View file

@ -8,13 +8,17 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=babeld PKG_NAME:=babeld
PKG_VERSION:=1.8.4 PKG_VERSION:=1.9.2
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://www.irif.fr/~jch/software/files/ PKG_SOURCE_URL:=https://www.irif.fr/~jch/software/files/
PKG_HASH:=98070dc418c190f047b8d69eb47987df30ded8f0fca353c49427d3137ad08b87 PKG_HASH:=154f00e0a8bf35d6ea9028886c3dc5c3c342dd1a367df55ef29a547b75867f07
PKG_MAINTAINER:=Gabriel Kerneis <gabriel@kerneis.info>, \
Baptiste Jonglez <openwrt-pkg@bitsofnetworks.org>
PKG_LICENSE:=MIT PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENCE
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
@ -22,21 +26,17 @@ define Package/babeld
SECTION:=net SECTION:=net
CATEGORY:=Network CATEGORY:=Network
SUBMENU:=Routing and Redirection SUBMENU:=Routing and Redirection
TITLE:=A loop-free distance-vector routing protocol TITLE:=A loop-avoiding distance-vector routing protocol
URL:=https://www.irif.fr/~jch/software/babel/ URL:=https://www.irif.fr/~jch/software/babel/
MAINTAINER:=Gabriel Kerneis <gabriel@kerneis.info>, \
Baptiste Jonglez <openwrt-pkg@bitsofnetworks.org>
DEPENDS:=@IPV6 DEPENDS:=@IPV6
endef endef
define Package/babeld/description define Package/babeld/description
Babel is a loop-avoiding distance-vector routing protocol roughly based Babel is a loop-avoiding distance-vector routing protocol for IPv6 and IPv4
on DSDV and AODV, but with provisions for link cost estimation and with fast convergence properties. It is based on the ideas in DSDV, AODV and
redistribution of routes from other routing protocols. Cisco's EIGRP, but is designed to work well not only in wired networks but
While it is optimised for wireless mesh networks, Babel will also work also in wireless mesh networks, and has been extended with support for
efficiently on wired networks. It will generate between 1.2 and 2.4 times overlay networks. Babel is in the process of becoming an IETF Standard.
the amount of routing traffic that RIPng would generate, while
never counting to infinity.
endef endef
define Package/babeld/conffiles define Package/babeld/conffiles

View file

@ -1,5 +1,7 @@
package babeld package babeld
# Detailed documentation: https://openwrt.org/docs/guide-user/services/babeld
# Babeld reads options from the following files (the last one takes precedence # Babeld reads options from the following files (the last one takes precedence
# if an option is defined in several places): # if an option is defined in several places):
# - the file defined by the option conf_file (default: /etc/babeld.conf), # - the file defined by the option conf_file (default: /etc/babeld.conf),
@ -39,7 +41,10 @@ config interface
option 'ignore' 'true' option 'ignore' 'true'
## Physical interface name ## Physical interface name
option 'ifname' 'tun-example' option 'ifname' 'tun-example'
# option 'max_rtt_penalty' '90' ## Specify the type of interface: tunnels use the RTT-based metric.
option 'type' 'tunnel'
## Other options that can be overriden.
# option 'max_rtt_penalty' '96'
# A config interface without "option ifname" will set default options # A config interface without "option ifname" will set default options
# for all interfaces. Interface-specific configuration always overrides # for all interfaces. Interface-specific configuration always overrides
@ -49,27 +54,49 @@ config interface
# option 'update_interval' '30' # option 'update_interval' '30'
# A filter consists of a type ('in', 'out' or 'redistribute'), an action # A filter consists of a type ('in', 'out', 'redistribute' or 'install'),
# ('allow', 'deny' or 'metric xxx') and a set of selectors ('ip', 'eq', # a set of selectors ('ip', 'eq', etc.) and a set of actions to perform
# etc.). See babeld man page ("Filtering rules") for more details. # ('allow', 'deny', 'metric xxx', 'src-prefix xxx', 'table xxx', 'pref-src xxx').
# Here is a sample filter wich redistributes the default route if its # See babeld man page ("Filtering rules") for more details.
# protocol number is "boot", e.g. when it installed by dhcp. It is
# disabled by default. # Below is a sample filter that redistributes the default route if its
# protocol number is "boot", e.g. when it is installed by dhcp (see
# /etc/iproute2/rt_protos). This filter is disabled thanks to the 'ignore'
# setting.
config filter config filter
option 'ignore' 'true' option 'ignore' 'true'
# Type # Type of filter
option 'type' 'redistribute' option 'type' 'redistribute'
# Selectors: ip, eq, le, ge, src_ip, src_eq, src_le, src_ge, neigh, id, # Selectors: ip, eq, le, ge, src_ip, src_eq, src_le, src_ge, neigh, id,
# proto, local, if. # proto, local, if.
option 'ip' '0.0.0.0/0' option 'ip' '0.0.0.0/0'
option 'eq' '0' option 'eq' '0'
option 'proto' '3' option 'proto' '3'
# Action (one of: allow, deny, metric XXX, src-prefix XXX). # Action, which can be any of: allow, deny, metric <NUMBER>, src-prefix <PREFIX>,
# table <ID>, pref-src <IP>.
# The action defaults to "allow" if not specified. Here, we specify a higher
# redistribution metric than the default (0).
option 'action' 'metric 128' option 'action' 'metric 128'
# Notice that the 'local' selector is a boolean. # Another example filter: don't redistribute local addresses in a certain IP prefix.
# By default, babeld redistributes *all* local addresses.
config filter config filter
option 'ignore' 'true' option 'ignore' 'true'
option 'type' 'redistribute' option 'type' 'redistribute'
# Only apply to routes/addresses within this prefix.
option 'ip' '198.51.100.0/24'
# Notice that the 'local' selector is a boolean.
option 'local' 'true' option 'local' 'true'
# No action means "allow" # Don't redistribute.
option 'action' 'deny'
# Example install filter, to change or filter routes before they are inserted
# into the kernel.
config filter
option 'ignore' 'true'
option 'type' 'install'
# Optional: only apply to routes within 2001:db8:cafe::/48
option 'ip' '2001:db8:cafe::/48'
# We specify the kernel routing table and the preferred source address to use for these routes.
# "Allow" is implicit.
option 'action' 'table 200 pref-src 2001:db8:ba:be1::42'

View file

@ -197,10 +197,6 @@ start_service() {
procd_close_instance procd_close_instance
} }
stop_service() {
killall -9 babeld
}
service_triggers() { service_triggers() {
procd_add_reload_trigger babeld procd_add_reload_trigger babeld
} }

View file

@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=batctl PKG_NAME:=batctl
PKG_VERSION:=2019.2 PKG_VERSION:=2019.2
PKG_RELEASE:=1 PKG_RELEASE:=8
PKG_HASH:=fb656208ff7d4cd8b1b422f60c9e6d8747302a347cbf6c199d7afa9b80f80ea3 PKG_HASH:=fb656208ff7d4cd8b1b422f60c9e6d8747302a347cbf6c199d7afa9b80f80ea3
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
@ -167,7 +167,7 @@ config-tables := \
claimtable \ claimtable \
dat_cache \ dat_cache \
gateways \ gateways \
loglevel \ mcast_flags \
nc_nodes \ nc_nodes \
neighbors \ neighbors \
originators \ originators \

View file

@ -1,5 +1,5 @@
From: Sven Eckelmann <sven@narfation.org> From: Sven Eckelmann <sven@narfation.org>
Date: Thu, 13 Jun 2019 21:12:14 +0200 Date: Tue, 9 Jul 2019 19:26:46 +0200
Subject: batctl: Make vlan setting explicit Subject: batctl: Make vlan setting explicit
The requirement to have a VLAN master device on top of the batadv mesh The requirement to have a VLAN master device on top of the batadv mesh
@ -12,12 +12,48 @@ that the VLAN is identified using the VID and not the vlan device.
Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Sven Eckelmann <sven@narfation.org>
Forwarded: https://patchwork.open-mesh.org/patch/17947/ Origin: upstream, https://git.open-mesh.org/batctl.git/commit/4704c5e05af7a4f6a397d80ff80f2f2c56fe8f2c
diff --git a/ap_isolation.c b/ap_isolation.c diff --git a/ap_isolation.c b/ap_isolation.c
index 71dcd00eac845d488c4969b17e1339f181c6c913..7c34649225dcc9cc557cc5bb4cbfa2343f8c0763 100644 index 71dcd00eac845d488c4969b17e1339f181c6c913..36fd4d607d03768251150951ebe450740501d446 100644
--- a/ap_isolation.c --- a/ap_isolation.c
+++ b/ap_isolation.c +++ b/ap_isolation.c
@@ -28,7 +28,7 @@ static int get_attrs_ap_isolation(struct nl_msg *msg, void *arg)
{
struct state *state = arg;
- if (state->vid >= 0)
+ if (state->selector == SP_VLAN)
nla_put_u16(msg, BATADV_ATTR_VLANID, state->vid);
return 0;
@@ -38,7 +38,7 @@ static int get_ap_isolation(struct state *state)
{
enum batadv_nl_commands nl_cmd = BATADV_CMD_SET_MESH;
- if (state->vid >= 0)
+ if (state->selector == SP_VLAN)
nl_cmd = BATADV_CMD_GET_VLAN;
return sys_simple_nlquery(state, nl_cmd, get_attrs_ap_isolation,
@@ -53,7 +53,7 @@ static int set_attrs_ap_isolation(struct nl_msg *msg, void *arg)
nla_put_u8(msg, BATADV_ATTR_AP_ISOLATION_ENABLED, data->val);
- if (state->vid >= 0)
+ if (state->selector == SP_VLAN)
nla_put_u16(msg, BATADV_ATTR_VLANID, state->vid);
return 0;
@@ -63,7 +63,7 @@ static int set_ap_isolation(struct state *state)
{
enum batadv_nl_commands nl_cmd = BATADV_CMD_SET_MESH;
- if (state->vid >= 0)
+ if (state->selector == SP_VLAN)
nl_cmd = BATADV_CMD_SET_VLAN;
return sys_simple_nlquery(state, nl_cmd, set_attrs_ap_isolation, NULL);
@@ -81,3 +81,8 @@ COMMAND_NAMED(SUBCOMMAND, ap_isolation, "ap", handle_sys_setting, @@ -81,3 +81,8 @@ COMMAND_NAMED(SUBCOMMAND, ap_isolation, "ap", handle_sys_setting,
COMMAND_FLAG_MESH_IFACE | COMMAND_FLAG_NETLINK, COMMAND_FLAG_MESH_IFACE | COMMAND_FLAG_NETLINK,
&batctl_settings_ap_isolation, &batctl_settings_ap_isolation,
@ -27,8 +63,120 @@ index 71dcd00eac845d488c4969b17e1339f181c6c913..7c34649225dcc9cc557cc5bb4cbfa234
+ COMMAND_FLAG_MESH_IFACE | COMMAND_FLAG_NETLINK, + COMMAND_FLAG_MESH_IFACE | COMMAND_FLAG_NETLINK,
+ &batctl_settings_ap_isolation, + &batctl_settings_ap_isolation,
+ "[0|1] \tdisplay or modify ap_isolation setting for vlan device or id"); + "[0|1] \tdisplay or modify ap_isolation setting for vlan device or id");
diff --git a/functions.c b/functions.c
index aad6327a8f0fe6e512157e427d88dd0649acd052..61ea4879ebffbdadf8ef5bb12bb737c1ed7ff76f 100644
--- a/functions.c
+++ b/functions.c
@@ -919,32 +919,44 @@ static int query_rtnl_link_single(int mesh_ifindex,
return 0;
}
-int translate_mesh_iface(struct state *state)
+int translate_vlan_iface(struct state *state, const char *vlandev)
{
struct rtnl_link_iface_data link_data;
unsigned int arg_ifindex;
- arg_ifindex = if_nametoindex(state->arg_iface);
+ arg_ifindex = if_nametoindex(vlandev);
if (arg_ifindex == 0)
- goto fallback_meshif;
+ return -ENODEV;
query_rtnl_link_single(arg_ifindex, &link_data);
if (!link_data.vid_found)
- goto fallback_meshif;
+ return -ENODEV;
if (!link_data.link_found)
- goto fallback_meshif;
+ return -EINVAL;
if (!link_data.kind_found)
- goto fallback_meshif;
+ return -EINVAL;
if (strcmp(link_data.kind, "vlan") != 0)
- goto fallback_meshif;
+ return -EINVAL;
if (!if_indextoname(link_data.link, state->mesh_iface))
- goto fallback_meshif;
+ return -ENODEV;
state->vid = link_data.vid;
+ state->selector = SP_VLAN;
+
+ return 0;
+}
+
+int translate_mesh_iface_vlan(struct state *state, const char *vlandev)
+{
+ int ret;
+
+ ret = translate_vlan_iface(state, vlandev);
+ if (ret < 0)
+ goto fallback_meshif;
return 0;
@@ -952,9 +964,36 @@ int translate_mesh_iface(struct state *state)
/* if there is no vid then the argument must be the
* mesh interface
*/
- snprintf(state->mesh_iface, sizeof(state->mesh_iface), "%s",
- state->arg_iface);
- state->vid = -1;
+ snprintf(state->mesh_iface, sizeof(state->mesh_iface), "%s", vlandev);
+ state->selector = SP_NONE_OR_MESHIF;
+
+ return 0;
+}
+
+int translate_vid(struct state *state, const char *vidstr)
+{
+ unsigned long vid;
+ char *endptr;
+
+ if (vidstr[0] == '\0') {
+ fprintf(stderr, "Error - unparsable vid\n");
+ return -EINVAL;
+ }
+
+ vid = strtoul(vidstr, &endptr, 0);
+ if (!endptr || *endptr != '\0') {
+ fprintf(stderr, "Error - unparsable vid\n");
+ return -EINVAL;
+ }
+
+ if (vid > 4095) {
+ fprintf(stderr, "Error - too large vid (max 4095)\n");
+ return -ERANGE;
+ }
+
+ /* get mesh interface and overwrite vid afterwards */
+ state->vid = vid;
+ state->selector = SP_VLAN;
return 0;
}
diff --git a/functions.h b/functions.h
index d4a556879664eb5b4b11e6c638c22728db7a83a4..7474c40bbcdcb8fac8865def2e82514aede62b69 100644
--- a/functions.h
+++ b/functions.h
@@ -50,7 +50,9 @@ struct ether_addr *translate_mac(const char *mesh_iface,
struct ether_addr *resolve_mac(const char *asc);
int query_rtnl_link(int ifindex, nl_recvmsg_msg_cb_t func, void *arg);
int netlink_simple_request(struct nl_msg *msg);
-int translate_mesh_iface(struct state *state);
+int translate_mesh_iface_vlan(struct state *state, const char *vlandev);
+int translate_vlan_iface(struct state *state, const char *vlandev);
+int translate_vid(struct state *state, const char *vidstr);
int get_algoname(const char *mesh_iface, char *algoname, size_t algoname_len);
int check_mesh_iface(struct state *state);
int check_mesh_iface_ownership(struct state *state, char *hard_iface);
diff --git a/main.c b/main.c diff --git a/main.c b/main.c
index 278683c6080e3ff4a9f3225931d0c5eb44f89595..6ca13ac0ec4c82ee969be04737a339fd702b52bd 100644 index 278683c6080e3ff4a9f3225931d0c5eb44f89595..309087799b839848029bd5cbec60cbe1213f9190 100644
--- a/main.c --- a/main.c
+++ b/main.c +++ b/main.c
@@ -28,48 +28,75 @@ extern const struct command *__stop___command[]; @@ -28,48 +28,75 @@ extern const struct command *__stop___command[];
@ -127,88 +275,150 @@ index 278683c6080e3ff4a9f3225931d0c5eb44f89595..6ca13ac0ec4c82ee969be04737a339fd
} }
} }
} }
@@ -93,13 +120,19 @@ static void version(void) @@ -93,13 +120,17 @@ static void version(void)
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
-static const struct command *find_command(const char *name) -static const struct command *find_command(const char *name)
+static const struct command *find_command(struct state *state, const char *name) +static const struct command *find_command_by_types(uint32_t types,
+ const char *name)
{ {
const struct command **p; const struct command **p;
for (p = __start___command; p < __stop___command; p++) { for (p = __start___command; p < __stop___command; p++) {
const struct command *cmd = *p; const struct command *cmd = *p;
+ if (state->vid >= 0 && cmd->type != SUBCOMMAND_VID) + if (!(BIT(cmd->type) & types))
+ continue;
+
+ if (state->vid < 0 && cmd->type == SUBCOMMAND_VID)
+ continue; + continue;
+ +
if (strcmp(cmd->name, name) == 0) if (strcmp(cmd->name, name) == 0)
return cmd; return cmd;
@@ -110,6 +143,51 @@ static const struct command *find_command(const char *name) @@ -110,13 +141,123 @@ static const struct command *find_command(const char *name)
return NULL; return NULL;
} }
+static const struct command *find_command(struct state *state, const char *name)
+{
+ uint32_t types;
+
+ switch (state->selector) {
+ case SP_NONE_OR_MESHIF:
+ types = BIT(SUBCOMMAND) |
+ BIT(DEBUGTABLE);
+ break;
+ case SP_VLAN:
+ types = BIT(SUBCOMMAND_VID);
+ break;
+ default:
+ return NULL;
+ }
+
+ return find_command_by_types(types, name);
+}
+
+static int detect_selector_prefix(int argc, char *argv[],
+ enum selector_prefix *selector)
+{
+ /* not enough remaining arguments to detect anything */
+ if (argc < 2)
+ return -EINVAL;
+
+ /* only detect selector prefix which identifies meshif */
+ if (strcmp(argv[0], "vlan") == 0) {
+ *selector = SP_VLAN;
+ return 2;
+ }
+
+ return 0;
+}
+
+static int parse_meshif_args(struct state *state, int argc, char *argv[])
+{
+ enum selector_prefix selector;
+ int parsed_args;
+ char *dev_arg;
+ int ret;
+
+ parsed_args = detect_selector_prefix(argc, argv, &selector);
+ if (parsed_args < 1)
+ goto fallback_meshif_vlan;
+
+ dev_arg = argv[parsed_args - 1];
+
+ switch (selector) {
+ case SP_VLAN:
+ ret = translate_vlan_iface(state, dev_arg);
+ if (ret < 0) {
+ fprintf(stderr, "Error - invalid vlan device %s: %s\n",
+ dev_arg, strerror(-ret));
+ return ret;
+ }
+
+ return parsed_args;
+ case SP_NONE_OR_MESHIF:
+ /* not allowed - see detect_selector_prefix */
+ break;
+ }
+
+fallback_meshif_vlan:
+ /* parse vlan as part of -m parameter or mesh_dfl_iface */
+ translate_mesh_iface_vlan(state, state->arg_iface);
+ return 0;
+}
+
+static int parse_dev_args(struct state *state, int argc, char *argv[]) +static int parse_dev_args(struct state *state, int argc, char *argv[])
+{ +{
+ unsigned long vid; + int dev_arguments;
+ char *endptr; + int ret;
+ +
+ /* not enough arguments to parse */ + /* try to parse selector prefix which can be used to identify meshif */
+ if (argc < 2) { + dev_arguments = parse_meshif_args(state, argc, argv);
+ translate_mesh_iface(state); + if (dev_arguments < 0)
+ return 0; + return dev_arguments;
+
+ /* try to parse secondary prefix selectors which cannot be used to
+ * identify the meshif
+ */
+ argv += dev_arguments;
+ argc -= dev_arguments;
+
+ switch (state->selector) {
+ case SP_NONE_OR_MESHIF:
+ /* continue below */
+ break;
+ default:
+ return dev_arguments;
+ } + }
+ +
+ /* enough room for additional selectors? */
+ if (argc < 2)
+ return dev_arguments;
+
+ if (strcmp(argv[0], "vid") == 0) { + if (strcmp(argv[0], "vid") == 0) {
+ if (argv[1] == '\0') { + ret = translate_vid(state, argv[1]);
+ fprintf(stderr, "Error - unparsable vid\n"); + if (ret < 0)
+ return -EINVAL; + return ret;
+ }
+ +
+ vid = strtoul(argv[1], &endptr, 0); + return dev_arguments + 2;
+ if (!endptr || *endptr != '\0') {
+ fprintf(stderr, "Error - unparsable vid\n");
+ return -EINVAL;
+ }
+
+ if (vid > 4095) {
+ fprintf(stderr, "Error - too large vid (max 4095)\n");
+ return -ERANGE;
+ }
+
+ /* get mesh interface and overwrite vid afterwards */
+ translate_mesh_iface(state);
+ state->vid = vid;
+
+ return 2;
+ } else if (strcmp(argv[0], "vlan") == 0) {
+ state->arg_iface = argv[1];
+ translate_mesh_iface(state);
+
+ return 2;
+ } else {
+ /* parse vlan as part of -m parameter */
+ translate_mesh_iface(state);
+ return 0;
+ } + }
+
+ return dev_arguments;
+} +}
+ +
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
const struct command *cmd; const struct command *cmd;
@@ -117,6 +195,7 @@ int main(int argc, char **argv) struct state state = {
.arg_iface = mesh_dfl_iface, .arg_iface = mesh_dfl_iface,
+ .selector = SP_NONE_OR_MESHIF,
.cmd = NULL, .cmd = NULL,
}; };
+ int dev_arguments; + int dev_arguments;
int opt; int opt;
int ret; int ret;
@@ -152,7 +231,15 @@ int main(int argc, char **argv) @@ -152,7 +293,20 @@ int main(int argc, char **argv)
argc -= optind; argc -= optind;
optind = 0; optind = 0;
@ -221,11 +431,16 @@ index 278683c6080e3ff4a9f3225931d0c5eb44f89595..6ca13ac0ec4c82ee969be04737a339fd
+ argv += dev_arguments; + argv += dev_arguments;
+ argc -= dev_arguments; + argc -= dev_arguments;
+ +
+ if (argc == 0) {
+ fprintf(stderr, "Error - no command specified\n");
+ goto err;
+ }
+
+ cmd = find_command(&state, argv[0]); + cmd = find_command(&state, argv[0]);
if (!cmd) { if (!cmd) {
fprintf(stderr, fprintf(stderr,
"Error - no valid command or debug table specified: %s\n", "Error - no valid command or debug table specified: %s\n",
@@ -162,8 +249,6 @@ int main(int argc, char **argv) @@ -162,8 +316,6 @@ int main(int argc, char **argv)
state.cmd = cmd; state.cmd = cmd;
@ -235,18 +450,31 @@ index 278683c6080e3ff4a9f3225931d0c5eb44f89595..6ca13ac0ec4c82ee969be04737a339fd
check_mesh_iface(&state) < 0) { check_mesh_iface(&state) < 0) {
fprintf(stderr, fprintf(stderr,
diff --git a/main.h b/main.h diff --git a/main.h b/main.h
index 1a4701513c49ad8974b9c9189619f5dde622acd4..1d952610aefb8367bd52e24bea8c04c3d70b94ea 100644 index 1a4701513c49ad8974b9c9189619f5dde622acd4..efc277c5465942d7b4dba284d29f653273b42dce 100644
--- a/main.h --- a/main.h
+++ b/main.h +++ b/main.h
@@ -58,6 +58,7 @@ enum command_flags { @@ -56,13 +56,20 @@ enum command_flags {
COMMAND_FLAG_INVERSE = BIT(2),
};
+enum selector_prefix {
+ SP_NONE_OR_MESHIF,
+ SP_VLAN,
+};
+
enum command_type { enum command_type {
SUBCOMMAND, SUBCOMMAND,
+ SUBCOMMAND_VID, + SUBCOMMAND_VID,
DEBUGTABLE, DEBUGTABLE,
}; };
@@ -84,7 +85,7 @@ struct command { struct state {
char *arg_iface;
+ enum selector_prefix selector;
char mesh_iface[IF_NAMESIZE];
unsigned int mesh_ifindex;
int vid;
@@ -84,7 +91,7 @@ struct command {
}; };
#define COMMAND_NAMED(_type, _name, _abbr, _handler, _flags, _arg, _usage) \ #define COMMAND_NAMED(_type, _name, _abbr, _handler, _flags, _arg, _usage) \
@ -255,7 +483,7 @@ index 1a4701513c49ad8974b9c9189619f5dde622acd4..1d952610aefb8367bd52e24bea8c04c3
.type = (_type), \ .type = (_type), \
.name = (#_name), \ .name = (#_name), \
.abbr = _abbr, \ .abbr = _abbr, \
@@ -93,8 +94,8 @@ struct command { @@ -93,8 +100,8 @@ struct command {
.arg = (_arg), \ .arg = (_arg), \
.usage = (_usage), \ .usage = (_usage), \
}; \ }; \
@ -267,20 +495,33 @@ index 1a4701513c49ad8974b9c9189619f5dde622acd4..1d952610aefb8367bd52e24bea8c04c3
#define COMMAND(_type, _handler, _abbr, _flags, _arg, _usage) \ #define COMMAND(_type, _handler, _abbr, _flags, _arg, _usage) \
COMMAND_NAMED(_type, _handler, _abbr, _handler, _flags, _arg, _usage) COMMAND_NAMED(_type, _handler, _abbr, _handler, _flags, _arg, _usage)
diff --git a/man/batctl.8 b/man/batctl.8 diff --git a/man/batctl.8 b/man/batctl.8
index 0b430313075b5a7a4c796eba0867954e10061002..acb4288c4e6f59b322d20631ef8e3aee6f2215e5 100644 index 0b430313075b5a7a4c796eba0867954e10061002..a5656cf9059bd82c1b85928c22e30d01c56e475f 100644
--- a/man/batctl.8 --- a/man/batctl.8
+++ b/man/batctl.8 +++ b/man/batctl.8
@@ -68,7 +68,7 @@ free all attached interfaces and remove batman-adv interface. @@ -46,7 +46,7 @@ performances, is also included.
If no parameter is given the current originator interval setting is displayed otherwise the parameter is used to set the .SH OPTIONS
originator interval. The interval is in units of milliseconds. .TP
.I \fBoptions:
-\-m specify mesh interface or VLAN created on top of a mesh interface (default 'bat0')
+\-m specify mesh interface (default 'bat0')
.br .br
-.IP "\fBap_isolation\fP|\fBap\fP [\fB0\fP|\fB1\fP]" \-h print general batctl help
+.IP "[\fBvlan <vdev>\fP|\fBvid <vid>\fP] \fBap_isolation\fP|\fBap\fP [\fB0\fP|\fB1\fP]" .br
@@ -70,7 +70,11 @@ originator interval. The interval is in units of milliseconds.
.br
.IP "\fBap_isolation\fP|\fBap\fP [\fB0\fP|\fB1\fP]"
If no parameter is given the current ap isolation setting is displayed. Otherwise the parameter is used to enable or If no parameter is given the current ap isolation setting is displayed. Otherwise the parameter is used to enable or
disable ap isolation. This command can be used in conjunction with "\-m" option to target per VLAN configurations. -disable ap isolation. This command can be used in conjunction with "\-m" option to target per VLAN configurations.
+disable ap isolation.
+.br
+.IP "<\fBvlan <vdev>\fP|\fBvid <vid>\fP> \fBap_isolation\fP|\fBap\fP [\fB0\fP|\fB1\fP]"
+If no parameter is given the current ap isolation setting for the specified VLAN is displayed. Otherwise the parameter is used to enable or
+disable ap isolation for the specified VLAN.
.br .br
.IP "\fBbridge_loop_avoidance\fP|\fBbl\fP [\fB0\fP|\fB1\fP]"
If no parameter is given the current bridge loop avoidance setting is displayed. Otherwise the parameter is used to enable
diff --git a/sys.c b/sys.c diff --git a/sys.c b/sys.c
index 39123db87d391b8898b7454eba7708515bfb3c78..f19719cfad61f36f2a5c1078305de83eb5be142a 100644 index 39123db87d391b8898b7454eba7708515bfb3c78..61a314d88010ef34507ec9dd6a77b53f318f63a8 100644
--- a/sys.c --- a/sys.c
+++ b/sys.c +++ b/sys.c
@@ -141,9 +141,35 @@ int sys_simple_print_boolean(struct nl_msg *msg, void *arg, @@ -141,9 +141,35 @@ int sys_simple_print_boolean(struct nl_msg *msg, void *arg,
@ -322,3 +563,30 @@ index 39123db87d391b8898b7454eba7708515bfb3c78..f19719cfad61f36f2a5c1078305de83e
fprintf(stderr, "parameters:\n"); fprintf(stderr, "parameters:\n");
fprintf(stderr, " \t -h print this help\n"); fprintf(stderr, " \t -h print this help\n");
@@ -233,15 +259,19 @@ int handle_sys_setting(struct state *state, int argc, char **argv)
return EXIT_FAILURE;
}
- /* if the specified interface is a VLAN then change the path to point
- * to the proper "vlan%{vid}" subfolder in the sysfs tree.
- */
- if (state->vid >= 0)
- snprintf(path_buff, PATH_BUFF_LEN, SYS_VLAN_PATH,
- state->mesh_iface, state->vid);
- else
+ switch (state->selector) {
+ case SP_NONE_OR_MESHIF:
snprintf(path_buff, PATH_BUFF_LEN, SYS_BATIF_PATH_FMT,
state->mesh_iface);
+ break;
+ case SP_VLAN:
+ /* if the specified interface is a VLAN then change the path to
+ * point to the proper "vlan%{vid}" subfolder in the sysfs tree.
+ */
+ snprintf(path_buff, PATH_BUFF_LEN, SYS_VLAN_PATH,
+ state->mesh_iface, state->vid);
+ break;
+ }
if (argc == 1) {
res = sys_read_setting(state, path_buff, settings->sysfs_name);

View file

@ -1,5 +1,5 @@
From: Sven Eckelmann <sven@narfation.org> From: Sven Eckelmann <sven@narfation.org>
Date: Thu, 13 Jun 2019 21:12:15 +0200 Date: Tue, 9 Jul 2019 19:26:47 +0200
Subject: batctl: Integrate hardif setting framework Subject: batctl: Integrate hardif setting framework
batctl currently supports settings which are either mesh interface or vlan batctl currently supports settings which are either mesh interface or vlan
@ -9,14 +9,59 @@ hard (slave) interface specific.
To support these, an additional command prefix called hardif is implemented To support these, an additional command prefix called hardif is implemented
for some sysfs commands: for some sysfs commands:
$ batctl -m bat0 hardif eth0 ... $ batctl hardif eth0 ...
Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Sven Eckelmann <sven@narfation.org>
Forwarded: https://patchwork.open-mesh.org/patch/17948/ Origin: upstream, https://git.open-mesh.org/batctl.git/commit/6ed4dfc5459fd3b9ed221308075db592e538c92f
diff --git a/functions.c b/functions.c
index 61ea4879ebffbdadf8ef5bb12bb737c1ed7ff76f..4ffa86ca7830dea3ed2599656831b56f6fec9e33 100644
--- a/functions.c
+++ b/functions.c
@@ -998,6 +998,28 @@ int translate_vid(struct state *state, const char *vidstr)
return 0;
}
+int translate_hard_iface(struct state *state, const char *hardif)
+{
+ struct rtnl_link_iface_data link_data;
+ unsigned int arg_ifindex;
+
+ arg_ifindex = if_nametoindex(hardif);
+ if (arg_ifindex == 0)
+ return -ENODEV;
+
+ query_rtnl_link_single(arg_ifindex, &link_data);
+ if (!link_data.master_found)
+ return -ENOLINK;
+
+ if (!if_indextoname(link_data.master, state->mesh_iface))
+ return -ENOLINK;
+
+ state->hif = arg_ifindex;
+ state->selector = SP_HARDIF;
+
+ return 0;
+}
+
static int check_mesh_iface_netlink(struct state *state)
{
struct rtnl_link_iface_data link_data;
diff --git a/functions.h b/functions.h
index 7474c40bbcdcb8fac8865def2e82514aede62b69..0a08870cee651ee676e67d3e55677c53f59e41c4 100644
--- a/functions.h
+++ b/functions.h
@@ -53,6 +53,7 @@ int netlink_simple_request(struct nl_msg *msg);
int translate_mesh_iface_vlan(struct state *state, const char *vlandev);
int translate_vlan_iface(struct state *state, const char *vlandev);
int translate_vid(struct state *state, const char *vidstr);
+int translate_hard_iface(struct state *state, const char *hardif);
int get_algoname(const char *mesh_iface, char *algoname, size_t algoname_len);
int check_mesh_iface(struct state *state);
int check_mesh_iface_ownership(struct state *state, char *hard_iface);
diff --git a/main.c b/main.c diff --git a/main.c b/main.c
index 6ca13ac0ec4c82ee969be04737a339fd702b52bd..c806dbf4373fd082ff368cba391bdf14eebf4eae 100644 index 309087799b839848029bd5cbec60cbe1213f9190..3b3a16f4c1caffdd2be897e6bf2a00564e5580f8 100644
--- a/main.c --- a/main.c
+++ b/main.c +++ b/main.c
@@ -35,7 +35,8 @@ static void print_usage(void) @@ -35,7 +35,8 @@ static void print_usage(void)
@ -50,51 +95,55 @@ index 6ca13ac0ec4c82ee969be04737a339fd702b52bd..c806dbf4373fd082ff368cba391bdf14
default: default:
prefixes = default_prefixes; prefixes = default_prefixes;
break; break;
@@ -133,6 +141,12 @@ static const struct command *find_command(struct state *state, const char *name) @@ -153,6 +161,9 @@ static const struct command *find_command(struct state *state, const char *name)
if (state->vid < 0 && cmd->type == SUBCOMMAND_VID) case SP_VLAN:
continue; types = BIT(SUBCOMMAND_VID);
break;
+ if (state->hif > 0 && cmd->type != SUBCOMMAND_HIF) + case SP_HARDIF:
+ continue; + types = BIT(SUBCOMMAND_HIF);
+ + break;
+ if (state->hif == 0 && cmd->type == SUBCOMMAND_HIF) default:
+ continue; return NULL;
+ }
if (strcmp(cmd->name, name) == 0) @@ -171,6 +182,9 @@ static int detect_selector_prefix(int argc, char *argv[],
return cmd; if (strcmp(argv[0], "vlan") == 0) {
*selector = SP_VLAN;
@@ -180,6 +194,18 @@ static int parse_dev_args(struct state *state, int argc, char *argv[])
state->arg_iface = argv[1];
translate_mesh_iface(state);
+ return 2;
+ } else if (strcmp(argv[0], "hardif") == 0) {
+ state->hif = if_nametoindex(argv[1]);
+ if (state->hif == 0) {
+ fprintf(stderr, "Error - hard interface not found\n");
+ return -ENODEV;
+ }
+
+ snprintf(state->hard_iface, sizeof(state->hard_iface), "%s",
+ argv[1]);
+
+ translate_mesh_iface(state);
return 2; return 2;
} else { + } else if (strcmp(argv[0], "hardif") == 0) {
/* parse vlan as part of -m parameter */ + *selector = SP_HARDIF;
@@ -193,6 +219,7 @@ int main(int argc, char **argv) + return 2;
const struct command *cmd; }
struct state state = {
.arg_iface = mesh_dfl_iface, return 0;
+ .hif = 0, @@ -197,7 +211,17 @@ static int parse_meshif_args(struct state *state, int argc, char *argv[])
.cmd = NULL, dev_arg, strerror(-ret));
}; return ret;
int dev_arguments; }
+ return parsed_args;
+ case SP_HARDIF:
+ ret = translate_hard_iface(state, dev_arg);
+ if (ret < 0) {
+ fprintf(stderr, "Error - invalid hardif %s: %s\n",
+ dev_arg, strerror(-ret));
+ return ret;
+ }
+ snprintf(state->hard_iface, sizeof(state->hard_iface), "%s",
+ dev_arg);
return parsed_args;
case SP_NONE_OR_MESHIF:
/* not allowed - see detect_selector_prefix */
diff --git a/main.h b/main.h diff --git a/main.h b/main.h
index 1d952610aefb8367bd52e24bea8c04c3d70b94ea..a27d8486ef689206b27b1b50cb017b1b740e91c9 100644 index efc277c5465942d7b4dba284d29f653273b42dce..a97b26fe7b969e01cbdb848e58824e36e3d236ab 100644
--- a/main.h --- a/main.h
+++ b/main.h +++ b/main.h
@@ -59,6 +59,7 @@ enum command_flags { @@ -59,11 +59,13 @@ enum command_flags {
enum selector_prefix {
SP_NONE_OR_MESHIF,
SP_VLAN,
+ SP_HARDIF,
};
enum command_type { enum command_type {
SUBCOMMAND, SUBCOMMAND,
SUBCOMMAND_VID, SUBCOMMAND_VID,
@ -102,17 +151,21 @@ index 1d952610aefb8367bd52e24bea8c04c3d70b94ea..a27d8486ef689206b27b1b50cb017b1b
DEBUGTABLE, DEBUGTABLE,
}; };
@@ -66,6 +67,8 @@ struct state { @@ -72,7 +74,11 @@ struct state {
char *arg_iface; enum selector_prefix selector;
char mesh_iface[IF_NAMESIZE]; char mesh_iface[IF_NAMESIZE];
unsigned int mesh_ifindex; unsigned int mesh_ifindex;
- int vid;
+ char hard_iface[IF_NAMESIZE]; + char hard_iface[IF_NAMESIZE];
+ unsigned int hif; + union {
int vid; + unsigned int hif;
+ int vid;
+ };
const struct command *cmd; const struct command *cmd;
struct nl_sock *sock;
diff --git a/sys.c b/sys.c diff --git a/sys.c b/sys.c
index f19719cfad61f36f2a5c1078305de83eb5be142a..fd34b2fa3bcf168a32bd53fc0df3f35d5532433f 100644 index 61a314d88010ef34507ec9dd6a77b53f318f63a8..b9555ee484f89c1022c0b4e74e18154d18b7af6b 100644
--- a/sys.c --- a/sys.c
+++ b/sys.c +++ b/sys.c
@@ -150,6 +150,10 @@ static void settings_usage(struct state *state) @@ -150,6 +150,10 @@ static void settings_usage(struct state *state)
@ -136,35 +189,21 @@ index f19719cfad61f36f2a5c1078305de83eb5be142a..fd34b2fa3bcf168a32bd53fc0df3f35d
default: default:
prefixes = default_prefixes; prefixes = default_prefixes;
break; break;
@@ -259,15 +266,23 @@ int handle_sys_setting(struct state *state, int argc, char **argv) @@ -271,6 +278,14 @@ int handle_sys_setting(struct state *state, int argc, char **argv)
return EXIT_FAILURE; snprintf(path_buff, PATH_BUFF_LEN, SYS_VLAN_PATH,
} state->mesh_iface, state->vid);
break;
- /* if the specified interface is a VLAN then change the path to point + case SP_HARDIF:
- * to the proper "vlan%{vid}" subfolder in the sysfs tree.
- */
- if (state->vid >= 0)
+ if (state->hif > 0) {
+ /* if a hard interface was specified then change the path to + /* if a hard interface was specified then change the path to
+ * point to the proper ${hardif}/batman-adv path in the sysfs + * point to the proper ${hardif}/batman-adv path in the sysfs
+ * tree. + * tree.
+ */ + */
+ snprintf(path_buff, PATH_BUFF_LEN, SYS_HARDIF_PATH, + snprintf(path_buff, PATH_BUFF_LEN, SYS_HARDIF_PATH,
+ state->hard_iface); + state->hard_iface);
+ } else if (state->vid >= 0) { + break;
+ /* if the specified interface is a VLAN then change the path to }
+ * point to the proper "vlan%{vid}" subfolder in the sysfs tree.
+ */
snprintf(path_buff, PATH_BUFF_LEN, SYS_VLAN_PATH,
state->mesh_iface, state->vid);
- else
+ } else {
snprintf(path_buff, PATH_BUFF_LEN, SYS_BATIF_PATH_FMT,
state->mesh_iface);
+ }
if (argc == 1) { if (argc == 1) {
res = sys_read_setting(state, path_buff, settings->sysfs_name);
diff --git a/sys.h b/sys.h diff --git a/sys.h b/sys.h
index d4f2fcf542bc66b2b1c6ec55a9ac16e10fdc5cac..b6f0f9043a9af8e3c4d4f8bf7e4af4cab0aa5df9 100644 index d4f2fcf542bc66b2b1c6ec55a9ac16e10fdc5cac..b6f0f9043a9af8e3c4d4f8bf7e4af4cab0aa5df9 100644
--- a/sys.h --- a/sys.h

View file

@ -1,5 +1,5 @@
From: Sven Eckelmann <sven@narfation.org> From: Sven Eckelmann <sven@narfation.org>
Date: Thu, 13 Jun 2019 21:12:16 +0200 Date: Tue, 9 Jul 2019 19:26:48 +0200
Subject: batctl: Add elp_interval setting command Subject: batctl: Add elp_interval setting command
B.A.T.M.A.N. V introduced a hard interface specific setting called B.A.T.M.A.N. V introduced a hard interface specific setting called
@ -8,7 +8,7 @@ emits probing packets for neighbor sensing (ELP).
Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Sven Eckelmann <sven@narfation.org>
Forwarded: https://patchwork.open-mesh.org/patch/17949/ Origin: upstream, https://git.open-mesh.org/batctl.git/commit/df5c452a446951c5f2fde265d08f3c2809ac2334
diff --git a/Makefile b/Makefile diff --git a/Makefile b/Makefile
index b7bd545e92963c62128efe60c0dc401bdd9fa023..f071da20f866bff6c162d697d2e43fa9d68ee08d 100755 index b7bd545e92963c62128efe60c0dc401bdd9fa023..f071da20f866bff6c162d697d2e43fa9d68ee08d 100755
@ -167,10 +167,10 @@ index 0000000000000000000000000000000000000000..0a5e98923a622f52e523696b1ec1bfb8
+ &batctl_settings_elp_interval, + &batctl_settings_elp_interval,
+ "[interval] \tdisplay or modify elp_interval setting"); + "[interval] \tdisplay or modify elp_interval setting");
diff --git a/man/batctl.8 b/man/batctl.8 diff --git a/man/batctl.8 b/man/batctl.8
index acb4288c4e6f59b322d20631ef8e3aee6f2215e5..690da023fd1ac6f51915a9167e92030a650fe1bd 100644 index a5656cf9059bd82c1b85928c22e30d01c56e475f..eef7cd8f1246b83f03627cf307471abcade87cfc 100644
--- a/man/batctl.8 --- a/man/batctl.8
+++ b/man/batctl.8 +++ b/man/batctl.8
@@ -93,6 +93,10 @@ the bonding mode. @@ -97,6 +97,10 @@ the bonding mode.
batctl will monitor for events from the netlink kernel interface of batman-adv. The local timestamp of the event will be printed batctl will monitor for events from the netlink kernel interface of batman-adv. The local timestamp of the event will be printed
when parameter \fB\-t\fP is specified. Parameter \fB\-r\fP will do the same but with relative timestamps. when parameter \fB\-t\fP is specified. Parameter \fB\-r\fP will do the same but with relative timestamps.
.br .br

View file

@ -1,5 +1,5 @@
From: Sven Eckelmann <sven@narfation.org> From: Sven Eckelmann <sven@narfation.org>
Date: Thu, 13 Jun 2019 21:12:17 +0200 Date: Tue, 9 Jul 2019 19:26:49 +0200
Subject: batctl: Add throughput_override setting command Subject: batctl: Add throughput_override setting command
B.A.T.M.A.N. V introduced a hard interface specific setting called B.A.T.M.A.N. V introduced a hard interface specific setting called
@ -9,7 +9,7 @@ set to 0 then batman-adv will try to estimate the throughput by itself.
Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Sven Eckelmann <sven@narfation.org>
Forwarded: https://patchwork.open-mesh.org/patch/17950/ Origin: upstream, https://git.open-mesh.org/batctl.git/commit/e5e6560df82813a9aad4a6c958be4d8ea012e909
diff --git a/Makefile b/Makefile diff --git a/Makefile b/Makefile
index f071da20f866bff6c162d697d2e43fa9d68ee08d..e3747a2a28eb34323e34a1e22f5507dd1d7cd0f6 100755 index f071da20f866bff6c162d697d2e43fa9d68ee08d..e3747a2a28eb34323e34a1e22f5507dd1d7cd0f6 100755
@ -52,10 +52,10 @@ index 92983aa6030e2a890283bca448b9203cd4d56b51..128f539852fa085d023fb6d26ae436e7
=============== ===============
diff --git a/man/batctl.8 b/man/batctl.8 diff --git a/man/batctl.8 b/man/batctl.8
index 690da023fd1ac6f51915a9167e92030a650fe1bd..b8218963712bbf0cc9470459896fc904cd393748 100644 index eef7cd8f1246b83f03627cf307471abcade87cfc..d42b6825dd3172009369e370e45ed6e7a9bf9d0d 100644
--- a/man/batctl.8 --- a/man/batctl.8
+++ b/man/batctl.8 +++ b/man/batctl.8
@@ -203,6 +203,12 @@ supported routing algorithms are displayed. @@ -207,6 +207,12 @@ supported routing algorithms are displayed.
Otherwise the parameter is used to select the routing algorithm for the following Otherwise the parameter is used to select the routing algorithm for the following
batX interface to be created. batX interface to be created.
.br .br

View file

@ -0,0 +1,90 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Wed, 19 Jun 2019 09:37:50 +0200
Subject: batctl: Prefer netlink hardif status retrieval over sysfs
The sysfs code in batman-adv was changed to print a deprecated warning when
sysfs files are accessed. The `batctl if` call would therefore cause
warnings like this in the kernel log:
batman_adv: [Deprecated]: batctl (pid 18540) Use of sysfs file "iface_status".
Use batadv genl family instead
It is now appropriate to try the generic netlink BATADV_CMD_GET_HARDIF
request first to get the status of the interface before falling back to
sysfs.
Reported-by: Linus Lüssing <linus.luessing@c0d3.blue>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batctl.git/commit/ce5f0efb35bff8a80992df63876bcac1d4a94867
diff --git a/interface.c b/interface.c
index 5ff25a7b790d68aa69155f0cc7661080145ac86e..0a694c9f41f71a3dd72ae87b79b28434f7e8918f 100644
--- a/interface.c
+++ b/interface.c
@@ -67,18 +67,18 @@ static int get_iface_status_netlink_parse(struct nl_msg *msg, void *arg)
static char *get_iface_status_netlink(unsigned int meshif, unsigned int hardif,
char *iface_status)
{
+ char *ret_status = NULL;
struct nl_sock *sock;
struct nl_msg *msg;
int batadv_family;
struct nl_cb *cb;
int ret;
- strncpy(iface_status, "<error reading status>\n", IFACE_STATUS_LEN);
- iface_status[IFACE_STATUS_LEN - 1] = '\0';
+ iface_status[0] = '\0';
sock = nl_socket_alloc();
if (!sock)
- return iface_status;
+ return NULL;
ret = genl_connect(sock);
if (ret < 0)
@@ -111,6 +111,9 @@ static char *get_iface_status_netlink(unsigned int meshif, unsigned int hardif,
nl_recvmsgs(sock, cb);
+ if (strlen(iface_status) > 0)
+ ret_status = iface_status;
+
err_free_msg:
nlmsg_free(msg);
err_free_cb:
@@ -118,7 +121,7 @@ static char *get_iface_status_netlink(unsigned int meshif, unsigned int hardif,
err_free_sock:
nl_socket_free(sock);
- return iface_status;
+ return ret_status;
}
static struct nla_policy link_policy[IFLA_MAX + 1] = {
@@ -161,13 +164,17 @@ static int print_interfaces_rtnl_parse(struct nl_msg *msg, void *arg)
if (master != print_arg->ifindex)
goto err;
- snprintf(path_buff, sizeof(path_buff), SYS_IFACE_STATUS_FMT, ifname);
- ret = read_file("", path_buff, USE_READ_BUFF | SILENCE_ERRORS, 0, 0, 0);
- if (ret != EXIT_SUCCESS)
- status = get_iface_status_netlink(master, ifm->ifi_index,
- iface_status);
- else
- status = line_ptr;
+ status = get_iface_status_netlink(master, ifm->ifi_index, iface_status);
+ if (!status) {
+ snprintf(path_buff, sizeof(path_buff), SYS_IFACE_STATUS_FMT,
+ ifname);
+ ret = read_file("", path_buff, USE_READ_BUFF | SILENCE_ERRORS,
+ 0, 0, 0);
+ if (ret != EXIT_SUCCESS)
+ status = "<error reading status>\n";
+ else
+ status = line_ptr;
+ }
printf("%s: %s", ifname, status);

View file

@ -0,0 +1,37 @@
From: Leonardo Mörlein <me@irrelefant.net>
Date: Wed, 8 Apr 2020 23:49:03 +0200
Subject: batctl: Return EXIT_FAILURE when throughputmeter failed
The command returned a success even an error was shown during the
execution.
$ (sudo batctl tp 77:77:77:77:77:77 && echo true) || echo false
Destination unreachable
true
Instead it should indicate a failure when the kernel replied with a
non-success return_value:
$ (sudo ./batctl tp 77:77:77:77:77:77 && echo true) || echo false
Destination unreachable
false
Fixes: f109b3473f86 ("batctl: introduce throughput meter support")
Signed-off-by: Leonardo Mörlein <me@irrelefant.net>
[sven@narfation.org: adjusted commit message]
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batctl.git/commit/df8bf5164b6904f61ae0b0db090fb5bb41b4f06d
diff --git a/throughputmeter.c b/throughputmeter.c
index f9d98cfcac86d7a9398e2adddd143924b38e50b0..f19d4891981c99b7b9f3fae39c8d59f549243d0a 100644
--- a/throughputmeter.c
+++ b/throughputmeter.c
@@ -465,6 +465,7 @@ static int throughputmeter(struct state *state, int argc, char **argv)
goto out;
}
+ ret = EXIT_FAILURE;
switch (result.return_value) {
case BATADV_TP_REASON_DST_UNREACHABLE:
fprintf(stderr, "Destination unreachable\n");

View file

@ -0,0 +1,38 @@
From: Marek Lindner <mareklindner@neomailbox.ch>
Date: Wed, 29 Apr 2020 12:09:44 +0200
Subject: batctl: fix endianness when reading radiotap header
All radiotap header fields are specified in little endian byte-order.
Header length conversion is necessary on some platforms.
Fixes: c6fcdb6dc9a9 ("batctl: add radiotap wifi packet decapsulation support")
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batctl.git/commit/440ae55a6ef96eb73ee628f9237915cf9fb26dee
diff --git a/tcpdump.c b/tcpdump.c
index 8106a6457ac1b000f2f802e4b0a751d783540b69..72c1869eb50d25c1f6b1e1fcae42199b9337cb4e 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -15,6 +15,7 @@
#include <time.h>
#include <sys/time.h>
#include <arpa/inet.h>
+#include <endian.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <netinet/in.h>
@@ -1034,10 +1035,10 @@ static int monitor_header_length(unsigned char *packet_buff, ssize_t buff_len, i
return -1;
radiotap_hdr = (struct radiotap_header*)packet_buff;
- if (buff_len <= radiotap_hdr->it_len)
+ if (buff_len <= le16toh(radiotap_hdr->it_len))
return -1;
else
- return radiotap_hdr->it_len;
+ return le16toh(radiotap_hdr->it_len);
}
return -1;

View file

@ -0,0 +1,49 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Sat, 13 Jun 2020 17:59:34 +0200
Subject: batctl: Only remove batadv interface on hardif reduction
A deletion of a hardif from a batadv meshif will also get a success reply
from the kernel when the hardif was never part of the batadv meshif. If the
batadv meshif had no attached hardifs before the removal was started, then
users are then not expecting that the batadv meshif is removed at all.
Since the delete operation is not an atomic compare-and-swap operation,
just check first the number of attached interfaces and only start the
removal of the batadv meshif when the number attached hardifs was reduced.
Fixes: 25022e0b154d ("batctl: Use rtnl to add/remove interfaces")
Reported-by: Matthias Schiffer <mschiffer@universe-factory.net>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batctl.git/commit/6d49a82cf58ee5ebd6235b6ddaca46febd42f876
diff --git a/interface.c b/interface.c
index 0a694c9f41f71a3dd72ae87b79b28434f7e8918f..138a6cd45744081a04f986fe4be67901b3305b74 100644
--- a/interface.c
+++ b/interface.c
@@ -386,6 +386,7 @@ static int interface(struct state *state, int argc, char **argv)
int ret;
unsigned int ifindex;
unsigned int ifmaster;
+ unsigned int pre_cnt;
const char *long_op;
unsigned int cnt;
int rest_argc;
@@ -502,6 +503,8 @@ static int interface(struct state *state, int argc, char **argv)
goto err;
}
+ pre_cnt = count_interfaces(state->mesh_iface);
+
for (i = 1; i < rest_argc; i++) {
ifindex = if_nametoindex(rest_argv[i]);
@@ -531,7 +534,7 @@ static int interface(struct state *state, int argc, char **argv)
/* check if there is no interface left and then destroy mesh_iface */
if (!manual_mode && rest_argv[0][0] == 'd') {
cnt = count_interfaces(state->mesh_iface);
- if (cnt == 0)
+ if (cnt == 0 && pre_cnt > 0)
destroy_interface(state->mesh_iface);
}

View file

@ -0,0 +1,39 @@
From: Linus Lüssing <linus.luessing@c0d3.blue>
Date: Sun, 13 Sep 2020 23:30:19 +0200
Subject: batctl: tcpdump: Fix endianness in ICMPv6 Echo Request/Reply parsing
The ICMPv6 Echo Request/Reply sequence number and id as well as the
IPv6 header length are two byte long fields and therefore might need a
conversion on a little endian system. Otherwise the output will be
broken on such a machine.
Fixes: 35b37756f4a3 ("add IPv6 support to tcpdump parser")
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/batctl.git/commit/e42f73d0d2a04edfbed1b9d0ad9fd57af9e90faf
diff --git a/tcpdump.c b/tcpdump.c
index 72c1869eb50d25c1f6b1e1fcae42199b9337cb4e..f3b1b8bd536e83e583bc535d01630843b80a558d 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -537,13 +537,15 @@ static void dump_ipv6(unsigned char *packet_buff, ssize_t buff_len,
break;
case ICMP6_ECHO_REQUEST:
printf(" echo request, id: %d, seq: %d, length: %hu\n",
- icmphdr->icmp6_id, icmphdr->icmp6_seq,
- iphdr->ip6_plen);
+ ntohs(icmphdr->icmp6_id),
+ ntohs(icmphdr->icmp6_seq),
+ ntohs(iphdr->ip6_plen));
break;
case ICMP6_ECHO_REPLY:
printf(" echo reply, id: %d, seq: %d, length: %hu\n",
- icmphdr->icmp6_id, icmphdr->icmp6_seq,
- iphdr->ip6_plen);
+ ntohs(icmphdr->icmp6_id),
+ ntohs(icmphdr->icmp6_seq),
+ ntohs(iphdr->ip6_plen));
break;
case ICMP6_TIME_EXCEEDED:
printf(" time exceeded in-transit, length %zu\n",

View file

@ -0,0 +1,31 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Fri, 15 Jan 2021 23:38:31 +0100
Subject: batctl: Don't stop when create_interface detected existing interface
"batctl meshif bat0 interface add ..." should never be called in parallel.
But when something still does this, it could be that the code first detects
the missing meshif and then tries to create it - which fails when another
process requested the creation of the same interface slightly before batctl
did it.
But this should not prevent batctl to add the lower interface to the
meshif. It is not really important that the batctl process was the one
which created it - only that it exists is important.
Fixes: 25022e0b154d ("batctl: Use rtnl to add/remove interfaces")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batctl.git/commit/5d465bfd9a19c4bda20fb4e36c6e4b22c56ceb17
diff --git a/interface.c b/interface.c
index 138a6cd45744081a04f986fe4be67901b3305b74..2c6a78ad17cb716fbb7f6a1c78e0076494397b01 100644
--- a/interface.c
+++ b/interface.c
@@ -479,7 +479,7 @@ static int interface(struct state *state, int argc, char **argv)
ifmaster = if_nametoindex(state->mesh_iface);
if (!manual_mode && !ifmaster && rest_argv[0][0] == 'a') {
ret = create_interface(state->mesh_iface);
- if (ret < 0) {
+ if (ret < 0 && ret != -EEXIST) {
fprintf(stderr,
"Error - failed to create batman-adv interface: %s\n",
strerror(-ret));

View file

@ -0,0 +1,26 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Sat, 31 Oct 2020 18:00:26 +0100
Subject: batctl: Fix retrieval of meshif ap_isolation
The batadv command to retrieve the attributes is called
BATADV_CMD_GET_MESH. The used BATADV_CMD_SET_MESH will only return the
current settings via the "config" multicast group which is not evaluated by
the ap_isolation command.
Fixes: c56a63a5f12a ("batctl: Support generic netlink for ap_isolation command")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batctl.git/commit/107cee536a0f8024208923f49a2a548b40bfc432
diff --git a/ap_isolation.c b/ap_isolation.c
index 36fd4d607d03768251150951ebe450740501d446..4854bcd1d6514a02786388dc014966f326818122 100644
--- a/ap_isolation.c
+++ b/ap_isolation.c
@@ -36,7 +36,7 @@ static int get_attrs_ap_isolation(struct nl_msg *msg, void *arg)
static int get_ap_isolation(struct state *state)
{
- enum batadv_nl_commands nl_cmd = BATADV_CMD_SET_MESH;
+ enum batadv_nl_commands nl_cmd = BATADV_CMD_GET_MESH;
if (state->selector == SP_VLAN)
nl_cmd = BATADV_CMD_GET_VLAN;

View file

@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=batman-adv PKG_NAME:=batman-adv
PKG_VERSION:=2019.2 PKG_VERSION:=2019.2
PKG_RELEASE:=3 PKG_RELEASE:=14
PKG_HASH:=70c3f6a6cf88d2b25681a76768a52ed92d9fe992ba8e358368b6a8088757adc8 PKG_HASH:=70c3f6a6cf88d2b25681a76768a52ed92d9fe992ba8e358368b6a8088757adc8
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz

View file

@ -7,11 +7,9 @@ API of Linux 5.2.
This reverts commit 337ae19a00d4455cf84afa58abfb432f78c882b9. This reverts commit 337ae19a00d4455cf84afa58abfb432f78c882b9.
diff --git a/compat-include/linux/fs.h b/compat-include/linux/fs.h
index 480722f04ba7ddefc837d5e55a340271e0814b14..c52e0e8e87584d106ab64ef2c522e6ac1ff6e796 100644
--- a/compat-include/linux/fs.h --- a/compat-include/linux/fs.h
+++ b/compat-include/linux/fs.h +++ b/compat-include/linux/fs.h
@@ -31,15 +31,4 @@ static inline struct dentry *batadv_file_dentry(const struct file *file) @@ -31,15 +31,4 @@ static inline struct dentry *batadv_file
#endif /* < KERNEL_VERSION(4, 6, 0) */ #endif /* < KERNEL_VERSION(4, 6, 0) */
@ -27,11 +25,9 @@ index 480722f04ba7ddefc837d5e55a340271e0814b14..c52e0e8e87584d106ab64ef2c522e6ac
-#endif /* < KERNEL_VERSION(5, 2, 0) */ -#endif /* < KERNEL_VERSION(5, 2, 0) */
- -
#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_FS_H_ */ #endif /* _NET_BATMAN_ADV_COMPAT_LINUX_FS_H_ */
diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c
index 0a91c8661357d4ddbea1ba20dcd0df67b8ba5a97..de81b5ecad91afd8d684edbf781c70a3bae38c60 100644
--- a/net/batman-adv/icmp_socket.c --- a/net/batman-adv/icmp_socket.c
+++ b/net/batman-adv/icmp_socket.c +++ b/net/batman-adv/icmp_socket.c
@@ -65,7 +65,7 @@ static int batadv_socket_open(struct inode *inode, struct file *file) @@ -65,7 +65,7 @@ static int batadv_socket_open(struct ino
batadv_debugfs_deprecated(file, ""); batadv_debugfs_deprecated(file, "");
@ -40,11 +36,9 @@ index 0a91c8661357d4ddbea1ba20dcd0df67b8ba5a97..de81b5ecad91afd8d684edbf781c70a3
socket_client = kmalloc(sizeof(*socket_client), GFP_KERNEL); socket_client = kmalloc(sizeof(*socket_client), GFP_KERNEL);
if (!socket_client) { if (!socket_client) {
diff --git a/net/batman-adv/log.c b/net/batman-adv/log.c
index f79ebd5b46e95b3b6de717c7ea1ecf44e5c96051..60ce11e16a905e790424a2d7aca81c1f945c1ec2 100644
--- a/net/batman-adv/log.c --- a/net/batman-adv/log.c
+++ b/net/batman-adv/log.c +++ b/net/batman-adv/log.c
@@ -90,7 +90,7 @@ static int batadv_log_open(struct inode *inode, struct file *file) @@ -90,7 +90,7 @@ static int batadv_log_open(struct inode
batadv_debugfs_deprecated(file, batadv_debugfs_deprecated(file,
"Use tracepoint batadv:batadv_dbg instead\n"); "Use tracepoint batadv:batadv_dbg instead\n");

View file

@ -7,8 +7,6 @@ API of Linux 5.2.
This reverts commit 1d30dbe3917d0d6fdb8ba473dfdd6265ac46670b. This reverts commit 1d30dbe3917d0d6fdb8ba473dfdd6265ac46670b.
diff --git a/compat-include/net/genetlink.h b/compat-include/net/genetlink.h
index ee5b82288be97193c1a8e8340a2ea7e0c7ce112c..fbfdb733a3dd63c251def43cae416c7fe32cadab 100644
--- a/compat-include/net/genetlink.h --- a/compat-include/net/genetlink.h
+++ b/compat-include/net/genetlink.h +++ b/compat-include/net/genetlink.h
@@ -42,6 +42,7 @@ enum genl_validate_flags { @@ -42,6 +42,7 @@ enum genl_validate_flags {
@ -19,7 +17,7 @@ index ee5b82288be97193c1a8e8340a2ea7e0c7ce112c..fbfdb733a3dd63c251def43cae416c7f
int (*dumpit)(struct sk_buff *skb, int (*dumpit)(struct sk_buff *skb,
struct netlink_callback *cb); struct netlink_callback *cb);
int (*done)(struct netlink_callback *cb); int (*done)(struct netlink_callback *cb);
@@ -104,6 +105,7 @@ static inline int batadv_genl_register_family(struct batadv_genl_family *family) @@ -104,6 +105,7 @@ static inline int batadv_genl_register_f
for (i = 0; i < family->family.n_ops; i++) { for (i = 0; i < family->family.n_ops; i++) {
ops[i].doit = family->ops[i].doit; ops[i].doit = family->ops[i].doit;

View file

@ -7,11 +7,9 @@ API of Linux 5.2.
This reverts commit 2ee47abaeb35ca62bb909830e10b0e973393b853. This reverts commit 2ee47abaeb35ca62bb909830e10b0e973393b853.
diff --git a/compat-include/net/genetlink.h b/compat-include/net/genetlink.h
index fbfdb733a3dd63c251def43cae416c7fe32cadab..7d17a705273650355f074788e9220fc4981b0db1 100644
--- a/compat-include/net/genetlink.h --- a/compat-include/net/genetlink.h
+++ b/compat-include/net/genetlink.h +++ b/compat-include/net/genetlink.h
@@ -33,25 +33,6 @@ void batadv_genl_dump_check_consistent(struct netlink_callback *cb, @@ -33,25 +33,6 @@ void batadv_genl_dump_check_consistent(s
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 2, 0) #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 2, 0)
@ -55,7 +53,7 @@ index fbfdb733a3dd63c251def43cae416c7fe32cadab..7d17a705273650355f074788e9220fc4
static inline int batadv_genl_register_family(struct batadv_genl_family *family) static inline int batadv_genl_register_family(struct batadv_genl_family *family)
{ {
struct genl_ops *ops; struct genl_ops *ops;
@@ -99,20 +82,12 @@ static inline int batadv_genl_register_family(struct batadv_genl_family *family) @@ -99,20 +82,12 @@ static inline int batadv_genl_register_f
family->family.n_mcgrps = family->n_mcgrps; family->family.n_mcgrps = family->n_mcgrps;
family->family.module = family->module; family->family.module = family->module;
@ -78,7 +76,7 @@ index fbfdb733a3dd63c251def43cae416c7fe32cadab..7d17a705273650355f074788e9220fc4
family->family.ops = ops; family->family.ops = ops;
family->copy_ops = ops; family->copy_ops = ops;
@@ -120,17 +95,6 @@ static inline int batadv_genl_register_family(struct batadv_genl_family *family) @@ -120,17 +95,6 @@ static inline int batadv_genl_register_f
return genl_register_family(&family->family); return genl_register_family(&family->family);
} }
@ -96,11 +94,9 @@ index fbfdb733a3dd63c251def43cae416c7fe32cadab..7d17a705273650355f074788e9220fc4
#define genl_register_family(family) \ #define genl_register_family(family) \
batadv_genl_register_family((family)) batadv_genl_register_family((family))
diff --git a/net/batman-adv/netlink.c b/net/batman-adv/netlink.c
index a67720fad46ca496c932c0306e2f7ec4ed496fc9..e7907308b331ddc3e4917ff7d648bca27a65536b 100644
--- a/net/batman-adv/netlink.c --- a/net/batman-adv/netlink.c
+++ b/net/batman-adv/netlink.c +++ b/net/batman-adv/netlink.c
@@ -1343,34 +1343,29 @@ static void batadv_post_doit(const struct genl_ops *ops, struct sk_buff *skb, @@ -1343,34 +1343,29 @@ static void batadv_post_doit(const struc
static const struct genl_ops batadv_netlink_ops[] = { static const struct genl_ops batadv_netlink_ops[] = {
{ {
.cmd = BATADV_CMD_GET_MESH, .cmd = BATADV_CMD_GET_MESH,
@ -135,7 +131,7 @@ index a67720fad46ca496c932c0306e2f7ec4ed496fc9..e7907308b331ddc3e4917ff7d648bca2
/* can be retrieved by unprivileged users */ /* can be retrieved by unprivileged users */
.dumpit = batadv_netlink_dump_hardif, .dumpit = batadv_netlink_dump_hardif,
.doit = batadv_netlink_get_hardif, .doit = batadv_netlink_get_hardif,
@@ -1379,68 +1374,57 @@ static const struct genl_ops batadv_netlink_ops[] = { @@ -1379,68 +1374,57 @@ static const struct genl_ops batadv_netl
}, },
{ {
.cmd = BATADV_CMD_GET_TRANSTABLE_LOCAL, .cmd = BATADV_CMD_GET_TRANSTABLE_LOCAL,
@ -204,7 +200,7 @@ index a67720fad46ca496c932c0306e2f7ec4ed496fc9..e7907308b331ddc3e4917ff7d648bca2
.flags = GENL_ADMIN_PERM, .flags = GENL_ADMIN_PERM,
.doit = batadv_netlink_set_hardif, .doit = batadv_netlink_set_hardif,
.internal_flags = BATADV_FLAG_NEED_MESH | .internal_flags = BATADV_FLAG_NEED_MESH |
@@ -1448,7 +1432,6 @@ static const struct genl_ops batadv_netlink_ops[] = { @@ -1448,7 +1432,6 @@ static const struct genl_ops batadv_netl
}, },
{ {
.cmd = BATADV_CMD_GET_VLAN, .cmd = BATADV_CMD_GET_VLAN,
@ -212,7 +208,7 @@ index a67720fad46ca496c932c0306e2f7ec4ed496fc9..e7907308b331ddc3e4917ff7d648bca2
/* can be retrieved by unprivileged users */ /* can be retrieved by unprivileged users */
.doit = batadv_netlink_get_vlan, .doit = batadv_netlink_get_vlan,
.internal_flags = BATADV_FLAG_NEED_MESH | .internal_flags = BATADV_FLAG_NEED_MESH |
@@ -1456,7 +1439,6 @@ static const struct genl_ops batadv_netlink_ops[] = { @@ -1456,7 +1439,6 @@ static const struct genl_ops batadv_netl
}, },
{ {
.cmd = BATADV_CMD_SET_VLAN, .cmd = BATADV_CMD_SET_VLAN,

View file

@ -7,8 +7,6 @@ API of Linux 5.2.
This reverts commit acfc9a214d01695d1676313ca80cfd2d9309f633. This reverts commit acfc9a214d01695d1676313ca80cfd2d9309f633.
diff --git a/compat-include/linux/cache.h b/compat-include/linux/cache.h
index 9ddda31232ed4b58efcb57dc2ee99ae82d09d6e2..efe440d11d04a1c3999649ba52058ad82e4d6bea 100644
--- a/compat-include/linux/cache.h --- a/compat-include/linux/cache.h
+++ b/compat-include/linux/cache.h +++ b/compat-include/linux/cache.h
@@ -13,8 +13,12 @@ @@ -13,8 +13,12 @@
@ -25,11 +23,9 @@ index 9ddda31232ed4b58efcb57dc2ee99ae82d09d6e2..efe440d11d04a1c3999649ba52058ad8
#define __ro_after_init #define __ro_after_init
#endif /* < KERNEL_VERSION(4, 6, 0) */ #endif /* < KERNEL_VERSION(4, 6, 0) */
diff --git a/compat-include/net/genetlink.h b/compat-include/net/genetlink.h
index 7d17a705273650355f074788e9220fc4981b0db1..58fc24d7147a7f79c2db1976b36351d294f2aa4c 100644
--- a/compat-include/net/genetlink.h --- a/compat-include/net/genetlink.h
+++ b/compat-include/net/genetlink.h +++ b/compat-include/net/genetlink.h
@@ -30,92 +30,4 @@ void batadv_genl_dump_check_consistent(struct netlink_callback *cb, @@ -30,92 +30,4 @@ void batadv_genl_dump_check_consistent(s
#endif /* < KERNEL_VERSION(4, 15, 0) */ #endif /* < KERNEL_VERSION(4, 15, 0) */
@ -122,11 +118,9 @@ index 7d17a705273650355f074788e9220fc4981b0db1..58fc24d7147a7f79c2db1976b36351d2
-#endif /* < KERNEL_VERSION(5, 2, 0) */ -#endif /* < KERNEL_VERSION(5, 2, 0) */
- -
#endif /* _NET_BATMAN_ADV_COMPAT_NET_GENETLINK_H_ */ #endif /* _NET_BATMAN_ADV_COMPAT_NET_GENETLINK_H_ */
diff --git a/net/batman-adv/netlink.c b/net/batman-adv/netlink.c
index e7907308b331ddc3e4917ff7d648bca27a65536b..daf56933223d478399c63360203bcf283d7686a3 100644
--- a/net/batman-adv/netlink.c --- a/net/batman-adv/netlink.c
+++ b/net/batman-adv/netlink.c +++ b/net/batman-adv/netlink.c
@@ -1344,29 +1344,34 @@ static const struct genl_ops batadv_netlink_ops[] = { @@ -1344,29 +1344,34 @@ static const struct genl_ops batadv_netl
{ {
.cmd = BATADV_CMD_GET_MESH, .cmd = BATADV_CMD_GET_MESH,
/* can be retrieved by unprivileged users */ /* can be retrieved by unprivileged users */
@ -161,7 +155,7 @@ index e7907308b331ddc3e4917ff7d648bca27a65536b..daf56933223d478399c63360203bcf28
.dumpit = batadv_netlink_dump_hardif, .dumpit = batadv_netlink_dump_hardif,
.doit = batadv_netlink_get_hardif, .doit = batadv_netlink_get_hardif,
.internal_flags = BATADV_FLAG_NEED_MESH | .internal_flags = BATADV_FLAG_NEED_MESH |
@@ -1375,57 +1380,68 @@ static const struct genl_ops batadv_netlink_ops[] = { @@ -1375,57 +1380,68 @@ static const struct genl_ops batadv_netl
{ {
.cmd = BATADV_CMD_GET_TRANSTABLE_LOCAL, .cmd = BATADV_CMD_GET_TRANSTABLE_LOCAL,
.flags = GENL_ADMIN_PERM, .flags = GENL_ADMIN_PERM,
@ -230,7 +224,7 @@ index e7907308b331ddc3e4917ff7d648bca27a65536b..daf56933223d478399c63360203bcf28
.doit = batadv_netlink_set_hardif, .doit = batadv_netlink_set_hardif,
.internal_flags = BATADV_FLAG_NEED_MESH | .internal_flags = BATADV_FLAG_NEED_MESH |
BATADV_FLAG_NEED_HARDIF, BATADV_FLAG_NEED_HARDIF,
@@ -1433,6 +1449,7 @@ static const struct genl_ops batadv_netlink_ops[] = { @@ -1433,6 +1449,7 @@ static const struct genl_ops batadv_netl
{ {
.cmd = BATADV_CMD_GET_VLAN, .cmd = BATADV_CMD_GET_VLAN,
/* can be retrieved by unprivileged users */ /* can be retrieved by unprivileged users */
@ -238,7 +232,7 @@ index e7907308b331ddc3e4917ff7d648bca27a65536b..daf56933223d478399c63360203bcf28
.doit = batadv_netlink_get_vlan, .doit = batadv_netlink_get_vlan,
.internal_flags = BATADV_FLAG_NEED_MESH | .internal_flags = BATADV_FLAG_NEED_MESH |
BATADV_FLAG_NEED_VLAN, BATADV_FLAG_NEED_VLAN,
@@ -1440,6 +1457,7 @@ static const struct genl_ops batadv_netlink_ops[] = { @@ -1440,6 +1457,7 @@ static const struct genl_ops batadv_netl
{ {
.cmd = BATADV_CMD_SET_VLAN, .cmd = BATADV_CMD_SET_VLAN,
.flags = GENL_ADMIN_PERM, .flags = GENL_ADMIN_PERM,
@ -246,7 +240,7 @@ index e7907308b331ddc3e4917ff7d648bca27a65536b..daf56933223d478399c63360203bcf28
.doit = batadv_netlink_set_vlan, .doit = batadv_netlink_set_vlan,
.internal_flags = BATADV_FLAG_NEED_MESH | .internal_flags = BATADV_FLAG_NEED_MESH |
BATADV_FLAG_NEED_VLAN, BATADV_FLAG_NEED_VLAN,
@@ -1451,7 +1469,6 @@ struct genl_family batadv_netlink_family __ro_after_init = { @@ -1451,7 +1469,6 @@ struct genl_family batadv_netlink_family
.name = BATADV_NL_NAME, .name = BATADV_NL_NAME,
.version = 1, .version = 1,
.maxattr = BATADV_ATTR_MAX, .maxattr = BATADV_ATTR_MAX,

View file

@ -24,11 +24,9 @@ Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/c92331e0df3c0c5645ee5a897eb018c5da5e4aa5 Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/c92331e0df3c0c5645ee5a897eb018c5da5e4aa5
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index bd4138ddf7e09a0020d9842d603dc98f21e225c7..240ed70912d6a014c0a48280741989133034396c 100644
--- a/net/batman-adv/bat_iv_ogm.c --- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c
@@ -2337,7 +2337,7 @@ batadv_iv_ogm_neigh_is_sob(struct batadv_neigh_node *neigh1, @@ -2337,7 +2337,7 @@ batadv_iv_ogm_neigh_is_sob(struct batadv
return ret; return ret;
} }
@ -37,7 +35,7 @@ index bd4138ddf7e09a0020d9842d603dc98f21e225c7..240ed70912d6a014c0a4828074198913
{ {
/* begin scheduling originator messages on that interface */ /* begin scheduling originator messages on that interface */
batadv_iv_ogm_schedule(hard_iface); batadv_iv_ogm_schedule(hard_iface);
@@ -2683,8 +2683,8 @@ static void batadv_iv_gw_dump(struct sk_buff *msg, struct netlink_callback *cb, @@ -2683,8 +2683,8 @@ unlock:
static struct batadv_algo_ops batadv_batman_iv __read_mostly = { static struct batadv_algo_ops batadv_batman_iv __read_mostly = {
.name = "BATMAN_IV", .name = "BATMAN_IV",
.iface = { .iface = {
@ -47,11 +45,9 @@ index bd4138ddf7e09a0020d9842d603dc98f21e225c7..240ed70912d6a014c0a4828074198913
.disable = batadv_iv_ogm_iface_disable, .disable = batadv_iv_ogm_iface_disable,
.update_mac = batadv_iv_ogm_iface_update_mac, .update_mac = batadv_iv_ogm_iface_update_mac,
.primary_set = batadv_iv_ogm_primary_iface_set, .primary_set = batadv_iv_ogm_primary_iface_set,
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 79d1731b83066c60f9aef958d2bc343233bce67a..3719cfd026f04093f5d86ffe1b41a41849b2af62 100644
--- a/net/batman-adv/hard-interface.c --- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c
@@ -795,6 +795,9 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface, @@ -795,6 +795,9 @@ int batadv_hardif_enable_interface(struc
batadv_hardif_recalc_extra_skbroom(soft_iface); batadv_hardif_recalc_extra_skbroom(soft_iface);
@ -61,8 +57,6 @@ index 79d1731b83066c60f9aef958d2bc343233bce67a..3719cfd026f04093f5d86ffe1b41a418
out: out:
return 0; return 0;
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 74b644738a36bfe063eef6df016278b45a1a0256..e0b25104cbfa9f715df364658621c29faa7ad637 100644
--- a/net/batman-adv/types.h --- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h +++ b/net/batman-adv/types.h
@@ -2129,6 +2129,9 @@ struct batadv_algo_iface_ops { @@ -2129,6 +2129,9 @@ struct batadv_algo_iface_ops {

View file

@ -0,0 +1,27 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Sun, 7 Jul 2019 22:19:22 +0200
Subject: batman-adv: Fix netlink dumping of all mcast_flags buckets
The bucket variable is only updated outside the loop over the mcast_flags
buckets. It will only be updated during a dumping run when the dumping has
to be interrupted and a new message has to be started.
This could result in repeated or missing entries when the multicast flags
are dumped to userspace.
Fixes: 06c82b7b15b1 ("batman-adv: Add inconsistent multicast netlink dump detection")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/d1de7f7aa316d6f7b3268f61afa88f5d2c1a5db5
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -1653,7 +1653,7 @@ __batadv_mcast_flags_dump(struct sk_buff
while (bucket_tmp < hash->size) {
if (batadv_mcast_flags_dump_bucket(msg, portid, cb, hash,
- *bucket, &idx_tmp))
+ bucket_tmp, &idx_tmp))
break;
bucket_tmp++;

View file

@ -0,0 +1,56 @@
From: Eric Dumazet <edumazet@google.com>
Date: Mon, 12 Aug 2019 04:57:27 -0700
Subject: batman-adv: fix uninit-value in batadv_netlink_get_ifindex()
batadv_netlink_get_ifindex() needs to make sure user passed
a correct u32 attribute.
syzbot reported :
BUG: KMSAN: uninit-value in batadv_netlink_dump_hardif+0x70d/0x880 net/batman-adv/netlink.c:968
CPU: 1 PID: 11705 Comm: syz-executor888 Not tainted 5.1.0+ #1
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x191/0x1f0 lib/dump_stack.c:113
kmsan_report+0x130/0x2a0 mm/kmsan/kmsan.c:622
__msan_warning+0x75/0xe0 mm/kmsan/kmsan_instr.c:310
batadv_netlink_dump_hardif+0x70d/0x880 net/batman-adv/netlink.c:968
genl_lock_dumpit+0xc6/0x130 net/netlink/genetlink.c:482
netlink_dump+0xa84/0x1ab0 net/netlink/af_netlink.c:2253
__netlink_dump_start+0xa3a/0xb30 net/netlink/af_netlink.c:2361
genl_family_rcv_msg net/netlink/genetlink.c:550 [inline]
genl_rcv_msg+0xfc1/0x1a40 net/netlink/genetlink.c:627
netlink_rcv_skb+0x431/0x620 net/netlink/af_netlink.c:2486
genl_rcv+0x63/0x80 net/netlink/genetlink.c:638
netlink_unicast_kernel net/netlink/af_netlink.c:1311 [inline]
netlink_unicast+0xf3e/0x1020 net/netlink/af_netlink.c:1337
netlink_sendmsg+0x127e/0x12f0 net/netlink/af_netlink.c:1926
sock_sendmsg_nosec net/socket.c:651 [inline]
sock_sendmsg net/socket.c:661 [inline]
___sys_sendmsg+0xcc6/0x1200 net/socket.c:2260
__sys_sendmsg net/socket.c:2298 [inline]
__do_sys_sendmsg net/socket.c:2307 [inline]
__se_sys_sendmsg+0x305/0x460 net/socket.c:2305
__x64_sys_sendmsg+0x4a/0x70 net/socket.c:2305
do_syscall_64+0xbc/0xf0 arch/x86/entry/common.c:291
entry_SYSCALL_64_after_hwframe+0x63/0xe7
RIP: 0033:0x440209
Fixes: 55d368c3a57e ("batman-adv: netlink: hardif query")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/9b470b8a2b9ef4ce68d6e95febd3a0574be1ac14
--- a/net/batman-adv/netlink.c
+++ b/net/batman-adv/netlink.c
@@ -164,7 +164,7 @@ batadv_netlink_get_ifindex(const struct
{
struct nlattr *attr = nlmsg_find_attr(nlh, GENL_HDRLEN, attrtype);
- return attr ? nla_get_u32(attr) : 0;
+ return (attr && nla_len(attr) == sizeof(u32)) ? nla_get_u32(attr) : 0;
}
/**

View file

@ -0,0 +1,72 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Fri, 23 Aug 2019 14:34:27 +0200
Subject: batman-adv: Only read OGM tvlv_len after buffer len check
Multiple batadv_ogm_packet can be stored in an skbuff. The functions
batadv_iv_ogm_send_to_if()/batadv_iv_ogm_receive() use
batadv_iv_ogm_aggr_packet() to check if there is another additional
batadv_ogm_packet in the skb or not before they continue processing the
packet.
The length for such an OGM is BATADV_OGM_HLEN +
batadv_ogm_packet->tvlv_len. The check must first check that at least
BATADV_OGM_HLEN bytes are available before it accesses tvlv_len (which is
part of the header. Otherwise it might try read outside of the currently
available skbuff to get the content of tvlv_len.
Fixes: 0b6aa0d43767 ("batman-adv: tvlv - basic infrastructure")
Reported-by: syzbot+355cab184197dbbfa384@syzkaller.appspotmail.com
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Acked-by: Antonio Quartulli <a@unstable.cc>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/07b6051ebcfaa7ea89b4f278eca2ff4070d29e56
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -277,17 +277,23 @@ static u8 batadv_hop_penalty(u8 tq, cons
* batadv_iv_ogm_aggr_packet() - checks if there is another OGM attached
* @buff_pos: current position in the skb
* @packet_len: total length of the skb
- * @tvlv_len: tvlv length of the previously considered OGM
+ * @ogm_packet: potential OGM in buffer
*
* Return: true if there is enough space for another OGM, false otherwise.
*/
-static bool batadv_iv_ogm_aggr_packet(int buff_pos, int packet_len,
- __be16 tvlv_len)
+static bool
+batadv_iv_ogm_aggr_packet(int buff_pos, int packet_len,
+ const struct batadv_ogm_packet *ogm_packet)
{
int next_buff_pos = 0;
- next_buff_pos += buff_pos + BATADV_OGM_HLEN;
- next_buff_pos += ntohs(tvlv_len);
+ /* check if there is enough space for the header */
+ next_buff_pos += buff_pos + sizeof(*ogm_packet);
+ if (next_buff_pos > packet_len)
+ return false;
+
+ /* check if there is enough space for the optional TVLV */
+ next_buff_pos += ntohs(ogm_packet->tvlv_len);
return (next_buff_pos <= packet_len) &&
(next_buff_pos <= BATADV_MAX_AGGREGATION_BYTES);
@@ -315,7 +321,7 @@ static void batadv_iv_ogm_send_to_if(str
/* adjust all flags and log packets */
while (batadv_iv_ogm_aggr_packet(buff_pos, forw_packet->packet_len,
- batadv_ogm_packet->tvlv_len)) {
+ batadv_ogm_packet)) {
/* we might have aggregated direct link packets with an
* ordinary base packet
*/
@@ -1704,7 +1710,7 @@ static int batadv_iv_ogm_receive(struct
/* unpack the aggregated packets and process them one by one */
while (batadv_iv_ogm_aggr_packet(ogm_offset, skb_headlen(skb),
- ogm_packet->tvlv_len)) {
+ ogm_packet)) {
batadv_iv_ogm_process(skb, ogm_offset, if_incoming);
ogm_offset += BATADV_OGM_HLEN;

View file

@ -0,0 +1,60 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Fri, 23 Aug 2019 14:34:28 +0200
Subject: batman-adv: Only read OGM2 tvlv_len after buffer len check
Multiple batadv_ogm2_packet can be stored in an skbuff. The functions
batadv_v_ogm_send_to_if() uses batadv_v_ogm_aggr_packet() to check if there
is another additional batadv_ogm2_packet in the skb or not before they
continue processing the packet.
The length for such an OGM2 is BATADV_OGM2_HLEN +
batadv_ogm2_packet->tvlv_len. The check must first check that at least
BATADV_OGM2_HLEN bytes are available before it accesses tvlv_len (which is
part of the header. Otherwise it might try read outside of the currently
available skbuff to get the content of tvlv_len.
Fixes: 667996ebeab4 ("batman-adv: OGMv2 - implement originators logic")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/18f77da3761c5550f42a2d131f0fe5cac62e022d
--- a/net/batman-adv/bat_v_ogm.c
+++ b/net/batman-adv/bat_v_ogm.c
@@ -631,17 +631,23 @@ batadv_v_ogm_process_per_outif(struct ba
* batadv_v_ogm_aggr_packet() - checks if there is another OGM aggregated
* @buff_pos: current position in the skb
* @packet_len: total length of the skb
- * @tvlv_len: tvlv length of the previously considered OGM
+ * @ogm2_packet: potential OGM2 in buffer
*
* Return: true if there is enough space for another OGM, false otherwise.
*/
-static bool batadv_v_ogm_aggr_packet(int buff_pos, int packet_len,
- __be16 tvlv_len)
+static bool
+batadv_v_ogm_aggr_packet(int buff_pos, int packet_len,
+ const struct batadv_ogm2_packet *ogm2_packet)
{
int next_buff_pos = 0;
- next_buff_pos += buff_pos + BATADV_OGM2_HLEN;
- next_buff_pos += ntohs(tvlv_len);
+ /* check if there is enough space for the header */
+ next_buff_pos += buff_pos + sizeof(*ogm2_packet);
+ if (next_buff_pos > packet_len)
+ return false;
+
+ /* check if there is enough space for the optional TVLV */
+ next_buff_pos += ntohs(ogm2_packet->tvlv_len);
return (next_buff_pos <= packet_len) &&
(next_buff_pos <= BATADV_MAX_AGGREGATION_BYTES);
@@ -818,7 +824,7 @@ int batadv_v_ogm_packet_recv(struct sk_b
ogm_packet = (struct batadv_ogm2_packet *)skb->data;
while (batadv_v_ogm_aggr_packet(ogm_offset, skb_headlen(skb),
- ogm_packet->tvlv_len)) {
+ ogm_packet)) {
batadv_v_ogm_process(skb, ogm_offset, if_incoming);
ogm_offset += BATADV_OGM2_HLEN;

View file

@ -0,0 +1,115 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Thu, 3 Oct 2019 17:02:01 +0200
Subject: batman-adv: Avoid free/alloc race when handling OGM2 buffer
A B.A.T.M.A.N. V virtual interface has an OGM2 packet buffer which is
initialized using data from the RTNL lock protected netdevice notifier and
other rtnetlink related hooks. It is sent regularly via various slave
interfaces of the batadv virtual interface and in this process also
modified (realloced) to integrate additional state information via TVLV
containers.
It must be avoided that the worker item is executed without a common lock
with the netdevice notifier/rtnetlink helpers. Otherwise it can either
happen that half modified data is sent out or the functions modifying the
OGM2 buffer try to access already freed memory regions.
Fixes: 632835348e65 ("batman-adv: OGMv2 - add basic infrastructure")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/14ee24576213ff02272b7f8d975c7c61d5448aa2
--- a/net/batman-adv/bat_v_ogm.c
+++ b/net/batman-adv/bat_v_ogm.c
@@ -21,6 +21,7 @@
#include <linux/random.h>
#include <linux/rculist.h>
#include <linux/rcupdate.h>
+#include <linux/rtnetlink.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/stddef.h>
@@ -116,14 +117,12 @@ static void batadv_v_ogm_send_to_if(stru
}
/**
- * batadv_v_ogm_send() - periodic worker broadcasting the own OGM
- * @work: work queue item
+ * batadv_v_ogm_send_softif() - periodic worker broadcasting the own OGM
+ * @bat_priv: the bat priv with all the soft interface information
*/
-static void batadv_v_ogm_send(struct work_struct *work)
+static void batadv_v_ogm_send_softif(struct batadv_priv *bat_priv)
{
struct batadv_hard_iface *hard_iface;
- struct batadv_priv_bat_v *bat_v;
- struct batadv_priv *bat_priv;
struct batadv_ogm2_packet *ogm_packet;
struct sk_buff *skb, *skb_tmp;
unsigned char *ogm_buff;
@@ -131,8 +130,7 @@ static void batadv_v_ogm_send(struct wor
u16 tvlv_len = 0;
int ret;
- bat_v = container_of(work, struct batadv_priv_bat_v, ogm_wq.work);
- bat_priv = container_of(bat_v, struct batadv_priv, bat_v);
+ ASSERT_RTNL();
if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_DEACTIVATING)
goto out;
@@ -224,6 +222,22 @@ out:
}
/**
+ * batadv_v_ogm_send() - periodic worker broadcasting the own OGM
+ * @work: work queue item
+ */
+static void batadv_v_ogm_send(struct work_struct *work)
+{
+ struct batadv_priv_bat_v *bat_v;
+ struct batadv_priv *bat_priv;
+
+ rtnl_lock();
+ bat_v = container_of(work, struct batadv_priv_bat_v, ogm_wq.work);
+ bat_priv = container_of(bat_v, struct batadv_priv, bat_v);
+ batadv_v_ogm_send_softif(bat_priv);
+ rtnl_unlock();
+}
+
+/**
* batadv_v_ogm_iface_enable() - prepare an interface for B.A.T.M.A.N. V
* @hard_iface: the interface to prepare
*
@@ -249,6 +263,8 @@ void batadv_v_ogm_primary_iface_set(stru
struct batadv_priv *bat_priv = netdev_priv(primary_iface->soft_iface);
struct batadv_ogm2_packet *ogm_packet;
+ ASSERT_RTNL();
+
if (!bat_priv->bat_v.ogm_buff)
return;
@@ -857,6 +873,8 @@ int batadv_v_ogm_init(struct batadv_priv
unsigned char *ogm_buff;
u32 random_seqno;
+ ASSERT_RTNL();
+
bat_priv->bat_v.ogm_buff_len = BATADV_OGM2_HLEN;
ogm_buff = kzalloc(bat_priv->bat_v.ogm_buff_len, GFP_ATOMIC);
if (!ogm_buff)
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -1477,10 +1477,10 @@ struct batadv_softif_vlan {
* struct batadv_priv_bat_v - B.A.T.M.A.N. V per soft-interface private data
*/
struct batadv_priv_bat_v {
- /** @ogm_buff: buffer holding the OGM packet */
+ /** @ogm_buff: buffer holding the OGM packet. rtnl protected */
unsigned char *ogm_buff;
- /** @ogm_buff_len: length of the OGM packet buffer */
+ /** @ogm_buff_len: length of the OGM packet buffer. rtnl protected */
int ogm_buff_len;
/** @ogm_seqno: OGM sequence number - used to identify each OGM */

View file

@ -0,0 +1,39 @@
From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Date: Mon, 5 Apr 2021 19:16:50 +0900
Subject: batman-adv: initialize "struct batadv_tvlv_tt_vlan_data"->reserved field
KMSAN found uninitialized value at batadv_tt_prepare_tvlv_local_data()
[1], for commit ced72933a5e8ab52 ("batman-adv: use CRC32C instead of CRC16
in TT code") inserted 'reserved' field into "struct batadv_tvlv_tt_data"
and commit 7ea7b4a142758dea ("batman-adv: make the TT CRC logic VLAN
specific") moved that field to "struct batadv_tvlv_tt_vlan_data" but left
that field uninitialized.
[1] https://syzkaller.appspot.com/bug?id=07f3e6dba96f0eb3cabab986adcd8a58b9bdbe9d
Reported-by: syzbot <syzbot+50ee810676e6a089487b@syzkaller.appspotmail.com>
Tested-by: syzbot <syzbot+50ee810676e6a089487b@syzkaller.appspotmail.com>
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Fixes: c5e7a06a2961 ("batman-adv: use CRC32C instead of CRC16 in TT code")
Fixes: 21a57f6e7a3b ("batman-adv: make the TT CRC logic VLAN specific")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/fe8bf38f47a0c1a0e53c487228e3f5a44c86939f
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -891,6 +891,7 @@ batadv_tt_prepare_tvlv_global_data(struc
hlist_for_each_entry_rcu(vlan, &orig_node->vlan_list, list) {
tt_vlan->vid = htons(vlan->vid);
tt_vlan->crc = htonl(vlan->tt.crc);
+ tt_vlan->reserved = 0;
tt_vlan++;
}
@@ -974,6 +975,7 @@ batadv_tt_prepare_tvlv_local_data(struct
tt_vlan->vid = htons(vlan->vid);
tt_vlan->crc = htonl(vlan->tt.crc);
+ tt_vlan->reserved = 0;
tt_vlan++;
}

View file

@ -0,0 +1,132 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Thu, 3 Oct 2019 17:02:01 +0200
Subject: batman-adv: Avoid free/alloc race when handling OGM buffer
Each slave interface of an B.A.T.M.A.N. IV virtual interface has an OGM
packet buffer which is initialized using data from the RTNL lock protected
netdevice notifier and other rtnetlink related hooks. It is sent regularly
via various slave interfaces of the batadv virtual interface and in this
process also modified (realloced) to integrate additional state information
via TVLV containers.
It must be avoided that the worker item is executed without a common lock
with the netdevice notifier/rtnetlink helpers. Otherwise it can either
happen that half modified/freed data is sent out or functions modifying the
OGM buffer try to access already freed memory regions.
Reported-by: syzbot+0cc629f19ccb8534935b@syzkaller.appspotmail.com
Fixes: ea6f8d42a595 ("batman-adv: move /proc interface handling to /sys")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/9b8ceef26c697d0c8319748428944c3339a498dc
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -29,6 +29,7 @@
#include <linux/random.h>
#include <linux/rculist.h>
#include <linux/rcupdate.h>
+#include <linux/rtnetlink.h>
#include <linux/seq_file.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
@@ -193,6 +194,8 @@ static int batadv_iv_ogm_iface_enable(st
unsigned char *ogm_buff;
u32 random_seqno;
+ ASSERT_RTNL();
+
/* randomize initial seqno to avoid collision */
get_random_bytes(&random_seqno, sizeof(random_seqno));
atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
@@ -217,6 +220,8 @@ static int batadv_iv_ogm_iface_enable(st
static void batadv_iv_ogm_iface_disable(struct batadv_hard_iface *hard_iface)
{
+ ASSERT_RTNL();
+
kfree(hard_iface->bat_iv.ogm_buff);
hard_iface->bat_iv.ogm_buff = NULL;
}
@@ -226,6 +231,8 @@ static void batadv_iv_ogm_iface_update_m
struct batadv_ogm_packet *batadv_ogm_packet;
unsigned char *ogm_buff = hard_iface->bat_iv.ogm_buff;
+ ASSERT_RTNL();
+
batadv_ogm_packet = (struct batadv_ogm_packet *)ogm_buff;
ether_addr_copy(batadv_ogm_packet->orig,
hard_iface->net_dev->dev_addr);
@@ -239,6 +246,8 @@ batadv_iv_ogm_primary_iface_set(struct b
struct batadv_ogm_packet *batadv_ogm_packet;
unsigned char *ogm_buff = hard_iface->bat_iv.ogm_buff;
+ ASSERT_RTNL();
+
batadv_ogm_packet = (struct batadv_ogm_packet *)ogm_buff;
batadv_ogm_packet->ttl = BATADV_TTL;
}
@@ -753,6 +762,8 @@ static void batadv_iv_ogm_schedule(struc
u16 tvlv_len = 0;
unsigned long send_time;
+ ASSERT_RTNL();
+
if (hard_iface->if_status == BATADV_IF_NOT_IN_USE ||
hard_iface->if_status == BATADV_IF_TO_BE_REMOVED)
return;
@@ -1643,16 +1654,12 @@ static void batadv_iv_ogm_process(const
batadv_orig_node_put(orig_node);
}
-static void batadv_iv_send_outstanding_bat_ogm_packet(struct work_struct *work)
+static void
+batadv_iv_send_outstanding_forw_packet(struct batadv_forw_packet *forw_packet)
{
- struct delayed_work *delayed_work;
- struct batadv_forw_packet *forw_packet;
struct batadv_priv *bat_priv;
bool dropped = false;
- delayed_work = to_delayed_work(work);
- forw_packet = container_of(delayed_work, struct batadv_forw_packet,
- delayed_work);
bat_priv = netdev_priv(forw_packet->if_incoming->soft_iface);
if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_DEACTIVATING) {
@@ -1681,6 +1688,20 @@ out:
batadv_forw_packet_free(forw_packet, dropped);
}
+static void batadv_iv_send_outstanding_bat_ogm_packet(struct work_struct *work)
+{
+ struct delayed_work *delayed_work;
+ struct batadv_forw_packet *forw_packet;
+
+ delayed_work = to_delayed_work(work);
+ forw_packet = container_of(delayed_work, struct batadv_forw_packet,
+ delayed_work);
+
+ rtnl_lock();
+ batadv_iv_send_outstanding_forw_packet(forw_packet);
+ rtnl_unlock();
+}
+
static int batadv_iv_ogm_receive(struct sk_buff *skb,
struct batadv_hard_iface *if_incoming)
{
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -71,10 +71,10 @@ enum batadv_dhcp_recipient {
* struct batadv_hard_iface_bat_iv - per hard-interface B.A.T.M.A.N. IV data
*/
struct batadv_hard_iface_bat_iv {
- /** @ogm_buff: buffer holding the OGM packet */
+ /** @ogm_buff: buffer holding the OGM packet. rtnl protected */
unsigned char *ogm_buff;
- /** @ogm_buff_len: length of the OGM packet buffer */
+ /** @ogm_buff_len: length of the OGM packet buffer. rtnl protected */
int ogm_buff_len;
/** @ogm_seqno: OGM sequence number - used to identify each OGM */

View file

@ -0,0 +1,134 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Sun, 13 Oct 2019 21:03:06 +0200
Subject: batman-adv: Introduce own OGM2 buffer mutex
Only a single function is currently automatically locked by the rtnl_lock
because (unlike B.A.T.M.A.N. IV) the OGM2 buffer is independent of the hard
interfaces on which it will be transmitted. A private mutex can be used
instead to avoid unnecessary delays which would have been introduced by the
global lock.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/8069c581f9097f1f9398f2d49047a1dab8093821
--- a/net/batman-adv/bat_v_ogm.c
+++ b/net/batman-adv/bat_v_ogm.c
@@ -17,11 +17,12 @@
#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
+#include <linux/lockdep.h>
+#include <linux/mutex.h>
#include <linux/netdevice.h>
#include <linux/random.h>
#include <linux/rculist.h>
#include <linux/rcupdate.h>
-#include <linux/rtnetlink.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/stddef.h>
@@ -130,7 +131,7 @@ static void batadv_v_ogm_send_softif(str
u16 tvlv_len = 0;
int ret;
- ASSERT_RTNL();
+ lockdep_assert_held(&bat_priv->bat_v.ogm_buff_mutex);
if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_DEACTIVATING)
goto out;
@@ -230,11 +231,12 @@ static void batadv_v_ogm_send(struct wor
struct batadv_priv_bat_v *bat_v;
struct batadv_priv *bat_priv;
- rtnl_lock();
bat_v = container_of(work, struct batadv_priv_bat_v, ogm_wq.work);
bat_priv = container_of(bat_v, struct batadv_priv, bat_v);
+
+ mutex_lock(&bat_priv->bat_v.ogm_buff_mutex);
batadv_v_ogm_send_softif(bat_priv);
- rtnl_unlock();
+ mutex_unlock(&bat_priv->bat_v.ogm_buff_mutex);
}
/**
@@ -263,13 +265,15 @@ void batadv_v_ogm_primary_iface_set(stru
struct batadv_priv *bat_priv = netdev_priv(primary_iface->soft_iface);
struct batadv_ogm2_packet *ogm_packet;
- ASSERT_RTNL();
-
+ mutex_lock(&bat_priv->bat_v.ogm_buff_mutex);
if (!bat_priv->bat_v.ogm_buff)
- return;
+ goto unlock;
ogm_packet = (struct batadv_ogm2_packet *)bat_priv->bat_v.ogm_buff;
ether_addr_copy(ogm_packet->orig, primary_iface->net_dev->dev_addr);
+
+unlock:
+ mutex_unlock(&bat_priv->bat_v.ogm_buff_mutex);
}
/**
@@ -873,8 +877,6 @@ int batadv_v_ogm_init(struct batadv_priv
unsigned char *ogm_buff;
u32 random_seqno;
- ASSERT_RTNL();
-
bat_priv->bat_v.ogm_buff_len = BATADV_OGM2_HLEN;
ogm_buff = kzalloc(bat_priv->bat_v.ogm_buff_len, GFP_ATOMIC);
if (!ogm_buff)
@@ -893,6 +895,8 @@ int batadv_v_ogm_init(struct batadv_priv
atomic_set(&bat_priv->bat_v.ogm_seqno, random_seqno);
INIT_DELAYED_WORK(&bat_priv->bat_v.ogm_wq, batadv_v_ogm_send);
+ mutex_init(&bat_priv->bat_v.ogm_buff_mutex);
+
return 0;
}
@@ -904,7 +908,11 @@ void batadv_v_ogm_free(struct batadv_pri
{
cancel_delayed_work_sync(&bat_priv->bat_v.ogm_wq);
+ mutex_lock(&bat_priv->bat_v.ogm_buff_mutex);
+
kfree(bat_priv->bat_v.ogm_buff);
bat_priv->bat_v.ogm_buff = NULL;
bat_priv->bat_v.ogm_buff_len = 0;
+
+ mutex_unlock(&bat_priv->bat_v.ogm_buff_mutex);
}
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -16,6 +16,7 @@
#include <linux/compiler.h>
#include <linux/if_ether.h>
#include <linux/kref.h>
+#include <linux/mutex.h>
#include <linux/netdevice.h>
#include <linux/netlink.h>
#include <linux/sched.h> /* for linux/wait.h */
@@ -1477,15 +1478,18 @@ struct batadv_softif_vlan {
* struct batadv_priv_bat_v - B.A.T.M.A.N. V per soft-interface private data
*/
struct batadv_priv_bat_v {
- /** @ogm_buff: buffer holding the OGM packet. rtnl protected */
+ /** @ogm_buff: buffer holding the OGM packet */
unsigned char *ogm_buff;
- /** @ogm_buff_len: length of the OGM packet buffer. rtnl protected */
+ /** @ogm_buff_len: length of the OGM packet buffer */
int ogm_buff_len;
/** @ogm_seqno: OGM sequence number - used to identify each OGM */
atomic_t ogm_seqno;
+ /** @ogm_buff_mutex: lock protecting ogm_buff and ogm_buff_len */
+ struct mutex ogm_buff_mutex;
+
/** @ogm_wq: workqueue used to schedule OGM transmissions */
struct delayed_work ogm_wq;
};

View file

@ -0,0 +1,257 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Sun, 13 Oct 2019 21:03:07 +0200
Subject: batman-adv: Avoid OGM workqueue synchronous cancel deadlock
batadv_forw_packet_list_free can be called when an interface is being
disabled. Under this circumstance, the rntl_lock will be held and while it
calls cancel_delayed_work_sync.
cancel_delayed_work_sync will stop the execution of the current context
when the work item is currently processed. It can now happen that the
cancel_delayed_work_sync was called when rtnl_lock was already called in
batadv_iv_send_outstanding_bat_ogm_packet or when it was in the process of
calling it. In this case, batadv_iv_send_outstanding_bat_ogm_packet waits
for the lock and cancel_delayed_work_sync (which holds the rtnl_lock) is
waiting for batadv_iv_send_outstanding_bat_ogm_packet to finish.
This can only be avoided by not using (conflicting) blocking locks while
cancel_delayed_work_sync is called. It also has the benefit that the
ogm scheduling functionality can avoid unnecessary delays which can be
introduced by a global lock.
Fixes: 9b8ceef26c69 ("batman-adv: Avoid free/alloc race when handling OGM buffer")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/d3be478f1aa27b47f61c4a62e18eb063d47c9168
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -22,6 +22,8 @@
#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
+#include <linux/lockdep.h>
+#include <linux/mutex.h>
#include <linux/netdevice.h>
#include <linux/netlink.h>
#include <linux/pkt_sched.h>
@@ -29,7 +31,6 @@
#include <linux/random.h>
#include <linux/rculist.h>
#include <linux/rcupdate.h>
-#include <linux/rtnetlink.h>
#include <linux/seq_file.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
@@ -194,7 +195,7 @@ static int batadv_iv_ogm_iface_enable(st
unsigned char *ogm_buff;
u32 random_seqno;
- ASSERT_RTNL();
+ mutex_lock(&hard_iface->bat_iv.ogm_buff_mutex);
/* randomize initial seqno to avoid collision */
get_random_bytes(&random_seqno, sizeof(random_seqno));
@@ -202,8 +203,10 @@ static int batadv_iv_ogm_iface_enable(st
hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
- if (!ogm_buff)
+ if (!ogm_buff) {
+ mutex_unlock(&hard_iface->bat_iv.ogm_buff_mutex);
return -ENOMEM;
+ }
hard_iface->bat_iv.ogm_buff = ogm_buff;
@@ -215,41 +218,59 @@ static int batadv_iv_ogm_iface_enable(st
batadv_ogm_packet->reserved = 0;
batadv_ogm_packet->tq = BATADV_TQ_MAX_VALUE;
+ mutex_unlock(&hard_iface->bat_iv.ogm_buff_mutex);
+
return 0;
}
static void batadv_iv_ogm_iface_disable(struct batadv_hard_iface *hard_iface)
{
- ASSERT_RTNL();
+ mutex_lock(&hard_iface->bat_iv.ogm_buff_mutex);
kfree(hard_iface->bat_iv.ogm_buff);
hard_iface->bat_iv.ogm_buff = NULL;
+
+ mutex_unlock(&hard_iface->bat_iv.ogm_buff_mutex);
}
static void batadv_iv_ogm_iface_update_mac(struct batadv_hard_iface *hard_iface)
{
struct batadv_ogm_packet *batadv_ogm_packet;
- unsigned char *ogm_buff = hard_iface->bat_iv.ogm_buff;
+ void *ogm_buff;
- ASSERT_RTNL();
+ mutex_lock(&hard_iface->bat_iv.ogm_buff_mutex);
- batadv_ogm_packet = (struct batadv_ogm_packet *)ogm_buff;
+ ogm_buff = hard_iface->bat_iv.ogm_buff;
+ if (!ogm_buff)
+ goto unlock;
+
+ batadv_ogm_packet = ogm_buff;
ether_addr_copy(batadv_ogm_packet->orig,
hard_iface->net_dev->dev_addr);
ether_addr_copy(batadv_ogm_packet->prev_sender,
hard_iface->net_dev->dev_addr);
+
+unlock:
+ mutex_unlock(&hard_iface->bat_iv.ogm_buff_mutex);
}
static void
batadv_iv_ogm_primary_iface_set(struct batadv_hard_iface *hard_iface)
{
struct batadv_ogm_packet *batadv_ogm_packet;
- unsigned char *ogm_buff = hard_iface->bat_iv.ogm_buff;
+ void *ogm_buff;
- ASSERT_RTNL();
+ mutex_lock(&hard_iface->bat_iv.ogm_buff_mutex);
- batadv_ogm_packet = (struct batadv_ogm_packet *)ogm_buff;
+ ogm_buff = hard_iface->bat_iv.ogm_buff;
+ if (!ogm_buff)
+ goto unlock;
+
+ batadv_ogm_packet = ogm_buff;
batadv_ogm_packet->ttl = BATADV_TTL;
+
+unlock:
+ mutex_unlock(&hard_iface->bat_iv.ogm_buff_mutex);
}
/* when do we schedule our own ogm to be sent */
@@ -751,7 +772,11 @@ batadv_iv_ogm_slide_own_bcast_window(str
}
}
-static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
+/**
+ * batadv_iv_ogm_schedule_buff() - schedule submission of hardif ogm buffer
+ * @hard_iface: interface whose ogm buffer should be transmitted
+ */
+static void batadv_iv_ogm_schedule_buff(struct batadv_hard_iface *hard_iface)
{
struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
unsigned char **ogm_buff = &hard_iface->bat_iv.ogm_buff;
@@ -762,11 +787,7 @@ static void batadv_iv_ogm_schedule(struc
u16 tvlv_len = 0;
unsigned long send_time;
- ASSERT_RTNL();
-
- if (hard_iface->if_status == BATADV_IF_NOT_IN_USE ||
- hard_iface->if_status == BATADV_IF_TO_BE_REMOVED)
- return;
+ lockdep_assert_held(&hard_iface->bat_iv.ogm_buff_mutex);
/* the interface gets activated here to avoid race conditions between
* the moment of activating the interface in
@@ -834,6 +855,17 @@ out:
batadv_hardif_put(primary_if);
}
+static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
+{
+ if (hard_iface->if_status == BATADV_IF_NOT_IN_USE ||
+ hard_iface->if_status == BATADV_IF_TO_BE_REMOVED)
+ return;
+
+ mutex_lock(&hard_iface->bat_iv.ogm_buff_mutex);
+ batadv_iv_ogm_schedule_buff(hard_iface);
+ mutex_unlock(&hard_iface->bat_iv.ogm_buff_mutex);
+}
+
/**
* batadv_iv_orig_ifinfo_sum() - Get bcast_own sum for originator over iterface
* @orig_node: originator which reproadcasted the OGMs directly
@@ -1654,12 +1686,16 @@ static void batadv_iv_ogm_process(const
batadv_orig_node_put(orig_node);
}
-static void
-batadv_iv_send_outstanding_forw_packet(struct batadv_forw_packet *forw_packet)
+static void batadv_iv_send_outstanding_bat_ogm_packet(struct work_struct *work)
{
+ struct delayed_work *delayed_work;
+ struct batadv_forw_packet *forw_packet;
struct batadv_priv *bat_priv;
bool dropped = false;
+ delayed_work = to_delayed_work(work);
+ forw_packet = container_of(delayed_work, struct batadv_forw_packet,
+ delayed_work);
bat_priv = netdev_priv(forw_packet->if_incoming->soft_iface);
if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_DEACTIVATING) {
@@ -1688,20 +1724,6 @@ out:
batadv_forw_packet_free(forw_packet, dropped);
}
-static void batadv_iv_send_outstanding_bat_ogm_packet(struct work_struct *work)
-{
- struct delayed_work *delayed_work;
- struct batadv_forw_packet *forw_packet;
-
- delayed_work = to_delayed_work(work);
- forw_packet = container_of(delayed_work, struct batadv_forw_packet,
- delayed_work);
-
- rtnl_lock();
- batadv_iv_send_outstanding_forw_packet(forw_packet);
- rtnl_unlock();
-}
-
static int batadv_iv_ogm_receive(struct sk_buff *skb,
struct batadv_hard_iface *if_incoming)
{
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -17,6 +17,7 @@
#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
+#include <linux/mutex.h>
#include <linux/netdevice.h>
#include <linux/printk.h>
#include <linux/rculist.h>
@@ -930,6 +931,7 @@ batadv_hardif_add_interface(struct net_d
INIT_LIST_HEAD(&hard_iface->list);
INIT_HLIST_HEAD(&hard_iface->neigh_list);
+ mutex_init(&hard_iface->bat_iv.ogm_buff_mutex);
spin_lock_init(&hard_iface->neigh_list_lock);
kref_init(&hard_iface->refcount);
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -72,14 +72,17 @@ enum batadv_dhcp_recipient {
* struct batadv_hard_iface_bat_iv - per hard-interface B.A.T.M.A.N. IV data
*/
struct batadv_hard_iface_bat_iv {
- /** @ogm_buff: buffer holding the OGM packet. rtnl protected */
+ /** @ogm_buff: buffer holding the OGM packet */
unsigned char *ogm_buff;
- /** @ogm_buff_len: length of the OGM packet buffer. rtnl protected */
+ /** @ogm_buff_len: length of the OGM packet buffer */
int ogm_buff_len;
/** @ogm_seqno: OGM sequence number - used to identify each OGM */
atomic_t ogm_seqno;
+
+ /** @ogm_buff_mutex: lock protecting ogm_buff and ogm_buff_len */
+ struct mutex ogm_buff_mutex;
};
/**

View file

@ -0,0 +1,41 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Thu, 28 Nov 2019 12:43:49 +0100
Subject: batman-adv: Fix DAT candidate selection on little endian systems
The distributed arp table is using a DHT to store and retrieve MAC address
information for an IP address. This is done using unicast messages to
selected peers. The potential peers are looked up using the IP address and
the VID.
While the IP address is always stored in big endian byte order, it is not
the case of the VID. It can (depending on the host system) either be big
endian or little endian. The host must therefore always convert it to big
endian to ensure that all devices calculate the same peers for the same
lookup data.
Fixes: 3e26722bc9f2 ("batman-adv: make the Distributed ARP Table vlan aware")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Acked-by: Antonio Quartulli <a@unstable.cc>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/728aea06f38e0e4d70f4f7d43698187f7f7055c5
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -285,6 +285,7 @@ static u32 batadv_hash_dat(const void *d
u32 hash = 0;
const struct batadv_dat_entry *dat = data;
const unsigned char *key;
+ __be16 vid;
u32 i;
key = (const unsigned char *)&dat->ip;
@@ -294,7 +295,8 @@ static u32 batadv_hash_dat(const void *d
hash ^= (hash >> 6);
}
- key = (const unsigned char *)&dat->vid;
+ vid = htons(dat->vid);
+ key = (__force const unsigned char *)&vid;
for (i = 0; i < sizeof(dat->vid); i++) {
hash += key[i];
hash += (hash << 10);

View file

@ -0,0 +1,35 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Sun, 16 Feb 2020 13:02:06 +0100
Subject: batman-adv: Don't schedule OGM for disabled interface
A transmission scheduling for an interface which is currently dropped by
batadv_iv_ogm_iface_disable could still be in progress. The B.A.T.M.A.N. V
is simply cancelling the workqueue item in an synchronous way but this is
not possible with B.A.T.M.A.N. IV because the OGM submissions are
intertwined.
Instead it has to stop submitting the OGM when it detect that the buffer
pointer is set to NULL.
Reported-by: syzbot+a98f2016f40b9cd3818a@syzkaller.appspotmail.com
Reported-by: syzbot+ac36b6a33c28a491e929@syzkaller.appspotmail.com
Fixes: c6c8fea29769 ("net: Add batman-adv meshing protocol")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Cc: Hillf Danton <hdanton@sina.com>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/a089c55ca004b396d340baae58abe9a79f32cc0f
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -789,6 +789,10 @@ static void batadv_iv_ogm_schedule_buff(
lockdep_assert_held(&hard_iface->bat_iv.ogm_buff_mutex);
+ /* interface already disabled by batadv_iv_ogm_iface_disable */
+ if (!*ogm_buff)
+ return;
+
/* the interface gets activated here to avoid race conditions between
* the moment of activating the interface in
* hardif_activate_interface() where the originator mac is set and

View file

@ -0,0 +1,57 @@
From: George Spelvin <lkml@sdf.org>
Date: Sun, 8 Mar 2020 09:44:59 -0400
Subject: batman-adv: fix batadv_nc_random_weight_tq
and change to pseudorandom numbers, as this is a traffic dithering
operation that doesn't need crypto-grade.
The previous code operated in 4 steps:
1. Generate a random byte 0 <= rand_tq <= 255
2. Multiply it by BATADV_TQ_MAX_VALUE - tq
3. Divide by 255 (= BATADV_TQ_MAX_VALUE)
4. Return BATADV_TQ_MAX_VALUE - rand_tq
This would apperar to scale (BATADV_TQ_MAX_VALUE - tq) by a random
value between 0/255 and 255/255.
But! The intermediate value between steps 3 and 4 is stored in a u8
variable. So it's truncated, and most of the time, is less than 255, after
which the division produces 0. Specifically, if tq is odd, the product is
always even, and can never be 255. If tq is even, there's exactly one
random byte value that will produce a product byte of 255.
Thus, the return value is 255 (511/512 of the time) or 254 (1/512
of the time).
If we assume that the truncation is a bug, and the code is meant to scale
the input, a simpler way of looking at it is that it's returning a random
value between tq and BATADV_TQ_MAX_VALUE, inclusive.
Well, we have an optimized function for doing just that.
Fixes: c3289f3650d3 ("batman-adv: network coding - code and transmit packets if possible")
Signed-off-by: George Spelvin <lkml@sdf.org>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/db48c60b0edb995450ee846157364bd09bb23762
--- a/net/batman-adv/network-coding.c
+++ b/net/batman-adv/network-coding.c
@@ -1009,15 +1009,8 @@ static struct batadv_nc_path *batadv_nc_
*/
static u8 batadv_nc_random_weight_tq(u8 tq)
{
- u8 rand_val, rand_tq;
-
- get_random_bytes(&rand_val, sizeof(rand_val));
-
/* randomize the estimated packet loss (max TQ - estimated TQ) */
- rand_tq = rand_val * (BATADV_TQ_MAX_VALUE - tq);
-
- /* normalize the randomized packet loss */
- rand_tq /= BATADV_TQ_MAX_VALUE;
+ u8 rand_tq = prandom_u32_max(BATADV_TQ_MAX_VALUE + 1 - tq);
/* convert to (randomized) estimated tq again */
return BATADV_TQ_MAX_VALUE - rand_tq;

View file

@ -0,0 +1,36 @@
From: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Date: Wed, 15 Apr 2020 16:31:50 +0800
Subject: batman-adv: Fix refcnt leak in batadv_show_throughput_override
batadv_show_throughput_override() invokes batadv_hardif_get_by_netdev(),
which gets a batadv_hard_iface object from net_dev with increased refcnt
and its reference is assigned to a local pointer 'hard_iface'.
When batadv_show_throughput_override() returns, "hard_iface" becomes
invalid, so the refcount should be decreased to keep refcount balanced.
The issue happens in the normal path of
batadv_show_throughput_override(), which forgets to decrease the refcnt
increased by batadv_hardif_get_by_netdev() before the function returns,
causing a refcnt leak.
Fix this issue by calling batadv_hardif_put() before the
batadv_show_throughput_override() returns in the normal path.
Fixes: c513176e4b7a ("batman-adv: add throughput override attribute to hard_ifaces")
Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/f301bfed59b146a63471d0f147b767d7cafede6f
--- a/net/batman-adv/sysfs.c
+++ b/net/batman-adv/sysfs.c
@@ -1189,6 +1189,7 @@ static ssize_t batadv_show_throughput_ov
tp_override = atomic_read(&hard_iface->bat_v.throughput_override);
+ batadv_hardif_put(hard_iface);
return sprintf(buff, "%u.%u MBit\n", tp_override / 10,
tp_override % 10);
}

View file

@ -0,0 +1,37 @@
From: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Date: Wed, 15 Apr 2020 16:35:21 +0800
Subject: batman-adv: Fix refcnt leak in batadv_store_throughput_override
batadv_show_throughput_override() invokes batadv_hardif_get_by_netdev(),
which gets a batadv_hard_iface object from net_dev with increased refcnt
and its reference is assigned to a local pointer 'hard_iface'.
When batadv_store_throughput_override() returns, "hard_iface" becomes
invalid, so the refcount should be decreased to keep refcount balanced.
The issue happens in one error path of
batadv_store_throughput_override(). When batadv_parse_throughput()
returns NULL, the refcnt increased by batadv_hardif_get_by_netdev() is
not decreased, causing a refcnt leak.
Fix this issue by jumping to "out" label when batadv_parse_throughput()
returns NULL.
Fixes: c513176e4b7a ("batman-adv: add throughput override attribute to hard_ifaces")
Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/b69cd8bdbfd6fa7e61878c2fa9e6637406f40dd9
--- a/net/batman-adv/sysfs.c
+++ b/net/batman-adv/sysfs.c
@@ -1149,7 +1149,7 @@ static ssize_t batadv_store_throughput_o
ret = batadv_parse_throughput(net_dev, buff, "throughput_override",
&tp_override);
if (!ret)
- return count;
+ goto out;
old_tp_override = atomic_read(&hard_iface->bat_v.throughput_override);
if (old_tp_override == tp_override)

View file

@ -0,0 +1,37 @@
From: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Date: Mon, 20 Apr 2020 13:37:20 +0800
Subject: batman-adv: Fix refcnt leak in batadv_v_ogm_process
batadv_v_ogm_process() invokes batadv_hardif_neigh_get(), which returns
a reference of the neighbor object to "hardif_neigh" with increased
refcount.
When batadv_v_ogm_process() returns, "hardif_neigh" becomes invalid, so
the refcount should be decreased to keep refcount balanced.
The reference counting issue happens in one exception handling paths of
batadv_v_ogm_process(). When batadv_v_ogm_orig_get() fails to get the
orig node and returns NULL, the refcnt increased by
batadv_hardif_neigh_get() is not decreased, causing a refcnt leak.
Fix this issue by jumping to "out" label when batadv_v_ogm_orig_get()
fails to get the orig node.
Fixes: 667996ebeab4 ("batman-adv: OGMv2 - implement originators logic")
Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/4515f5e6a4ccbe1c563b05f2d487eb9eef3c9740
--- a/net/batman-adv/bat_v_ogm.c
+++ b/net/batman-adv/bat_v_ogm.c
@@ -723,7 +723,7 @@ static void batadv_v_ogm_process(const s
orig_node = batadv_v_ogm_orig_get(bat_priv, ogm_packet->orig);
if (!orig_node)
- return;
+ goto out;
neigh_node = batadv_neigh_node_get_or_create(orig_node, if_incoming,
ethhdr->h_source);

View file

@ -0,0 +1,72 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Mon, 25 Nov 2019 10:46:50 +0100
Subject: batman-adv: Revert "disable ethtool link speed detection when auto negotiation off"
The commit d60b8fc69ef2 ("batman-adv: disable ethtool link speed detection
when auto negotiation off") disabled the usage of ethtool's link_ksetting
when auto negotation was enabled due to invalid values when used with
tun/tap virtual net_devices. According to the patch, automatic measurements
should be used for these kind of interfaces.
But there are major flaws with this argumentation:
* automatic measurements are not implemented
* auto negotiation has nothing to do with the validity of the retrieved
values
The first point has to be fixed by a longer patch series. The "validity"
part of the second point must be addressed in the same patch series by
dropping the usage of ethtool's link_ksetting (thus always doing automatic
measurements over ethernet).
Drop the patch again to have more default values for various net_device
types/configurations. The user can still overwrite them using the
batadv_hardif's BATADV_ATTR_THROUGHPUT_OVERRIDE.
Reported-by: Matthias Schiffer <mschiffer@universe-factory.net>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/6e860b3d5e4147bafcda32bf9b3e769926f232c5
--- a/compat-include/linux/ethtool.h
+++ b/compat-include/linux/ethtool.h
@@ -21,7 +21,6 @@ struct batadv_ethtool_link_ksettings {
struct {
__u32 speed;
__u8 duplex;
- __u8 autoneg;
} base;
};
@@ -42,7 +41,6 @@ batadv_ethtool_get_link_ksettings(struct
return ret;
link_ksettings->base.duplex = cmd.duplex;
- link_ksettings->base.autoneg = cmd.autoneg;
link_ksettings->base.speed = ethtool_cmd_speed(&cmd);
return 0;
--- a/net/batman-adv/bat_v_elp.c
+++ b/net/batman-adv/bat_v_elp.c
@@ -120,20 +120,7 @@ static u32 batadv_v_elp_get_throughput(s
rtnl_lock();
ret = __ethtool_get_link_ksettings(hard_iface->net_dev, &link_settings);
rtnl_unlock();
-
- /* Virtual interface drivers such as tun / tap interfaces, VLAN, etc
- * tend to initialize the interface throughput with some value for the
- * sake of having a throughput number to export via ethtool. This
- * exported throughput leaves batman-adv to conclude the interface
- * throughput is genuine (reflecting reality), thus no measurements
- * are necessary.
- *
- * Based on the observation that those interface types also tend to set
- * the link auto-negotiation to 'off', batman-adv shall check this
- * setting to differentiate between genuine link throughput information
- * and placeholders installed by virtual interfaces.
- */
- if (ret == 0 && link_settings.base.autoneg == AUTONEG_ENABLE) {
+ if (ret == 0) {
/* link characteristics might change over time */
if (link_settings.base.duplex == DUPLEX_FULL)
hard_iface->bat_v.flags |= BATADV_FULL_DUPLEX;

View file

@ -0,0 +1,40 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Wed, 22 Jul 2020 20:49:23 +0200
Subject: batman-adv: Avoid uninitialized chaddr when handling DHCP
The gateway client code can try to optimize the delivery of DHCP packets to
avoid broadcasting them through the whole mesh. But also transmissions to
the client can be optimized by looking up the destination via the chaddr of
the DHCP packet.
But the chaddr is currently only done when chaddr is fully inside the
non-paged area of the skbuff. Otherwise it will not be initialized and the
unoptimized path should have been taken.
But the implementation didn't handle this correctly. It didn't retrieve the
correct chaddr but still tried to perform the TT lookup with this
uninitialized memory.
Reported-by: syzbot+ab16e463b903f5a37036@syzkaller.appspotmail.com
Fixes: 2d5b555644b2 ("batman-adv: send every DHCP packet as bat-unicast")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Acked-by: Antonio Quartulli <a@unstable.cc>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/fcdf008ffd749246632d1f9423163af5dc3f8c7f
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -703,8 +703,10 @@ batadv_gw_dhcp_recipient_get(struct sk_b
chaddr_offset = *header_len + BATADV_DHCP_CHADDR_OFFSET;
/* store the client address if the message is going to a client */
- if (ret == BATADV_DHCP_TO_CLIENT &&
- pskb_may_pull(skb, chaddr_offset + ETH_ALEN)) {
+ if (ret == BATADV_DHCP_TO_CLIENT) {
+ if (!pskb_may_pull(skb, chaddr_offset + ETH_ALEN))
+ return BATADV_DHCP_NO;
+
/* check if the DHCP packet carries an Ethernet DHCP */
p = skb->data + *header_len + BATADV_DHCP_HTYPE_OFFSET;
if (*p != BATADV_DHCP_HTYPE_ETHERNET)

View file

@ -0,0 +1,57 @@
From: Linus Lüssing <linus.luessing@c0d3.blue>
Date: Fri, 31 Jul 2020 00:22:55 +0200
Subject: batman-adv: Fix own OGM check in aggregated OGMs
The own OGM check is currently misplaced and can lead to the following
issues:
For one thing we might receive an aggregated OGM from a neighbor node
which has our own OGM in the first place. We would then not only skip
our own OGM but erroneously also any other, following OGM in the
aggregate.
For another, we might receive an OGM aggregate which has our own OGM in
a place other then the first one. Then we would wrongly not skip this
OGM, leading to populating the orginator and gateway table with ourself.
The latter seems to not only be a cosmetic issue, but there were reports
that this causes issues with various subsystems of batman-adv, too. For
instance there were reports about issues with DAT and either disabling
DAT or aggregation seemed to solve it.
Fixing these issues by applying the own OGM check not on the first OGM
in an aggregate but for each OGM in an aggregate instead.
Fixes: 667996ebeab ("batman-adv: OGMv2 - implement originators logic")
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/d41cc7cb62c184b2fb8ab97fda45815918200001
--- a/net/batman-adv/bat_v_ogm.c
+++ b/net/batman-adv/bat_v_ogm.c
@@ -704,6 +704,12 @@ static void batadv_v_ogm_process(const s
ntohl(ogm_packet->seqno), ogm_throughput, ogm_packet->ttl,
ogm_packet->version, ntohs(ogm_packet->tvlv_len));
+ if (batadv_is_my_mac(bat_priv, ogm_packet->orig)) {
+ batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
+ "Drop packet: originator packet from ourself\n");
+ return;
+ }
+
/* If the throughput metric is 0, immediately drop the packet. No need
* to create orig_node / neigh_node for an unusable route.
*/
@@ -831,11 +837,6 @@ int batadv_v_ogm_packet_recv(struct sk_b
if (batadv_is_my_mac(bat_priv, ethhdr->h_source))
goto free_skb;
- ogm_packet = (struct batadv_ogm2_packet *)skb->data;
-
- if (batadv_is_my_mac(bat_priv, ogm_packet->orig))
- goto free_skb;
-
batadv_inc_counter(bat_priv, BATADV_CNT_MGMT_RX);
batadv_add_counter(bat_priv, BATADV_CNT_MGMT_RX_BYTES,
skb->len + ETH_HLEN);

View file

@ -0,0 +1,29 @@
From: Jussi Kivilinna <jussi.kivilinna@haltian.com>
Date: Tue, 18 Aug 2020 17:46:10 +0300
Subject: batman-adv: bla: use netif_rx_ni when not in interrupt context
batadv_bla_send_claim() gets called from worker thread context through
batadv_bla_periodic_work(), thus netif_rx_ni needs to be used in that
case. This fixes "NOHZ: local_softirq_pending 08" log messages seen
when batman-adv is enabled.
Fixes: a9ce0dc43e2c ("batman-adv: add basic bridge loop avoidance code")
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@haltian.com>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/3747f81a1380b65740fc52fc71c7a3af4c6e49de
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -437,7 +437,10 @@ static void batadv_bla_send_claim(struct
batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES,
skb->len + ETH_HLEN);
- netif_rx(skb);
+ if (in_interrupt())
+ netif_rx(skb);
+ else
+ netif_rx_ni(skb);
out:
if (primary_if)
batadv_hardif_put(primary_if);

View file

@ -0,0 +1,39 @@
From: Linus Lüssing <ll@simonwunderlich.de>
Date: Thu, 27 Aug 2020 17:34:48 +0200
Subject: batman-adv: bla: fix type misuse for backbone_gw hash indexing
It seems that due to a copy & paste error the void pointer
in batadv_choose_backbone_gw() is cast to the wrong type.
Fixing this by using "struct batadv_bla_backbone_gw" instead of "struct
batadv_bla_claim" which better matches the caller's side.
For now it seems that we were lucky because the two structs both have
their orig/vid and addr/vid in the beginning. However I stumbled over
this issue when I was trying to add some debug variables in front of
"orig" in batadv_backbone_gw, which caused hash lookups to fail.
Fixes: 7e15c9305ce0 ("batman-adv: don't rely on positions in struct for hashing")
Signed-off-by: Linus Lüssing <ll@simonwunderlich.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/398a706cd46c1fc085aef56ae8ed11f76e182bd1
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -83,11 +83,12 @@ static inline u32 batadv_choose_claim(co
*/
static inline u32 batadv_choose_backbone_gw(const void *data, u32 size)
{
- const struct batadv_bla_claim *claim = (struct batadv_bla_claim *)data;
+ const struct batadv_bla_backbone_gw *gw;
u32 hash = 0;
- hash = jhash(&claim->addr, sizeof(claim->addr), hash);
- hash = jhash(&claim->vid, sizeof(claim->vid), hash);
+ gw = (struct batadv_bla_backbone_gw *)data;
+ hash = jhash(&gw->orig, sizeof(gw->orig), hash);
+ hash = jhash(&gw->vid, sizeof(gw->vid), hash);
return hash % size;
}

View file

@ -0,0 +1,43 @@
From: Linus Lüssing <linus.luessing@c0d3.blue>
Date: Fri, 4 Sep 2020 20:28:00 +0200
Subject: batman-adv: mcast/TT: fix wrongly dropped or rerouted packets
The unicast packet rerouting code makes several assumptions. For
instance it assumes that there is always exactly one destination in the
TT. This breaks for multicast frames in a unicast packets in several ways:
For one thing if there is actually no TT entry and the destination node
was selected due to the multicast tvlv flags it announced. Then an
intermediate node will wrongly drop the packet.
For another thing if there is a TT entry but the TTVN of this entry is
newer than the originally addressed destination node: Then the
intermediate node will wrongly redirect the packet, leading to
duplicated multicast packets at a multicast listener and missing
packets at other multicast listeners or multicast routers.
Fixing this by not applying the unicast packet rerouting to batman-adv
unicast packets with a multicast payload. We are not able to detect a
roaming multicast listener at the moment and will just continue to send
the multicast frame to both the new and old destination for a while in
case of such a roaming multicast listener.
Fixes: cea194d90b11 ("batman-adv: improved client announcement mechanism")
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/22e740c5e6c9342e0f5028beb3d14b84a018d113
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -826,6 +826,10 @@ static bool batadv_check_unicast_ttvn(st
vid = batadv_get_vid(skb, hdr_len);
ethhdr = (struct ethhdr *)(skb->data + hdr_len);
+ /* do not reroute multicast frames in a unicast header */
+ if (is_multicast_ether_addr(ethhdr->h_dest))
+ return true;
+
/* check if the destination client was served by this node and it is now
* roaming. In this case, it means that the node has got a ROAM_ADV
* message and that it knows the new destination in the mesh to re-route

View file

@ -0,0 +1,24 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Mon, 14 Sep 2020 13:58:16 +0200
Subject: batman-adv: Add missing include for in_interrupt()
The fix for receiving (internally generated) bla packets outside the
interrupt context introduced the usage of in_interrupt(). But this
functionality is only defined in linux/preempt.h which was not included
with the same patch.
Fixes: 3747f81a1380 ("batman-adv: bla: use netif_rx_ni when not in interrupt context")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/6ea99cd9c82b2d1bc4a313fe9006bcf5d956380e
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -25,6 +25,7 @@
#include <linux/lockdep.h>
#include <linux/netdevice.h>
#include <linux/netlink.h>
+#include <linux/preempt.h>
#include <linux/rculist.h>
#include <linux/rcupdate.h>
#include <linux/seq_file.h>

View file

@ -0,0 +1,164 @@
From: Linus Lüssing <linus.luessing@c0d3.blue>
Date: Tue, 15 Sep 2020 09:54:08 +0200
Subject: batman-adv: mcast: fix duplicate mcast packets in BLA backbone from LAN
Scenario:
* Multicast frame send from a BLA backbone (multiple nodes with
their bat0 bridged together, with BLA enabled)
Issue:
* BLA backbone nodes receive the frame multiple times on bat0
For multicast frames received via batman-adv broadcast packets the
originator of the broadcast packet is checked before decapsulating and
forwarding the frame to bat0 (batadv_bla_is_backbone_gw()->
batadv_recv_bcast_packet()). If it came from a node which shares the
same BLA backbone with us then it is not forwarded to bat0 to avoid a
loop.
When sending a multicast frame in a non-4-address batman-adv unicast
packet we are currently missing this check - and cannot do so because
the batman-adv unicast packet has no originator address field.
However, we can simply fix this on the sender side by only sending the
multicast frame via unicasts to interested nodes which do not share the
same BLA backbone with us. This also nicely avoids some unnecessary
transmissions on mesh side.
Note that no infinite loop was observed, probably because of dropping
via batadv_interface_tx()->batadv_bla_tx(). However the duplicates still
utterly confuse switches/bridges, ICMPv6 duplicate address detection and
neighbor discovery and therefore leads to long delays before being able
to establish TCP connections, for instance. And it also leads to the Linux
bridge printing messages like:
"br-lan: received packet on eth1 with own address as source address ..."
Fixes: 405cc1e5a81e ("batman-adv: Modified forwarding behaviour for multicast packets")
Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
Acked-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: backport, https://git.open-mesh.org/batman-adv.git/commit/3c39a2455a5be02ecceeaf1a15976bddd611392e
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -50,6 +50,7 @@
#include <uapi/linux/batadv_packet.h>
#include <uapi/linux/batman_adv.h>
+#include "bridge_loop_avoidance.h"
#include "hard-interface.h"
#include "hash.h"
#include "log.h"
@@ -1020,6 +1021,35 @@ batadv_mcast_forw_mode(struct batadv_pri
}
/**
+ * batadv_mcast_forw_send_orig() - send a multicast packet to an originator
+ * @bat_priv: the bat priv with all the soft interface information
+ * @skb: the multicast packet to send
+ * @vid: the vlan identifier
+ * @orig_node: the originator to send the packet to
+ *
+ * Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
+ */
+int batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv,
+ struct sk_buff *skb,
+ unsigned short vid,
+ struct batadv_orig_node *orig_node)
+{
+ /* Avoid sending multicast-in-unicast packets to other BLA
+ * gateways - they already got the frame from the LAN side
+ * we share with them.
+ * TODO: Refactor to take BLA into account earlier, to avoid
+ * reducing the mcast_fanout count.
+ */
+ if (batadv_bla_is_backbone_gw_orig(bat_priv, orig_node->orig, vid)) {
+ dev_kfree_skb(skb);
+ return NET_XMIT_SUCCESS;
+ }
+
+ return batadv_send_skb_unicast(bat_priv, skb, BATADV_UNICAST, 0,
+ orig_node, vid);
+}
+
+/**
* batadv_mcast_forw_tt() - forwards a packet to multicast listeners
* @bat_priv: the bat priv with all the soft interface information
* @skb: the multicast packet to transmit
@@ -1056,8 +1086,8 @@ batadv_mcast_forw_tt(struct batadv_priv
break;
}
- batadv_send_skb_unicast(bat_priv, newskb, BATADV_UNICAST, 0,
- orig_entry->orig_node, vid);
+ batadv_mcast_forw_send_orig(bat_priv, newskb, vid,
+ orig_entry->orig_node);
}
rcu_read_unlock();
@@ -1098,8 +1128,7 @@ batadv_mcast_forw_want_all_ipv4(struct b
break;
}
- batadv_send_skb_unicast(bat_priv, newskb, BATADV_UNICAST, 0,
- orig_node, vid);
+ batadv_mcast_forw_send_orig(bat_priv, newskb, vid, orig_node);
}
rcu_read_unlock();
return ret;
@@ -1136,8 +1165,7 @@ batadv_mcast_forw_want_all_ipv6(struct b
break;
}
- batadv_send_skb_unicast(bat_priv, newskb, BATADV_UNICAST, 0,
- orig_node, vid);
+ batadv_mcast_forw_send_orig(bat_priv, newskb, vid, orig_node);
}
rcu_read_unlock();
return ret;
--- a/net/batman-adv/multicast.h
+++ b/net/batman-adv/multicast.h
@@ -46,6 +46,11 @@ enum batadv_forw_mode
batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
struct batadv_orig_node **mcast_single_orig);
+int batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv,
+ struct sk_buff *skb,
+ unsigned short vid,
+ struct batadv_orig_node *orig_node);
+
int batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb,
unsigned short vid);
@@ -72,6 +77,16 @@ batadv_mcast_forw_mode(struct batadv_pri
}
static inline int
+batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv,
+ struct sk_buff *skb,
+ unsigned short vid,
+ struct batadv_orig_node *orig_node)
+{
+ kfree_skb(skb);
+ return NET_XMIT_DROP;
+}
+
+static inline int
batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb,
unsigned short vid)
{
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -363,9 +363,8 @@ send:
goto dropped;
ret = batadv_send_skb_via_gw(bat_priv, skb, vid);
} else if (mcast_single_orig) {
- ret = batadv_send_skb_unicast(bat_priv, skb,
- BATADV_UNICAST, 0,
- mcast_single_orig, vid);
+ 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);
} else {

View file

@ -0,0 +1,150 @@
From: Linus Lüssing <linus.luessing@c0d3.blue>
Date: Tue, 15 Sep 2020 09:54:09 +0200
Subject: batman-adv: mcast: fix duplicate mcast packets in BLA backbone from mesh
Scenario:
* Multicast frame send from mesh to a BLA backbone (multiple nodes
with their bat0 bridged together, with BLA enabled)
Issue:
* BLA backbone nodes receive the frame multiple times on bat0,
once from mesh->bat0 and once from each backbone_gw from LAN
For unicast, a node will send only to the best backbone gateway
according to the TQ. However for multicast we currently cannot determine
if multiple destination nodes share the same backbone if they don't share
the same backbone with us. So we need to keep sending the unicasts to
all backbone gateways and let the backbone gateways decide which one
will forward the frame. We can use the CLAIM mechanism to make this
decision.
One catch: The batman-adv gateway feature for DHCP packets potentially
sends multicast packets in the same batman-adv unicast header as the
multicast optimizations code. And we are not allowed to drop those even
if we did not claim the source address of the sender, as for such
packets there is only this one multicast-in-unicast packet.
How can we distinguish the two cases?
The gateway feature uses a batman-adv unicast 4 address header. While
the multicast-to-unicasts feature uses a simple, 3 address batman-adv
unicast header. So let's use this to distinguish.
Fixes: e32470167379 ("batman-adv: check incoming packet type for bla")
Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
Acked-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/d7665cf8a824c41c61c6e2110ab63d37eb7a8ef7
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -1814,7 +1814,7 @@ batadv_bla_loopdetect_check(struct batad
* @bat_priv: the bat priv with all the soft interface information
* @skb: the frame to be checked
* @vid: the VLAN ID of the frame
- * @is_bcast: the packet came in a broadcast packet type.
+ * @packet_type: the batman packet type this frame came in
*
* batadv_bla_rx avoidance checks if:
* * we have to race for a claim
@@ -1826,7 +1826,7 @@ batadv_bla_loopdetect_check(struct batad
* further process the skb.
*/
bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
- unsigned short vid, bool is_bcast)
+ unsigned short vid, int packet_type)
{
struct batadv_bla_backbone_gw *backbone_gw;
struct ethhdr *ethhdr;
@@ -1848,9 +1848,24 @@ bool batadv_bla_rx(struct batadv_priv *b
goto handled;
if (unlikely(atomic_read(&bat_priv->bla.num_requests)))
- /* don't allow broadcasts while requests are in flight */
- if (is_multicast_ether_addr(ethhdr->h_dest) && is_bcast)
- goto handled;
+ /* don't allow multicast packets while requests are in flight */
+ if (is_multicast_ether_addr(ethhdr->h_dest))
+ /* Both broadcast flooding or multicast-via-unicasts
+ * delivery might send to multiple backbone gateways
+ * sharing the same LAN and therefore need to coordinate
+ * which backbone gateway forwards into the LAN,
+ * by claiming the payload source address.
+ *
+ * Broadcast flooding and multicast-via-unicasts
+ * delivery use the following two batman packet types.
+ * Note: explicitly exclude BATADV_UNICAST_4ADDR,
+ * as the DHCP gateway feature will send explicitly
+ * to only one BLA gateway, so the claiming process
+ * should be avoided there.
+ */
+ if (packet_type == BATADV_BCAST ||
+ packet_type == BATADV_UNICAST)
+ goto handled;
ether_addr_copy(search_claim.addr, ethhdr->h_source);
search_claim.vid = vid;
@@ -1885,13 +1900,14 @@ bool batadv_bla_rx(struct batadv_priv *b
goto allow;
}
- /* if it is a broadcast ... */
- if (is_multicast_ether_addr(ethhdr->h_dest) && is_bcast) {
+ /* if it is a multicast ... */
+ if (is_multicast_ether_addr(ethhdr->h_dest) &&
+ (packet_type == BATADV_BCAST || packet_type == BATADV_UNICAST)) {
/* ... drop it. the responsible gateway is in charge.
*
- * We need to check is_bcast because with the gateway
+ * We need to check packet type because with the gateway
* feature, broadcasts (like DHCP requests) may be sent
- * using a unicast packet type.
+ * using a unicast 4 address packet type. See comment above.
*/
goto handled;
} else {
--- a/net/batman-adv/bridge_loop_avoidance.h
+++ b/net/batman-adv/bridge_loop_avoidance.h
@@ -36,7 +36,7 @@ static inline bool batadv_bla_is_loopdet
#ifdef CONFIG_BATMAN_ADV_BLA
bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
- unsigned short vid, bool is_bcast);
+ unsigned short vid, int packet_type);
bool batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
unsigned short vid);
bool batadv_bla_is_backbone_gw(struct sk_buff *skb,
@@ -67,7 +67,7 @@ bool batadv_bla_check_claim(struct batad
static inline bool batadv_bla_rx(struct batadv_priv *bat_priv,
struct sk_buff *skb, unsigned short vid,
- bool is_bcast)
+ int packet_type)
{
return false;
}
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -423,10 +423,10 @@ void batadv_interface_rx(struct net_devi
struct vlan_ethhdr *vhdr;
struct ethhdr *ethhdr;
unsigned short vid;
- bool is_bcast;
+ int packet_type;
batadv_bcast_packet = (struct batadv_bcast_packet *)skb->data;
- is_bcast = (batadv_bcast_packet->packet_type == BATADV_BCAST);
+ packet_type = batadv_bcast_packet->packet_type;
skb_pull_rcsum(skb, hdr_size);
skb_reset_mac_header(skb);
@@ -469,7 +469,7 @@ void batadv_interface_rx(struct net_devi
/* Let the bridge loop avoidance check the packet. If will
* not handle it, we can safely push it up.
*/
- if (batadv_bla_rx(bat_priv, skb, vid, is_bcast))
+ if (batadv_bla_rx(bat_priv, skb, vid, packet_type))
goto out;
if (orig_node)

View file

@ -0,0 +1,189 @@
From: Linus Lüssing <linus.luessing@c0d3.blue>
Date: Tue, 15 Sep 2020 09:54:10 +0200
Subject: batman-adv: mcast: fix duplicate mcast packets from BLA backbone to mesh
Scenario:
* Multicast frame send from BLA backbone gateways (multiple nodes
with their bat0 bridged together, with BLA enabled) sharing the same
LAN to nodes in the mesh
Issue:
* Nodes receive the frame multiple times on bat0 from the mesh,
once from each foreign BLA backbone gateway which shares the same LAN
with another
For multicast frames via batman-adv broadcast packets coming from the
same BLA backbone but from different backbone gateways duplicates are
currently detected via a CRC history of previously received packets.
However this CRC so far was not performed for multicast frames received
via batman-adv unicast packets. Fixing this by appyling the same check
for such packets, too.
Room for improvements in the future: Ideally we would introduce the
possibility to not only claim a client, but a complete originator, too.
This would allow us to only send a multicast-in-unicast packet from a BLA
backbone gateway claiming the node and by that avoid potential redundant
transmissions in the first place.
Fixes: e5cf86d30a9b ("batman-adv: add broadcast duplicate check")
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/c5cb6a670cc3070d9d5c5562f95fa75faac767ba
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -1581,13 +1581,16 @@ int batadv_bla_init(struct batadv_priv *
}
/**
- * batadv_bla_check_bcast_duplist() - Check if a frame is in the broadcast dup.
+ * batadv_bla_check_duplist() - Check if a frame is in the broadcast dup.
* @bat_priv: the bat priv with all the soft interface information
- * @skb: contains the bcast_packet to be checked
- *
- * check if it is on our broadcast list. Another gateway might
- * have sent the same packet because it is connected to the same backbone,
- * so we have to remove this duplicate.
+ * @skb: contains the multicast packet to be checked
+ * @payload_ptr: pointer to position inside the head buffer of the skb
+ * marking the start of the data to be CRC'ed
+ * @orig: originator mac address, NULL if unknown
+ *
+ * Check if it is on our broadcast list. Another gateway might have sent the
+ * same packet because it is connected to the same backbone, so we have to
+ * remove this duplicate.
*
* This is performed by checking the CRC, which will tell us
* with a good chance that it is the same packet. If it is furthermore
@@ -1596,19 +1599,17 @@ int batadv_bla_init(struct batadv_priv *
*
* Return: true if a packet is in the duplicate list, false otherwise.
*/
-bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
- struct sk_buff *skb)
+static bool batadv_bla_check_duplist(struct batadv_priv *bat_priv,
+ struct sk_buff *skb, u8 *payload_ptr,
+ const u8 *orig)
{
- int i, curr;
- __be32 crc;
- struct batadv_bcast_packet *bcast_packet;
struct batadv_bcast_duplist_entry *entry;
bool ret = false;
-
- bcast_packet = (struct batadv_bcast_packet *)skb->data;
+ int i, curr;
+ __be32 crc;
/* calculate the crc ... */
- crc = batadv_skb_crc32(skb, (u8 *)(bcast_packet + 1));
+ crc = batadv_skb_crc32(skb, payload_ptr);
spin_lock_bh(&bat_priv->bla.bcast_duplist_lock);
@@ -1627,8 +1628,21 @@ bool batadv_bla_check_bcast_duplist(stru
if (entry->crc != crc)
continue;
- if (batadv_compare_eth(entry->orig, bcast_packet->orig))
- continue;
+ /* are the originators both known and not anonymous? */
+ if (orig && !is_zero_ether_addr(orig) &&
+ !is_zero_ether_addr(entry->orig)) {
+ /* If known, check if the new frame came from
+ * the same originator:
+ * We are safe to take identical frames from the
+ * same orig, if known, as multiplications in
+ * the mesh are detected via the (orig, seqno) pair.
+ * So we can be a bit more liberal here and allow
+ * identical frames from the same orig which the source
+ * host might have sent multiple times on purpose.
+ */
+ if (batadv_compare_eth(entry->orig, orig))
+ continue;
+ }
/* this entry seems to match: same crc, not too old,
* and from another gw. therefore return true to forbid it.
@@ -1644,7 +1658,14 @@ bool batadv_bla_check_bcast_duplist(stru
entry = &bat_priv->bla.bcast_duplist[curr];
entry->crc = crc;
entry->entrytime = jiffies;
- ether_addr_copy(entry->orig, bcast_packet->orig);
+
+ /* known originator */
+ if (orig)
+ ether_addr_copy(entry->orig, orig);
+ /* anonymous originator */
+ else
+ eth_zero_addr(entry->orig);
+
bat_priv->bla.bcast_duplist_curr = curr;
out:
@@ -1654,6 +1675,48 @@ out:
}
/**
+ * batadv_bla_check_ucast_duplist() - Check if a frame is in the broadcast dup.
+ * @bat_priv: the bat priv with all the soft interface information
+ * @skb: contains the multicast packet to be checked, decapsulated from a
+ * unicast_packet
+ *
+ * Check if it is on our broadcast list. Another gateway might have sent the
+ * same packet because it is connected to the same backbone, so we have to
+ * remove this duplicate.
+ *
+ * Return: true if a packet is in the duplicate list, false otherwise.
+ */
+static bool batadv_bla_check_ucast_duplist(struct batadv_priv *bat_priv,
+ struct sk_buff *skb)
+{
+ return batadv_bla_check_duplist(bat_priv, skb, (u8 *)skb->data, NULL);
+}
+
+/**
+ * batadv_bla_check_bcast_duplist() - Check if a frame is in the broadcast dup.
+ * @bat_priv: the bat priv with all the soft interface information
+ * @skb: contains the bcast_packet to be checked
+ *
+ * Check if it is on our broadcast list. Another gateway might have sent the
+ * same packet because it is connected to the same backbone, so we have to
+ * remove this duplicate.
+ *
+ * Return: true if a packet is in the duplicate list, false otherwise.
+ */
+bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
+ struct sk_buff *skb)
+{
+ struct batadv_bcast_packet *bcast_packet;
+ u8 *payload_ptr;
+
+ bcast_packet = (struct batadv_bcast_packet *)skb->data;
+ payload_ptr = (u8 *)(bcast_packet + 1);
+
+ return batadv_bla_check_duplist(bat_priv, skb, payload_ptr,
+ bcast_packet->orig);
+}
+
+/**
* batadv_bla_is_backbone_gw_orig() - Check if the originator is a gateway for
* the VLAN identified by vid.
* @bat_priv: the bat priv with all the soft interface information
@@ -1867,6 +1930,14 @@ bool batadv_bla_rx(struct batadv_priv *b
packet_type == BATADV_UNICAST)
goto handled;
+ /* potential duplicates from foreign BLA backbone gateways via
+ * multicast-in-unicast packets
+ */
+ if (is_multicast_ether_addr(ethhdr->h_dest) &&
+ packet_type == BATADV_UNICAST &&
+ batadv_bla_check_ucast_duplist(bat_priv, skb))
+ goto handled;
+
ether_addr_copy(search_claim.addr, ethhdr->h_source);
search_claim.vid = vid;
claim = batadv_claim_hash_find(bat_priv, &search_claim);

View file

@ -0,0 +1,23 @@
From: Taehee Yoo <ap420073@gmail.com>
Date: Sun, 15 Nov 2020 10:30:04 +0000
Subject: batman-adv: set .owner to THIS_MODULE
If THIS_MODULE is not set, the module would be removed while debugfs is
being used.
It eventually makes kernel panic.
Fixes: 24571be14371 ("batman-adv: add routing debug log accessible via debugfs")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/6e2937539a2c9f8a8536515258bc1f08bed19a06
--- a/net/batman-adv/log.c
+++ b/net/batman-adv/log.c
@@ -180,6 +180,7 @@ static const struct file_operations bata
.read = batadv_log_read,
.poll = batadv_log_poll,
.llseek = no_llseek,
+ .owner = THIS_MODULE,
};
/**

View file

@ -0,0 +1,28 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Thu, 26 Nov 2020 18:15:06 +0100
Subject: batman-adv: Consider fragmentation for needed_headroom
If a batman-adv packets has to be fragmented, then the original batman-adv
packet header is not stripped away. Instead, only a new header is added in
front of the packet after it was split.
This size must be considered to avoid cost intensive reallocations during
the transmission through the various device layers.
Fixes: e2b4301f4e2d ("batman-adv: Add lower layer needed_(head|tail)room to own ones")
Reported-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/92064deda9b063ca2d5a53b307c6127a9453357c
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -553,6 +553,9 @@ static void batadv_hardif_recalc_extra_s
needed_headroom = lower_headroom + (lower_header_len - ETH_HLEN);
needed_headroom += batadv_max_header_len();
+ /* fragmentation headers don't strip the unicast/... header */
+ needed_headroom += sizeof(struct batadv_frag_packet);
+
soft_iface->needed_headroom = needed_headroom;
soft_iface->needed_tailroom = lower_tailroom;
}

View file

@ -0,0 +1,79 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Wed, 25 Nov 2020 13:16:43 +0100
Subject: batman-adv: Reserve needed_*room for fragments
The batadv net_device is trying to propagate the needed_headroom and
needed_tailroom from the lower devices. This is needed to avoid cost
intensive reallocations using pskb_expand_head during the transmission.
But the fragmentation code split the skb's without adding extra room at the
end/beginning of the various fragments. This reduced the performance of
transmissions over complex scenarios (batadv on vxlan on wireguard) because
the lower devices had to perform the reallocations at least once.
Fixes: db56e4ecf5c2 ("batman-adv: Fragment and send skbs larger than mtu")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/0966d5424bb87e863037301488519ccdd69e4d26
--- a/net/batman-adv/fragmentation.c
+++ b/net/batman-adv/fragmentation.c
@@ -391,6 +391,7 @@ out:
/**
* batadv_frag_create() - create a fragment from skb
+ * @net_dev: outgoing device for fragment
* @skb: skb to create fragment from
* @frag_head: header to use in new fragment
* @fragment_size: size of new fragment
@@ -401,22 +402,25 @@ out:
*
* Return: the new fragment, NULL on error.
*/
-static struct sk_buff *batadv_frag_create(struct sk_buff *skb,
+static struct sk_buff *batadv_frag_create(struct net_device *net_dev,
+ struct sk_buff *skb,
struct batadv_frag_packet *frag_head,
unsigned int fragment_size)
{
+ unsigned int ll_reserved = LL_RESERVED_SPACE(net_dev);
+ unsigned int tailroom = net_dev->needed_tailroom;
struct sk_buff *skb_fragment;
unsigned int header_size = sizeof(*frag_head);
unsigned int mtu = fragment_size + header_size;
- skb_fragment = netdev_alloc_skb(NULL, mtu + ETH_HLEN);
+ skb_fragment = dev_alloc_skb(ll_reserved + mtu + tailroom);
if (!skb_fragment)
goto err;
skb_fragment->priority = skb->priority;
/* Eat the last mtu-bytes of the skb */
- skb_reserve(skb_fragment, header_size + ETH_HLEN);
+ skb_reserve(skb_fragment, ll_reserved + header_size);
skb_split(skb, skb_fragment, skb->len - fragment_size);
/* Add the header */
@@ -439,11 +443,12 @@ int batadv_frag_send_packet(struct sk_bu
struct batadv_orig_node *orig_node,
struct batadv_neigh_node *neigh_node)
{
+ struct net_device *net_dev = neigh_node->if_incoming->net_dev;
struct batadv_priv *bat_priv;
struct batadv_hard_iface *primary_if = NULL;
struct batadv_frag_packet frag_header;
struct sk_buff *skb_fragment;
- unsigned int mtu = neigh_node->if_incoming->net_dev->mtu;
+ unsigned int mtu = net_dev->mtu;
unsigned int header_size = sizeof(frag_header);
unsigned int max_fragment_size, num_fragments;
int ret;
@@ -503,7 +508,7 @@ int batadv_frag_send_packet(struct sk_bu
goto put_primary_if;
}
- skb_fragment = batadv_frag_create(skb, &frag_header,
+ skb_fragment = batadv_frag_create(net_dev, skb, &frag_header,
max_fragment_size);
if (!skb_fragment) {
ret = -ENOMEM;

View file

@ -0,0 +1,39 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Thu, 26 Nov 2020 18:24:49 +0100
Subject: batman-adv: Don't always reallocate the fragmentation skb head
When a packet is fragmented by batman-adv, the original batman-adv header
is not modified. Only a new fragmentation is inserted between the original
one and the ethernet header. The code must therefore make sure that it has
a writable region of this size in the skbuff head.
But it is not useful to always reallocate the skbuff by this size even when
there would be more than enough headroom still in the skb. The reallocation
is just to costly during in this codepath.
Fixes: db56e4ecf5c2 ("batman-adv: Fragment and send skbs larger than mtu")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/3e3ff987876d3be70d928561acbefe5a48ab1654
--- a/net/batman-adv/fragmentation.c
+++ b/net/batman-adv/fragmentation.c
@@ -527,13 +527,14 @@ int batadv_frag_send_packet(struct sk_bu
frag_header.no++;
}
- /* Make room for the fragment header. */
- if (batadv_skb_head_push(skb, header_size) < 0 ||
- pskb_expand_head(skb, header_size + ETH_HLEN, 0, GFP_ATOMIC) < 0) {
- ret = -ENOMEM;
+ /* make sure that there is at least enough head for the fragmentation
+ * and ethernet headers
+ */
+ ret = skb_cow_head(skb, ETH_HLEN + header_size);
+ if (ret < 0)
goto put_primary_if;
- }
+ skb_push(skb, header_size);
memcpy(skb->data, &frag_header, header_size);
/* Send the last fragment */

View file

@ -0,0 +1,31 @@
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;

View file

@ -0,0 +1,162 @@
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
@@ -1561,10 +1561,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
@@ -197,29 +197,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);
@@ -229,8 +241,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
@@ -155,8 +155,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
@@ -4405,8 +4405,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,

View file

@ -0,0 +1,182 @@
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: backport, 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
@@ -1350,21 +1350,21 @@ static const struct genl_ops batadv_netl
},
{
.cmd = BATADV_CMD_TP_METER,
- .flags = GENL_ADMIN_PERM,
+ .flags = GENL_UNS_ADMIN_PERM,
.policy = batadv_netlink_policy,
.doit = batadv_netlink_tp_meter_start,
.internal_flags = BATADV_FLAG_NEED_MESH,
},
{
.cmd = BATADV_CMD_TP_METER_CANCEL,
- .flags = GENL_ADMIN_PERM,
+ .flags = GENL_UNS_ADMIN_PERM,
.policy = batadv_netlink_policy,
.doit = batadv_netlink_tp_meter_cancel,
.internal_flags = BATADV_FLAG_NEED_MESH,
},
{
.cmd = BATADV_CMD_GET_ROUTING_ALGOS,
- .flags = GENL_ADMIN_PERM,
+ .flags = GENL_UNS_ADMIN_PERM,
.policy = batadv_netlink_policy,
.dumpit = batadv_algo_dump,
},
@@ -1379,68 +1379,68 @@ static const struct genl_ops batadv_netl
},
{
.cmd = BATADV_CMD_GET_TRANSTABLE_LOCAL,
- .flags = GENL_ADMIN_PERM,
+ .flags = GENL_UNS_ADMIN_PERM,
.policy = batadv_netlink_policy,
.dumpit = batadv_tt_local_dump,
},
{
.cmd = BATADV_CMD_GET_TRANSTABLE_GLOBAL,
- .flags = GENL_ADMIN_PERM,
+ .flags = GENL_UNS_ADMIN_PERM,
.policy = batadv_netlink_policy,
.dumpit = batadv_tt_global_dump,
},
{
.cmd = BATADV_CMD_GET_ORIGINATORS,
- .flags = GENL_ADMIN_PERM,
+ .flags = GENL_UNS_ADMIN_PERM,
.policy = batadv_netlink_policy,
.dumpit = batadv_orig_dump,
},
{
.cmd = BATADV_CMD_GET_NEIGHBORS,
- .flags = GENL_ADMIN_PERM,
+ .flags = GENL_UNS_ADMIN_PERM,
.policy = batadv_netlink_policy,
.dumpit = batadv_hardif_neigh_dump,
},
{
.cmd = BATADV_CMD_GET_GATEWAYS,
- .flags = GENL_ADMIN_PERM,
+ .flags = GENL_UNS_ADMIN_PERM,
.policy = batadv_netlink_policy,
.dumpit = batadv_gw_dump,
},
{
.cmd = BATADV_CMD_GET_BLA_CLAIM,
- .flags = GENL_ADMIN_PERM,
+ .flags = GENL_UNS_ADMIN_PERM,
.policy = batadv_netlink_policy,
.dumpit = batadv_bla_claim_dump,
},
{
.cmd = BATADV_CMD_GET_BLA_BACKBONE,
- .flags = GENL_ADMIN_PERM,
+ .flags = GENL_UNS_ADMIN_PERM,
.policy = batadv_netlink_policy,
.dumpit = batadv_bla_backbone_dump,
},
{
.cmd = BATADV_CMD_GET_DAT_CACHE,
- .flags = GENL_ADMIN_PERM,
+ .flags = GENL_UNS_ADMIN_PERM,
.policy = batadv_netlink_policy,
.dumpit = batadv_dat_cache_dump,
},
{
.cmd = BATADV_CMD_GET_MCAST_FLAGS,
- .flags = GENL_ADMIN_PERM,
+ .flags = GENL_UNS_ADMIN_PERM,
.policy = batadv_netlink_policy,
.dumpit = batadv_mcast_flags_dump,
},
{
.cmd = BATADV_CMD_SET_MESH,
- .flags = GENL_ADMIN_PERM,
+ .flags = GENL_UNS_ADMIN_PERM,
.policy = batadv_netlink_policy,
.doit = batadv_netlink_set_mesh,
.internal_flags = BATADV_FLAG_NEED_MESH,
},
{
.cmd = BATADV_CMD_SET_HARDIF,
- .flags = GENL_ADMIN_PERM,
+ .flags = GENL_UNS_ADMIN_PERM,
.policy = batadv_netlink_policy,
.doit = batadv_netlink_set_hardif,
.internal_flags = BATADV_FLAG_NEED_MESH |
@@ -1456,7 +1456,7 @@ static const struct genl_ops batadv_netl
},
{
.cmd = BATADV_CMD_SET_VLAN,
- .flags = GENL_ADMIN_PERM,
+ .flags = GENL_UNS_ADMIN_PERM,
.policy = batadv_netlink_policy,
.doit = batadv_netlink_set_vlan,
.internal_flags = BATADV_FLAG_NEED_MESH |

View file

@ -7,12 +7,12 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=bird1 PKG_NAME:=bird1
PKG_VERSION:=1.6.4 PKG_VERSION:=1.6.6
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_SOURCE:=bird-$(PKG_VERSION).tar.gz PKG_SOURCE:=bird-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=ftp://bird.network.cz/pub/bird PKG_SOURCE_URL:=ftp://bird.network.cz/pub/bird
PKG_MD5SUM:=c26b8caae988dba81a9dbbee93502463d4326d1b749d728d62aa5529c605afc0 PKG_HASH:=975b3b7aefbe1e0dc9c11e55517f0ca2d82cca1d544e2e926f78bc843aaf2d70
PKG_BUILD_DEPENDS:=ncurses readline PKG_BUILD_DEPENDS:=ncurses readline
PKG_MAINTAINER:=Álvaro Fernández Rojas <noltari@gmail.com> PKG_MAINTAINER:=Álvaro Fernández Rojas <noltari@gmail.com>
PKG_BUILD_DIR:=$(BUILD_DIR)/bird-$(PKG_VERSION) PKG_BUILD_DIR:=$(BUILD_DIR)/bird-$(PKG_VERSION)
@ -23,19 +23,19 @@ include $(INCLUDE_DIR)/package.mk
define Package/bird1/Default define Package/bird1/Default
TITLE:=The BIRD Internet Routing Daemon (v1.6) TITLE:=The BIRD Internet Routing Daemon (v1.6)
URL:=http://bird.network.cz/ URL:=https://bird.network.cz/
DEPENDS:=+libpthread DEPENDS:=+libpthread
endef endef
define Package/bird1c/Default define Package/bird1c/Default
TITLE:=The BIRD command-line client (v1.6) TITLE:=The BIRD command-line client (v1.6)
URL:=http://bird.network.cz/ URL:=https://bird.network.cz/
DEPENDS:= +libreadline +libncurses DEPENDS:=+libreadline +libncurses
endef endef
define Package/bird1cl/Default define Package/bird1cl/Default
TITLE:=The BIRD lightweight command-line client (v1.6) TITLE:=The BIRD lightweight command-line client (v1.6)
URL:=http://bird.network.cz/ URL:=https://bird.network.cz/
endef endef
define Package/bird1/Default/description1 define Package/bird1/Default/description1
@ -93,7 +93,7 @@ $(call Package/bird1c/Default)
CATEGORY:=Network CATEGORY:=Network
SUBMENU:=Routing and Redirection SUBMENU:=Routing and Redirection
TITLE+= (IPv4) TITLE+= (IPv4)
DEPENDS+= +bird1-ipv4 DEPENDS+=+bird1-ipv4
CONFLICTS+=birdc4 CONFLICTS+=birdc4
endef endef
@ -103,7 +103,7 @@ $(call Package/bird1cl/Default)
CATEGORY:=Network CATEGORY:=Network
SUBMENU:=Routing and Redirection SUBMENU:=Routing and Redirection
TITLE+= (IPv4) TITLE+= (IPv4)
DEPENDS+= +bird1-ipv4 DEPENDS+=+bird1-ipv4
CONFLICTS+=birdcl4 CONFLICTS+=birdcl4
endef endef
@ -122,7 +122,7 @@ $(call Package/bird1c/Default)
CATEGORY:=Network CATEGORY:=Network
SUBMENU:=Routing and Redirection SUBMENU:=Routing and Redirection
TITLE+= (IPv6) TITLE+= (IPv6)
DEPENDS+= +bird1-ipv6 DEPENDS+=+bird1-ipv6
CONFLICTS+=birdc6 CONFLICTS+=birdc6
endef endef
@ -132,7 +132,7 @@ $(call Package/bird1cl/Default)
CATEGORY:=Network CATEGORY:=Network
SUBMENU:=Routing and Redirection SUBMENU:=Routing and Redirection
TITLE+= (IPv6) TITLE+= (IPv6)
DEPENDS+= +bird1-ipv6 DEPENDS+=+bird1-ipv6
CONFLICTS+=birdcl6 CONFLICTS+=birdcl6
endef endef

View file

@ -7,17 +7,18 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=bird2 PKG_NAME:=bird2
PKG_VERSION:=2.0.2 PKG_VERSION:=2.0.10
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_SOURCE:=bird-$(PKG_VERSION).tar.gz PKG_SOURCE:=bird-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=ftp://bird.network.cz/pub/bird PKG_SOURCE_URL:=ftp://bird.network.cz/pub/bird
PKG_HASH:=035f91d6f568f8ed438a0814235ac4c5c79147cd2acf201322c307732883480f PKG_HASH:=7ed341ddd8dc87fa9736586b3515447a8436fec442d65f4022155ab9de1ffd5a
PKG_BUILD_DEPENDS:=ncurses readline
PKG_MAINTAINER:=Toke Høiland-Jørgensen <toke@toke.dk>
PKG_BUILD_DIR:=$(BUILD_DIR)/bird-$(PKG_VERSION)
PKG_LICENSE:=GPL-2.0 PKG_MAINTAINER:=Toke Høiland-Jørgensen <toke@toke.dk>
PKG_LICENSE:=GPL-2.0-or-later
PKG_BUILD_DEPENDS:=ncurses readline
PKG_BUILD_DIR:=$(BUILD_DIR)/bird-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
@ -96,7 +97,7 @@ protocols, telling BIRD to show various information, telling it to show
a routing table filtered by a filter, or asking BIRD to reconfigure. a routing table filtered by a filter, or asking BIRD to reconfigure.
endef endef
CONFIGURE_ARGS += --with-linux-headers="$(LINUX_DIR)" --disable-libssh CONFIGURE_ARGS += --disable-libssh
define Package/bird2/conffiles define Package/bird2/conffiles
/etc/bird.conf /etc/bird.conf

View file

@ -11,10 +11,14 @@ BIRD_PID_FILE="/var/run/bird.pid"
start_service() { start_service() {
mkdir -p /var/run mkdir -p /var/run
procd_open_instance procd_open_instance
procd_set_param command $BIRD_BIN -c $BIRD_CONF -P $BIRD_PID_FILE procd_set_param command $BIRD_BIN -f -c $BIRD_CONF -P $BIRD_PID_FILE
procd_set_param file "$BIRD_CONF" procd_set_param file "$BIRD_CONF"
procd_set_param stdout 1 procd_set_param stdout 1
procd_set_param stderr 1 procd_set_param stderr 1
procd_set_param respawn procd_set_param respawn
procd_close_instance procd_close_instance
} }
reload_service() {
procd_send_signal bird
}

View file

@ -1,29 +0,0 @@
From f3a8cf050e6181e158dcde2fe885d7bf220eedc3 Mon Sep 17 00:00:00 2001
From: "Ondrej Zajicek (work)" <santiago@crfreenet.org>
Date: Thu, 12 Apr 2018 16:55:56 +0200
Subject: [PATCH] BGP: Fix extended next hop handling
For IPv4 with extended next hop, we use MP-BGP format and therefore no
independent NEXT_HOP attribute.
Thanks to Arvin Gan for the bugreport.
---
proto/bgp/attrs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c
index 0f41f818..9003feb2 100644
--- a/proto/bgp/attrs.c
+++ b/proto/bgp/attrs.c
@@ -295,7 +295,7 @@ bgp_encode_next_hop(struct bgp_write_state *s, eattr *a, byte *buf, uint size)
* store it and encode it later by AFI-specific hooks.
*/
- if (s->channel->afi == BGP_AF_IPV4)
+ if ((s->channel->afi == BGP_AF_IPV4) && !s->channel->ext_next_hop)
{
ASSERT(a->u.ptr->length == sizeof(ip_addr));
--
2.17.0

View file

@ -1,37 +0,0 @@
From 823ad12191e66e243dd088a81c66e4a518563e40 Mon Sep 17 00:00:00 2001
From: Jan Maria Matejka <mq@ucw.cz>
Date: Fri, 27 Apr 2018 14:38:41 +0200
Subject: [PATCH] Filter: Added missing instruction comparators.
These instructions caused SIGABORTs on reconfiguration.
---
filter/filter.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/filter/filter.c b/filter/filter.c
index bb3146e7..881ba420 100644
--- a/filter/filter.c
+++ b/filter/filter.c
@@ -1712,7 +1712,10 @@ i_same(struct f_inst *f1, struct f_inst *f2)
case FI_EA_SET: ONEARG; A2_SAME; break;
case FI_RETURN: ONEARG; break;
+ case FI_ROA_MAXLEN: ONEARG; break;
+ case FI_ROA_ASN: ONEARG; break;
case FI_IP: ONEARG; break;
+ case FI_IS_V4: ONEARG; break;
case FI_ROUTE_DISTINGUISHER: ONEARG; break;
case FI_CALL: /* Call rewriting trickery to avoid exponential behaviour */
ONEARG;
@@ -1735,6 +1738,8 @@ i_same(struct f_inst *f1, struct f_inst *f2)
((struct f_inst_roa_check *) f2)->rtc->name))
return 0;
break;
+ case FI_FORMAT: ONEARG; break;
+ case FI_ASSERT: ONEARG; break;
default:
bug( "Unknown instruction %d in same (%c)", f1->fi_code, f1->fi_code & 0xff);
}
--
2.17.0

View file

@ -1,33 +0,0 @@
From 40e7bd0e39849a03bd3f6f44d6719a5f8b1dd291 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= <toke@toke.dk>
Date: Mon, 30 Apr 2018 16:29:20 +0200
Subject: [PATCH] babel: Fix type of route entry router ID
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The router ID being assigned to routes was a uint, which discards the upper
32 bits. This also has the nice side effect of echoing the wrong router ID
back to other routers.
Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
---
proto/babel/babel.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/proto/babel/babel.c b/proto/babel/babel.c
index 4fd88042..a8eb5ea8 100644
--- a/proto/babel/babel.c
+++ b/proto/babel/babel.c
@@ -2140,7 +2140,7 @@ babel_rt_notify(struct proto *P, struct channel *c UNUSED, struct network *net,
uint internal = (new->attrs->src->proto == P);
uint rt_seqno = internal ? new->u.babel.seqno : p->update_seqno;
uint rt_metric = ea_get_int(attrs, EA_BABEL_METRIC, 0);
- uint rt_router_id = internal ? new->u.babel.router_id : p->router_id;
+ u64 rt_router_id = internal ? new->u.babel.router_id : p->router_id;
if (rt_metric > BABEL_INFINITY)
{
--
2.17.0

View file

@ -1,118 +0,0 @@
From 70fab17837dbb4c5848681e4c6b9b90891891130 Mon Sep 17 00:00:00 2001
From: "Ondrej Zajicek (work)" <santiago@crfreenet.org>
Date: Thu, 3 May 2018 16:55:11 +0200
Subject: [PATCH 1/2] Babel: Add option to randomize router ID
When a Babel node restarts, it loses its sequence number, which can cause
its routes to be rejected by peers until the state is cleared out by other
nodes in the network (which can take on the order of minutes).
There are two ways to fix this: Having stable storage to keep the sequence
number across restarts, or picking a different router ID each time.
This implements the latter, by introducing a new option that will cause
BIRD to randomize a high 32 bits of router ID every time it starts up.
This avoids the problem at the cost of not having stable router IDs in
the network.
Thanks to Toke Hoiland-Jorgensen for the patch.
---
doc/bird.sgml | 10 ++++++++++
proto/babel/babel.c | 11 +++++++++++
proto/babel/babel.h | 1 +
proto/babel/config.Y | 3 ++-
4 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/doc/bird.sgml b/doc/bird.sgml
index 1191fa03..ae308d4c 100644
--- a/doc/bird.sgml
+++ b/doc/bird.sgml
@@ -1691,6 +1691,7 @@ supports the following per-interface configuration options:
protocol babel [<name>] {
ipv4 { <channel config> };
ipv6 [sadr] { <channel config> };
+ randomize router id <switch>;
interface <interface pattern> {
type <wired|wireless>;
rxcost <number>;
@@ -1713,6 +1714,15 @@ protocol babel [<name>] {
<tag><label id="babel-channel">ipv4 | ipv6 [sadr] <m/channel config/</tag>
The supported channels are IPv4, IPv6, and IPv6 SADR.
+ <tag><label id="babel-random-router-id">randomize router id <m/switch/</tag>
+ If enabled, Bird will randomize the top 32 bits of its router ID whenever
+ the protocol instance starts up. If a Babel node restarts, it loses its
+ sequence number, which can cause its routes to be rejected by peers until
+ the state is cleared out by other nodes in the network (which can take on
+ the order of minutes). Enabling this option causes Bird to pick a random
+ router ID every time it starts up, which avoids this problem at the cost
+ of not having stable router IDs in the network. Default: no.
+
<tag><label id="babel-type">type wired|wireless </tag>
This option specifies the interface type: Wired or wireless. On wired
interfaces a neighbor is considered unreachable after a small number of
diff --git a/proto/babel/babel.c b/proto/babel/babel.c
index 797a83d4..ce05191c 100644
--- a/proto/babel/babel.c
+++ b/proto/babel/babel.c
@@ -2226,6 +2226,14 @@ babel_init(struct proto_config *CF)
return P;
}
+static inline void
+babel_randomize_router_id(struct babel_proto *p)
+{
+ p->router_id &= (u64) 0xffffffff;
+ p->router_id |= ((u64) random()) << 32;
+ TRACE(D_EVENTS, "Randomized router ID to %lR", p->router_id);
+}
+
static int
babel_start(struct proto *P)
{
@@ -2244,6 +2252,9 @@ babel_start(struct proto *P)
p->update_seqno = 1;
p->router_id = proto_get_router_id(&cf->c);
+ if (cf->randomize_router_id)
+ babel_randomize_router_id(p);
+
p->route_slab = sl_new(P->pool, sizeof(struct babel_route));
p->source_slab = sl_new(P->pool, sizeof(struct babel_source));
p->msg_slab = sl_new(P->pool, sizeof(struct babel_msg_node));
diff --git a/proto/babel/babel.h b/proto/babel/babel.h
index b194ce30..e5c9cd5b 100644
--- a/proto/babel/babel.h
+++ b/proto/babel/babel.h
@@ -112,6 +112,7 @@ struct babel_config {
struct proto_config c;
list iface_list; /* List of iface configs (struct babel_iface_config) */
uint hold_time; /* Time to hold stale entries and unreachable routes */
+ u8 randomize_router_id;
struct channel_config *ip4_channel;
struct channel_config *ip6_channel;
diff --git a/proto/babel/config.Y b/proto/babel/config.Y
index 7adfb4bb..205b4e4f 100644
--- a/proto/babel/config.Y
+++ b/proto/babel/config.Y
@@ -25,7 +25,7 @@ CF_DECLS
CF_KEYWORDS(BABEL, INTERFACE, METRIC, RXCOST, HELLO, UPDATE, INTERVAL, PORT,
TYPE, WIRED, WIRELESS, RX, TX, BUFFER, PRIORITY, LENGTH, CHECK, LINK,
NEXT, HOP, IPV4, IPV6, BABEL_METRIC, SHOW, INTERFACES, NEIGHBORS,
- ENTRIES)
+ ENTRIES, RANDOMIZE, ROUTER, ID)
CF_GRAMMAR
@@ -42,6 +42,7 @@ babel_proto_item:
proto_item
| proto_channel
| INTERFACE babel_iface
+ | RANDOMIZE ROUTER ID bool { BABEL_CFG->randomize_router_id = $4; }
;
babel_proto_opts:
--
2.17.0

View file

@ -1,30 +0,0 @@
From eaf63d314d50cba5b2cfa8f18de64a91d3131b94 Mon Sep 17 00:00:00 2001
From: "Ondrej Zajicek (work)" <santiago@crfreenet.org>
Date: Thu, 3 May 2018 17:07:39 +0200
Subject: [PATCH 2/2] Better initialization of random generator
Use full time precision to initialize random generator. The old
code was prone to initialize it to the same values in specific
circumstances (boot without RTC, multiple VMs starting at once).
---
sysdep/unix/io.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
index 012deaf0..11a0d6f1 100644
--- a/sysdep/unix/io.c
+++ b/sysdep/unix/io.c
@@ -2144,7 +2144,9 @@ io_init(void)
// XXX init_times();
// XXX update_times();
boot_time = current_time();
- srandom((uint) (current_real_time() TO_S));
+
+ u64 now = (u64) current_real_time();
+ srandom((uint) (now ^ (now >> 32)));
}
static int short_loops = 0;
--
2.17.0

View file

@ -1,40 +0,0 @@
From 0ca3156f64a46c52c6d6fc913958f83970d3e57f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= <toke@toke.dk>
Date: Mon, 30 Apr 2018 11:13:02 +0200
Subject: [PATCH] babel: Set onlink flag for IPv4 routes with unreachable next
hop
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
If the next hop of a route is not a reachable address, the route should be
installed as onlink. This enables a configuration common in mesh networks
where the mesh interface is assigned a /32 and babel handles the routing by
installing onlink routes.
Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
---
proto/babel/babel.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/proto/babel/babel.c b/proto/babel/babel.c
index ce05191c..afd2eb19 100644
--- a/proto/babel/babel.c
+++ b/proto/babel/babel.c
@@ -640,6 +640,13 @@ babel_announce_rte(struct babel_proto *p, struct babel_entry *e)
.nh.iface = r->neigh->ifa->iface,
};
+ /* If we cannot find a reachable neighbour, set the entry to be onlink. This
+ * makes it possible to, e.g., assign /32 addresses on a mesh interface and
+ * have routing work.
+ */
+ if (!neigh_find2(&p->p, &r->next_hop, r->neigh->ifa->iface, 0))
+ a0.nh.flags = RNF_ONLINK;
+
rta *a = rta_lookup(&a0);
rte *rte = rte_get_temp(a);
rte->u.babel.seqno = r->seqno;
--
2.17.0

View file

@ -1,28 +0,0 @@
diff --git a/Makefile.in b/Makefile.in
index c8168bb..eb6cc5c 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -21,11 +21,6 @@ INSTALL=@INSTALL@
INSTALL_PROGRAM=@INSTALL_PROGRAM@
INSTALL_DATA=@INSTALL_DATA@
-git-label:=$(strip $(shell git describe --always --dirty=-x 2>/dev/null))
-ifneq ($(git-label),)
- CFLAGS += -DGIT_LABEL="$(git-label)"
-endif
-
client=$(addprefix $(exedir)/,@CLIENT@)
daemon=$(exedir)/bird
protocols=@protocols@
@@ -42,6 +37,11 @@ srcdir := @srcdir@
objdir := @objdir@
exedir := @exedir@
+git-label:=$(strip $(shell cd $(srcdir) && [ "$$(git rev-parse --show-toplevel)" = "$$(readlink -f .)" ] && git describe --always --dirty=-x 2>/dev/null))
+ifneq ($(git-label),)
+ CFLAGS += -DGIT_LABEL="$(git-label)"
+endif
+
ifeq ($(objdir),.)
objdir := $(realpath .)
endif

View file

@ -1,99 +0,0 @@
From b24b781117179f301116837f0a39468343e4805b Mon Sep 17 00:00:00 2001
From: "Ondrej Zajicek (work)" <santiago@crfreenet.org>
Date: Wed, 16 May 2018 11:19:29 +0200
Subject: [PATCH] Filter: Add support for src filter op to access SADR source
prefix
The patch allows to use 'net.src' to access SADR source prefix
from filters.
Thanks to Toke Hoiland-Jorgensen for the original patch for srclen.
---
filter/config.Y | 3 ++-
filter/filter.c | 15 +++++++++++++++
filter/filter.h | 1 +
lib/net.h | 2 ++
4 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/filter/config.Y b/filter/config.Y
index f8170a83..e01e02ef 100644
--- a/filter/config.Y
+++ b/filter/config.Y
@@ -411,7 +411,7 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, UNSET, RETURN,
TRUE, FALSE, RT, RO, UNKNOWN, GENERIC,
FROM, GW, NET, MASK, PROTO, SOURCE, SCOPE, DEST, IFNAME, IFINDEX,
PREFERENCE,
- ROA_CHECK, ASN,
+ ROA_CHECK, ASN, SRC,
IS_V4, IS_V6,
LEN, MAXLEN,
DEFINED,
@@ -898,6 +898,7 @@ term:
| term '.' LEN { $$ = f_new_inst(FI_LENGTH); $$->a1.p = $1; }
| term '.' MAXLEN { $$ = f_new_inst(FI_ROA_MAXLEN); $$->a1.p = $1; }
| term '.' ASN { $$ = f_new_inst(FI_ROA_ASN); $$->a1.p = $1; }
+ | term '.' SRC { $$ = f_new_inst(FI_SADR_SRC); $$->a1.p = $1; }
| term '.' MASK '(' term ')' { $$ = f_new_inst(FI_IP_MASK); $$->a1.p = $1; $$->a2.p = $5; }
| term '.' FIRST { $$ = f_new_inst(FI_AS_PATH_FIRST); $$->a1.p = $1; }
| term '.' LAST { $$ = f_new_inst(FI_AS_PATH_LAST); $$->a1.p = $1; }
diff --git a/filter/filter.c b/filter/filter.c
index 881ba420..3d7b5c9f 100644
--- a/filter/filter.c
+++ b/filter/filter.c
@@ -1241,6 +1241,20 @@ interpret(struct f_inst *what)
default: runtime( "Prefix, path, clist or eclist expected" );
}
break;
+ case FI_SADR_SRC: /* Get SADR src prefix */
+ ONEARG;
+ if (v1.type != T_NET || !net_is_sadr(v1.val.net))
+ runtime( "SADR expected" );
+
+ {
+ net_addr_ip6_sadr *net = (void *) v1.val.net;
+ net_addr *src = lp_alloc(f_pool, sizeof(net_addr_ip6));
+ net_fill_ip6(src, net->src_prefix, net->src_pxlen);
+
+ res.type = T_NET;
+ res.val.net = src;
+ }
+ break;
case FI_ROA_MAXLEN: /* Get ROA max prefix length */
ONEARG;
if (v1.type != T_NET || !net_is_roa(v1.val.net))
@@ -1714,6 +1728,7 @@ i_same(struct f_inst *f1, struct f_inst *f2)
case FI_RETURN: ONEARG; break;
case FI_ROA_MAXLEN: ONEARG; break;
case FI_ROA_ASN: ONEARG; break;
+ case FI_SADR_SRC: ONEARG; break;
case FI_IP: ONEARG; break;
case FI_IS_V4: ONEARG; break;
case FI_ROUTE_DISTINGUISHER: ONEARG; break;
diff --git a/filter/filter.h b/filter/filter.h
index d347924a..982276f0 100644
--- a/filter/filter.h
+++ b/filter/filter.h
@@ -55,6 +55,7 @@
F(FI_LENGTH, 0, 'L') \
F(FI_ROA_MAXLEN, 'R', 'M') \
F(FI_ROA_ASN, 'R', 'A') \
+ F(FI_SADR_SRC, 'n', 's') \
F(FI_IP, 'c', 'p') \
F(FI_ROUTE_DISTINGUISHER, 'R', 'D') \
F(FI_AS_PATH_FIRST, 'a', 'f') \
diff --git a/lib/net.h b/lib/net.h
index ad4000fd..0cd5f735 100644
--- a/lib/net.h
+++ b/lib/net.h
@@ -268,6 +268,8 @@ static inline int net_is_roa(const net_addr *a)
static inline int net_is_flow(const net_addr *a)
{ return (a->type == NET_FLOW4) || (a->type == NET_FLOW6); }
+static inline int net_is_sadr(const net_addr *a)
+{ return (a->type == NET_IP6_SADR); }
static inline ip4_addr net4_prefix(const net_addr *a)
{ return ((net_addr_ip4 *) a)->prefix; }
--
2.17.0

View file

@ -21,6 +21,7 @@ PKG_VERSION:=20.2
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_SOURCE_URL:=https://github.com/cjdelisle/cjdns.git PKG_SOURCE_URL:=https://github.com/cjdelisle/cjdns.git
PKG_MIRROR_HASH:=2bcf168b48faab8352db95f85a664adf733554ccc8ea788f1689385b1e7acecb
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=77259a49e5bc7ca7bc6dca5bd423e02be563bdc5 PKG_SOURCE_VERSION:=77259a49e5bc7ca7bc6dca5bd423e02be563bdc5
PKG_LICENSE:=GPL-3.0 PKG_LICENSE:=GPL-3.0
@ -38,7 +39,7 @@ define Package/cjdns
TITLE:=Encrypted near-zero-conf mesh routing protocol TITLE:=Encrypted near-zero-conf mesh routing protocol
URL:=https://github.com/cjdelisle/cjdns URL:=https://github.com/cjdelisle/cjdns
MAINTAINER:=Lars Gierth <larsg@systemli.org> MAINTAINER:=Lars Gierth <larsg@systemli.org>
DEPENDS:=@IPV6 +kmod-tun +libnl-tiny +libpthread +librt \ DEPENDS:=@!arc @IPV6 +kmod-tun +libnl-tiny +libpthread +librt \
+libuci-lua +lua-bencode +dkjson +luasocket +lua-sha2 +libuci-lua +lua-bencode +dkjson +luasocket +lua-sha2
endef endef
@ -56,7 +57,7 @@ define Package/cjdns-tests
TITLE:=cjdns test cases TITLE:=cjdns test cases
URL:=https://github.com/cjdelisle/cjdns URL:=https://github.com/cjdelisle/cjdns
MAINTAINER:=Lars Gierth <larsg@systemli.org> MAINTAINER:=Lars Gierth <larsg@systemli.org>
DEPENDS:=+libpthread +librt DEPENDS:=+libpthread +librt @!arc
endef endef
define Package/cjdns-test/description define Package/cjdns-test/description

View file

@ -13,6 +13,7 @@ PKG_RELEASE:=2
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/sbyx/hnetd.git PKG_SOURCE_URL:=https://github.com/sbyx/hnetd.git
PKG_MIRROR_HASH:=5f06f72d5620de25e29b3e34a6524aebd8e7b5c8160cfd29135a6ec0f12ffa3e
PKG_MAINTAINER:=Steven Barth <cyrus@openwrt.org> PKG_MAINTAINER:=Steven Barth <cyrus@openwrt.org>
PKG_LICENSE:=GPL-2.0 PKG_LICENSE:=GPL-2.0

View file

@ -10,8 +10,6 @@ Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
src/dtls.c | 20 +++++++++++++++++--- src/dtls.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-) 1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/src/dtls.c b/src/dtls.c
index ed5d408..511f724 100644
--- a/src/dtls.c --- a/src/dtls.c
+++ b/src/dtls.c +++ b/src/dtls.c
@@ -38,6 +38,7 @@ @@ -38,6 +38,7 @@
@ -51,7 +49,7 @@ index ed5d408..511f724 100644
if (!d) if (!d)
{ {
@@ -916,7 +930,7 @@ bool dtls_set_local_cert(dtls d, const char *certfile, const char *pkfile) @@ -916,7 +930,7 @@ bool dtls_set_local_cert(dtls d, const c
|SSL_VERIFY_FAIL_IF_NO_PEER_CERT |SSL_VERIFY_FAIL_IF_NO_PEER_CERT
#endif /* DTLS_OPENSSL */ #endif /* DTLS_OPENSSL */
, _verify_cert_cb); , _verify_cert_cb);
@ -60,7 +58,7 @@ index ed5d408..511f724 100644
#ifndef USE_ONE_CONTEXT #ifndef USE_ONE_CONTEXT
R1("client cert", R1("client cert",
@@ -928,7 +942,7 @@ bool dtls_set_local_cert(dtls d, const char *certfile, const char *pkfile) @@ -928,7 +942,7 @@ bool dtls_set_local_cert(dtls d, const c
|SSL_VERIFY_PEER_FAIL_IF_NO_PEER_CERT |SSL_VERIFY_PEER_FAIL_IF_NO_PEER_CERT
#endif /* DTLS_OPENSSL */ #endif /* DTLS_OPENSSL */
, _verify_cert_cb); , _verify_cert_cb);

View file

@ -20,7 +20,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-bmx6 PKG_NAME:=luci-app-bmx6
PKG_RELEASE:=5 PKG_RELEASE:=6
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
PKG_LICENSE:=GPL-2.0+ PKG_LICENSE:=GPL-2.0+

View file

@ -1,6 +1,6 @@
<script type="text/javascript">//<![CDATA[ <script type="text/javascript">//<![CDATA[
XHR.poll(5, '/cgi-bin/bmx6-info', { '$neighbours': '' }, XHR.poll(5, '/cgi-bin/bmx6-info', { 'neighbours': '' },
function(x, st) function(x, st)
{ {
var originators = st.neighbours[0].originators; var originators = st.neighbours[0].originators;

View file

@ -87,7 +87,7 @@
document.getElementById('extra-info').innerHTML = document.getElementById(id).innerHTML; document.getElementById('extra-info').innerHTML = document.getElementById(id).innerHTML;
} }
new TablePooler(5,"/cgi-bin/bmx6-info", {'$neighbours':''}, "descriptions_table", function(st){ new TablePooler(5,"/cgi-bin/bmx6-info", {'neighbours':''}, "descriptions_table", function(st){
var infoicon = "<%=resource%>/bmx6/world_small.png"; var infoicon = "<%=resource%>/bmx6/world_small.png";
var nodeicon = "<%=resource%>/bmx6/world.png"; var nodeicon = "<%=resource%>/bmx6/world.png";
var originators = st.neighbours[0].originators; var originators = st.neighbours[0].originators;

View file

@ -63,7 +63,7 @@ Visit <a href="http://bmx6.net">bmx6.net</a> for more info.
</div> </div>
<script type="text/javascript">//<![CDATA[ <script type="text/javascript">//<![CDATA[
new TablePooler(5,"/cgi-bin/bmx6-info", {'$info':''}, "status_table", function(st){ new TablePooler(5,"/cgi-bin/bmx6-info", {'info':''}, "status_table", function(st){
var res = Array(); var res = Array();
var sta = st.info[0].status; var sta = st.info[0].status;
var ifaces = st.info[1].interfaces; var ifaces = st.info[1].interfaces;

View file

@ -81,7 +81,7 @@
</div> </div>
<script type="text/javascript">//<![CDATA[ <script type="text/javascript">//<![CDATA[
new TablePooler(5,"/cgi-bin/bmx6-info", {'$tunnels':''}, "descriptions_table", function(st){ new TablePooler(5,"/cgi-bin/bmx6-info", {'tunnels':''}, "descriptions_table", function(st){
var tunicon = "<%=resource%>/icons/tunnel.png"; var tunicon = "<%=resource%>/icons/tunnel.png";
var tunicon_dis = "<%=resource%>/icons/tunnel_disabled.png"; var tunicon_dis = "<%=resource%>/icons/tunnel_disabled.png";
var applyicon = "<%=resource%>/cbi/apply.gif"; var applyicon = "<%=resource%>/cbi/apply.gif";
@ -91,7 +91,7 @@
var nodename = tunnel.remoteName.replace(/\..+$/,''); var nodename = tunnel.remoteName.replace(/\..+$/,'');
var advnet = tunnel.advNet; var advnet = tunnel.advNet;
var status = '<img src="'+tunicon_dis+'"/>'; var status = '<img src="'+tunicon_dis+'"/>';
if ( tunnel.tunName != "---" ) status = '<img src="'+tunicon+'"/>'; if ( tunnel.tunName != "---" ) status = '<img src="'+tunicon+'"/>';
if ( advnet == "0.0.0.0/0" ) advnet = "<b>Internet</b>"; if ( advnet == "0.0.0.0/0" ) advnet = "<b>Internet</b>";

View file

@ -10,10 +10,11 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=mcproxy PKG_NAME:=mcproxy
PKG_SOURCE_VERSION:=93b5ace42268160ebbfff4c61818fb15fa2d9b99 PKG_SOURCE_VERSION:=93b5ace42268160ebbfff4c61818fb15fa2d9b99
PKG_VERSION:=2017-08-24-$(PKG_SOURCE_VERSION) PKG_VERSION:=2017-08-24-$(PKG_SOURCE_VERSION)
PKG_RELEASE:=1 PKG_RELEASE:=2
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/mcproxy/mcproxy.git PKG_SOURCE_URL:=https://github.com/mcproxy/mcproxy.git
PKG_MIRROR_HASH:=5779a78dedaef491825ada632fe6d8282067025dede41d0eede5c441893a2994
PKG_MAINTAINER:=Steven Barth <cyrus@openwrt.org> PKG_MAINTAINER:=Steven Barth <cyrus@openwrt.org>
PKG_LICENSE:=GPL-2.0+ PKG_LICENSE:=GPL-2.0+

View file

@ -4,7 +4,7 @@
#include <numeric> #include <numeric>
#include <unistd.h> #include <unistd.h>
+#ifndef __GLIBC__ +#if !defined(__GLIBC__) || defined(__UCLIBC__)
+#include "sourcefilter.cpp" +#include "sourcefilter.cpp"
+#endif /* __GLIBC__ */ +#endif /* __GLIBC__ */
+ +

View file

@ -3,7 +3,7 @@
@@ -38,6 +38,8 @@ @@ -38,6 +38,8 @@
#include <unistd.h> #include <unistd.h>
#ifndef __GLIBC__ #if !defined(__GLIBC__) || defined(__UCLIBC__)
+#define IP_MULTICAST_ALL 49 +#define IP_MULTICAST_ALL 49
+ +
#include "sourcefilter.cpp" #include "sourcefilter.cpp"

View file

@ -13,6 +13,7 @@ PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/fingon/minimalist-pcproxy.git PKG_SOURCE_URL:=https://github.com/fingon/minimalist-pcproxy.git
PKG_MIRROR_HASH:=d3e872ee6207829ef142d22d591d203e4836f6aa150167411b542e8df4af4d53
PKG_MAINTAINER:=Markus Stenberg <fingon@iki.fi> PKG_MAINTAINER:=Markus Stenberg <fingon@iki.fi>
PKG_LICENSE:=GPL-2.0 PKG_LICENSE:=GPL-2.0

View file

@ -14,6 +14,7 @@ PKG_RELEASE:=2
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/hugosantos/mrd6.git PKG_SOURCE_URL:=https://github.com/hugosantos/mrd6.git
PKG_MIRROR_HASH:=d338549549c1e7b3f8a292c76e04cbfad1c7c6c9c77cbce6afbaa99bee9b8460
PKG_MAINTAINER:=Steven Barth <cyrus@openwrt.org> PKG_MAINTAINER:=Steven Barth <cyrus@openwrt.org>
PKG_LICENSE:=GPL-2.0+ PKG_LICENSE:=GPL-2.0+

View file

@ -7,12 +7,12 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=nodogsplash PKG_NAME:=nodogsplash
PKG_FIXUP:=autoreconf PKG_FIXUP:=autoreconf
PKG_VERSION:=3.3.2 PKG_VERSION:=4.0.3
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_SOURCE_URL:=https://codeload.github.com/nodogsplash/nodogsplash/tar.gz/v$(PKG_VERSION)? PKG_SOURCE_URL:=https://codeload.github.com/nodogsplash/nodogsplash/tar.gz/v$(PKG_VERSION)?
PKG_SOURCE:=nodogsplash-$(PKG_VERSION).tar.gz PKG_SOURCE:=nodogsplash-$(PKG_VERSION).tar.gz
PKG_HASH:=5a7b14dd2cce6a8ca261a720d87948565fc2f05d4926bf155b9e0db483ff6bcb PKG_HASH:=cae212fe7f3c1be8ff5a294a97ab414798f03425635407e18f069e7e4670b250
PKG_BUILD_DIR:=$(BUILD_DIR)/nodogsplash-$(PKG_VERSION) PKG_BUILD_DIR:=$(BUILD_DIR)/nodogsplash-$(PKG_VERSION)
PKG_MAINTAINER:=Moritz Warning <moritzwarning@web.de> PKG_MAINTAINER:=Moritz Warning <moritzwarning@web.de>
@ -60,6 +60,7 @@ define Package/nodogsplash/install
$(CP) $(PKG_BUILD_DIR)/openwrt/nodogsplash/files/etc/uci-defaults/40_nodogsplash $(1)/etc/uci-defaults/ $(CP) $(PKG_BUILD_DIR)/openwrt/nodogsplash/files/etc/uci-defaults/40_nodogsplash $(1)/etc/uci-defaults/
$(CP) $(PKG_BUILD_DIR)/openwrt/nodogsplash/files/usr/lib/nodogsplash/restart.sh $(1)/usr/lib/nodogsplash/ $(CP) $(PKG_BUILD_DIR)/openwrt/nodogsplash/files/usr/lib/nodogsplash/restart.sh $(1)/usr/lib/nodogsplash/
$(CP) $(PKG_BUILD_DIR)/forward_authentication_service/PreAuth/demo-preauth.sh $(1)/usr/lib/nodogsplash/login.sh $(CP) $(PKG_BUILD_DIR)/forward_authentication_service/PreAuth/demo-preauth.sh $(1)/usr/lib/nodogsplash/login.sh
$(CP) $(PKG_BUILD_DIR)/forward_authentication_service/fas-aes/fas-aes.php $(1)/etc/nodogsplash/
endef endef
define Package/nodogsplash/postrm define Package/nodogsplash/postrm

View file

@ -13,6 +13,7 @@ PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/sbyx/ohybridproxy.git PKG_SOURCE_URL:=https://github.com/sbyx/ohybridproxy.git
PKG_MIRROR_HASH:=bddd7554300b41cc82d24363bfb5f552c1e5ea51b34daeea242c0e5e1522785b
PKG_MAINTAINER:=Steven Barth <cyrus@openwrt.org> PKG_MAINTAINER:=Steven Barth <cyrus@openwrt.org>
PKG_LICENSE:=GPL-2.0 PKG_LICENSE:=GPL-2.0

View file

@ -7,8 +7,6 @@ Subject: [PATCH] Cmake: Search and find libubox/utils.h
CMakeLists.txt | 3 +++ CMakeLists.txt | 3 +++
1 file changed, 3 insertions(+) 1 file changed, 3 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2556669d2a52..1c970d92ff56 100644
--- a/CMakeLists.txt --- a/CMakeLists.txt
+++ b/CMakeLists.txt +++ b/CMakeLists.txt
@@ -16,6 +16,9 @@ else(${APPLE}) @@ -16,6 +16,9 @@ else(${APPLE})
@ -21,6 +19,3 @@ index 2556669d2a52..1c970d92ff56 100644
set(CORE src/cache.c src/io.c src/socket.c) set(CORE src/cache.c src/io.c src/socket.c)
add_executable(ohybridproxy src/ohybridproxy.c src/dns2mdns.c ${CORE}) add_executable(ohybridproxy src/ohybridproxy.c src/dns2mdns.c ${CORE})
--
2.9.3

View file

@ -13,6 +13,7 @@ PKG_RELEASE=$(PKG_SOURCE_VERSION)
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/OLSR/olsrd.git PKG_SOURCE_URL:=https://github.com/OLSR/olsrd.git
PKG_MIRROR_HASH:=77bdfdf2fe8aa0033f99a1b53326caaa73929720633a307a5155a2aee014d938
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=v0.9.7 PKG_SOURCE_VERSION:=v0.9.7
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz

View file

View file

@ -7,6 +7,7 @@ PKG_RELEASE:=$(PKG_REV)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=https://github.com/OLSR/OONF.git PKG_SOURCE_URL:=https://github.com/OLSR/OONF.git
PKG_MIRROR_HASH:=cee8fb6c087e6dc62789fabccbe79e3cbc843a669a3f79cde885e8f81b4585f4
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=$(PKG_REV) PKG_SOURCE_VERSION:=$(PKG_REV)

Some files were not shown because too many files have changed in this diff Show more