Compare commits

..

150 commits

Author SHA1 Message Date
Moritz Warning
ff31270ed7
Merge pull request #327 from wigyori/for-15.05-ndppd2
ndppd: fix source URL
2018-03-04 00:34:24 +01:00
Bastian Bittorf
6865dcb07e
Merge pull request #306 from HRogge/for-15.05
OONF 0.14.1-1
2017-12-13 12:41:57 +01:00
elektra42
cb742b8574
Merge pull request #328 from wigyori/for-15.05-batmand2
CC: batmand: move download source
2017-11-13 13:28:44 +01:00
Alexander Ryzhov
f62f82020d ndppd: fix source URL (#209)
Signed-off-by: Alexander Ryzhov <openwrt@ryzhov-al.ru>
2017-11-10 21:30:39 +01:00
Sven Eckelmann
6684bff253 batmand: Use git repository to retrieve sources
The current package is build around the subversion repository which does
not exist anymore. The package can therefore be moved to the git repository
to have an official source for the revision used in OpenWrt.

The SVN version of batman r1439 was actually r1435. The git export of revision
r1435 is referenced by this commit. The version number was only increased
to 1440 to create a new source tarball. SVN revision r1440 is not a commit
for batman and therefore no code changes in batman was done in r1440.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2017-11-10 20:57:09 +01:00
Sven Eckelmann
4eb57b4298 vis: Extract vis package from batmand
The batmand and vis sources are actually stored in two different
repositories. It therefore makes more sense to have these two packages also
split in two different OpenWrt packages. This also allows to get the vis
sources directly from the git repository.

The SVN version of vis r1439 was actually r1346. The git export of revision
r1346 is referenced by this commit.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2017-11-10 20:57:04 +01:00
Sven Eckelmann
c48460940d batmand: Switch upstream URL to HTTPS
The open-mesh.org server is not serving plain HTTP pages since a while.
Updating the default URL to https is therefore prefered.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2017-11-10 20:56:59 +01:00
Sven Eckelmann
fd0439743a batmand: Replace maintainer with Elektra
The mail address for Marek Lindner was not up to date. Marek was also not
maintaining this package and was forwarding requests to Elektra:

  "Elektra is the maintainer for batmand. I'd rather not interfere."

https://github.com/openwrt-routing/packages/pull/134#issuecomment-236346560

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2017-11-10 20:56:56 +01:00
Jo-Philipp Wich
a31039825c batmand: switch to tarball download, fix build with musl libc
Since the upstream SVN repository is not available anymore, update the
Makefile to fetch tarballs cached by the LEDE or OpenWrt projects instead.

Also add a missing -D_GNU_SOURCE to the target flags to fix compilation
with musl libc.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2017-11-10 20:56:52 +01:00
Henning Rogge
39b42f3e29 Update OONF to 0.14.1-1 2017-06-13 10:59:44 +02:00
Henning Rogge
42d763fb2f Add v0.14.0 OONF 2017-06-06 16:48:41 +02:00
Saverio Proto
79b4b3eff1 Merge pull request #285 from gabri94/for-15.05
Version bump of the poprouting package
2017-03-04 21:58:11 +01:00
Gabriel
f2b1aa2640 fixed +PKG_RELEASE 2017-03-04 21:51:30 +01:00
Gabriel
66215e36db Makefile for v0.3.1 2017-03-04 19:44:30 +01:00
gabri94
e00d8bb35b Symbolic Version number 2017-03-02 18:06:56 +01:00
gabri94
740fab1483 compile v0.3 2017-03-02 12:55:42 +01:00
gabri94
eea095ac63 New makefile for prince v0.3 2017-03-01 09:27:00 +01:00
Bastian Bittorf
c4d975fc18 Merge pull request #265 from gabri94/for-15.05
For 15.05
2017-01-27 10:26:14 +01:00
Gabriel
7737ef11ef Changed description 2017-01-26 22:21:44 +01:00
Gabriel
e4fadd105e added install 2017-01-26 22:21:44 +01:00
Gabriel
c46abbf197 fixup! fixup! addedd poprouting makefile 2017-01-26 22:21:44 +01:00
Gabriel
cfdc4583ea fixup! addedd poprouting makefile
Conflicts:
	poprouting/Makefile
2017-01-26 22:21:42 +01:00
Bastian Bittorf
1975a41c2c Merge pull request #239 from sarumpaet/for-15.05
Cherry-pick olsrd1 IPv6 fixes to for-15.05
2016-11-05 10:16:04 +01:00
Stefan Sperling
27762fdabe Replace == operator in test with = operator.
Requested by bittorf in https://github.com/openwrt-routing/packages/pull/155

(cherry picked from commit cde0b2f813)
2016-11-05 02:05:56 +01:00
Stefan Sperling
497950bf2c Fix '/etc/init.d/olsrd6 restart' breaks IPv4 SmartGateway.
Restarting olsrd for IPv6 clears SmartGateway firewall rules for both IPv4
and IPv6, and does not restore the IPv4 rules. As a result, IPv4 SmartGateway
functionality is broken after /etc/init.d/olsrd6 restart.

(cherry picked from commit f7ffb388b1)
2016-11-05 02:00:01 +01:00
Bastian Bittorf
17d50421de Merge pull request #235 from HRogge/for-15.05
Update to OONF version 0.13.0
2016-10-21 13:00:41 +02:00
Henning Rogge
270f11bfb2 Update to OONF version 0.13.0 2016-10-21 12:50:57 +02:00
Bastian Bittorf
26268e3fcc Merge pull request #229 from HRogge/for-15.05
Update to OONF 0.12.4
2016-09-09 20:16:54 +02:00
Henning Rogge
97cad3cdb3 Update to OONF 0.12.4 2016-09-04 14:22:01 +02:00
Bastian Bittorf
7a89a2bb06 Merge pull request #225 from HRogge/for-15.05
Update to OONF 0.12.3
2016-08-18 13:44:34 +02:00
Henning Rogge
8251c442a8 Update to OONF 0.12.3 2016-08-17 17:21:35 +02:00
Bastian Bittorf
82e0aece7c Merge pull request #218 from HRogge/for-15.05
Update to OONF 0.12.2 + coverity fix
2016-08-09 13:15:14 +02:00
Henning Rogge
5a0d85dc53 Update to OONF 0.12.2 + coverity fix 2016-08-01 11:58:51 +02:00
zorun
06844bbcb7 Merge pull request #214 from zorun/babeld_update_url_cc
babeld: Update source URL
2016-07-30 13:36:02 +02:00
Baptiste Jonglez
7aa480831c babeld: Update source URL
There is a HTTP redirection in place from the old URL to the new URL, but
better change it now than waiting for the redirection to disappear.

Signed-off-by: Baptiste Jonglez <git@bitsofnetworks.org>
2016-07-30 13:31:11 +02:00
Axel Neumann
d9cadd9c7b bmx7: update source (fixing several DoS scenarios) 2016-07-20 11:17:37 +02:00
Axel Neumann
0dc9e3911e bmx7: update source (disable sysctl settings for net/ipv4/conf/{all|default}) 2016-07-19 16:01:49 +02:00
Axel Neumann
0e56d45e21 bmx7: update source (fixing discarded dhm packet signatures) 2016-07-12 15:00:23 +02:00
lindnermarek
216429d8fd Merge pull request #207 from ecsv/ecsv/batadv-cc-speedyjoin
CC: batman-adv: Fix speedy join in gateway client mode
2016-07-06 21:38:15 +08:00
Sven Eckelmann
0d86d08be9 batman-adv: Fix speedy join in gateway client mode
Speedy join only works when the received packet is either broadcast or an
4addr unicast packet. Thus packets converted from broadcast to unicast via
the gateway handling code have to be converted to 4addr packets to allow
the receiving gateway server to add the sender address as temporary entry
to the translation table.

Not doing it will make the batman-adv gateway server drop the DHCP response
in many situations because it doesn't yet have the TT entry for the
destination of the DHCP response.

Signed-off-by: Sven Eckelmann <sven.eckelmann@open-mesh.com>
2016-07-06 15:36:23 +02:00
Sven Eckelmann
14e98d86ac batman-adv: Add reference counting + nullptr fixes
* Avoid nullptr dereference in bla after vlan_insert_tag
 * Avoid nullptr dereference in dat after vlan_insert_tag
 * Avoid tt_req_node list put for unhashed entry
 * Fix orig_node_vlan leak on orig_node_release
 * Fix non-atomic bla_claim::backbone_gw access
 * Fix reference leak in batadv_find_router
 * Free last_bonding_candidate on release of orig_node

Signed-off-by: Sven Eckelmann <sven.eckelmann@open-mesh.com>
2016-07-05 12:03:44 +02:00
Axel Neumann
654c00719a bmx7: update source 2016-07-01 11:05:27 +02:00
Markus Stenberg
50ac90a9cc miniupnpd: Fix UUID dependency not to check outside the tree, and use uuid always. 2016-06-28 15:18:52 +03:00
Markus Stenberg
d6658ba5fe Merge pull request #202 from axet/for-15.05
miniupnpd-2.0
2016-06-28 00:26:16 +03:00
Alexey Kuznetsov
18a43e9c1d Update Makefile 2016-06-27 20:07:55 +03:00
Alexey Kuznetsov
cf7ecaa1e4 miniupnpd-2.0 2016-06-27 19:52:57 +03:00
Bastian Bittorf
b5c3eed9ee Merge pull request #199 from HRogge/for-15.05
OONF v0.12.1
2016-06-20 11:57:13 +02:00
Henning Rogge
257136013c OONF release 0.12.1 2016-06-07 11:20:36 +02:00
lindnermarek
d26f350b01 Merge pull request #194 from ecsv/for-15.05/batman-adv
batman-adv: Add fixes from upcoming 2016.2 release
2016-06-07 14:25:35 +08:00
Sven Eckelmann
f1f7684c2c batman-adv: Add fixes from upcoming 2016.2 release
The upcoming batman-adv 2016.2 contains multiple new features, code
refactoring and similar things. These may not be fitting for Chaos Calmer
but the changes in the maintenance branch (bugfixes) should be integrated
to increase the stability.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
2016-06-07 08:14:51 +02:00
Alexander Couzens
29c2d49c8e batman-adv: remove DEPENDS:=kmod-crypto-core
kmod-crypto-core was removed in openwrt/trunk svn 46820 and all
kconfig's are now built-in.

Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
2016-06-06 18:56:37 +02:00
Axel Neumann
f99ea75b41 bmx7: update code version 2016-06-04 17:01:22 +02:00
Henning Rogge
688d19d3a8 Update to OONF 0.12.0 2016-05-31 09:02:24 +02:00
Henning Rogge
546bf039db Merge branch 'for-15.05' of github.com:HRogge/packages into for-15.05 2016-05-31 09:02:05 +02:00
Bastian Bittorf
cb1c017cf2 Merge pull request #188 from HRogge/for-15.05
For 15.05
2016-05-25 10:15:18 +02:00
Markus Stenberg
810780abb1 hnetd: Updated to RFC7787/7788 compliant version. 2016-05-17 00:13:29 +03:00
Markus Stenberg
0788f346e3 ohybridproxy: Bumped to latest (has bunch of bugfixes). 2016-05-17 00:13:09 +03:00
Henning Rogge
14bf7626cf Update OONF to v0.11.7 2016-05-13 15:05:06 +02:00
Henning Rogge
4aa0be2da8 Update OONF to 0.11.6 2016-05-13 10:50:19 +02:00
Henning Rogge
0290758f22 Update OONF packages to 0.11.5 2016-05-12 20:17:53 +02:00
Marek Lindner
a3cd8a1729 batman-adv: 2016.1 bugfixes & stability updates
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
2016-05-07 20:43:29 +08:00
Axel Neumann
16ceff232d bmx7: bump version (report channel via topology plugin) 2016-05-06 10:35:47 +02:00
Axel Neumann
b5ad75c563 bmx7: bump version (report link snr via topology plugin) 2016-05-06 10:19:53 +02:00
Marek Lindner
76e83819b4 batman-adv: revert partial cfg80211 kernel dependency
The entire batman-adv code relies on the kernel backports introduced
by the mac80211 package.

Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
2016-05-06 00:09:54 +08:00
Marek Lindner
e35df7827f batman-adv: autoload cfg80211 kernel dependency
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
2016-05-05 21:46:51 +08:00
Henning Rogge
619af6de6c Add remotecontrol plugin to selectable Olsrd2 plugins 2016-05-05 14:21:31 +01:00
Henning Rogge
88996c497c Add optional packages to OONF olsrd2 2016-05-05 13:59:44 +01:00
Roger Pueyo Centelles
c57a7977fe [luci-app-bmx7] Add world icons resources 2016-05-04 15:44:03 +02:00
Roger Pueyo Centelles
0599a18235 [luci-app-bmx7] Add Nodes view page 2016-05-04 15:44:02 +02:00
Roger Pueyo Centelles
ef61e355eb [luci-app-bmx7] Add Nodes page menu entry 2016-05-04 15:44:00 +02:00
Roger Pueyo Centelles
74078557b7 [luci-app-bmx7] Update configuration and installation definitions in Makefile 2016-05-04 15:43:59 +02:00
Roger Pueyo Centelles
83a20d1c40 [luci-app-bmx7] Add bmx7-info script to obtain JSON-formatted input for the Status page 2016-05-04 15:43:57 +02:00
Roger Pueyo Centelles
0e3c16c887 [luci-app-bmx7] Add BMX7 logo resource 2016-05-04 15:43:56 +02:00
Roger Pueyo Centelles
ffe6daf597 [luci-app-bmx7] Add polling.js resource 2016-05-04 15:43:55 +02:00
Roger Pueyo Centelles
06789715c4 [luci-app-bmx7] Add Status view page 2016-05-04 15:43:53 +02:00
Roger Pueyo Centelles
7e59d9c95f [luci-app-bmx7] Add Status page menu entry 2016-05-04 15:43:51 +02:00
Roger Pueyo Centelles
6d5e6dd4b0 [luci-app-bmx7] Add empty controller and default configurations for BMX7 LuCI 2016-05-04 15:43:48 +02:00
Roger Pueyo Centelles
52cc9e35ed [luci-app-bmx7] Create luci-app-bmx7 package structure including Makefile and
COPYING license file
2016-05-04 15:43:35 +02:00
Axel Neumann
551c246976 bmx7: bump to latest code version 2016-05-01 17:03:21 +02:00
Marek Lindner
049cae3fe8 batman-adv: upgrade package to latest release 2016.1
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
2016-04-25 17:47:14 +08:00
Marek Lindner
cd13a319ed batctl: upgrade package to latest release 2016.1
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
2016-04-25 17:45:00 +08:00
Bastian Bittorf
d28aca37ef Merge pull request #179 from HRogge/for-15.05
Update to OONF v0.11.4
2016-04-25 11:15:26 +02:00
Henning Rogge
349a14f634 Update to OONF v0.11.4 2016-04-25 08:23:08 +02:00
Bastian Bittorf
df98ea3d1e Merge pull request #175 from HRogge/for-15.05
Update to OONF 0.11.3
2016-04-23 17:28:03 +02:00
Henning Rogge
4376f76b98 Update to OONF 0.11.3 2016-04-19 12:31:55 +02:00
Sven Roederer
2a6f4cdaa5 [olsr, oonf] change to new repo
Conflicts:
	olsrd/Makefile

Resolution:
	leave olsrd Makefile untouched, since current URL is working

Signed-off-by: Gui Iribarren <gui@altermundi.net>
2016-04-18 16:04:04 +02:00
Bastian Bittorf
be1d27c0e6 Merge pull request #165 from HRogge/for-15.05
Update to version 0.11.2
2016-03-19 16:40:11 +01:00
Henning Rogge
24e92ddee8 Update to version 0.11.2 2016-03-17 14:16:38 +01:00
Bastian Bittorf
f5e992734a Merge pull request #159 from HRogge/for-15.05
Update to OONF 0.11.1
2016-03-13 16:24:22 +01:00
Henning Rogge
1ba5d1d743 Update to OONF 0.11.1 2016-03-12 00:47:19 +01:00
Bastian Bittorf
c506c492c9 Merge pull request #154 from HRogge/for-15.05
For 15.05
2016-03-04 15:56:01 +01:00
Henning Rogge
69087c2ebe Forgot to change to switch from os_socket to os_fd for OONF 2016-02-29 19:04:56 +01:00
Henning Rogge
9de1efba1e OONF version 0.11.0 2016-02-28 21:31:59 +01:00
Pau Escrich
4830444a7c [luci-app-bmx6] When drawing the network topology graph, try first wget-ssl
Signed-off-by: Pau Escrich <p4u@dabax.net>
2016-02-23 17:04:34 +01:00
Gabriel Kerneis
d7701f4ada babeld: release 1.7.1
Signed-off-by: Gabriel Kerneis <kerneis@google.com>
2016-02-16 10:58:40 +01:00
Axel Neumann
19cf787674 bmx7: update source: fix bmx7_tun plugin Makefile and new --setTrustedNode options 2016-02-15 23:09:09 +01:00
Axel Neumann
60254635bb bmx7: fix source url 2016-02-11 07:17:01 +01:00
Axel Neumann
ec98977f7a bmx7: separate bmx7 namespace for binaries, libs, config, runtimedir, ... 2016-02-11 07:06:46 +01:00
Lars Gierth
57009dafe0 cjdns: update source, bump release
Signed-off-by: Lars Gierth <larsg@systemli.org>
2016-02-06 04:55:29 +01:00
Lars Gierth
0267f29f63 cjdns: fix dependency on git revision
Signed-off-by: Lars Gierth <larsg@systemli.org>
2016-02-06 04:55:29 +01:00
Axel Neumann
5eaad909c6 bmx7 security enhanced mesh routing 2016-01-18 13:59:52 +01:00
Daniel Golle
4104e7b92d cjdns: update source
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2016-01-17 15:45:54 +01:00
Bastian Bittorf
587411eebd Merge pull request #142 from mmunz/for-15.05
make ipv6only boolean in olsrd init, backport from master
2016-01-05 08:15:03 +01:00
Manuel Munz
a30af3990f make ipv6only boolean in olsrd init, backport from master 2016-01-04 21:45:46 +01:00
Lars Gierth
e870c3373e cjdns: update source, bump version
Conflicts:
	cjdns/Makefile
2015-10-09 16:57:03 +02:00
Saverio Proto
5876cd389f olsrd: bump to version 0.9.0.3 2015-09-21 10:40:34 +02:00
Bastian Bittorf
cf17e79ae5 Merge pull request #139 from HRogge/for-15.05
update to v0.9.2
2015-09-09 01:40:10 +02:00
Henning Rogge
7a882de7cc update to v0.9.2 2015-09-08 18:26:46 +02:00
Bastian Bittorf
f2a462fa65 Merge pull request #128 from HRogge/for-15.05
OONF Init script fix for the case that /var/etc does not exist
2015-08-13 14:53:48 +02:00
Henning Rogge
b8e9b6486b Move OONF temporary config to /var/run 2015-08-12 16:59:36 +02:00
Henning Rogge
79325157d0 Merge remote-tracking branch 'openwrt/for-15.05' into for-15.05 2015-08-10 14:13:43 +02:00
Henning Rogge
94fd3231da OONF Init script fix for the case that /var/etc does not exist 2015-08-10 13:53:25 +02:00
Axel Neumann
c2871131b4 [bmx6] update to latest bmx6-master branch (fix rule corruption on the fly) 2015-08-07 20:44:02 +02:00
Bastian Bittorf
217048f800 Merge pull request #122 from HRogge/for-15.05
Unified openwrt init files for OONF
2015-08-06 22:46:01 +02:00
Henning Rogge
57658dbe2a Unified openwrt init files for OONF 2015-08-06 21:43:33 +02:00
Bastian Bittorf
0e8fd185c2 Merge pull request #119 from HRogge/for-15.05
OONF v0.9.1 for chaos calmer
2015-08-05 16:21:24 +02:00
Henning Rogge
b13b00b0ec OONF v0.9.1 for chaos calmer 2015-08-05 13:19:59 +02:00
Steven Barth
0a514a34e7 miniupnpd: shorten OS name to silence SSDP warnings
Signed-off-by: Steven Barth <steven@midlink.org>
2015-07-15 08:29:56 +02:00
Steven Barth
14204998ea minimalist-pcpproxy: fix uci call in default-script
Signed-off-by: Steven Barth <steven@midlink.org>
2015-07-15 08:29:48 +02:00
Steven Barth
dea54bb9f3 hnetd: fix issues on 32-bit platforms
Signed-off-by: Steven Barth <steven@midlink.org>
2015-07-15 08:29:37 +02:00
Markus Stenberg
8636d0d894 hnetd: Bump. Some corner case fixes + dncp-07/hncp-07 compatibility (more or less). 2015-07-15 08:29:29 +02:00
Steven Barth
4e0fa4f572 nat46: fix netfilter references
Signed-off-by: Steven Barth <steven@midlink.org>
2015-07-02 20:54:27 +02:00
Bastian Bittorf
4d8398f4ec olsrd: for15.05: 0.9.0.1 -> 0.9.0.2 (bugfix-release) 2015-07-01 21:33:04 +02:00
Steven Barth
aeb176d818 nat46: fix leak of conntrack entries, fix checksum calculation
Signed-off-by: Steven Barth <steven@midlink.org>
2015-06-30 15:56:34 +02:00
Bastian Bittorf
f5eab926d7 olsrd: bump to version 0.9.0.1 (bugfixes)
We did a bug-fix release of olsrd v1.
It fixes a route-recalculation issue and at least one crash.

Everyone using olsrd v1 is strongly urged to upgrade, especially people
using Smart-Gateway.

The shortlog is appended.

0.9.0.1 -------------------------------------------------------------------

Ferry Huberts (3):
      neighbors: signal link changes when deleting a neighbor
      jsoninfo: do not output smart-gateway info when not enabled.
      txtinfo: do not output smart-gateway info when not enabled.

Henning Rogge (2):
      Update version after release of v0.9.0
      Release v0.9.0.1
2015-06-24 22:58:01 +02:00
Gabriel Kerneis
2f6ed8abd1 babeld: bump to 1.6.1
16 June 2015: babeld-1.6.1.
  * Fixed a buffer overflow in zone_equal.  This is probably not
    exploitable, but might cause incorrect routing tables in the presence
    of source-specific routing.
  * Added support for defaulting ipv6-subtrees automatically based on the
    kernel version.
  * Fixed compilation under musl.

Signed-off-by: Gabriel Kerneis <kerneis@google.com>
2015-06-17 12:27:03 +02:00
Steven Barth
5d29a11161 hnetd: stability improvements
Signed-off-by: Steven Barth <steven@midlink.org>
2015-06-17 11:13:47 +02:00
Axel Neumann
ebcfa63254 bmx6: bump to latest (auto tunOutTimeout) version 2015-06-16 15:29:39 +02:00
Markus Stenberg
a8ec8f672e miniupnpd: Bump to 1.9.20150609. 2015-06-15 13:15:12 +02:00
Steven Barth
f789112125 hnetd: stability improvements
Signed-off-by: Steven Barth <steven@midlink.org>
2015-06-09 08:44:32 +02:00
Axel Neumann
168ee1c50b bmx6: bump to latest (--tunnel and --redistTable fixing) version 2015-06-05 16:42:03 +02:00
Steven Barth
2bca6fb55f babels: obsoleted by babeld
Signed-off-by: Steven Barth <steven@midlink.org>
2015-05-28 08:34:38 +02:00
Steven Barth
f7f1ccfdb7 hnetd: switch to babeld instead of babels
Signed-off-by: Steven Barth <steven@midlink.org>
2015-05-28 08:19:22 +02:00
Steven Barth
4b4b01efff hnetd: bump to latest
Signed-off-by: Steven Barth <steven@midlink.org>
2015-05-28 08:16:11 +02:00
Gabriel Kerneis
4489688125 babeld: allow changing alternative configuration file and directory
Signed-off-by: Gabriel Kerneis <kerneis@google.com>
Signed-off-by: Markus Stenberg <markus.stenberg@iki.fi>
2015-05-26 08:56:05 +02:00
Steven Barth
8978061d1c babeld: remove unnecessary librt linking & dependency
Signed-off-by: Steven Barth <steven@midlink.org>
Signed-off-by: Markus Stenberg <markus.stenberg@iki.fi>
2015-05-26 08:55:58 +02:00
Steven Barth
991dd1fc82 babeld: add support for dynamic config files
Signed-off-by: Steven Barth <steven@midlink.org>
Signed-off-by: Markus Stenberg <markus.stenberg@iki.fi>
2015-05-26 08:55:51 +02:00
Lars
3f5520edda Merge pull request #101 from dangowrt/update-cjdns-for-15.05
cjdns: update source, bump release
2015-05-21 23:41:31 +02:00
Daniel Golle
c067288758 cjdns: update source, bump release
Fixes seccomp on ARM or musl-based builds, notable upstream changes:
a97c189 fix Hex_test unit test
4bceb72 seccomp: allow readv and writev syscalls (used by musl)
64f4791 seccomp: define GET_SYSCALL_NUM accessor macro
0102181 seccomp: allow gettimeofday syscall (required on ARM)
18979ee Add a check to prevent a rare assertion failure

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2015-05-21 13:27:12 +02:00
Lars Gierth
b1c3bdfbf4 luci-app-cjdns: bump release
Signed-off-by: Lars Gierth <larsg@systemli.org>
2015-05-13 01:47:38 +02:00
Lars Gierth
febc9ff92b cjdns: bump release
Signed-off-by: Lars Gierth <larsg@systemli.org>
2015-05-13 01:47:38 +02:00
Lars Gierth
d7c9e1bc5e luci-app-cjdns: add seccomp checkbox
Signed-off-by: Lars Gierth <larsg@systemli.org>
2015-05-13 01:47:38 +02:00
Lars Gierth
fc1aec3116 cjdns: add seccomp config flag
Signed-off-by: Lars Gierth <larsg@systemli.org>
2015-05-13 01:47:38 +02:00
Lars Gierth
a6da56d4c3 luci-app-cjdns: add copyright notice to Makefile
Signed-off-by: Lars Gierth <larsg@systemli.org>
2015-05-13 01:47:38 +02:00
Lars Gierth
9a4461cd20 cjdns: add copyright notice to Makefile
Signed-off-by: Lars Gierth <larsg@systemli.org>
2015-05-13 01:47:38 +02:00
Lars
e1da56cd9d Merge pull request #98 from SeattleMeshnet/for-15.05
cjdns: update source, bump release
2015-05-12 21:37:50 +02:00
Daniel Golle
b439c8771a cjdns: update source, bump release
upstream changes:
3d879c0 typo in GET32()
f964d14 Fixed IpTunnel unaligned access, thanks Viric for pointing it out
a05ade4 attempt to fix a rare assertion failure
6f1fdd8 Fix a memory leak in InterfaceController.c

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2015-05-12 21:04:26 +02:00
Markus Stenberg
c0fcae0d4e hnetd: Update to the latest. 2015-05-12 09:27:40 +02:00
Steven Barth
650a820269 miniupnpd: remove libnfnetlink dependency
Signed-off-by: Steven Barth <steven@midlink.org>
2015-05-12 09:27:39 +02:00
Markus Stenberg
7deb0f0238 miniupnpd: Bumped to 1.9.20150430. Seems to work in my tests. 2015-05-12 09:27:18 +02:00
282 changed files with 13636 additions and 7541 deletions

View file

@ -1,16 +0,0 @@
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 ```
```

View file

@ -1,5 +0,0 @@
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:

View file

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

View file

@ -1,91 +0,0 @@
name: Check autorelease deprecation
on:
pull_request_target:
types: [opened, synchronize, converted_to_draft, ready_for_review, edited]
jobs:
build:
name: Check autorelease deprecation
runs-on: ubuntu-latest
strategy:
fail-fast: false
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v3
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: Determine changed packages
run: |
RET=0
# 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
if grep -q '$(AUTORELEASE)' "$ROOT/Makefile"; then
CONTAINS_AUTORELEASE+="$ROOT"
fi
break
fi
done
done
if [ -n "$CONTAINS_AUTORELEASE" ]; then
RET=1
cat > "$GITHUB_WORKSPACE/pr_comment.md" << EOF
Please do no longer set *PKG_RELEASE* to *AUTORELEASE* as the
feature is deprecated. Please use an integer instead. Below is a
list of affected packages including correct *PKG_RELEASE*:
EOF
fi
for ROOT in $CONTAINS_AUTORELEASE; do
echo -n " - ${ROOT}Makefile: PKG_RELEASE:=" >> "$GITHUB_WORKSPACE/pr_comment.md"
last_bump="$(git log --pretty=format:'%h %s' "$ROOT" |
grep --max-count=1 -e ': [uU]pdate to ' -e ': [bB]ump to ' |
cut -f 1 -d ' ')"
if [ -n "$last_bump" ]; then
echo -n $(($(git rev-list --count "$last_bump..HEAD" "$ROOT") + 2)) >> "$GITHUB_WORKSPACE/pr_comment.md"
else
echo -n $(($(git rev-list --count HEAD "$ROOT") + 2)) >> "$GITHUB_WORKSPACE/pr_comment.md"
fi
echo >> "$GITHUB_WORKSPACE/pr_comment.md"
done
exit $RET
- name: Find Comment
uses: peter-evans/find-comment@v2
if: ${{ failure() }}
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v2
if: ${{ failure() }}
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body-file: 'pr_comment.md'
edit-mode: replace

View file

@ -1,26 +0,0 @@
#!/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
}

View file

@ -1,62 +0,0 @@
#!/bin/sh
# not enabling `errtrace` and `pipefail` since those are bash specific
set -o errexit # failing commands causes script to fail
set -o nounset # undefined variables causes script to fail
echo "src/gz packages_ci file:///ci" >> /etc/opkg/distfeeds.conf
FINGERPRINT="$(usign -F -p /ci/packages_ci.pub)"
cp /ci/packages_ci.pub "/etc/opkg/keys/$FINGERPRINT"
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"
export PKG_NAME PKG_VERSION CI_HELPER
PRE_TEST_SCRIPT=$(find /ci/ -name "$PKG_SOURCE" -type d)/pre-test.sh
if [ -f "$PRE_TEST_SCRIPT" ]; then
echo "Use package specific pre-test.sh"
if sh "$PRE_TEST_SCRIPT" "$PKG_NAME" "$PKG_VERSION"; then
echo "Pre-test successful"
else
echo "Pre-test failed"
exit 1
fi
else
echo "No pre-test.sh script available"
fi
opkg install "$PKG"
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 --autoremove || true
done

View file

@ -1,63 +0,0 @@
name: Test Formalities
on:
pull_request:
jobs:
build:
name: Test Formalities
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
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

@ -1,157 +0,0 @@
name: Test Build
on:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
build:
name: Test ${{ matrix.arch }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- arch: aarch64_generic
target: armsr-armv8
runtime_test: true
- arch: arm_cortex-a15_neon-vfpv4
target: armsr-armv7
runtime_test: true
- arch: arm_cortex-a9_vfpv3-d16
target: mvebu-cortexa9
runtime_test: false
- arch: i386_pentium-mmx
target: x86-geode
runtime_test: true
- arch: mips_24kc
target: ath79-generic
runtime_test: true
- arch: powerpc_464fp
target: apm821xx-nand
runtime_test: false
- arch: powerpc_8548
target: mpc85xx-p1010
runtime_test: false
- arch: riscv64_riscv64
target: sifiveu-generic
runtime_test: false
- arch: x86_64
target: x86-64
runtime_test: true
steps:
- uses: actions/checkout@v3
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:-bird2 cjdns olsrd}"
echo "Building $PACKAGES"
echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV
- name: Generate build keys
run: |
sudo apt-get update
sudo apt-get install -y signify-openbsd
signify-openbsd -G -n -c 'DO NOT USE - OpenWrt packages feed CI' -p packages_ci.pub -s packages_ci.sec
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "KEY_BUILD<<$EOF" >> $GITHUB_ENV
cat packages_ci.sec >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
- name: Build
uses: openwrt/gh-action-sdk@v5
env:
ARCH: ${{ matrix.arch }}-${{ env.BRANCH }}
FEEDNAME: packages_ci
INDEX: 1
KEY_BUILD: ${{ env.KEY_BUILD }}
- name: Move created packages to project dir
run: cp bin/packages/${{ matrix.arch }}/packages_ci/* . || true
- name: Store packages
uses: actions/upload-artifact@v3
with:
name: ${{env.ARCHIVE_NAME}}-packages
path: |
Packages
Packages.*
*.ipk
PKG-INFO
- name: Store logs
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.arch}}-logs
path: logs/
- name: Remove logs
run: sudo rm -rf logs/ || true
- name: Check if any packages were built
run: |
if [ -n "$(find . -maxdepth 1 -type f -name '*.ipk' -print -quit)" ]; then
echo "Found *.ipk files"
HAVE_IPKS=true
else
echo "No *.ipk files found"
HAVE_IPKS=false
fi
echo "HAVE_IPKS=$HAVE_IPKS" >> $GITHUB_ENV
- name: Register QEMU
if: ${{ matrix.runtime_test && fromJSON(env.HAVE_IPKS) }}
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static binfmt-support
sudo update-binfmts --import
- name: Build Docker container
if: ${{ matrix.runtime_test && fromJSON(env.HAVE_IPKS) }}
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 && fromJSON(env.HAVE_IPKS) }}
run: |
docker run --rm -v $GITHUB_WORKSPACE:/ci test-container

View file

@ -8,12 +8,12 @@
# use alphabetical order when updating the list.
Axel "axn" Neumann <neumann@cgws.de>
Baptiste Jonglez <openwrt-pkg@bitsofnetworks.org>
Bastian Bittorf <bb@npl.de>
Baptiste Jonglez <bjonglez@illyse.org>
Bastian Bittorf <bittorf@bluebottle.com>
Corinna "Elektra" Aichele <onelektra@gmx.net>
Gabriel Kerneis <gabriel@kerneis.info>
Gui Iribarren <gui@altermundi.net>
Jo-Philipp Wich <jo@mein.io>
Jo-Philipp Wich <jow@openwrt.org>
Luka Perkov <luka@openwrt.org>
Marek Lindner <mareklindner@neomailbox.ch>
Moritz Warning <moritzwarning@web.de>
@ -21,5 +21,5 @@ Nicolás Echániz <nicoechaniz@altermundi.net>
Pau Escrich <pau@dabax.net>
Saverio Proto <zioproto@gmail.com>
Simon Wunderlich <sw@simonwunderlich.de>
Steven Barth <steven@midlink.org>
Steven Barth <cyrus@openwrt.org>
Vasilis "acinonyx" Tsiligiannis <acinonyx@openwrt.gr>

18
README Normal file
View file

@ -0,0 +1,18 @@
This is an OpenWrt package feed containing community maintained routing packages.
To use these packages, add the following line to the feeds.conf
in the OpenWrt buildroot:
src-git routing git://github.com/openwrt-routing/packages.git
Update the feed:
./scripts/feeds update routing
Activate the package:
./scripts/feeds install -a -p routing
The routing packages should now appear in menuconfig.

View file

@ -1,21 +0,0 @@
# OpenWrt Routing Feed
## Description
This OpenWrt package feed contains community maintained routing packages.
## Usage
This repository is intended to be layered on-top of an OpenWrt buildroot.
If you do not have an OpenWrt buildroot installed, see the documentation at:
[OpenWrt Buildroot Installation][1] on the OpenWrt support site.
This feed is enabled by default. To install all its package definitions, run:
```
./scripts/feeds update routing
./scripts/feeds install -a -p routing
```
[1]: https://openwrt.org/docs/guide-developer/build-system/install-buildsystem

View file

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

View file

@ -1,55 +1,52 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
#
# The latest alfred git hash in PKG_REV can be obtained from http://git.open-mesh.org/alfred.git
#
PKG_NAME:=alfred
PKG_VERSION:=2024.0
PKG_RELEASE:=1
PKG_VERSION:=2014.4.0
PKG_RELEASE:=0
PKG_MD5SUM:=053cb5d9e7ca9384598e82944343dea2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
PKG_HASH:=d029a43638ab16771e5f71e134bc843d1713d74041c65bcda18a31d18f5531bd
PKG_MAINTAINER:=Simon Wunderlich <sw@simonwunderlich.de>
PKG_LICENSE:=GPL-2.0-only MIT
PKG_LICENSE_FILES:=LICENSES/preferred/GPL-2.0 LICENSES/preferred/MIT
PKG_BUILD_PARALLEL:=1
PKG_BUILD_FLAGS:=gc-sections lto
PKG_CONFIG_DEPENDS += \
CONFIG_ALFRED_NEEDS_lua \
CONFIG_ALFRED_NEEDS_libgps \
CONFIG_PACKAGE_ALFRED_VIS \
CONFIG_PACKAGE_ALFRED_BATHOSTS \
CONFIG_PACKAGE_ALFRED_GPSD
PKG_SOURCE_URL:=http://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
PKG_LICENSE:=GPL-2.0
include $(INCLUDE_DIR)/package.mk
init-y := alfred
define Package/alfred
URL:=http://www.open-mesh.org/
SECTION:=net
CATEGORY:=Network
TITLE:=A.L.F.R.E.D. - Almighty Lightweight Fact Remote Exchange Daemon
URL:=https://www.open-mesh.org/
DEPENDS:= +libc @IPV6 +libnl-tiny +librt \
+ALFRED_NEEDS_lua:lua \
+ALFRED_NEEDS_libgps:libgps
DEPENDS:= +libc +IPV6:kmod-ipv6 +librt \
+ALFRED_NEEDS_lua:lua \
+ALFRED_NEEDS_libgps:libgps
endef
define Package/alfred/description
alfred is a user space daemon for distributing arbitrary local information
over the mesh/network in a decentralized fashion. This data can be anything
which appears to be useful - originally designed to replace the batman-adv
visualization (vis), you may distribute hostnames, phone books, administration
information, DNS information, the local weather forecast ...
alfred is a user space daemon for distributing arbitrary local information over
the mesh/network in a decentralized fashion. This data can be anything which
appears to be useful - originally designed to replace the batman-adv
visualization (vis), you may distribute hostnames, phone books, administration
information, DNS information, the local weather forecast ...
alfred runs as daemon in the background of the system. A user may insert
information by using the alfred binary on the command line, or use special
programs to communicate with alfred (done via unix sockets). alfred then takes
care of distributing the local information to other alfred servers on other
nodes. This is done via IPv6 link-local multicast, and does not require any
configuration. A user can request data from alfred, and will receive the
information available from all alfred servers in the network.
alfred runs as daemon in the background of the system. A user may insert
information by using the alfred binary on the command line, or use special
programs to communicate with alfred (done via unix sockets). alfred then takes
care of distributing the local information to other alfred servers on other
nodes. This is done via IPv6 link-local multicast, and does not require any
configuration. A user can request data from alfred, and will receive the
information available from all alfred servers in the network.
endef
define Package/alfred/conffiles
@ -60,13 +57,18 @@ define Package/alfred/config
source "$(SOURCE)/Config.in"
endef
MAKE_FLAGS += \
MAKE_ALFRED_FLAGS=\
CONFIG_ALFRED_VIS=$(if $(CONFIG_PACKAGE_ALFRED_VIS),y,n) \
CONFIG_ALFRED_GPSD=$(if $(CONFIG_PACKAGE_ALFRED_GPSD),y,n) \
CONFIG_ALFRED_CAPABILITIES=n \
LIBNL_NAME="libnl-tiny" \
LIBNL_GENL_NAME="libnl-tiny" \
REVISION="$(PKG_VERSION)-openwrt-$(PKG_RELEASE)"
CONFIG_ALFRED_GPSD=$(if $(CONFIG_PACKAGE_ALFRED_GPSD),y,n)
TARGET_CFLAGS += -ffunction-sections -fdata-sections -flto
TARGET_LDFLAGS += -Wl,--gc-sections -fuse-linker-plugin
define Build/Compile
CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS)" \
$(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS) $(MAKE_ALFRED_FLAGS) all
endef
define Package/alfred/install
$(INSTALL_DIR) $(1)/usr/sbin

View file

@ -1,5 +1,5 @@
config 'alfred' 'alfred'
list interface 'br-lan'
option interface 'br-lan'
option mode 'master'
option batmanif 'bat0'
option start_vis '1'

View file

@ -1,41 +1,39 @@
#!/bin/sh /etc/rc.common
#
# Copyright (C) 2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
START=99
USE_PROCD=1
STOP=99
alfred_args=""
vis_args=""
facters_dir="/etc/alfred"
pid_file_alfred="/var/run/alfred.pid"
pid_file_vis="/var/run/batadv-vis.pid"
enable=0
vis_enable=0
batmanif=""
SERVICE_DAEMONIZE=1
SERVICE_WRITE_PID=1
append_interface()
alfred_start()
{
append "interfaces" "$1" ","
}
alfred_start() {
local args=""
local section="$1"
local disabled interface mode
local interfaces
# check if section is disabled
config_get_bool disabled "$section" disabled 0
[ $disabled = 0 ] || return 1
args="-f"
args=""
config_list_foreach "$section" "interface" append_interface
if [ -z "$interfaces" ]; then
config_get interface "$section" interface
append_interface "$interface"
fi
append args "-i $interfaces"
config_get interface "$section" interface
append args "-i $interface"
config_get mode "$section" mode
[ "$mode" = "master" ] && append args "-m"
@ -46,52 +44,66 @@ alfred_start() {
append alfred_args "$args"
enable=1
config_get_bool start_vis "$section" start_vis 0
if [ "$start_vis" = 1 ] && [ -x /usr/sbin/batadv-vis ]; then
vis_enable=1
append vis_args "-i $batmanif -s"
fi
config_get_bool start_vis "$section" start_vis 0
if [ "$start_vis" = 1 ] && [ -x /usr/sbin/batadv-vis ]; then
vis_enable=1
append vis_args "-i $batmanif -s"
fi
config_get_bool run_facters "$section" run_facters 0
return 0
}
start_service() {
start()
{
config_load "alfred"
config_foreach alfred_start alfred
[ "$enable" = "0" ] && return 0
if [ "$enable" = "0" ]; then
exit 0
fi
procd_open_instance "alfred"
procd_set_param command /usr/sbin/alfred
procd_append_param command ${alfred_args}
procd_close_instance
mesh_dir="/sys/class/net/$batmanif/mesh/"
if ! [ -d "$mesh_dir" ] ; then
timeout=30
echo "${initscript}: waiting $timeout secs for $batmanif interface..."
for i in $(seq $timeout); do
sleep 1
[ -d "$mesh_dir" ] && break
if [ $i == $timeout ] ; then
echo "${initscript}: $batmanif not detected, alfred not starting."
exit 1
fi
done
fi
[ "$vis_enable" = "1" ] && {
procd_open_instance "batadv-vis"
procd_set_param command /usr/sbin/batadv-vis
procd_append_param command ${vis_args}
procd_close_instance
}
echo "${initscript}: starting alfred"
SERVICE_PID_FILE="$pid_file_alfred"
service_start /usr/sbin/alfred ${alfred_args}
[ "$run_facters" = "1" ] && {
if [ "$vis_enable" = "1" ]; then
echo "${initscript}: starting batadv-vis"
SERVICE_PID_FILE="$pid_file_vis"
service_start /usr/sbin/batadv-vis ${vis_args}
fi
if [ "$run_facters" = "1" ]; then
( for file in $facters_dir/* ; do [ -x $file ] && $file ; done )
if ! ( grep -q "for file in $facters_dir/\* ; do " /etc/crontabs/root 2>/dev/null ) ; then
echo "*/5 * * * * ( for file in $facters_dir/* ; do [ -x \$file ] && \$file ; done )" >> /etc/crontabs/root
/etc/init.d/cron enable
/etc/init.d/cron restart
fi
}
fi
}
service_triggers() {
procd_add_reload_trigger "alfred"
}
stop_service() {
[ -e /etc/crontabs/root ] && {
sed "\|for file in $facters_dir/\* ; do |d" -i /etc/crontabs/root
/etc/init.d/cron restart
}
stop()
{
SERVICE_PID_FILE="$pid_file_alfred"
service_stop /usr/sbin/alfred
SERVICE_PID_FILE="$pid_file_vis"
[ -x /usr/sbin/batadv-vis ] && service_stop /usr/sbin/batadv-vis
sed "\|for file in $facters_dir/\* ; do |d" -i /etc/crontabs/root
/etc/init.d/cron restart
}

View file

@ -87,24 +87,19 @@ end
local function receive_bat_hosts()
-- read raw chunks from alfred, convert them to a nested table and call write_bat_hosts
-- "alfred -r" can fail in slave nodes (returns empty stdout), so:
-- check output is not null before writing /tmp/bat-hosts, and retry 3 times before giving up.
for n = 1, 3 do
local fd = io.popen("alfred -r " .. type_id)
--[[ this command returns something like
{ "54:e6:fc:b9:cb:37", "00:11:22:33:44:55 ham_wlan0\x0a00:22:33:22:33:22 ham_eth0\x0a" },
{ "90:f6:52:bb:ec:57", "00:22:33:22:33:23 spam\x0a" },
]]--
local fd = io.popen("alfred -r " .. type_id)
--[[ this command returns something like
{ "54:e6:fc:b9:cb:37", "00:11:22:33:44:55 ham_wlan0\x0a00:22:33:22:33:22 ham_eth0\x0a" },
{ "90:f6:52:bb:ec:57", "00:22:33:22:33:23 spam\x0a" },
]]--
if fd then
local output = fd:read("*a")
fd:close()
if output and output ~= "" then
assert(loadstring("rows = {" .. output .. "}"))()
write_bat_hosts(rows)
break
end
if fd then
local output = fd:read("*a")
if output then
assert(loadstring("rows = {" .. output .. "}"))()
write_bat_hosts(rows)
end
fd:close()
end
end

View file

@ -10,7 +10,7 @@ PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.pps.univ-paris-diderot.fr/~jch/software/files/
PKG_HASH:=c411430bb102f08d3d68d2fb5010b5da0149908b671ac0fb12abd8c8ee6380c5
PKG_MD5SUM:=40d4931986913f5f8d9b5b70abf6fda5
include $(INCLUDE_DIR)/package.mk

View file

@ -1,23 +1,20 @@
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Copyright (C) 2007-2021 OpenWrt.org
# Copyright (C) 2007-2009 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=babeld
PKG_VERSION:=1.13.1
PKG_VERSION:=1.7.1
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://www.irif.fr/~jch/software/files/
PKG_HASH:=15f24d26da0ccfc073abcdef0309f281e4684f2aa71126f826572c4c845e8dd9
PKG_MAINTAINER:=Gabriel Kerneis <gabriel@kerneis.info>, \
Baptiste Jonglez <openwrt-pkg@bitsofnetworks.org>, \
Nick Hainke <vincent@systemli.org>
PKG_SOURCE_URL:=https://www.irif.univ-paris-diderot.fr/~jch/software/files/
PKG_MD5SUM:=2f71794d4e67f8a5352164ce33611549
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENCE
include $(INCLUDE_DIR)/package.mk
@ -25,17 +22,20 @@ define Package/babeld
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
TITLE:=A loop-avoiding distance-vector routing protocol
URL:=https://www.irif.fr/~jch/software/babel/
DEPENDS:=@IPV6 +libubus +libubox
TITLE:=A loop-free distance-vector routing protocol
URL:=http://www.pps.univ-paris-diderot.fr/~jch/software/babel/
MAINTAINER:=Gabriel Kerneis <gabriel@kerneis.info>
DEPENDS:=+kmod-ipv6
endef
define Package/babeld/description
Babel is a loop-avoiding distance-vector routing protocol for IPv6 and IPv4
with fast convergence properties. It is based on the ideas in DSDV, AODV and
Cisco's EIGRP, but is designed to work well not only in wired networks but
also in wireless mesh networks, and has been extended with support for
overlay networks. Babel is an IETF standard protocol (RFC 8966).
Babel is a loop-avoiding distance-vector routing protocol roughly based
on DSDV and AODV, but with provisions for link cost estimation and
redistribution of routes from other routing protocols.
While it is optimised for wireless mesh networks, Babel will also work
efficiently on wired networks. It will generate between 1.2 and 2.4 times
the amount of routing traffic that RIPng would generate, while
never counting to infinity.
endef
define Package/babeld/conffiles
@ -46,7 +46,6 @@ endef
MAKE_FLAGS+= \
CFLAGS="$(TARGET_CFLAGS)" \
LDLIBS="" \
LDLIBS+="-lubus -lubox"
define Package/babeld/install
$(INSTALL_DIR) $(1)/usr/sbin

View file

@ -1,7 +1,5 @@
package babeld
# Detailed documentation: https://openwrt.org/docs/guide-user/services/babeld
# Babeld reads options from the following files (the last one takes precedence
# if an option is defined in several places):
# - the file defined by the option conf_file (default: /etc/babeld.conf),
@ -18,13 +16,14 @@ config general
## Enable ipv6-subtrees by default since OpenWrt should ship with a
## recent enough kernel for it to work.
option 'ipv6_subtrees' 'true'
## This seems somewhat buggy on BB. If you need only one
## import-table statement, "option import_table 42" should work.
# list 'import_table' '42'
# list 'import_table' '100'
## Alternative configuration file and directory.
## See comment at the top of this file for more details.
# option 'conf_file' '/etc/babeld.conf'
# option 'conf_dir' '/tmp/babel.d/'
# option 'ubus_bindings' 'false'
config interface
## Remove this line to enable babeld on this interface
@ -42,10 +41,7 @@ config interface
option 'ignore' 'true'
## Physical interface name
option 'ifname' 'tun-example'
## 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'
# option 'max_rtt_penalty' '90'
# A config interface without "option ifname" will set default options
# for all interfaces. Interface-specific configuration always overrides
@ -55,49 +51,27 @@ config interface
# option 'update_interval' '30'
# A filter consists of a type ('in', 'out', 'redistribute' or 'install'),
# a set of selectors ('ip', 'eq', etc.) and a set of actions to perform
# ('allow', 'deny', 'metric xxx', 'src-prefix xxx', 'table xxx', 'pref-src xxx').
# See babeld man page ("Filtering rules") for more details.
# 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.
# A filter consists of a type ('in', 'out' or 'redistribute'), an action
# ('allow', 'deny' or 'metric xxx') and a set of selectors ('ip', 'eq',
# etc.). See babeld man page ("Filtering rules") for more details.
# Here is a sample filter wich redistributes the default route if its
# protocol number is "boot", e.g. when it installed by dhcp. It is
# disabled by default.
config filter
option 'ignore' 'true'
# Type of filter
# Type
option 'type' 'redistribute'
# Selectors: ip, eq, le, ge, src_ip, src_eq, src_le, src_ge, neigh, id,
# proto, local, if.
option 'ip' '0.0.0.0/0'
option 'eq' '0'
option 'proto' '3'
# 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).
# Action (one of: allow, deny, metric XXX, src-prefix XXX).
option 'action' 'metric 128'
# Another example filter: don't redistribute local addresses in a certain IP prefix.
# By default, babeld redistributes *all* local addresses.
# Notice that the 'local' selector is a boolean.
config filter
option 'ignore' 'true'
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'
# 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'
# No action means "allow"

View file

@ -1,20 +1,24 @@
#!/bin/sh /etc/rc.common
. $IPKG_INSTROOT/lib/functions/network.sh
. /lib/functions/network.sh
USE_PROCD=1
START=70
pidfile='/var/run/babeld.pid'
CONFIGFILE='/var/etc/babeld.conf'
OTHERCONFIGFILE="/etc/babeld.conf"
OTHERCONFIGDIR="/tmp/babeld.d/"
EXTRA_COMMANDS="status"
EXTRA_HELP=" status Dump Babel's table to the log file."
# Options to ignore for the global section (old options that are translated
# for backward compatibility with old configuration files)
ignored_options="carrier_sense assume_wireless no_split_horizon random_router_id multicast_address port hello_interval wired_hello_interval smoothing_half_time duplication_priority local_server conf_file conf_dir"
# Append a line to the configuration file
cfg_append() {
local value="$1"
echo "$value" >> "$CONFIGFILE"
echo "$value" >> $CONFIGFILE
}
cfg_append_option() {
@ -57,6 +61,63 @@ append_parm() {
append buffer "$switch $_loctmp"
}
# Provides backward compatibility for old option names in the global section.
translate_option() {
local section="$1"
local old_option="$2"
local new_option="$3"
local _value
config_get _value "$section" "$old_option"
[ -z "$_value" ] && return
cfg_append "${new_option//_/-} $_value"
}
translate_bool() {
local section="$1"
local old_option="$2"
local new_option="$3"
local _bool
local _value
config_get_bool _bool "$section" "$old_option" 0
[ "$_bool" -eq 0 ] && return
cfg_append "${new_option//_/-} true"
}
# Adds a new interface section for setting default interface options.
add_default_option() {
local option="$1"
local value="$2"
cfg_append "default ${option//_/-} $value"
}
# Global 'hello_interval' and 'wired_hello_interval' options are ignored,
# because they have no direct equivalent: you should use
# interface-specific settings.
parse_old_global_options() {
local section="$1"
translate_bool "$section" 'carrier_sense' 'link_detect'
translate_bool "$section" 'random_router_id' 'random_id'
translate_option "$section" 'multicast_address' 'protocol_group'
translate_option "$section" 'port' 'protocol_port'
translate_option "$section" 'local_server' 'local_port'
translate_option "$section" 'smoothing_half_time' 'smoothing_half_life'
translate_option "$section" 'duplication_priority' 'allow_duplicates'
# These two global options are turned into default interface options.
local _bool
config_get_bool _bool "$section" 'assume_wireless' 0
[ "$_bool" -eq 1 ] && add_default_option "wired" "false"
config_get_bool _bool "$section" 'no_split_horizon' 0
[ "$_bool" -eq 1 ] && add_default_option "split_horizon" "false"
# Configure alternative configuration file and directory
local conf_file
config_get conf_file "$section" "conf_file"
[ -n "$conf_file" ] && OTHERCONFIGFILE="$conf_file"
local conf_dir
config_get conf_dir "$section" "conf_dir"
[ -n "$conf_dir" ] && OTHERCONFIGDIR="$conf_dir"
}
babel_filter() {
local cfg="$1"
local _loctmp
@ -103,18 +164,17 @@ babel_config_cb() {
option_cb() {
local option="$1"
local value="$2"
# Ignore options that are not supposed to be given to babeld
[ "$option" = "conf_file" ] && return
[ "$option" = "conf_dir" ] && return
# Skip lists. They will be taken care of by list_cb
test "${option#*_ITEM}" != "$option" && return
test "${option#*_LENGTH}" != "$option" && return
# Ignore old options
list_contains ignored_options "$option" && return
cfg_append "${option//_/-} $value"
}
;;
"interface")
local _ifname
config_get _ifname "$section" 'ifname'
# Backward compatibility: try to use the section name
# if no "option ifname" was used.
[ -z "$_ifname" -a "${section:0:3}" != "cfg" ] && _ifname="$section"
# Try to resolve the logical interface name
unset interface
network_get_device interface "$_ifname" || interface="$_ifname"
@ -149,58 +209,49 @@ babel_config_cb() {
esac
}
# Support for conf_file and conf_dir
babel_configpaths() {
local cfg="$1"
local conf_file
config_get conf_file "$cfg" "conf_file"
[ -n "$conf_file" ] && OTHERCONFIGFILE="$conf_file"
local conf_dir
config_get conf_dir "$cfg" "conf_dir"
[ -n "$conf_dir" ] && OTHERCONFIGDIR="$conf_dir"
}
start_service() {
start() {
mkdir -p /var/lib
mkdir -p /var/etc
# First load the whole config file, without callbacks, so that we are
# aware of all "ignore" options in the second pass. This also allows
# to load the configuration paths (conf_file and conf_dir).
config_load babeld
# Configure alternative configuration file and directory
config_foreach babel_configpaths "general"
mkdir -p $OTHERCONFIGDIR
# Start by emptying the generated config file
>"$CONFIGFILE"
# Import dynamic config files
mkdir -p "$OTHERCONFIGDIR"
for f in "$OTHERCONFIGDIR"/*.conf; do
[ -f "$f" ] && cat "$f" >> "$CONFIGFILE"
for f in $OTHERCONFIGDIR/*.conf; do
[ -f "$f" ] && cat $f >> $CONFIGFILE
done
# First load the whole config file, without callbacks, so that we are
# aware of all "ignore" options in the second pass.
config_load babeld
# Parse general and interface sections thanks to the "config_cb()"
# callback. This allows to loop over all options without having to
# know their name in advance.
config_cb() { babel_config_cb "$@"; }
config_load babeld
# Backward compatibility
config_foreach parse_old_global_options general
# Parse filters separately, since we know which options we expect
config_foreach babel_filter filter
procd_open_instance
# Using multiple config files is supported since babeld 1.5.1
procd_set_param command /usr/sbin/babeld -I "" -c "$OTHERCONFIGFILE" -c "$CONFIGFILE"
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param file "$OTHERCONFIGFILE" "$OTHERCONFIGDIR"/*.conf "$CONFIGFILE"
procd_set_param respawn
procd_close_instance
/usr/sbin/babeld -D -I "$pidfile" -c "$OTHERCONFIGFILE" -c "$CONFIGFILE"
# Wait for the pidfile to appear
for i in 1 2
do
[ -f "$pidfile" ] || sleep 1
done
[ -f "$pidfile" ] || (echo "Failed to start babeld"; exit 42)
}
service_triggers() {
procd_add_reload_trigger babeld
stop() {
[ -f "$pidfile" ] && kill $(cat $pidfile)
# avoid race-condition on restart: wait for
# babeld to die for real.
[ -f "$pidfile" ] && sleep 1
[ -f "$pidfile" ] && sleep 1
[ -f "$pidfile" ] && sleep 1
[ -f "$pidfile" ] && exit 42
}
status() {
kill -USR1 $(pgrep -P 1 babeld)
[ -f "$pidfile" ] && kill -USR1 $(cat $pidfile)
}

View file

@ -1,132 +0,0 @@
--- a/babeld.c
+++ b/babeld.c
@@ -54,6 +54,8 @@ THE SOFTWARE.
#include "local.h"
#include "version.h"
+#include "ubus.h"
+
struct timeval now;
unsigned char myid[8];
@@ -505,6 +507,9 @@ main(int argc, char **argv)
}
}
+ if(ubus_bindings)
+ babeld_add_ubus();
+
init_signals();
rc = resize_receive_buffer(1500);
if(rc < 0)
@@ -597,6 +602,8 @@ main(int argc, char **argv)
FD_SET(local_sockets[i].fd, &readfds);
maxfd = MAX(maxfd, local_sockets[i].fd);
}
+ if(ubus_bindings)
+ maxfd = babeld_ubus_add_read_sock(&readfds, maxfd);
rc = select(maxfd + 1, &readfds, NULL, NULL, &tv);
if(rc < 0) {
if(errno != EINTR) {
@@ -665,6 +672,9 @@ main(int argc, char **argv)
i++;
}
+ if(ubus_bindings)
+ babeld_ubus_receive(&readfds);
+
if(reopening) {
kernel_dump_time = now.tv_sec;
check_neighbours_timeout = now;
--- a/generate-version.sh
+++ b/generate-version.sh
@@ -10,4 +10,4 @@ else
version="unknown"
fi
-echo "#define BABELD_VERSION \"$version\""
+echo "#define BABELD_VERSION \"$version-ubus-mod\""
--- a/configuration.c
+++ b/configuration.c
@@ -42,6 +42,8 @@ THE SOFTWARE.
#include "hmac.h"
#include "configuration.h"
+#include "ubus.h"
+
static struct filter *input_filters = NULL;
static struct filter *output_filters = NULL;
static struct filter *redistribute_filters = NULL;
@@ -1024,7 +1026,8 @@ parse_option(int c, gnc_t gnc, void *clo
strcmp(token, "daemonise") == 0 ||
strcmp(token, "skip-kernel-setup") == 0 ||
strcmp(token, "ipv6-subtrees") == 0 ||
- strcmp(token, "reflect-kernel-metric") == 0) {
+ strcmp(token, "reflect-kernel-metric") == 0 ||
+ strcmp(token, "ubus-bindings") == 0) {
int b;
c = getbool(c, &b, gnc, closure);
if(c < -1)
@@ -1042,6 +1045,8 @@ parse_option(int c, gnc_t gnc, void *clo
has_ipv6_subtrees = b;
else if(strcmp(token, "reflect-kernel-metric") == 0)
reflect_kernel_metric = b;
+ else if(strcmp(token, "ubus-bindings") == 0)
+ ubus_bindings = b;
else
abort();
} else if(strcmp(token, "protocol-group") == 0) {
--- a/local.c
+++ b/local.c
@@ -42,6 +42,8 @@ THE SOFTWARE.
#include "local.h"
#include "version.h"
+#include "ubus.h"
+
int local_server_socket = -1;
struct local_socket local_sockets[MAX_LOCAL_SOCKETS];
int num_local_sockets = 0;
@@ -191,6 +193,8 @@ local_notify_neighbour(struct neighbour
if(local_sockets[i].monitor)
local_notify_neighbour_1(&local_sockets[i], neigh, kind);
}
+ if(ubus_bindings)
+ ubus_notify_neighbour(neigh, kind);
}
static void
@@ -228,6 +232,8 @@ local_notify_xroute(struct xroute *xrout
if(local_sockets[i].monitor)
local_notify_xroute_1(&local_sockets[i], xroute, kind);
}
+ if(ubus_bindings)
+ ubus_notify_xroute(xroute, kind);
}
static void
@@ -273,6 +279,8 @@ local_notify_route(struct babel_route *r
if(local_sockets[i].monitor)
local_notify_route_1(&local_sockets[i], route, kind);
}
+ if(ubus_bindings)
+ ubus_notify_route(route, kind);
}
static void
--- a/Makefile
+++ b/Makefile
@@ -11,11 +11,11 @@ LDLIBS = -lrt
SRCS = babeld.c net.c kernel.c util.c interface.c source.c neighbour.c \
route.c xroute.c message.c resend.c configuration.c local.c \
- hmac.c rfc6234/sha224-256.c BLAKE2/ref/blake2s-ref.c
+ hmac.c ubus.c rfc6234/sha224-256.c BLAKE2/ref/blake2s-ref.c
OBJS = babeld.o net.o kernel.o util.o interface.o source.o neighbour.o \
route.o xroute.o message.o resend.o configuration.o local.o \
- hmac.o rfc6234/sha224-256.o BLAKE2/ref/blake2s-ref.o
+ hmac.o ubus.o rfc6234/sha224-256.o BLAKE2/ref/blake2s-ref.o
babeld: $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o babeld $(OBJS) $(LDLIBS)

View file

@ -1,535 +0,0 @@
#include <stdint.h>
#include <stdlib.h>
#include <sys/select.h>
#include <libubox/blob.h>
#include <libubox/blobmsg.h>
#include <libubox/list.h>
#include <libubus.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <netinet/in.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include "babeld.h"
#include "configuration.h"
#include "interface.h"
#include "kernel.h"
#include "local.h"
#include "message.h"
#include "neighbour.h"
#include "net.h"
#include "resend.h"
#include "route.h"
#include "source.h"
#include "util.h"
#include "version.h"
#include "xroute.h"
#include "ubus.h"
// Definition of header variable whether to enable ubus bindings.
int ubus_bindings = 0;
// Shared state maintained throughout calls to handle ubus messages.
static struct ubus_context *shared_ctx;
// List of exported routes (to be used with ubox's list helpers).
struct xroute_list_entry {
struct list_head list;
struct xroute *xroute;
};
// List of received routes (to be used with ubox's list helpers).
struct route_list_entry {
struct list_head list;
struct babel_route *route;
};
// List of neighbours (to be used with ubox's list helpers).
struct neighbour_list_entry {
struct list_head list;
struct neighbour *neighbour;
};
// Definition of interface function enums (to be used with ubox's blobmsg
// helpers).
enum { INTERFACE_IFNAME, __INTERFACE_MAX };
// Definition of interface parsing (to be used with ubox's blobmsg helpers).
static const struct blobmsg_policy interface_policy[__INTERFACE_MAX] = {
[INTERFACE_IFNAME] = {"ifname", BLOBMSG_TYPE_STRING},
};
// Definition of filter function enums (to be used with ubox's blobmsg
// helpers).
enum { FILTER_IFNAME, FILTER_TYPE, FILTER_METRIC, __FILTER_MAX };
// Definition of filter parsing (to be used with ubox's blobmsg helpers).
static const struct blobmsg_policy filter_policy[__FILTER_MAX] = {
[FILTER_IFNAME] = {"ifname", BLOBMSG_TYPE_STRING},
[FILTER_TYPE] = {"type", BLOBMSG_TYPE_INT32},
[FILTER_METRIC] = {"metric", BLOBMSG_TYPE_INT32},
};
// Adds a filter (ubus equivalent to "filter"-function).
static int babeld_ubus_add_filter(struct ubus_context *ctx_local,
struct ubus_object *obj,
struct ubus_request_data *req,
const char *method, struct blob_attr *msg) {
struct blob_attr *tb[__FILTER_MAX];
struct blob_buf b = {0};
struct filter *filter = NULL;
char *ifname;
int metric, type;
blobmsg_parse(filter_policy, __FILTER_MAX, tb, blob_data(msg), blob_len(msg));
if (!tb[FILTER_IFNAME])
return UBUS_STATUS_INVALID_ARGUMENT;
if (!tb[FILTER_TYPE])
return UBUS_STATUS_INVALID_ARGUMENT;
type = blobmsg_get_u32(tb[FILTER_TYPE]);
if (tb[FILTER_METRIC])
metric = blobmsg_get_u32(tb[FILTER_METRIC]);
filter = calloc(1, sizeof(struct filter));
if (filter == NULL)
return UBUS_STATUS_UNKNOWN_ERROR;
filter->af = AF_INET6;
filter->proto = 0;
filter->plen_le = 128;
filter->src_plen_le = 128;
filter->action.add_metric = metric;
ifname = blobmsg_get_string(tb[FILTER_IFNAME]);
filter->ifname = strdup(ifname);
filter->ifindex = if_nametoindex(filter->ifname);
add_filter(filter, type);
return UBUS_STATUS_OK;
}
// Adds an inteface (ubus equivalent to "interface"-function).
static int babeld_ubus_add_interface(struct ubus_context *ctx_local,
struct ubus_object *obj,
struct ubus_request_data *req,
const char *method,
struct blob_attr *msg) {
struct blob_attr *tb[__INTERFACE_MAX];
struct blob_buf b = {0};
struct interface *ifp = NULL;
char *ifname;
blobmsg_parse(interface_policy, __INTERFACE_MAX, tb, blob_data(msg),
blob_len(msg));
if (!tb[INTERFACE_IFNAME])
return UBUS_STATUS_INVALID_ARGUMENT;
ifname = blobmsg_get_string(tb[INTERFACE_IFNAME]);
ifp = add_interface(ifname, NULL);
if (ifp == NULL)
return UBUS_STATUS_UNKNOWN_ERROR;
return UBUS_STATUS_OK;
}
// Sends a babel info message on ubus socket.
static int babeld_ubus_babeld_info(struct ubus_context *ctx_local,
struct ubus_object *obj,
struct ubus_request_data *req,
const char *method, struct blob_attr *msg) {
struct blob_buf b = {0};
void *prefix;
char host[64];
int ret;
blob_buf_init(&b, 0);
blobmsg_add_string(&b, "babeld-version", BABELD_VERSION);
blobmsg_add_string(&b, "my-id", format_eui64(myid));
if (!gethostname(host, sizeof(host)))
blobmsg_add_string(&b, "host", host);
ret = ubus_send_reply(ctx_local, req, b.head);
if (ret)
fprintf(stderr, "Failed to send reply: %s\n", ubus_strerror(ret));
blob_buf_free(&b);
return ret;
}
// Appends an exported route message entry to the buffer.
static void babeld_add_xroute_buf(struct xroute *xroute, struct blob_buf *b) {
void *prefix;
prefix = blobmsg_open_table(b, format_prefix(xroute->prefix, xroute->plen));
blobmsg_add_string(b, "src-prefix",
format_prefix(xroute->src_prefix, xroute->src_plen));
blobmsg_add_u32(b, "metric", xroute->metric);
blobmsg_close_table(b, prefix);
}
// Sends an exported routes message on ubus socket, splitting apart IPv4 and
// IPv6 routes.
static int babeld_ubus_get_xroutes(struct ubus_context *ctx_local,
struct ubus_object *obj,
struct ubus_request_data *req,
const char *method, struct blob_attr *msg) {
struct blob_buf b = {0};
struct xroute_stream *xroutes;
struct xroute_list_entry *cur, *tmp;
void *ipv4, *ipv6;
int ret;
LIST_HEAD(xroute_ipv4_list);
LIST_HEAD(xroute_ipv6_list);
blob_buf_init(&b, 0);
xroutes = xroute_stream();
if (xroutes) {
while (1) {
struct xroute *xroute = xroute_stream_next(xroutes);
if (xroute == NULL)
break;
struct xroute_list_entry *xr =
calloc(1, sizeof(struct xroute_list_entry));
xr->xroute = xroute;
if (v4mapped(xroute->prefix)) {
list_add(&xr->list, &xroute_ipv4_list);
} else {
list_add(&xr->list, &xroute_ipv6_list);
}
}
xroute_stream_done(xroutes);
}
ipv4 = blobmsg_open_table(&b, "IPv4");
list_for_each_entry_safe(cur, tmp, &xroute_ipv4_list, list) {
babeld_add_xroute_buf(cur->xroute, &b);
list_del(&cur->list);
free(cur);
}
blobmsg_close_table(&b, ipv4);
ipv6 = blobmsg_open_table(&b, "IPv6");
list_for_each_entry_safe(cur, tmp, &xroute_ipv6_list, list) {
babeld_add_xroute_buf(cur->xroute, &b);
list_del(&cur->list);
free(cur);
}
blobmsg_close_table(&b, ipv6);
ret = ubus_send_reply(ctx_local, req, b.head);
if (ret)
fprintf(stderr, "Failed to send reply: %s\n", ubus_strerror(ret));
blob_buf_free(&b);
return ret;
}
// Appends an route message entry to the buffer.
static void babeld_add_route_buf(struct babel_route *route,
struct blob_buf *b) {
void *prefix;
prefix = blobmsg_open_table(
b, format_prefix(route->src->prefix, route->src->plen));
blobmsg_add_string(
b, "src-prefix",
format_prefix(route->src->src_prefix, route->src->src_plen));
blobmsg_add_u32(b, "route_metric", route_metric(route));
blobmsg_add_u32(b, "route_smoothed_metric", route_smoothed_metric(route));
blobmsg_add_u32(b, "refmetric", route->refmetric);
blobmsg_add_string(b, "id", format_eui64(route->src->id));
blobmsg_add_u32(b, "seqno", (uint32_t)route->seqno);
blobmsg_add_u32(b, "age", (int)(now.tv_sec - route->time));
blobmsg_add_string(b, "via", format_address(route->neigh->address));
if (memcmp(route->nexthop, route->neigh->address, 16) != 0)
blobmsg_add_string(b, "nexthop", format_address(route->nexthop));
blobmsg_add_u8(b, "installed", route->installed);
blobmsg_add_u8(b, "feasible", route_feasible(route));
blobmsg_close_table(b, prefix);
}
// Sends received routes message on ubus socket, splitting apart IPv4 and IPv6
// routes.
static int babeld_ubus_get_routes(struct ubus_context *ctx_local,
struct ubus_object *obj,
struct ubus_request_data *req,
const char *method, struct blob_attr *msg) {
struct blob_buf b = {0};
struct route_stream *routes;
struct route_list_entry *cur, *tmp;
void *prefix, *ipv4, *ipv6;
int ret;
LIST_HEAD(route_ipv4_list);
LIST_HEAD(route_ipv6_list);
blob_buf_init(&b, 0);
routes = route_stream(0);
if (routes) {
while (1) {
struct babel_route *route = route_stream_next(routes);
if (route == NULL)
break;
struct route_list_entry *r = calloc(1, sizeof(struct route_list_entry));
r->route = route;
if (v4mapped(route->src->prefix)) {
list_add(&r->list, &route_ipv4_list);
} else {
list_add(&r->list, &route_ipv6_list);
}
}
route_stream_done(routes);
}
ipv4 = blobmsg_open_table(&b, "IPv4");
list_for_each_entry_safe(cur, tmp, &route_ipv4_list, list) {
babeld_add_route_buf(cur->route, &b);
list_del(&cur->list);
free(cur);
}
blobmsg_close_table(&b, ipv4);
ipv6 = blobmsg_open_table(&b, "IPv6");
list_for_each_entry_safe(cur, tmp, &route_ipv6_list, list) {
babeld_add_route_buf(cur->route, &b);
list_del(&cur->list);
free(cur);
}
blobmsg_close_table(&b, ipv6);
ret = ubus_send_reply(ctx_local, req, b.head);
if (ret)
fprintf(stderr, "Failed to send reply: %s\n", ubus_strerror(ret));
blob_buf_free(&b);
return ret;
}
// Appends an neighbour entry to the buffer.
static void babeld_add_neighbour_buf(struct neighbour *neigh,
struct blob_buf *b) {
void *neighbour;
neighbour = blobmsg_open_table(b, format_address(neigh->address));
blobmsg_add_string(b, "dev", neigh->ifp->name);
blobmsg_add_u32(b, "hello-reach", neigh->hello.reach);
blobmsg_add_u32(b, "uhello-reach", neigh->uhello.reach);
blobmsg_add_u32(b, "rxcost", neighbour_rxcost(neigh));
blobmsg_add_u32(b, "txcost", neigh->txcost);
blobmsg_add_string(b, "rtt", format_thousands(neigh->rtt));
blobmsg_add_u8(b, "if_up", if_up(neigh->ifp));
blobmsg_close_table(b, neighbour);
}
// Sends neighbours message on ubus socket, splitting apart IPv4 and IPv6
// neighbours.
static int babeld_ubus_get_neighbours(struct ubus_context *ctx_local,
struct ubus_object *obj,
struct ubus_request_data *req,
const char *method,
struct blob_attr *msg) {
struct blob_buf b = {0};
struct neighbour *neigh;
struct neighbour_list_entry *cur, *tmp;
void *ipv4, *ipv6;
int ret;
LIST_HEAD(neighbour_ipv4_list);
LIST_HEAD(neighbour_ipv6_list);
blob_buf_init(&b, 0);
FOR_ALL_NEIGHBOURS(neigh) {
struct neighbour_list_entry *n =
calloc(1, sizeof(struct neighbour_list_entry));
n->neighbour = neigh;
if (v4mapped(neigh->address)) {
list_add(&n->list, &neighbour_ipv4_list);
} else {
list_add(&n->list, &neighbour_ipv6_list);
}
}
ipv4 = blobmsg_open_table(&b, "IPv4");
list_for_each_entry_safe(cur, tmp, &neighbour_ipv4_list, list) {
babeld_add_neighbour_buf(cur->neighbour, &b);
list_del(&cur->list);
free(cur);
}
blobmsg_close_table(&b, ipv4);
ipv6 = blobmsg_open_table(&b, "IPv6");
list_for_each_entry_safe(cur, tmp, &neighbour_ipv6_list, list) {
babeld_add_neighbour_buf(cur->neighbour, &b);
list_del(&cur->list);
free(cur);
}
blobmsg_close_table(&b, ipv6);
ret = ubus_send_reply(ctx_local, req, b.head);
if (ret)
fprintf(stderr, "Failed to send reply: %s\n", ubus_strerror(ret));
blob_buf_free(&b);
return ret;
}
// List of functions we expose via the ubus bus.
static const struct ubus_method babeld_methods[] = {
UBUS_METHOD("add_interface", babeld_ubus_add_interface, interface_policy),
UBUS_METHOD("add_filter", babeld_ubus_add_filter, filter_policy),
UBUS_METHOD_NOARG("get_info", babeld_ubus_babeld_info),
UBUS_METHOD_NOARG("get_xroutes", babeld_ubus_get_xroutes),
UBUS_METHOD_NOARG("get_routes", babeld_ubus_get_routes),
UBUS_METHOD_NOARG("get_neighbours", babeld_ubus_get_neighbours),
};
// Definition of the ubus object type.
static struct ubus_object_type babeld_object_type =
UBUS_OBJECT_TYPE("babeld", babeld_methods);
// Object we announce via the ubus bus.
static struct ubus_object babeld_object = {
.name = "babeld",
.type = &babeld_object_type,
.methods = babeld_methods,
.n_methods = ARRAY_SIZE(babeld_methods),
};
// Registers handlers for babel methods in the global ubus context.
static bool ubus_init_object() {
int ret;
ret = ubus_add_object(shared_ctx, &babeld_object);
if (ret) {
fprintf(stderr, "Failed to add object: %s\n", ubus_strerror(ret));
return false;
}
return true;
}
// Initializes the global ubus context, connecting to the bus to be able to
// receive and send messages.
static bool babeld_ubus_init(void) {
if (shared_ctx)
return true;
shared_ctx = ubus_connect(NULL);
if (!shared_ctx)
return false;
return true;
}
void ubus_notify_route(struct babel_route *route, int kind) {
struct blob_buf b = {0};
char method[50]; // possible methods are route.change, route.add, route.flush
if (!babeld_object.has_subscribers)
return;
if (!route)
return;
if (!shared_ctx)
return;
blob_buf_init(&b, 0);
babeld_add_route_buf(route, &b);
snprintf(method, sizeof(method), "route.%s", local_kind(kind));
ubus_notify(shared_ctx, &babeld_object, method, b.head, -1);
blob_buf_free(&b);
}
void ubus_notify_xroute(struct xroute *xroute, int kind) {
struct blob_buf b = {0};
char method[50]; // possible methods are xroute.change, xroute.add,
// xroute.flush
if (!babeld_object.has_subscribers)
return;
if (!xroute)
return;
if (!shared_ctx)
return;
blob_buf_init(&b, 0);
babeld_add_xroute_buf(xroute, &b);
snprintf(method, sizeof(method), "xroute.%s", local_kind(kind));
ubus_notify(shared_ctx, &babeld_object, method, b.head, -1);
blob_buf_free(&b);
}
void ubus_notify_neighbour(struct neighbour *neigh, int kind) {
struct blob_buf b = {0};
char method[50]; // possible methods are neigh.change, neigh.add, neigh.flush
if (!babeld_object.has_subscribers)
return;
if (!neigh)
return;
if (!shared_ctx)
return;
blob_buf_init(&b, 0);
babeld_add_neighbour_buf(neigh, &b);
snprintf(method, sizeof(method), "neigh.%s", local_kind(kind));
ubus_notify(shared_ctx, &babeld_object, method, b.head, -1);
blob_buf_free(&b);
}
void babeld_ubus_receive(fd_set *readfds) {
if (!shared_ctx)
return;
if (FD_ISSET(shared_ctx->sock.fd, readfds))
ubus_handle_event(shared_ctx);
}
int babeld_ubus_add_read_sock(fd_set *readfds, int maxfd) {
if (!shared_ctx)
return maxfd;
FD_SET(shared_ctx->sock.fd, readfds);
return MAX(maxfd, shared_ctx->sock.fd);
}
bool babeld_add_ubus() {
if (!babeld_ubus_init()) {
fprintf(stderr, "Failed to initialize ubus!\n");
return false;
}
if (!ubus_init_object()) {
fprintf(stderr, "Failed to add objects to ubus!\n");
return false;
}
return true;
}

View file

@ -1,99 +0,0 @@
/*
IPC integration of babeld with OpenWrt.
The ubus interface offers following functions:
- add_filter '{"ifname":"eth0", "type":0, "metric":5000}'
type:
0: FILTER_TYPE_INPUT
1: FILTER_TYPE_OUTPUT
2: FILTER_TYPE_REDISTRIBUTE
3: FILTER_TYPE_INSTALL
- add_interface '{"ifname":"eth0"}'
- get_info
- get_neighbours
- get_xroutes
- get_routes
All output is divided into IPv4 and IPv6.
Ubus notifications are sent if we receive updates for
- xroutes
- routes
- neighbours
The format is:
- {route,xroute,neighbour}.add: Object was added
- {route,xroute,neighbour}.change: Object was changed
- {route,xroute,neighbour}.flush: Object was flushed
*/
#include <stdbool.h>
#include <sys/select.h>
struct babel_route;
struct neighbour;
struct xroute;
// Whether to enable ubus bindings (boolean option).
extern int ubus_bindings;
/**
* Initialize ubus interface.
*
* Connect to the ubus daemon and expose the ubus functions.
*
* @return if initializing ubus was successful
*/
bool babeld_add_ubus();
/**
* Add ubus socket to given filedescriptor set.
*
* We need to check repeatedly if the ubus socket has something to read.
* The functions allows to add the ubus socket to the normal while(1)-loop of
* babeld.
*
* @param readfs: the filedescriptor set
* @param maxfd: the current maximum file descriptor
* @return the maximum file descriptor
*/
int babeld_ubus_add_read_sock(fd_set *readfds, int maxfd);
/**
* Check and process ubus socket.
*
* If the ubus-socket signals that data is available, the ubus_handle_event is
* called.
*/
void babeld_ubus_receive(fd_set *readfds);
/***
* Notify the ubus bus that a new xroute is received.
*
* If a new xroute is received or changed, we will notify subscribers.
*
* @param xroute: xroute that experienced some change
* @param kind: kind that describes if we have a flush, add or change
*/
void ubus_notify_xroute(struct xroute *xroute, int kind);
/***
* Notify the ubus bus that a new route is received.
*
* If a new route is received or changed, we will notify subscribers.
*
* @param route: route that experienced some change
* @param kind: kind that describes if we have a flush, add or change
*/
void ubus_notify_route(struct babel_route *route, int kind);
/***
* Notify the ubus bus that a new neighbour is received.
*
* If a new neighbour is received or changed, we will notify subscribers.
*
* @param neigh: neighbour that experienced some change
* @param kind: kind that describes if we have a flush, add or change
*/
void ubus_notify_neighbour(struct neighbour *neigh, int kind);

View file

@ -1,248 +1,80 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2014 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=batctl
PKG_VERSION:=2024.0
PKG_VERSION:=2016.1
PKG_RELEASE:=1
PKG_MD5SUM:=b98a6e3b45927315cd6d4efba4c1a1ff
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
PKG_HASH:=76853e87201af63c411db152fd0c625a729a9733115897d1331604e2c5a67c7d
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
PKG_LICENSE:=GPL-2.0
PKG_MAINTAINER:=Simon Wunderlich <sw@simonwunderlich.de>
PKG_LICENSE:=GPL-2.0-only ISC MIT
PKG_LICENSE_FILES:=LICENSES/preferred/GPL-2.0 LICENSES/preferred/MIT LICENSES/deprecated/ISC
PKG_BUILD_PARALLEL:=1
PKG_BUILD_FLAGS:=gc-sections lto
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/$(PKG_NAME)-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
define Package/batctl/Default
define Package/batctl
URL:=https://www.open-mesh.org/
SECTION:=net
CATEGORY:=Network
URL:=https://www.open-mesh.org/
DEPENDS:=+libnl-tiny +libc +librt
PROVIDES:=batctl
DEPENDS:=+kmod-batman-adv +libnl-tiny +libc
TITLE:=B.A.T.M.A.N. Advanced user space configuration tool batctl
MAINTAINER:=Marek Lindner <mareklindner@neomailbox.ch>
endef
define Package/batctl/description
batctl is a more intuitive managment utility for B.A.T.M.A.N.-Advanced.
It is an easier method for configuring batman-adv and provides some
additional tools for debugging as well. This package builds
version $(PKG_VERSION) of the user space utility.
batctl is a more intuitive managment utility for B.A.T.M.A.N.-Advanced.
It is an easier method for configuring batman-adv and provides some
additional tools for debugging as well. This package builds
version $(PKG_VERSION) of the user space utility.
endef
define Package/batctl-tiny
$(call Package/batctl/Default)
TITLE:=B.A.T.M.A.N. Advanced user space configuration tool (Minimal)
VARIANT:=tiny
ALTERNATIVES:=100:/usr/sbin/batctl:/usr/libexec/batctl-tiny
# The linker can identify unused sections of a binary when each symbol is stored
# in a separate section. This mostly removes unused linker sections and reduces
# the size by ~3% on mipsel.
TARGET_CFLAGS += -ffunction-sections -fdata-sections
TARGET_LDFLAGS += -Wl,--gc-sections
# Link-time optimization allows to move parts of the optimization from the single
# source file to the global source view. This is done by emitting the GIMPLE
# representation in each object file and analyzing it again during the link step.
TARGET_CFLAGS += -flto
TARGET_LDFLAGS += -fuse-linker-plugin
MAKE_BATCTL_ENV += \
CPPFLAGS="$(TARGET_CPPFLAGS)" \
CFLAGS="$(TARGET_CFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS)" \
LIBNL_NAME="libnl-tiny"
MAKE_BATCTL_ARGS += \
REVISION="$(PKG_BATCTL_SHORTREV)" \
CC="$(TARGET_CC)" \
DESTDIR="$(PKG_INSTALL_DIR)" \
batctl install
define Build/Compile
$(MAKE_BATCTL_ENV) $(MAKE) -C "$(PKG_BUILD_DIR)" $(MAKE_BATCTL_ARGS)
endef
define Package/batctl-tiny/description
$(Package/batctl/description)
Only configuration relevant subcommands are enabled.
define Build/Clean
rm -rf $(BUILD_DIR)/$(PKG_NAME)/
endef
define Package/batctl-default
$(call Package/batctl/Default)
TITLE:=B.A.T.M.A.N. Advanced user space configuration tool (Default)
VARIANT:=default
ALTERNATIVES:=200:/usr/sbin/batctl:/usr/libexec/batctl-default
define Package/batctl/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/batctl $(1)/usr/sbin/
endef
define Package/batctl-default/description
$(Package/batctl/description)
Standard subcommands for configuration and online debugging are enabled.
endef
define Package/batctl-full
$(call Package/batctl/Default)
TITLE:=B.A.T.M.A.N. Advanced user space configuration tool (Full)
VARIANT:=full
ALTERNATIVES:=300:/usr/sbin/batctl:/usr/libexec/batctl-full
endef
define Package/batctl-full/description
$(Package/batctl/description)
Subcommands for configuration, online and offline debugging are enabled.
endef
MAKE_VARS += \
LIBNL_NAME="libnl-tiny" \
LIBNL_GENL_NAME="libnl-tiny"
MAKE_FLAGS += \
REVISION="$(PKG_VERSION)-openwrt-$(PKG_RELEASE)"
config-n := \
aggregation \
ap_isolation \
backbonetable \
bisect_iv \
bonding \
bla_backbone_json \
bla_claim_json \
bridge_loop_avoidance \
claimtable \
dat_cache \
dat_cache_json \
distributed_arp_table \
elp_interval \
event \
fragmentation \
gateways \
gateways_json \
gw_mode \
hardif_json \
hardifs_json \
hop_penalty \
interface \
isolation_mark \
loglevel \
mcast_flags \
mcast_flags_json \
mesh_json \
multicast_fanout \
multicast_forceflood \
multicast_mode \
neighbors \
neighbors_json \
network_coding \
orig_interval \
originators \
originators_json \
ping \
routing_algo \
statistics \
tcpdump \
throughput_override \
throughputmeter \
traceroute \
transglobal \
translate \
translocal \
transtable_global_json \
transtable_local_json \
vlan_json \
config-settings := \
aggregation \
ap_isolation \
bonding \
bridge_loop_avoidance \
distributed_arp_table \
elp_interval \
fragmentation \
gw_mode \
hop_penalty \
interface \
isolation_mark \
loglevel \
multicast_fanout \
multicast_forceflood \
multicast_mode \
network_coding \
orig_interval \
routing_algo \
throughput_override \
config-tables := \
backbonetable \
claimtable \
dat_cache \
gateways \
mcast_flags \
neighbors \
originators \
statistics \
transglobal \
translocal \
config-json := \
bla_backbone_json \
bla_claim_json \
dat_cache_json \
gateways_json \
hardif_json \
hardifs_json \
mcast_flags_json \
mesh_json \
neighbors_json \
originators_json \
transtable_global_json \
transtable_local_json \
vlan_json \
config-tools := \
event \
ping \
tcpdump \
throughputmeter \
traceroute \
translate \
config-extratools := \
bisect_iv \
ifeq ($(BUILD_VARIANT),tiny)
config-y := \
$(config-settings) \
endif
ifeq ($(BUILD_VARIANT),default)
config-y := \
$(config-settings) \
$(config-tables) \
$(config-json) \
$(config-tools) \
endif
ifeq ($(BUILD_VARIANT),full)
config-y := \
$(config-settings) \
$(config-tables) \
$(config-json) \
$(config-tools) \
$(config-extratools) \
endif
define ConfigVars
$(subst $(space),,$(foreach opt,$(config-$(1)),CONFIG_$(opt)=$(1)
))
endef
define batctl_config
$(call ConfigVars,n)$(call ConfigVars,y)
endef
$(eval $(call shexport,batctl_config))
MAKE_FLAGS += $$$$$(call shvar,batctl_config)
define Package/batctl-tiny/install
$(INSTALL_DIR) $(1)/usr/libexec
$(INSTALL_BIN) $(PKG_BUILD_DIR)/batctl $(1)/usr/libexec/batctl-tiny
endef
define Package/batctl-default/install
$(INSTALL_DIR) $(1)/usr/libexec
$(INSTALL_BIN) $(PKG_BUILD_DIR)/batctl $(1)/usr/libexec/batctl-default
endef
define Package/batctl-full/install
$(INSTALL_DIR) $(1)/usr/libexec
$(INSTALL_BIN) $(PKG_BUILD_DIR)/batctl $(1)/usr/libexec/batctl-full
endef
$(eval $(call BuildPackage,batctl-default))
$(eval $(call BuildPackage,batctl-tiny))
$(eval $(call BuildPackage,batctl-full))
$(eval $(call BuildPackage,batctl))

View file

@ -1,88 +1,30 @@
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2007-2019 B.A.T.M.A.N. contributors:
#
# Marek Lindner, Simon Wunderlich
#
# B.A.T.M.A.N meshing protocol
#
config KMOD_BATMAN_ADV_DEBUG_LOG
bool "enable verbose debug logging"
depends on PACKAGE_kmod-batman-adv
default n
config BATMAN_ADV_BATMAN_V
bool "B.A.T.M.A.N. V protocol"
config KMOD_BATMAN_ADV_BLA
bool "enable bridge loop avoidance"
depends on PACKAGE_kmod-batman-adv
default y
help
This option enables the B.A.T.M.A.N. V protocol, the successor
of the currently used B.A.T.M.A.N. IV protocol. The main
changes include splitting of the OGM protocol into a neighbor
discovery protocol (Echo Location Protocol, ELP) and a new OGM
Protocol OGMv2 for flooding protocol information through the
network, as well as a throughput based metric.
B.A.T.M.A.N. V is currently considered experimental and not
compatible to B.A.T.M.A.N. IV networks.
config BATMAN_ADV_BLA
bool "Bridge Loop Avoidance"
depends on PACKAGE_kmod-batman-adv
select PACKAGE_kmod-lib-crc16
default y
help
This option enables BLA (Bridge Loop Avoidance), a mechanism
to avoid Ethernet frames looping when mesh nodes are connected
to both the same LAN and the same mesh. If you will never use
more than one mesh node in the same LAN, you can safely remove
this feature and save some space.
config BATMAN_ADV_DAT
bool "Distributed ARP Table"
config KMOD_BATMAN_ADV_DAT
bool "enable distributed arp table"
depends on PACKAGE_kmod-batman-adv
default y
help
This option enables DAT (Distributed ARP Table), a DHT based
mechanism that increases ARP reliability on sparse wireless
mesh networks. If you think that your network does not need
this option you can safely remove it and save some space.
config BATMAN_ADV_NC
bool "Network Coding"
depends on PACKAGE_kmod-batman-adv
help
This option enables network coding, a mechanism that aims to
increase the overall network throughput by fusing multiple
packets in one transmission.
Note that interfaces controlled by batman-adv must be manually
configured to have promiscuous mode enabled in order to make
network coding work.
If you think that your network does not need this feature you
can safely disable it and save some space.
config BATMAN_ADV_MCAST
bool "Multicast optimisation"
config KMOD_BATMAN_ADV_MCAST
bool "enable multicast transmission optimization"
depends on PACKAGE_kmod-batman-adv
default y
help
This option enables the multicast optimisation which aims to
reduce the air overhead while improving the reliability of
multicast messages.
config BATMAN_ADV_DEBUG
bool "B.A.T.M.A.N. debugging"
config KMOD_BATMAN_ADV_NC
bool "enable network coding [requires promisc mode support]"
depends on PACKAGE_kmod-batman-adv
help
This is an option for use by developers; most people should
say N here. This enables compilation of support for
outputting debugging information to the debugfs log or tracing
buffer. The output is controlled via the batadv netdev specific
log_level setting.
default n
config BATMAN_ADV_TRACING
bool "B.A.T.M.A.N. tracing support"
config KMOD_BATMAN_ADV_BATMAN_V
bool "enable batman v routing algorithm"
depends on PACKAGE_kmod-batman-adv
select KERNEL_FTRACE
select KERNEL_ENABLE_DEFAULT_TRACERS
help
This is an option for use by developers; most people should
say N here. Select this option to gather traces like the debug
messages using the generic tracing infrastructure of the kernel.
BATMAN_ADV_DEBUG must also be selected to get trace events for
batadv_dbg.
default n

View file

@ -1,52 +1,42 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2010 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id: Makefile 5624 2006-11-23 00:29:07Z nbd $
include $(TOPDIR)/rules.mk
PKG_NAME:=batman-adv
PKG_VERSION:=2024.0
PKG_RELEASE:=2
PKG_VERSION:=2016.1
PKG_RELEASE:=3
PKG_MD5SUM:=8c8e449009b4d29512d26ee308960bb5
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
PKG_HASH:=61110697b5799f646a2a82a4dcf97faed4bb12a7cc43bf4683d2c4de4f6b40e7
PKG_EXTMOD_SUBDIRS:=net/batman-adv
PKG_LICENSE:=GPL-2.0
PKG_MAINTAINER:=Simon Wunderlich <sw@simonwunderlich.de>
PKG_LICENSE:=GPL-2.0-only MIT
PKG_LICENSE_FILES:=LICENSES/preferred/GPL-2.0 LICENSES/preferred/MIT
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/$(PKG_NAME)-$(PKG_VERSION)
PKG_BUILD_PARALLEL:=1
STAMP_CONFIGURED_DEPENDS := $(STAGING_DIR)/usr/include/mac80211-backport/backport/autoconf.h
PKG_CONFIG_DEPENDS += \
CONFIG_BATMAN_ADV_BATMAN_V \
CONFIG_BATMAN_ADV_BLA \
CONFIG_BATMAN_ADV_DAT \
CONFIG_BATMAN_ADV_NC \
CONFIG_BATMAN_ADV_MCAST \
CONFIG_BATMAN_ADV_DEBUG \
CONFIG_BATMAN_ADV_TRACING
include $(INCLUDE_DIR)/kernel.mk
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/kernel.mk
define KernelPackage/batman-adv
SUBMENU:=Network Support
TITLE:=B.A.T.M.A.N. Adv
URL:=https://www.open-mesh.org/
DEPENDS:=+BATMAN_ADV_BLA:kmod-lib-crc16 +kmod-lib-crc32c +kmod-cfg80211 +batctl
MAINTAINER:=Marek Lindner <mareklindner@neomailbox.ch>
SUBMENU:=Network Support
DEPENDS:=+KMOD_BATMAN_ADV_BLA:kmod-lib-crc16 +kmod-crypto-crc32c +kmod-lib-crc32c +kmod-cfg80211
TITLE:=B.A.T.M.A.N. Adv
FILES:=$(PKG_BUILD_DIR)/net/batman-adv/batman-adv.$(LINUX_KMOD_SUFFIX)
AUTOLOAD:=$(call AutoProbe,batman-adv)
AUTOLOAD:=$(call AutoLoad,50,cfg80211 batman-adv)
endef
define KernelPackage/batman-adv/description
B.A.T.M.A.N. (better approach to mobile ad-hoc networking) is
a routing protocol for multi-hop ad-hoc mesh networks. The
networks may be wired or wireless. See
https://www.open-mesh.org/ for more information and user space
tools. This package builds version $(PKG_VERSION) of the kernel
module.
B.A.T.M.A.N. advanced is a kernel module which allows to
build layer 2 mesh networks. This package builds
version $(PKG_VERSION) of the kernel module.
endef
define KernelPackage/batman-adv/config
@ -59,43 +49,55 @@ endef
PKG_EXTRA_KCONFIG:= \
CONFIG_BATMAN_ADV=m \
CONFIG_BATMAN_ADV_DEBUG=$(if $(CONFIG_BATMAN_ADV_DEBUG),y,n) \
CONFIG_BATMAN_ADV_BLA=$(if $(CONFIG_BATMAN_ADV_BLA),y,n) \
CONFIG_BATMAN_ADV_DAT=$(if $(CONFIG_BATMAN_ADV_DAT),y,n) \
CONFIG_BATMAN_ADV_MCAST=$(if $(CONFIG_BATMAN_ADV_MCAST),y,n) \
CONFIG_BATMAN_ADV_NC=$(if $(CONFIG_BATMAN_ADV_NC),y,n) \
CONFIG_BATMAN_ADV_BATMAN_V=$(if $(CONFIG_BATMAN_ADV_BATMAN_V),y,n) \
CONFIG_BATMAN_ADV_TRACING=$(if $(CONFIG_BATMAN_ADV_TRACING),y,n) \
CONFIG_BATMAN_ADV_DEBUG=$(if $(CONFIG_KMOD_BATMAN_ADV_DEBUG_LOG),y,n) \
CONFIG_BATMAN_ADV_BLA=$(if $(CONFIG_KMOD_BATMAN_ADV_BLA),y,n) \
CONFIG_BATMAN_ADV_DAT=$(if $(CONFIG_KMOD_BATMAN_ADV_DAT),y,n) \
CONFIG_BATMAN_ADV_MCAST=$(if $(CONFIG_KMOD_BATMAN_ADV_MCAST),y,n) \
CONFIG_BATMAN_ADV_NC=$(if $(CONFIG_KMOD_BATMAN_ADV_NC),y,n) \
CONFIG_BATMAN_ADV_BATMAN_V=$(if $(CONFIG_KMOD_BATMAN_ADV_BATMAN_V),y,n) \
PKG_EXTRA_CFLAGS:= \
$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(PKG_EXTRA_KCONFIG)))) \
$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(PKG_EXTRA_KCONFIG)))) \
NOSTDINC_FLAGS = \
$(KERNEL_NOSTDINC_FLAGS) \
-I$(PKG_BUILD_DIR)/net/batman-adv \
-I$(STAGING_DIR)/usr/include/mac80211-backport \
-I$(STAGING_DIR)/usr/include/mac80211-backport/uapi \
-I$(STAGING_DIR)/usr/include/mac80211 \
-I$(STAGING_DIR)/usr/include/mac80211-backport \
-I$(STAGING_DIR)/usr/include/mac80211/uapi \
-I$(PKG_BUILD_DIR)/include/ \
-include backport/autoconf.h \
-I$(STAGING_DIR)/usr/include/mac80211 \
-include backport/backport.h \
-include $(PKG_BUILD_DIR)/compat-hacks.h \
-DBATADV_SOURCE_VERSION=\\\"$(PKG_VERSION)-openwrt-$(PKG_RELEASE)\\\"
-include $(PKG_BUILD_DIR)/compat-hacks.h
define Build/Compile
$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \
$(KERNEL_MAKE_FLAGS) \
M="$(PKG_BUILD_DIR)/net/batman-adv" \
+$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \
ARCH="$(LINUX_KARCH)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
SUBDIRS="$(PKG_BUILD_DIR)/net/batman-adv" \
$(PKG_EXTRA_KCONFIG) \
EXTRA_CFLAGS="$(PKG_EXTRA_CFLAGS)" \
NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \
modules
endef
define Build/Prepare
$(call Build/Prepare/Default)
$(CP) ./files/compat-hacks.h $(PKG_BUILD_DIR)/
$(SED) '/#define _NET_BATMAN_ADV_MAIN_H_/a\#undef CONFIG_MODULE_STRIPPED' \
$(PKG_BUILD_DIR)/net/batman-adv/main.h
endef
define Build/Clean
rm -rf $(BUILD_DIR)/$(PKG_NAME)/
endef
define KernelPackage/batman-adv/install
$(CP) ./files/. $(1)/
$(INSTALL_DIR) $(1)/etc/config $(1)/etc/hotplug.d/net $(1)/etc/hotplug.d/iface $(1)/lib/batman-adv $(1)/usr/sbin $(1)/lib/netifd/proto
$(INSTALL_DATA) ./files/etc/config/batman-adv $(1)/etc/config
$(INSTALL_DATA) ./files/lib/batman-adv/config.sh $(1)/lib/batman-adv
$(INSTALL_BIN) ./files/etc/hotplug.d/net/99-batman-adv $(1)/etc/hotplug.d/net
$(INSTALL_BIN) ./files/lib/netifd/proto/batadv.sh $(1)/lib/netifd/proto
$(INSTALL_BIN) ./files/lib/netifd/proto/batadv_vlan.sh $(1)/lib/netifd/proto
endef
$(eval $(call KernelPackage,batman-adv))

View file

@ -0,0 +1,76 @@
/* Please avoid adding hacks here - instead add it to mac80211/backports.git */
#include <linux/version.h> /* LINUX_VERSION_CODE */
#include <linux/types.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
#define dev_get_iflink(_net_dev) ((_net_dev)->iflink)
#endif /* < KERNEL_VERSION(4, 1, 0) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0)
#include <linux/netdevice.h>
#define netdev_master_upper_dev_link(dev, upper_dev, upper_priv, upper_info) ({\
BUILD_BUG_ON(upper_priv != NULL); \
BUILD_BUG_ON(upper_info != NULL); \
netdev_set_master(dev, upper_dev); \
})
#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)
#include <linux/netdevice.h>
#define netdev_master_upper_dev_link(dev, upper_dev, upper_priv, upper_info) ({\
BUILD_BUG_ON(upper_priv != NULL); \
BUILD_BUG_ON(upper_info != NULL); \
netdev_master_upper_dev_link(dev, upper_dev); \
})
#endif /* < KERNEL_VERSION(4, 5, 0) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
#define IFF_NO_QUEUE 0; dev->tx_queue_len = 0
#endif /* < KERNEL_VERSION(4, 3, 0) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)
#include <linux/ethtool.h>
#define ethtool_link_ksettings batadv_ethtool_link_ksettings
struct batadv_ethtool_link_ksettings {
struct {
__u32 speed;
__u8 duplex;
} base;
};
#define __ethtool_get_link_ksettings(__dev, __link_settings) \
batadv_ethtool_get_link_ksettings(__dev, __link_settings)
static inline int
batadv_ethtool_get_link_ksettings(struct net_device *dev,
struct ethtool_link_ksettings *link_ksettings)
{
struct ethtool_cmd cmd;
int ret;
memset(&cmd, 0, sizeof(cmd));
ret = __ethtool_get_settings(dev, &cmd);
if (ret != 0)
return ret;
link_ksettings->base.duplex = cmd.duplex;
link_ksettings->base.speed = ethtool_cmd_speed(&cmd);
return 0;
}
#endif /* < KERNEL_VERSION(4, 6, 0) */

View file

@ -0,0 +1,22 @@
config 'mesh' 'bat0'
option 'aggregated_ogms'
option 'ap_isolation'
option 'bonding'
option 'fragmentation'
option 'gw_bandwidth'
option 'gw_mode'
option 'gw_sel_class'
option 'log_level'
option 'orig_interval'
option 'vis_mode'
option 'bridge_loop_avoidance'
option 'distributed_arp_table'
option 'multicast_mode'
option 'network_coding'
option 'hop_penalty'
option 'isolation_mark'
# yet another batX instance
# config 'mesh' 'bat5'
# option 'interfaces' 'second_mesh'

View file

@ -0,0 +1,12 @@
#!/bin/sh
. /lib/batman-adv/config.sh
bat_load_module
config_load batman-adv
case "$ACTION" in
add)
[ -d /sys/class/net/$INTERFACE/mesh/ ] && bat_config "$INTERFACE"
;;
esac

View file

@ -1,97 +0,0 @@
#!/bin/sh
# This UCI-Defaults script will split the batadv proto network interfaces
# in batadv_hardif and batadv proto. The configuration options from
# /etc/config/batman-adv will be moved to the latter.
. /lib/functions.sh
proto_batadv_to_batadv_hardif() {
local section="$1"
local proto
local mesh
local routing_algo
config_get proto "${section}" proto
config_get mesh "${section}" mesh
config_get routing_algo "${section}" routing_algo
if [ -z "$mesh" -o "${proto}" != "batadv" ]; then
continue
fi
uci set network."${section}".proto="batadv_hardif"
uci rename network."${section}".mesh="master"
uci delete network."${section}".routing_algo
# create new section or adjust existing one
uci set network."${mesh}"=interface
uci set network."${mesh}".proto=batadv
[ -n "${routing_algo}" ] && uci set network."${mesh}".routing_algo="${routing_algo}"
}
mv_batadv_config_section() {
local section="$1"
local aggregated_ogms
local ap_isolation
local bonding
local bridge_loop_avoidance
local distributed_arp_table
local fragmentation
local gw_bandwidth
local gw_mode
local gw_sel_class
local hop_penalty
local isolation_mark
local log_level
local multicast_mode
local network_coding
local orig_interval
config_get aggregated_ogms "${section}" aggregated_ogms
config_get ap_isolation "${section}" ap_isolation
config_get bonding "${section}" bonding
config_get bridge_loop_avoidance "${section}" bridge_loop_avoidance
config_get distributed_arp_table "${section}" distributed_arp_table
config_get fragmentation "${section}" fragmentation
config_get gw_bandwidth "${section}" gw_bandwidth
config_get gw_mode "${section}" gw_mode
config_get gw_sel_class "${section}" gw_sel_class
config_get hop_penalty "${section}" hop_penalty
config_get isolation_mark "${section}" isolation_mark
config_get log_level "${section}" log_level
config_get multicast_mode "${section}" multicast_mode
config_get network_coding "${section}" network_coding
config_get orig_interval "${section}" orig_interval
# update section in case it exists
[ -n "${aggregated_ogms}" ] && uci set network."${section}".aggregated_ogms="${aggregated_ogms}"
[ -n "${ap_isolation}" ] && uci set network."${section}".ap_isolation="${ap_isolation}"
[ -n "${bonding}" ] && uci set network."${section}".bonding="${bonding}"
[ -n "${bridge_loop_avoidance}" ] && uci set network."${section}".bridge_loop_avoidance="${bridge_loop_avoidance}"
[ -n "${distributed_arp_table}" ] && uci set network."${section}".distributed_arp_table="${distributed_arp_table}"
[ -n "${fragmentation}" ] && uci set network."${section}".fragmentation="${fragmentation}"
[ -n "${gw_bandwidth}" ] && uci set network."${section}".gw_bandwidth="${gw_bandwidth}"
[ -n "${gw_mode}" ] && uci set network."${section}".gw_mode="${gw_mode}"
[ -n "${gw_sel_class}" ] && uci set network."${section}".gw_sel_class="${gw_sel_class}"
[ -n "${hop_penalty}" ] && uci set network."${section}".hop_penalty="${hop_penalty}"
[ -n "${isolation_mark}" ] && uci set network."${section}".isolation_mark="${isolation_mark}"
[ -n "${log_level}" ] && uci set network."${section}".log_level="${log_level}"
[ -n "${multicast_mode}" ] && uci set network."${section}".multicast_mode="${multicast_mode}"
[ -n "${network_coding}" ] && uci set network."${section}".network_coding="${network_coding}"
[ -n "${orig_interval}" ] && uci set network."${section}".orig_interval="${orig_interval}"
}
if [ -f /etc/config/batman-adv ]; then
config_load network
config_foreach proto_batadv_to_batadv_hardif 'interface'
uci commit network
config_load batman-adv
config_foreach mv_batadv_config_section 'mesh'
uci commit network
rm -f /etc/config/batman-adv
fi
exit 0

View file

@ -0,0 +1,53 @@
#!/bin/sh
bat_load_module()
{
[ -d "/sys/module/batman_adv/" ] && return
. /lib/functions.sh
load_modules /etc/modules.d/*-crc16 /etc/modules.d/*-crypto* /etc/modules.d/*-lib-crc* /etc/modules.d/*-batman-adv*
}
bat_config()
{
local mesh="$1"
local aggregated_ogms ap_isolation bonding bridge_loop_avoidance distributed_arp_table fragmentation
local gw_bandwidth gw_mode gw_sel_class isolation_mark hop_penalty multicast_mode network_coding log_level
local orig_interval vis_mode
config_get aggregated_ogms "$mesh" aggregated_ogms
config_get ap_isolation "$mesh" ap_isolation
config_get bonding "$mesh" bonding
config_get bridge_loop_avoidance "$mesh" bridge_loop_avoidance
config_get distributed_arp_table "$mesh" distributed_arp_table
config_get fragmentation "$mesh" fragmentation
config_get gw_bandwidth "$mesh" gw_bandwidth
config_get gw_mode "$mesh" gw_mode
config_get gw_sel_class "$mesh" gw_sel_class
config_get hop_penalty "$mesh" hop_penalty
config_get isolation_mark "$mesh" isolation_mark
config_get multicast_mode "$mesh" multicast_mode
config_get network_coding "$mesh" network_coding
config_get log_level "$mesh" log_level
config_get orig_interval "$mesh" orig_interval
config_get vis_mode "$mesh" vis_mode
[ ! -f "/sys/class/net/$mesh/mesh/orig_interval" ] && echo "batman-adv mesh $mesh does not exist - check your interface configuration" && return 1
[ -n "$aggregate_ogms" ] && echo $aggregate_ogms > /sys/class/net/$mesh/mesh/aggregate_ogms
[ -n "$ap_isolation" ] && echo $ap_isolation > /sys/class/net/$mesh/mesh/ap_isolation
[ -n "$bonding" ] && echo $bonding > /sys/class/net/$mesh/mesh/bonding
[ -n "$bridge_loop_avoidance" ] && echo $bridge_loop_avoidance > /sys/class/net/$mesh/mesh/bridge_loop_avoidance 2>&-
[ -n "$distributed_arp_table" ] && echo $distributed_arp_table > /sys/class/net/$mesh/mesh/distributed_arp_table 2>&-
[ -n "$fragmentation" ] && echo $fragmentation > /sys/class/net/$mesh/mesh/fragmentation
[ -n "$gw_bandwidth" ] && echo $gw_bandwidth > /sys/class/net/$mesh/mesh/gw_bandwidth
[ -n "$gw_mode" ] && echo $gw_mode > /sys/class/net/$mesh/mesh/gw_mode
[ -n "$gw_sel_class" ] && echo $gw_sel_class > /sys/class/net/$mesh/mesh/gw_sel_class
[ -n "$hop_penalty" ] && echo $hop_penalty > /sys/class/net/$mesh/mesh/hop_penalty
[ -n "$isolation_mark" ] && echo $isolation_mark > /sys/class/net/$mesh/mesh/isolation_mark
[ -n "$multicast_mode" ] && echo $multicast_mode > /sys/class/net/$mesh/mesh/multicast_mode 2>&-
[ -n "$network_coding" ] && echo $network_coding > /sys/class/net/$mesh/mesh/network_coding 2>&-
[ -n "$log_level" ] && echo $log_level > /sys/class/net/$mesh/mesh/log_level 2>&-
[ -n "$orig_interval" ] && echo $orig_interval > /sys/class/net/$mesh/mesh/orig_interval
[ -n "$vis_mode" ] && echo $vis_mode > /sys/class/net/$mesh/mesh/vis_mode
}

115
batman-adv/files/lib/netifd/proto/batadv.sh Executable file → Normal file
View file

@ -1,123 +1,34 @@
#!/bin/sh
[ -n "$INCLUDE_ONLY" ] || {
. /lib/functions.sh
. ../netifd-proto.sh
init_proto "$@"
}
. /lib/functions.sh
. ../netifd-proto.sh
init_proto "$@"
proto_batadv_init_config() {
no_device=1
available=1
proto_config_add_boolean 'aggregated_ogms:bool'
proto_config_add_boolean 'ap_isolation:bool'
proto_config_add_boolean 'bonding:bool'
proto_config_add_boolean 'bridge_loop_avoidance:bool'
proto_config_add_boolean 'distributed_arp_table:bool'
proto_config_add_boolean 'fragmentation:bool'
proto_config_add_string 'gw_bandwidth'
proto_config_add_string 'gw_mode'
proto_config_add_int 'gw_sel_class'
proto_config_add_int 'hop_penalty'
proto_config_add_string 'isolation_mark'
proto_config_add_string 'log_level'
proto_config_add_int 'multicast_fanout'
proto_config_add_boolean 'multicast_mode:bool'
proto_config_add_boolean 'network_coding:bool'
proto_config_add_int 'orig_interval'
proto_config_add_string 'routing_algo'
proto_config_add_string "mesh"
proto_config_add_string "routing_algo"
}
proto_batadv_setup() {
local config="$1"
local iface="$config"
local iface="$2"
local aggregated_ogms
local ap_isolation
local bonding
local bridge_loop_avoidance
local distributed_arp_table
local fragmentation
local gw_bandwidth
local gw_mode
local gw_sel_class
local hop_penalty
local isolation_mark
local log_level
local multicast_fanout
local multicast_mode
local network_coding
local orig_interval
local routing_algo
local mesh routing_algo
json_get_vars mesh routing_algo
json_get_vars aggregated_ogms
json_get_vars ap_isolation
json_get_vars bonding
json_get_vars bridge_loop_avoidance
json_get_vars distributed_arp_table
json_get_vars fragmentation
json_get_vars gw_bandwidth
json_get_vars gw_mode
json_get_vars gw_sel_class
json_get_vars hop_penalty
json_get_vars isolation_mark
json_get_vars log_level
json_get_vars multicast_fanout
json_get_vars multicast_mode
json_get_vars network_coding
json_get_vars orig_interval
json_get_vars routing_algo
set_default routing_algo 'BATMAN_IV'
batctl routing_algo "$routing_algo"
batctl meshif "$iface" interface create
[ -n "$aggregated_ogms" ] && batctl meshif "$iface" aggregation "$aggregated_ogms"
[ -n "$ap_isolation" ] && batctl meshif "$iface" ap_isolation "$ap_isolation"
[ -n "$bonding" ] && batctl meshif "$iface" bonding "$bonding"
[ -n "$bridge_loop_avoidance" ] && batctl meshif "$iface" bridge_loop_avoidance "$bridge_loop_avoidance" 2>&-
[ -n "$distributed_arp_table" ] && batctl meshif "$iface" distributed_arp_table "$distributed_arp_table" 2>&-
[ -n "$fragmentation" ] && batctl meshif "$iface" fragmentation "$fragmentation"
case "$gw_mode" in
server)
if [ -n "$gw_bandwidth" ]; then
batctl meshif "$iface" gw_mode "server" "$gw_bandwidth"
else
batctl meshif "$iface" gw_mode "server"
fi
;;
client)
if [ -n "$gw_sel_class" ]; then
batctl meshif "$iface" gw_mode "client" "$gw_sel_class"
else
batctl meshif "$iface" gw_mode "client"
fi
;;
*)
batctl meshif "$iface" gw_mode "off"
;;
esac
[ -n "$hop_penalty" ] && batctl meshif "$iface" hop_penalty "$hop_penalty"
[ -n "$isolation_mark" ] && batctl meshif "$iface" isolation_mark "$isolation_mark"
[ -n "$multicast_fanout" ] && batctl meshif "$iface" multicast_fanout "$multicast_fanout"
[ -n "$multicast_mode" ] && batctl meshif "$iface" multicast_mode "$multicast_mode" 2>&-
[ -n "$network_coding" ] && batctl meshif "$iface" network_coding "$network_coding" 2>&-
[ -n "$log_level" ] && batctl meshif "$iface" loglevel "$log_level" 2>&-
[ -n "$orig_interval" ] && batctl meshif "$iface" orig_interval "$orig_interval"
[ -n "$routing_algo" ] || routing_algo="BATMAN_IV"
echo "$routing_algo" > "/sys/module/batman_adv/parameters/routing_algo"
echo "$mesh" > "/sys/class/net/$iface/batman_adv/mesh_iface"
proto_init_update "$iface" 1
proto_send_update "$config"
}
proto_batadv_teardown() {
local config="$1"
local iface="$config"
local iface="$2"
batctl meshif "$iface" interface destroy
echo "none" > "/sys/class/net/$iface/batman_adv/mesh_iface" || true
}
add_protocol batadv

View file

@ -1,53 +0,0 @@
#!/bin/sh
[ -n "$INCLUDE_ONLY" ] || {
. /lib/functions.sh
. ../netifd-proto.sh
init_proto "$@"
}
proto_batadv_hardif_init_config() {
proto_config_add_int 'elp_interval'
proto_config_add_int 'hop_penalty'
proto_config_add_string "master"
proto_config_add_string 'throughput_override'
}
proto_batadv_hardif_setup() {
local config="$1"
local iface="$2"
local elp_interval
local hop_penalty
local master
local throughput_override
json_get_vars elp_interval
json_get_vars hop_penalty
json_get_vars master
json_get_vars throughput_override
( proto_add_host_dependency "$config" '' "$master" )
batctl meshif "$master" interface -M add "$iface"
[ -n "$elp_interval" ] && batctl hardif "$iface" elp_interval "$elp_interval"
[ -n "$hop_penalty" ] && batctl hardif "$iface" hop_penalty "$hop_penalty"
[ -n "$throughput_override" ] && batctl hardif "$iface" throughput_override "$throughput_override"
proto_init_update "$iface" 1
proto_send_update "$config"
}
proto_batadv_hardif_teardown() {
local config="$1"
local iface="$2"
local master
json_get_vars master
batctl meshif "$master" interface -M del "$iface" || true
}
add_protocol batadv_hardif

12
batman-adv/files/lib/netifd/proto/batadv_vlan.sh Executable file → Normal file
View file

@ -5,25 +5,25 @@
init_proto "$@"
proto_batadv_vlan_init_config() {
proto_config_add_boolean 'ap_isolation:bool'
proto_config_add_string "ap_isolation"
}
proto_batadv_vlan_setup() {
local config="$1"
local iface="$2"
# VLAN specific variables
local device="${iface%.*}"
local vid="${iface#*.}"
# batadv_vlan options
local ap_isolation
json_get_vars ap_isolation
[ -n "$ap_isolation" ] && batctl vlan "$iface" ap_isolation "$ap_isolation"
echo "$ap_isolation" > "/sys/class/net/${device}/mesh/vlan${vid}/ap_isolation"
proto_init_update "$iface" 1
proto_send_update "$config"
}
proto_batadv_vlan_teardown() {
local cfg="$1"
}
add_protocol batadv_vlan

View file

@ -1,274 +0,0 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Fri, 6 May 2022 22:03:29 +0200
Subject: Revert "batman-adv: Migrate to linux/container_of.h"
The original patch requires Linux 5.16.0 or a mac80211 compat header with this
name. But the mac80211 package is currently not providing this header and
OpenWrt main is still using older Linux kernel versions for some targets.
This reverts commit 043ae5634bdfd4c4dd8b95a22890752495080bb5.
--- a/compat-include/linux/container_of.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* 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_LINUX_CONTAINER_OF_H_
-#define _NET_BATMAN_ADV_COMPAT_LINUX_CONTAINER_OF_H_
-
-#include <linux/version.h>
-#if LINUX_VERSION_IS_GEQ(5, 16, 0)
-#include_next <linux/container_of.h>
-#else
-#include <linux/kernel.h>
-#endif
-
-#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_CONTAINER_OF_H_ */
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -13,13 +13,13 @@
#include <linux/bug.h>
#include <linux/byteorder/generic.h>
#include <linux/cache.h>
-#include <linux/container_of.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
#include <linux/gfp.h>
#include <linux/if_ether.h>
#include <linux/init.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/lockdep.h>
--- a/net/batman-adv/bat_v_elp.c
+++ b/net/batman-adv/bat_v_elp.c
@@ -10,13 +10,13 @@
#include <linux/atomic.h>
#include <linux/bitops.h>
#include <linux/byteorder/generic.h>
-#include <linux/container_of.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
#include <linux/ethtool.h>
#include <linux/gfp.h>
#include <linux/if_ether.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/minmax.h>
#include <linux/netdevice.h>
--- a/net/batman-adv/bat_v_ogm.c
+++ b/net/batman-adv/bat_v_ogm.c
@@ -9,12 +9,12 @@
#include <linux/atomic.h>
#include <linux/byteorder/generic.h>
-#include <linux/container_of.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
#include <linux/gfp.h>
#include <linux/if_ether.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/lockdep.h>
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -10,7 +10,6 @@
#include <linux/atomic.h>
#include <linux/byteorder/generic.h>
#include <linux/compiler.h>
-#include <linux/container_of.h>
#include <linux/crc16.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -11,7 +11,6 @@
#include <linux/atomic.h>
#include <linux/bitops.h>
#include <linux/byteorder/generic.h>
-#include <linux/container_of.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
#include <linux/gfp.h>
@@ -21,6 +20,7 @@
#include <linux/in.h>
#include <linux/ip.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/netlink.h>
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -9,7 +9,6 @@
#include <linux/atomic.h>
#include <linux/byteorder/generic.h>
-#include <linux/container_of.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
#include <linux/gfp.h>
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -10,12 +10,12 @@
#include <linux/atomic.h>
#include <linux/byteorder/generic.h>
#include <linux/compiler.h>
-#include <linux/container_of.h>
#include <linux/errno.h>
#include <linux/gfp.h>
#include <linux/if.h>
#include <linux/if_arp.h>
#include <linux/if_ether.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/limits.h>
#include <linux/list.h>
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -10,7 +10,6 @@
#include <linux/atomic.h>
#include <linux/build_bug.h>
#include <linux/byteorder/generic.h>
-#include <linux/container_of.h>
#include <linux/crc32c.h>
#include <linux/device.h>
#include <linux/errno.h>
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -11,7 +11,6 @@
#include <linux/bitops.h>
#include <linux/bug.h>
#include <linux/byteorder/generic.h>
-#include <linux/container_of.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
#include <linux/gfp.h>
--- a/net/batman-adv/network-coding.c
+++ b/net/batman-adv/network-coding.c
@@ -11,7 +11,6 @@
#include <linux/bitops.h>
#include <linux/byteorder/generic.h>
#include <linux/compiler.h>
-#include <linux/container_of.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
#include <linux/gfp.h>
@@ -20,6 +19,7 @@
#include <linux/init.h>
#include <linux/jhash.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/lockdep.h>
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -8,11 +8,11 @@
#include "main.h"
#include <linux/atomic.h>
-#include <linux/container_of.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
#include <linux/gfp.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/lockdep.h>
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -10,13 +10,13 @@
#include <linux/atomic.h>
#include <linux/bug.h>
#include <linux/byteorder/generic.h>
-#include <linux/container_of.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
#include <linux/gfp.h>
#include <linux/if.h>
#include <linux/if_ether.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/netdevice.h>
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -11,7 +11,6 @@
#include <linux/byteorder/generic.h>
#include <linux/cache.h>
#include <linux/compiler.h>
-#include <linux/container_of.h>
#include <linux/cpumask.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
@@ -20,6 +19,7 @@
#include <linux/if_ether.h>
#include <linux/if_vlan.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/lockdep.h>
--- a/net/batman-adv/tp_meter.c
+++ b/net/batman-adv/tp_meter.c
@@ -12,13 +12,13 @@
#include <linux/byteorder/generic.h>
#include <linux/cache.h>
#include <linux/compiler.h>
-#include <linux/container_of.h>
#include <linux/err.h>
#include <linux/etherdevice.h>
#include <linux/gfp.h>
#include <linux/if_ether.h>
#include <linux/init.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/kthread.h>
#include <linux/limits.h>
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -13,7 +13,6 @@
#include <linux/byteorder/generic.h>
#include <linux/cache.h>
#include <linux/compiler.h>
-#include <linux/container_of.h>
#include <linux/crc32c.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
@@ -22,6 +21,7 @@
#include <linux/init.h>
#include <linux/jhash.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/lockdep.h>
--- a/net/batman-adv/tvlv.c
+++ b/net/batman-adv/tvlv.c
@@ -7,10 +7,10 @@
#include "main.h"
#include <linux/byteorder/generic.h>
-#include <linux/container_of.h>
#include <linux/etherdevice.h>
#include <linux/gfp.h>
#include <linux/if_ether.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/lockdep.h>

View file

@ -0,0 +1,64 @@
From a636bf0b69010222ea58337d425ca9ff8ce52639 Mon Sep 17 00:00:00 2001
From: Antonio Quartulli <a@unstable.cc>
Date: Mon, 2 May 2016 18:27:38 +0800
Subject: [PATCH 1/6] batman-adv: make sure ELP/OGM orig MAC is updated on
address change
When the MAC address of the primary interface is changed,
update the originator address in the ELP and OGM skb buffers as
well in order to reflect the change.
Fixes: a4b88af77e28 ("batman-adv: ELP - adding basic infrastructure")
Reported-by: Marek Lindner <marek@neomailbox.ch>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
---
net/batman-adv/bat_v.c | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c
index 4026f19..4547fce 100644
--- a/net/batman-adv/bat_v.c
+++ b/net/batman-adv/bat_v.c
@@ -72,16 +72,34 @@ static void batadv_v_iface_disable(struct batadv_hard_iface *hard_iface)
batadv_v_elp_iface_disable(hard_iface);
}
-static void batadv_v_iface_update_mac(struct batadv_hard_iface *hard_iface)
-{
-}
-
static void batadv_v_primary_iface_set(struct batadv_hard_iface *hard_iface)
{
batadv_v_elp_primary_iface_set(hard_iface);
batadv_v_ogm_primary_iface_set(hard_iface);
}
+/**
+ * batadv_v_iface_update_mac - react to hard-interface MAC address change
+ * @hard_iface: the modified interface
+ *
+ * If the modified interface is the primary one, update the originator
+ * address in the ELP and OGM messages to reflect the new MAC address.
+ */
+static void batadv_v_iface_update_mac(struct batadv_hard_iface *hard_iface)
+{
+ struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
+ struct batadv_hard_iface *primary_if;
+
+ primary_if = batadv_primary_if_get_selected(bat_priv);
+ if (primary_if != hard_iface)
+ goto out;
+
+ batadv_v_primary_iface_set(hard_iface);
+out:
+ if (primary_if)
+ batadv_hardif_put(primary_if);
+}
+
static void
batadv_v_hardif_neigh_init(struct batadv_hardif_neigh_node *hardif_neigh)
{
--
2.8.0.rc3

View file

@ -0,0 +1,89 @@
From 8013ae257447c99d7ba037967458f91ceb4051ae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Linus=20L=C3=BCssing?= <linus.luessing@c0d3.blue>
Date: Thu, 7 Jan 2016 08:11:12 +0100
Subject: [PATCH 2/6] batman-adv: Avoid duplicate neigh_node additions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Two parallel calls to batadv_neigh_node_new() might race for creating
and adding the same neig_node. Fix this by including the check for any
already existing, identical neigh_node within the spin-lock.
This fixes splats like the following:
[ 739.535069] ------------[ cut here ]------------
[ 739.535079] WARNING: CPU: 0 PID: 0 at /usr/src/batman-adv/git/batman-adv/net/batman-adv/bat_iv_ogm.c:1004 batadv_iv_ogm_process_per_outif+0xe3f/0xe60 [batman_adv]()
[ 739.535092] too many matching neigh_nodes
[ 739.535094] Modules linked in: dm_mod tun ip6table_filter ip6table_mangle ip6table_nat nf_nat_ipv6 ip6_tables xt_nat iptable_nat nf_nat_ipv4 nf_nat xt_TCPMSS xt_mark iptable_mangle xt_tcpudp xt_conntrack iptable_filter ip_tables x_tables ip_gre ip_tunnel gre bridge stp llc thermal_sys kvm_intel kvm crct10dif_pclmul crc32_pclmul sha256_ssse3 sha256_generic hmac drbg ansi_cprng aesni_intel aes_x86_64 lrw gf128mul glue_helper ablk_helper cryptd evdev pcspkr ip6_gre ip6_tunnel tunnel6 batman_adv(O) libcrc32c nf_conntrack_ipv6 nf_defrag_ipv6 nf_conntrack_ipv4 nf_defrag_ipv4 nf_conntrack autofs4 ext4 crc16 mbcache jbd2 xen_netfront xen_blkfront crc32c_intel
[ 739.535177] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G W O 4.2.0-0.bpo.1-amd64 #1 Debian 4.2.6-3~bpo8+2
[ 739.535186] 0000000000000000 ffffffffa013b050 ffffffff81554521 ffff88007d003c18
[ 739.535201] ffffffff8106fa01 0000000000000000 ffff8800047a087a ffff880079c3a000
[ 739.735602] ffff88007b82bf40 ffff88007bc2d1c0 ffffffff8106fa7a ffffffffa013aa8e
[ 739.735624] Call Trace:
[ 739.735639] <IRQ> [<ffffffff81554521>] ? dump_stack+0x40/0x50
[ 739.735677] [<ffffffff8106fa01>] ? warn_slowpath_common+0x81/0xb0
[ 739.735692] [<ffffffff8106fa7a>] ? warn_slowpath_fmt+0x4a/0x50
[ 739.735715] [<ffffffffa012448f>] ? batadv_iv_ogm_process_per_outif+0xe3f/0xe60 [batman_adv]
[ 739.735740] [<ffffffffa0124813>] ? batadv_iv_ogm_receive+0x363/0x380 [batman_adv]
[ 739.735762] [<ffffffffa0124813>] ? batadv_iv_ogm_receive+0x363/0x380 [batman_adv]
[ 739.735783] [<ffffffff810b0841>] ? __raw_callee_save___pv_queued_spin_unlock+0x11/0x20
[ 739.735804] [<ffffffffa012cb39>] ? batadv_batman_skb_recv+0xc9/0x110 [batman_adv]
[ 739.735825] [<ffffffff81464891>] ? __netif_receive_skb_core+0x841/0x9a0
[ 739.735838] [<ffffffff810b0841>] ? __raw_callee_save___pv_queued_spin_unlock+0x11/0x20
[ 739.735853] [<ffffffff81465681>] ? process_backlog+0xa1/0x140
[ 739.735864] [<ffffffff81464f1a>] ? net_rx_action+0x20a/0x320
[ 739.735878] [<ffffffff81073aa7>] ? __do_softirq+0x107/0x270
[ 739.735891] [<ffffffff81073d82>] ? irq_exit+0x92/0xa0
[ 739.735905] [<ffffffff8137e0d1>] ? xen_evtchn_do_upcall+0x31/0x40
[ 739.735924] [<ffffffff8155b8fe>] ? xen_do_hypervisor_callback+0x1e/0x40
[ 739.735939] <EOI> [<ffffffff810013aa>] ? xen_hypercall_sched_op+0xa/0x20
[ 739.735965] [<ffffffff810013aa>] ? xen_hypercall_sched_op+0xa/0x20
[ 739.735979] [<ffffffff8100a39c>] ? xen_safe_halt+0xc/0x20
[ 739.735991] [<ffffffff8101da6c>] ? default_idle+0x1c/0xa0
[ 739.736004] [<ffffffff810abf6b>] ? cpu_startup_entry+0x2eb/0x350
[ 739.736019] [<ffffffff81b2af5e>] ? start_kernel+0x480/0x48b
[ 739.736032] [<ffffffff81b2d116>] ? xen_start_kernel+0x507/0x511
[ 739.736048] ---[ end trace c106bb901244bc8c ]---
Reported-by: Martin Weinelt <martin@darmstadt.freifunk.net>
Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
---
net/batman-adv/originator.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index c355a82..28241a4 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -630,6 +630,8 @@ batadv_neigh_node_new(struct batadv_orig_node *orig_node,
struct batadv_neigh_node *neigh_node;
struct batadv_hardif_neigh_node *hardif_neigh = NULL;
+ spin_lock_bh(&orig_node->neigh_list_lock);
+
neigh_node = batadv_neigh_node_get(orig_node, hard_iface, neigh_addr);
if (neigh_node)
goto out;
@@ -666,15 +668,15 @@ batadv_neigh_node_new(struct batadv_orig_node *orig_node,
kref_init(&neigh_node->refcount);
kref_get(&neigh_node->refcount);
- spin_lock_bh(&orig_node->neigh_list_lock);
hlist_add_head_rcu(&neigh_node->list, &orig_node->neigh_list);
- spin_unlock_bh(&orig_node->neigh_list_lock);
batadv_dbg(BATADV_DBG_BATMAN, orig_node->bat_priv,
"Creating new neighbor %pM for orig_node %pM on interface %s\n",
neigh_addr, orig_node->orig, hard_iface->net_dev->name);
out:
+ spin_unlock_bh(&orig_node->neigh_list_lock);
+
if (hardif_neigh)
batadv_hardif_neigh_put(hardif_neigh);
return neigh_node;
--
2.8.0.rc3

View file

@ -1,19 +0,0 @@
From: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Date: Thu, 6 Apr 2023 18:05:50 -0500
Subject: fix batadv_is_cfg80211_netdev
Replace CONFIG_CFG80211 with CPTCFG_CFG80211, which is the correct
macro to use when building under backports.
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -308,8 +308,7 @@ static bool batadv_is_cfg80211_netdev(st
{
if (!net_device)
return false;
-
-#if IS_ENABLED(CONFIG_CFG80211)
+#if IS_ENABLED(CPTCFG_CFG80211)
/* cfg80211 drivers have to set ieee80211_ptr */
if (net_device->ieee80211_ptr)
return true;

View file

@ -1,97 +0,0 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Fri, 2 Feb 2024 22:49:00 +0100
Subject: Revert "batman-adv: Switch to linux/sprintf.h"
The original patch requires Linux 6.6.0 or a mac80211 compat header with this
name. But the mac80211 package is currently not providing this header and
OpenWrt main is still using older Linux kernel versions for some targets.
This reverts commit f0fb49c5ab70dfa064f0aa8d1c5d84f65e8cbc86.
--- a/compat-include/linux/sprintf.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* 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_LINUX_SPRINTF_H_
-#define _NET_BATMAN_ADV_COMPAT_LINUX_SPRINTF_H_
-
-#include <linux/version.h>
-#if LINUX_VERSION_IS_GEQ(6, 6, 0)
-#include_next <linux/sprintf.h>
-#else
-#include <linux/kernel.h>
-#endif
-
-#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_SPRINTF_H_ */
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -19,6 +19,7 @@
#include <linux/if_vlan.h>
#include <linux/jhash.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/lockdep.h>
@@ -29,7 +30,6 @@
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
-#include <linux/sprintf.h>
#include <linux/stddef.h>
#include <linux/string.h>
#include <linux/workqueue.h>
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -17,6 +17,7 @@
#include <linux/in.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
+#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/lockdep.h>
@@ -27,7 +28,6 @@
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
-#include <linux/sprintf.h>
#include <linux/stddef.h>
#include <linux/udp.h>
#include <net/sock.h>
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -32,7 +32,6 @@
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
-#include <linux/sprintf.h>
#include <linux/stddef.h>
#include <linux/string.h>
#include <linux/workqueue.h>
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -24,6 +24,7 @@
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/jiffies.h>
+#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/lockdep.h>
#include <linux/netdevice.h>
@@ -34,7 +35,6 @@
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
-#include <linux/sprintf.h>
#include <linux/stddef.h>
#include <linux/string.h>
#include <linux/types.h>

View file

@ -0,0 +1,38 @@
From 036aa7b7181ee96ae6971eb31dd97b6ace7c0a80 Mon Sep 17 00:00:00 2001
From: Sven Eckelmann <sven@narfation.org>
Date: Fri, 6 May 2016 11:43:38 +0200
Subject: [PATCH 3/6] batman-adv: Avoid nullptr derefence in
batadv_v_neigh_is_sob
batadv_neigh_ifinfo_get can return NULL when it cannot find (even when only
temporarily) anymore the neigh_ifinfo in the list neigh->ifinfo_list. This
has to be checked to avoid kernel Oopses when the ifinfo is dereferenced.
This a situation which isn't expected but is already handled by functions
like batadv_v_neigh_cmp. The same kind of warning is therefore used before
the function returns without dereferencing the pointers.
Fixes: b05bbab5e1fc ("batman-adv: B.A.T.M.A.N. V - implement neighbor comparison API calls")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
---
net/batman-adv/bat_v.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c
index 4547fce..7e1467a 100644
--- a/net/batman-adv/bat_v.c
+++ b/net/batman-adv/bat_v.c
@@ -295,6 +295,9 @@ static bool batadv_v_neigh_is_sob(struct batadv_neigh_node *neigh1,
ifinfo1 = batadv_neigh_ifinfo_get(neigh1, if_outgoing1);
ifinfo2 = batadv_neigh_ifinfo_get(neigh2, if_outgoing2);
+ if (WARN_ON(!ifinfo1 || !ifinfo2))
+ return false;
+
threshold = ifinfo1->bat_v.throughput / 4;
threshold = ifinfo1->bat_v.throughput - threshold;
--
2.8.0.rc3

View file

@ -1,69 +0,0 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Fri, 2 Feb 2024 22:49:48 +0100
Subject: Revert "batman-adv: Switch to linux/array_size.h"
The original patch requires Linux 6.7.0 or a mac80211 compat header with this
name. But the mac80211 package is currently not providing this header and
OpenWrt main is still using older Linux kernel versions for some targets.
This reverts commit f33d7f724675544a36b24c77f8d4b95d41252ae2.
--- a/compat-include/linux/array_size.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* 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_LINUX_ARRAY_SIZE_H_
-#define _NET_BATMAN_ADV_COMPAT_LINUX_ARRAY_SIZE_H_
-
-#include <linux/version.h>
-#if LINUX_VERSION_IS_GEQ(6, 7, 0)
-#include_next <linux/array_size.h>
-#else
-#include <linux/kernel.h>
-#endif
-
-#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_ARRAY_SIZE_H_ */
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -6,7 +6,6 @@
#include "main.h"
-#include <linux/array_size.h>
#include <linux/atomic.h>
#include <linux/build_bug.h>
#include <linux/byteorder/generic.h>
@@ -20,6 +19,7 @@
#include <linux/init.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
+#include <linux/kernel.h>
#include <linux/kobject.h>
#include <linux/kref.h>
#include <linux/list.h>
--- a/net/batman-adv/netlink.c
+++ b/net/batman-adv/netlink.c
@@ -7,7 +7,6 @@
#include "netlink.h"
#include "main.h"
-#include <linux/array_size.h>
#include <linux/atomic.h>
#include <linux/bitops.h>
#include <linux/bug.h>
@@ -21,6 +20,7 @@
#include <linux/if_ether.h>
#include <linux/if_vlan.h>
#include <linux/init.h>
+#include <linux/kernel.h>
#include <linux/limits.h>
#include <linux/list.h>
#include <linux/minmax.h>

View file

@ -0,0 +1,81 @@
From 650d41de4be2fe9e9d1842c1abdd357dedbaa7ba Mon Sep 17 00:00:00 2001
From: Sven Eckelmann <sven@narfation.org>
Date: Fri, 6 May 2016 11:43:39 +0200
Subject: [PATCH 4/6] batman-adv: Fix refcnt leak in batadv_v_neigh_*
The functions batadv_neigh_ifinfo_get increase the reference counter of the
batadv_neigh_ifinfo. These have to be reduced again when the reference is
not used anymore to correctly free the objects.
Fixes: b05bbab5e1fc ("batman-adv: B.A.T.M.A.N. V - implement neighbor comparison API calls")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
---
net/batman-adv/bat_v.c | 32 +++++++++++++++++++++++++-------
1 file changed, 25 insertions(+), 7 deletions(-)
diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c
index 7e1467a..2bcb29b 100644
--- a/net/batman-adv/bat_v.c
+++ b/net/batman-adv/bat_v.c
@@ -274,14 +274,23 @@ static int batadv_v_neigh_cmp(struct batadv_neigh_node *neigh1,
struct batadv_hard_iface *if_outgoing2)
{
struct batadv_neigh_ifinfo *ifinfo1, *ifinfo2;
+ int ret = 0;
ifinfo1 = batadv_neigh_ifinfo_get(neigh1, if_outgoing1);
+ if (WARN_ON(!ifinfo1))
+ goto err_ifinfo1;
+
ifinfo2 = batadv_neigh_ifinfo_get(neigh2, if_outgoing2);
+ if (WARN_ON(!ifinfo2))
+ goto err_ifinfo2;
- if (WARN_ON(!ifinfo1 || !ifinfo2))
- return 0;
+ ret = ifinfo1->bat_v.throughput - ifinfo2->bat_v.throughput;
- return ifinfo1->bat_v.throughput - ifinfo2->bat_v.throughput;
+ batadv_neigh_ifinfo_put(ifinfo2);
+err_ifinfo2:
+ batadv_neigh_ifinfo_put(ifinfo1);
+err_ifinfo1:
+ return ret;
}
static bool batadv_v_neigh_is_sob(struct batadv_neigh_node *neigh1,
@@ -291,17 +300,26 @@ static bool batadv_v_neigh_is_sob(struct batadv_neigh_node *neigh1,
{
struct batadv_neigh_ifinfo *ifinfo1, *ifinfo2;
u32 threshold;
+ bool ret = false;
ifinfo1 = batadv_neigh_ifinfo_get(neigh1, if_outgoing1);
- ifinfo2 = batadv_neigh_ifinfo_get(neigh2, if_outgoing2);
+ if (WARN_ON(!ifinfo1))
+ goto err_ifinfo1;
- if (WARN_ON(!ifinfo1 || !ifinfo2))
- return false;
+ ifinfo2 = batadv_neigh_ifinfo_get(neigh2, if_outgoing2);
+ if (WARN_ON(!ifinfo2))
+ goto err_ifinfo2;
threshold = ifinfo1->bat_v.throughput / 4;
threshold = ifinfo1->bat_v.throughput - threshold;
- return ifinfo2->bat_v.throughput > threshold;
+ ret = ifinfo2->bat_v.throughput > threshold;
+
+ batadv_neigh_ifinfo_put(ifinfo2);
+err_ifinfo2:
+ batadv_neigh_ifinfo_put(ifinfo1);
+err_ifinfo1:
+ return ret;
}
static struct batadv_algo_ops batadv_batman_v __read_mostly = {
--
2.8.0.rc3

View file

@ -0,0 +1,40 @@
From fc3e79d9ef2a1006f94e441d9613749cbbe7176a Mon Sep 17 00:00:00 2001
From: Sven Eckelmann <sven@narfation.org>
Date: Fri, 6 May 2016 22:27:09 +0200
Subject: [PATCH 5/6] batman-adv: Fix double neigh_node_put in
batadv_v_ogm_route_update
The router is put down twice when it was non-NULL and either orig_ifinfo is
NULL afterwards or batman-adv receives a packet with the same sequence
number. This will end up in a use-after-free when the batadv_neigh_node is
removed because the reference counter ended up too early at 0.
Fixes: 667996ebeab4 ("batman-adv: OGMv2 - implement originators logic")
Reported-by: Gui Iribarren <gui@altermundi.net>
Tested-by: Antonio Quartulli <a@unstable.cc>
Tested-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
---
net/batman-adv/bat_v_ogm.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c
index d9bcbe6..91df28a 100644
--- a/net/batman-adv/bat_v_ogm.c
+++ b/net/batman-adv/bat_v_ogm.c
@@ -529,8 +529,10 @@ static void batadv_v_ogm_route_update(struct batadv_priv *bat_priv,
goto out;
}
- if (router)
+ if (router) {
batadv_neigh_node_put(router);
+ router = NULL;
+ }
/* Update routes, and check if the OGM is from the best next hop */
batadv_v_ogm_orig_update(bat_priv, orig_node, neigh_node, ogm2,
--
2.8.0.rc3

View file

@ -0,0 +1,110 @@
From f58a0b03873fd3aa9568c11af198f997ed2208cc Mon Sep 17 00:00:00 2001
From: Marek Lindner <mareklindner@neomailbox.ch>
Date: Sat, 7 May 2016 19:54:17 +0800
Subject: [PATCH 6/6] batman-adv: initialize ELP orig address on secondary
interfaces
This fix prevents nodes to wrongly create a 00:00:00:00:00:00 originator
which can potentially interfere with the rest of the neighbor statistics.
Fixes: a4b88af77e28 ("batman-adv: ELP - adding basic infrastructure")
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
---
net/batman-adv/bat_v.c | 10 ++++++++++
net/batman-adv/bat_v_elp.c | 31 ++++++++++++++++++++++---------
net/batman-adv/bat_v_elp.h | 2 ++
3 files changed, 34 insertions(+), 9 deletions(-)
diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c
index 2bcb29b..0caca2f 100644
--- a/net/batman-adv/bat_v.c
+++ b/net/batman-adv/bat_v.c
@@ -39,6 +39,16 @@
static void batadv_v_iface_activate(struct batadv_hard_iface *hard_iface)
{
+ struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
+ struct batadv_hard_iface *primary_if;
+
+ primary_if = batadv_primary_if_get_selected(bat_priv);
+
+ if (primary_if) {
+ batadv_v_elp_iface_activate(primary_if, hard_iface);
+ batadv_hardif_put(primary_if);
+ }
+
/* B.A.T.M.A.N. V does not use any queuing mechanism, therefore it can
* set the interface as ACTIVE right away, without any risk of race
* condition
diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c
index 3844e7e..df42eb1 100644
--- a/net/batman-adv/bat_v_elp.c
+++ b/net/batman-adv/bat_v_elp.c
@@ -377,6 +377,27 @@ void batadv_v_elp_iface_disable(struct batadv_hard_iface *hard_iface)
}
/**
+ * batadv_v_elp_iface_activate - update the ELP buffer belonging to the given
+ * hard-interface
+ * @primary_iface: the new primary interface
+ * @hard_iface: interface holding the to-be-updated buffer
+ */
+void batadv_v_elp_iface_activate(struct batadv_hard_iface *primary_iface,
+ struct batadv_hard_iface *hard_iface)
+{
+ struct batadv_elp_packet *elp_packet;
+ struct sk_buff *skb;
+
+ if (!hard_iface->bat_v.elp_skb)
+ return;
+
+ skb = hard_iface->bat_v.elp_skb;
+ elp_packet = (struct batadv_elp_packet *)skb->data;
+ ether_addr_copy(elp_packet->orig,
+ primary_iface->net_dev->dev_addr);
+}
+
+/**
* batadv_v_elp_primary_iface_set - change internal data to reflect the new
* primary interface
* @primary_iface: the new primary interface
@@ -384,8 +405,6 @@ void batadv_v_elp_iface_disable(struct batadv_hard_iface *hard_iface)
void batadv_v_elp_primary_iface_set(struct batadv_hard_iface *primary_iface)
{
struct batadv_hard_iface *hard_iface;
- struct batadv_elp_packet *elp_packet;
- struct sk_buff *skb;
/* update orig field of every elp iface belonging to this mesh */
rcu_read_lock();
@@ -393,13 +412,7 @@ void batadv_v_elp_primary_iface_set(struct batadv_hard_iface *primary_iface)
if (primary_iface->soft_iface != hard_iface->soft_iface)
continue;
- if (!hard_iface->bat_v.elp_skb)
- continue;
-
- skb = hard_iface->bat_v.elp_skb;
- elp_packet = (struct batadv_elp_packet *)skb->data;
- ether_addr_copy(elp_packet->orig,
- primary_iface->net_dev->dev_addr);
+ batadv_v_elp_iface_activate(primary_iface, hard_iface);
}
rcu_read_unlock();
}
diff --git a/net/batman-adv/bat_v_elp.h b/net/batman-adv/bat_v_elp.h
index e95f1bc..cc130b2 100644
--- a/net/batman-adv/bat_v_elp.h
+++ b/net/batman-adv/bat_v_elp.h
@@ -25,6 +25,8 @@ struct work_struct;
int batadv_v_elp_iface_enable(struct batadv_hard_iface *hard_iface);
void batadv_v_elp_iface_disable(struct batadv_hard_iface *hard_iface);
+void batadv_v_elp_iface_activate(struct batadv_hard_iface *primary_iface,
+ struct batadv_hard_iface *hard_iface);
void batadv_v_elp_primary_iface_set(struct batadv_hard_iface *primary_iface);
int batadv_v_elp_packet_recv(struct sk_buff *skb,
struct batadv_hard_iface *if_incoming);
--
2.8.0.rc3

View file

@ -0,0 +1,28 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Sat, 7 May 2016 09:50:44 +0200
Subject: [PATCH] batman-adv: Add missing include for batadv_v_neigh_is_sob
batadv_v_neigh_is_sob started to use false which is defined in
linux/stddef.h.
Fixes: 036aa7b7181e ("batman-adv: Avoid nullptr derefence in batadv_v_neigh_is_sob")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/9685688ae7dd85804aec2f6ce760611551fe9635
---
net/batman-adv/bat_v.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c
index 0caca2f..1f960c9 100644
--- a/net/batman-adv/bat_v.c
+++ b/net/batman-adv/bat_v.c
@@ -27,6 +27,7 @@
#include <linux/rculist.h>
#include <linux/rcupdate.h>
#include <linux/seq_file.h>
+#include <linux/stddef.h>
#include <linux/types.h>
#include <linux/workqueue.h>

View file

@ -0,0 +1,46 @@
From: Florian Westphal <fw@strlen.de>
Date: Tue, 10 May 2016 23:17:59 +0200
Subject: [PATCH] batman-adv: fix skb deref after free
batadv_send_skb_to_orig() calls dev_queue_xmit() so we can't use skb->len.
Fixes: d28785996ad8 ("batman-adv: network coding - buffer unicast packets before forward")
Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/6863d3b59fd1f1bef3c4b86707a0b1c5d21e0a07
---
net/batman-adv/routing.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index b781bf7..0c0c30e 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -601,6 +601,7 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
struct batadv_unicast_packet *unicast_packet;
struct ethhdr *ethhdr = eth_hdr(skb);
int res, hdr_len, ret = NET_RX_DROP;
+ unsigned int len;
unicast_packet = (struct batadv_unicast_packet *)skb->data;
@@ -641,6 +642,7 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
if (hdr_len > 0)
batadv_skb_set_priority(skb, hdr_len);
+ len = skb->len;
res = batadv_send_skb_to_orig(skb, orig_node, recv_if);
/* translate transmit result into receive result */
@@ -648,7 +650,7 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
/* skb was transmitted and consumed */
batadv_inc_counter(bat_priv, BATADV_CNT_FORWARD);
batadv_add_counter(bat_priv, BATADV_CNT_FORWARD_BYTES,
- skb->len + ETH_HLEN);
+ len + ETH_HLEN);
ret = NET_RX_SUCCESS;
} else if (res == NET_XMIT_POLICED) {

View file

@ -0,0 +1,40 @@
From: Simon Wunderlich <sw@simonwunderlich.de>
Date: Thu, 12 May 2016 18:52:03 +0200
Subject: [PATCH] batman-adv: replace WARN with rate limited output on non-existing VLAN
If a VLAN tagged frame is received and the corresponding VLAN is not
configured on the soft interface, it will splat a WARN on every packet
received. This is a quite annoying behaviour for some scenarios, e.g. if
bat0 is bridged with eth0, and there are arbitrary VLAN tagged frames
from Ethernet coming in without having any VLAN configuration on bat0.
The code should probably create vlan objects on the fly and
transparently transport these VLAN-tagged Ethernet frames, but until
this is done, at least the WARN splat should be replaced by a rate
limited output.
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/04792115d24408a72bf8fccd5c4059478fc15eae
---
net/batman-adv/translation-table.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 9b4551a..48adb91 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -650,8 +650,10 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,
/* increase the refcounter of the related vlan */
vlan = batadv_softif_vlan_get(bat_priv, vid);
- if (WARN(!vlan, "adding TT local entry %pM to non-existent VLAN %d",
- addr, BATADV_PRINT_VID(vid))) {
+ if (!vlan) {
+ net_ratelimited_function(batadv_info, soft_iface,
+ "adding TT local entry %pM to non-existent VLAN %d\n",
+ addr, BATADV_PRINT_VID(vid));
kfree(tt_local);
tt_local = NULL;
goto out;

View file

@ -0,0 +1,58 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Sat, 28 May 2016 10:32:48 +0200
Subject: [PATCH] batman-adv: Fix build against recent Debian Stretch kernels
The kernels for Debian stretch require some special CFLAGS settings which
are only correctly defined when NOSTDINC_FLAGS is defined inside the
execution of the Makefile via kbuild. But batman-adv sets it currently
outside to insert compatibility include headers and compat-sources.
This can be avoided by making the top Makefile kbuild compatible and
redefining the NOSTDINC_FLAGS when kbuild include this Makefile. The actual
build of the batman-adv module is then done by adding the subdirectory to
obj-y.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Tested-by: Martin Weinelt <martin@darmstadt.freifunk.net>
Origin: https://git.open-mesh.org/batman-adv.git/commit/f8fd441e1e30f3a274c9bf44cc33372d4065cbb6
---
Makefile | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index 5d2c058..2568fb2 100644
--- a/Makefile
+++ b/Makefile
@@ -43,7 +43,7 @@ RM ?= rm -f
REVISION= $(shell if [ -d "$(PWD)/.git" ]; then \
echo $$(git --git-dir="$(PWD)/.git" describe --always --dirty --match "v*" |sed 's/^v//' 2> /dev/null || echo "[unknown]"); \
fi)
-export NOSTDINC_FLAGS := \
+NOSTDINC_FLAGS += \
-I$(PWD)/compat-include/ \
-include $(PWD)/compat.h \
$(CFLAGS)
@@ -52,8 +52,12 @@ ifneq ($(REVISION),)
NOSTDINC_FLAGS += -DBATADV_SOURCE_VERSION=\"$(REVISION)\"
endif
+obj-y += net/batman-adv/
+
BUILD_FLAGS := \
- M=$(PWD)/net/batman-adv \
+ M=$(PWD) \
+ PWD=$(PWD) \
+ REVISION=$(REVISION) \
CONFIG_BATMAN_ADV=m \
CONFIG_BATMAN_ADV_DEBUG=$(CONFIG_BATMAN_ADV_DEBUG) \
CONFIG_BATMAN_ADV_BLA=$(CONFIG_BATMAN_ADV_BLA) \
@@ -61,7 +65,7 @@ BUILD_FLAGS := \
CONFIG_BATMAN_ADV_NC=$(CONFIG_BATMAN_ADV_NC) \
CONFIG_BATMAN_ADV_MCAST=$(CONFIG_BATMAN_ADV_MCAST) \
CONFIG_BATMAN_ADV_BATMAN_V=$(CONFIG_BATMAN_ADV_BATMAN_V) \
- INSTALL_MOD_DIR=updates/net/batman-adv/
+ INSTALL_MOD_DIR=updates/
all: config
$(MAKE) -C $(KERNELPATH) $(BUILD_FLAGS) modules

View file

@ -0,0 +1,45 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Sat, 28 May 2016 14:38:26 +0200
Subject: [PATCH] batman-adv: Clean up untagged vlan when destroying via rtnl-link
The untagged vlan object is only destroyed when the interface is removed
via the legacy sysfs interface. But it also has to be destroyed when the
standard rtnl-link interface is used.
Fixes: 952cebb57518 ("batman-adv: add per VLAN interface attribute framework")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Cc: Antonio Quartulli <a@unstable.cc>
Origin: https://git.open-mesh.org/batman-adv.git/commit/e721749d57ff57d6df4017d62797626eab9902f1
---
net/batman-adv/soft-interface.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 8a136b6..3710620 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -1017,7 +1017,9 @@ void batadv_softif_destroy_sysfs(struct net_device *soft_iface)
static void batadv_softif_destroy_netlink(struct net_device *soft_iface,
struct list_head *head)
{
+ struct batadv_priv *bat_priv = netdev_priv(soft_iface);
struct batadv_hard_iface *hard_iface;
+ struct batadv_softif_vlan *vlan;
list_for_each_entry(hard_iface, &batadv_hardif_list, list) {
if (hard_iface->soft_iface == soft_iface)
@@ -1025,6 +1027,13 @@ static void batadv_softif_destroy_netlink(struct net_device *soft_iface,
BATADV_IF_CLEANUP_KEEP);
}
+ /* destroy the "untagged" VLAN */
+ vlan = batadv_softif_vlan_get(bat_priv, BATADV_NO_FLAGS);
+ if (vlan) {
+ batadv_softif_destroy_vlan(bat_priv, vlan);
+ batadv_softif_vlan_put(vlan);
+ }
+
batadv_sysfs_del_meshif(soft_iface);
unregister_netdevice_queue(soft_iface, head);
}

View file

@ -0,0 +1,31 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Sun, 29 May 2016 21:25:52 +0200
Subject: [PATCH] batman-adv: Fix ICMP RR ethernet access after skb_linearize
The skb_linearize may reallocate the skb. This makes the calculated pointer
for ethhdr invalid. But it the pointer is used later to fill in the RR
field of the batadv_icmp_packet_rr packet.
Instead re-evaluate eth_hdr after the skb_linearize+skb_cow to fix the
pointer and avoid the invalid read.
Fixes: bb69cb678d37 ("batman-adv: generalize batman-adv icmp packet handling")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/f6c80c29ef4e8b45b715976107b7ae06fc0be3a0
---
net/batman-adv/routing.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 0c0c30e..27e07dd 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -374,6 +374,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb,
if (skb_cow(skb, ETH_HLEN) < 0)
goto out;
+ ethhdr = eth_hdr(skb);
icmph = (struct batadv_icmp_header *)skb->data;
icmp_packet_rr = (struct batadv_icmp_packet_rr *)icmph;
if (icmp_packet_rr->rr_cur >= BATADV_RR_LEN)

View file

@ -0,0 +1,32 @@
From: Ben Hutchings <ben@decadent.org.uk>
Date: Fri, 3 Jun 2016 00:00:44 +0100
Subject: [PATCH] batman-adv: Fix double-put of vlan object
Commit a33d970d0b54 "batman-adv: Fix reference counting of vlan object
for tt_local_entry") makes each batadv_tt_local_entry hold a single
reference to a batadv_softif_vlan. In case a new entry cannot be
added to the hash table, the error path puts the reference, but the
reference will also now be dropped by batadv_tt_local_entry_release().
Fixes: a33d970d0b54 ("batman-adv: Fix reference counting of vlan object ...")
Cc: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Acked-by: Sven Eckelmann <sven@narfation.org>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/22bb8b894900064d3fb09032a47577e89fc30d7c
---
net/batman-adv/translation-table.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 48adb91..5ed782b 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -693,7 +693,6 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,
if (unlikely(hash_added != 0)) {
/* remove the reference for the hash */
batadv_tt_local_entry_put(tt_local);
- batadv_softif_vlan_put(vlan);
goto out;
}

View file

@ -0,0 +1,172 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Sat, 4 Jun 2016 08:52:12 +0200
Subject: [PATCH] batman-adv: Fix use-after-free/double-free of tt_req_node
The tt_req_node is added and removed from a list inside a spinlock. But the
locking is sometimes removed even when the object is still referenced and
will be used later via this reference. For example batadv_send_tt_request
can create a new tt_req_node (including add to a list) and later
re-acquires the lock to remove it from the list and to free it. But at this
time another context could have already removed this tt_req_node from the
list and freed it.
CPU#0
batadv_batman_skb_recv from net_device 0
-> batadv_iv_ogm_receive
-> batadv_iv_ogm_process
-> batadv_iv_ogm_process_per_outif
-> batadv_tvlv_ogm_receive
-> batadv_tvlv_ogm_receive
-> batadv_tvlv_containers_process
-> batadv_tvlv_call_handler
-> batadv_tt_tvlv_ogm_handler_v1
-> batadv_tt_update_orig
-> batadv_send_tt_request
-> batadv_tt_req_node_new
spin_lock(...)
allocates new tt_req_node and adds it to list
spin_unlock(...)
return tt_req_node
CPU#1
batadv_batman_skb_recv from net_device 1
-> batadv_recv_unicast_tvlv
-> batadv_tvlv_containers_process
-> batadv_tvlv_call_handler
-> batadv_tt_tvlv_unicast_handler_v1
-> batadv_handle_tt_response
spin_lock(...)
tt_req_node gets removed from list and is freed
spin_unlock(...)
CPU#0
<- returned to batadv_send_tt_request
spin_lock(...)
tt_req_node gets removed from list and is freed
MEMORY CORRUPTION/SEGFAULT/...
spin_unlock(...)
This can only be solved via reference counting to allow multiple contexts
to handle the list manipulation while making sure that only the last
context holding a reference will free the object.
Fixes: cea194d90b11 ("batman-adv: improved client announcement mechanism")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Tested-by: Martin Weinelt <martin@darmstadt.freifunk.net>
Tested-by: Amadeus Alfa <amadeus@chemnitz.freifunk.net>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/c3fef3d9ec6e8b882f321ec20f6f2cb2ee906503
---
net/batman-adv/translation-table.c | 37 +++++++++++++++++++++++++++++++++----
net/batman-adv/types.h | 2 ++
2 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 5ed782b..23fb7ea 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -2271,6 +2271,29 @@ static u32 batadv_tt_local_crc(struct batadv_priv *bat_priv,
return crc;
}
+/**
+ * batadv_tt_req_node_release - free tt_req node entry
+ * @ref: kref pointer of the tt req_node entry
+ */
+static void batadv_tt_req_node_release(struct kref *ref)
+{
+ struct batadv_tt_req_node *tt_req_node;
+
+ tt_req_node = container_of(ref, struct batadv_tt_req_node, refcount);
+
+ kfree(tt_req_node);
+}
+
+/**
+ * batadv_tt_req_node_put - decrement the tt_req_node refcounter and
+ * possibly release it
+ * @tt_req_node: tt_req_node to be free'd
+ */
+static void batadv_tt_req_node_put(struct batadv_tt_req_node *tt_req_node)
+{
+ kref_put(&tt_req_node->refcount, batadv_tt_req_node_release);
+}
+
static void batadv_tt_req_list_free(struct batadv_priv *bat_priv)
{
struct batadv_tt_req_node *node;
@@ -2280,7 +2303,7 @@ static void batadv_tt_req_list_free(struct batadv_priv *bat_priv)
hlist_for_each_entry_safe(node, safe, &bat_priv->tt.req_list, list) {
hlist_del_init(&node->list);
- kfree(node);
+ batadv_tt_req_node_put(node);
}
spin_unlock_bh(&bat_priv->tt.req_list_lock);
@@ -2317,7 +2340,7 @@ static void batadv_tt_req_purge(struct batadv_priv *bat_priv)
if (batadv_has_timed_out(node->issued_at,
BATADV_TT_REQUEST_TIMEOUT)) {
hlist_del_init(&node->list);
- kfree(node);
+ batadv_tt_req_node_put(node);
}
}
spin_unlock_bh(&bat_priv->tt.req_list_lock);
@@ -2349,9 +2372,11 @@ batadv_tt_req_node_new(struct batadv_priv *bat_priv,
if (!tt_req_node)
goto unlock;
+ kref_init(&tt_req_node->refcount);
ether_addr_copy(tt_req_node->addr, orig_node->orig);
tt_req_node->issued_at = jiffies;
+ kref_get(&tt_req_node->refcount);
hlist_add_head(&tt_req_node->list, &bat_priv->tt.req_list);
unlock:
spin_unlock_bh(&bat_priv->tt.req_list_lock);
@@ -2618,9 +2643,13 @@ out:
spin_lock_bh(&bat_priv->tt.req_list_lock);
/* hlist_del_init() verifies tt_req_node still is in the list */
hlist_del_init(&tt_req_node->list);
+ batadv_tt_req_node_put(tt_req_node);
spin_unlock_bh(&bat_priv->tt.req_list_lock);
- kfree(tt_req_node);
}
+
+ if (tt_req_node)
+ batadv_tt_req_node_put(tt_req_node);
+
kfree(tvlv_tt_data);
return ret;
}
@@ -3056,7 +3085,7 @@ static void batadv_handle_tt_response(struct batadv_priv *bat_priv,
if (!batadv_compare_eth(node->addr, resp_src))
continue;
hlist_del_init(&node->list);
- kfree(node);
+ batadv_tt_req_node_put(node);
}
spin_unlock_bh(&bat_priv->tt.req_list_lock);
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 1e47fbe..d75beef 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -1129,11 +1129,13 @@ struct batadv_tt_change_node {
* struct batadv_tt_req_node - data to keep track of the tt requests in flight
* @addr: mac address address of the originator this request was sent to
* @issued_at: timestamp used for purging stale tt requests
+ * @refcount: number of contexts the object is used by
* @list: list node for batadv_priv_tt::req_list
*/
struct batadv_tt_req_node {
u8 addr[ETH_ALEN];
unsigned long issued_at;
+ struct kref refcount;
struct hlist_node list;
};

View file

@ -0,0 +1,35 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Sat, 2 Jul 2016 09:52:13 +0200
Subject: [PATCH] batman-adv: Avoid nullptr dereference in bla after vlan_insert_tag
vlan_insert_tag can return NULL on errors. The bridge loop avoidance code
therefore has to check the return value of vlan_insert_tag for NULL before
it can safely operate on this pointer.
Fixes: a9ce0dc43e2c ("batman-adv: add basic bridge loop avoidance code")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/e4cffba4d3353ea15287abbfbdd65208aa62c156
---
net/batman-adv/bridge_loop_avoidance.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index 0a6c8b8..fe8b62f 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -409,9 +409,12 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, u8 *mac,
break;
}
- if (vid & BATADV_VLAN_HAS_TAG)
+ if (vid & BATADV_VLAN_HAS_TAG) {
skb = vlan_insert_tag(skb, htons(ETH_P_8021Q),
vid & VLAN_VID_MASK);
+ if (!skb)
+ goto out;
+ }
skb_reset_mac_header(skb);
skb->protocol = eth_type_trans(skb, soft_iface);

View file

@ -0,0 +1,49 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Sat, 2 Jul 2016 09:52:14 +0200
Subject: [PATCH] batman-adv: Avoid nullptr dereference in dat after vlan_insert_tag
vlan_insert_tag can return NULL on errors. The distributed arp table code
therefore has to check the return value of vlan_insert_tag for NULL before
it can safely operate on this pointer.
Fixes: 53c6c262a581 ("batman-adv: tag locally generated ARP reply if needed")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/898382d11fa1f737cd4f7033db1088c601fd11ed
---
net/batman-adv/distributed-arp-table.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
index 3e6b262..5a89be0 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -1009,9 +1009,12 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
if (!skb_new)
goto out;
- if (vid & BATADV_VLAN_HAS_TAG)
+ if (vid & BATADV_VLAN_HAS_TAG) {
skb_new = vlan_insert_tag(skb_new, htons(ETH_P_8021Q),
vid & VLAN_VID_MASK);
+ if (!skb_new)
+ goto out;
+ }
skb_reset_mac_header(skb_new);
skb_new->protocol = eth_type_trans(skb_new,
@@ -1089,9 +1092,12 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
*/
skb_reset_mac_header(skb_new);
- if (vid & BATADV_VLAN_HAS_TAG)
+ if (vid & BATADV_VLAN_HAS_TAG) {
skb_new = vlan_insert_tag(skb_new, htons(ETH_P_8021Q),
vid & VLAN_VID_MASK);
+ if (!skb_new)
+ goto out;
+ }
/* To preserve backwards compatibility, the node has choose the outgoing
* format based on the incoming request packet type. The assumption is

View file

@ -0,0 +1,41 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Fri, 24 Jun 2016 21:43:32 +0200
Subject: [PATCH] batman-adv: Avoid tt_req_node list put for unhashed entry
It can happen that a tt_req_node list entry was already removed from
tt.req_list when batadv_send_tt_request reaches the end of the function.
The reference counter was already reduced by 1 for the list entry and thus
the reference counter is not allowed to be reduced again. Otherwise, the
entry is freed too early and the next batadv_tt_req_node_put in this
function will operate on freed memory.
Fixes: cea194d90b11 ("batman-adv: improved client announcement mechanism")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/03ecc9f957b837c755f09251c5f684996521e487
---
net/batman-adv/translation-table.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 23fb7ea..f7d44c6 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -2639,11 +2639,13 @@ static int batadv_send_tt_request(struct batadv_priv *bat_priv,
out:
if (primary_if)
batadv_hardif_put(primary_if);
+
if (ret && tt_req_node) {
spin_lock_bh(&bat_priv->tt.req_list_lock);
- /* hlist_del_init() verifies tt_req_node still is in the list */
- hlist_del_init(&tt_req_node->list);
- batadv_tt_req_node_put(tt_req_node);
+ if (!hlist_unhashed(&tt_req_node->list)) {
+ hlist_del_init(&tt_req_node->list);
+ batadv_tt_req_node_put(tt_req_node);
+ }
spin_unlock_bh(&bat_priv->tt.req_list_lock);
}

View file

@ -0,0 +1,43 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Thu, 30 Jun 2016 20:10:46 +0200
Subject: [PATCH] batman-adv: Fix orig_node_vlan leak on orig_node_release
batadv_orig_node_new uses batadv_orig_node_vlan_new to allocate a new
batadv_orig_node_vlan and add it to batadv_orig_node::vlan_list. References
to this list have also to be cleaned when the batadv_orig_node is removed.
Fixes: 21a57f6e7a3b ("batman-adv: make the TT CRC logic VLAN specific")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/719afd254e812c7ff8688ce79bebb7324ec438d6
---
net/batman-adv/originator.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 28241a4..3a3948a 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -781,6 +781,7 @@ static void batadv_orig_node_release(struct kref *ref)
struct batadv_neigh_node *neigh_node;
struct batadv_orig_node *orig_node;
struct batadv_orig_ifinfo *orig_ifinfo;
+ struct batadv_orig_node_vlan *vlan;
orig_node = container_of(ref, struct batadv_orig_node, refcount);
@@ -800,6 +801,13 @@ static void batadv_orig_node_release(struct kref *ref)
}
spin_unlock_bh(&orig_node->neigh_list_lock);
+ spin_lock_bh(&orig_node->vlan_list_lock);
+ hlist_for_each_entry_safe(vlan, node_tmp, &orig_node->vlan_list, list) {
+ hlist_del_rcu(&vlan->list);
+ batadv_orig_node_vlan_put(vlan);
+ }
+ spin_unlock_bh(&orig_node->vlan_list_lock);
+
/* Free nc_nodes */
batadv_nc_purge_orig(orig_node->bat_priv, orig_node, NULL);

View file

@ -0,0 +1,291 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Fri, 1 Jul 2016 15:49:43 +0200
Subject: [PATCH] batman-adv: Fix non-atomic bla_claim::backbone_gw access
The pointer batadv_bla_claim::backbone_gw can be changed at any time.
Therefore, access to it must be protected to ensure that two function
accessing the same backbone_gw are actually accessing the same. This is
especially important when the crc_lock is used or when the backbone_gw of a
claim is exchanged.
Not doing so leads to invalid memory access and/or reference leaks.
Fixes: a9ce0dc43e2c ("batman-adv: add basic bridge loop avoidance code")
Fixes: b307e72d119f ("batman-adv: lock crc access in bridge loop avoidance")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Acked-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Origin: backport, https://git.open-mesh.org/batman-adv.git/commit/e401297e3a393896e9b07bef8d6e2df203b60d43
---
net/batman-adv/bridge_loop_avoidance.c | 111 ++++++++++++++++++++++++++-------
net/batman-adv/types.h | 2 +
2 files changed, 90 insertions(+), 23 deletions(-)
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index fe8b62f..30fd72e 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -176,10 +176,21 @@ static void batadv_backbone_gw_put(struct batadv_bla_backbone_gw *backbone_gw)
static void batadv_claim_release(struct kref *ref)
{
struct batadv_bla_claim *claim;
+ struct batadv_bla_backbone_gw *old_backbone_gw;
claim = container_of(ref, struct batadv_bla_claim, refcount);
- batadv_backbone_gw_put(claim->backbone_gw);
+ spin_lock_bh(&claim->backbone_lock);
+ old_backbone_gw = claim->backbone_gw;
+ claim->backbone_gw = NULL;
+ spin_unlock_bh(&claim->backbone_lock);
+
+ spin_lock_bh(&old_backbone_gw->crc_lock);
+ old_backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
+ spin_unlock_bh(&old_backbone_gw->crc_lock);
+
+ batadv_backbone_gw_put(old_backbone_gw);
+
kfree_rcu(claim, rcu);
}
@@ -637,8 +648,10 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
const u8 *mac, const unsigned short vid,
struct batadv_bla_backbone_gw *backbone_gw)
{
+ struct batadv_bla_backbone_gw *old_backbone_gw;
struct batadv_bla_claim *claim;
struct batadv_bla_claim search_claim;
+ bool remove_crc = false;
int hash_added;
ether_addr_copy(search_claim.addr, mac);
@@ -652,8 +665,10 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
return;
ether_addr_copy(claim->addr, mac);
+ spin_lock_init(&claim->backbone_lock);
claim->vid = vid;
claim->lasttime = jiffies;
+ kref_get(&backbone_gw->refcount);
claim->backbone_gw = backbone_gw;
kref_init(&claim->refcount);
@@ -681,15 +696,26 @@ static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
"bla_add_claim(): changing ownership for %pM, vid %d\n",
mac, BATADV_PRINT_VID(vid));
- spin_lock_bh(&claim->backbone_gw->crc_lock);
- claim->backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
- spin_unlock_bh(&claim->backbone_gw->crc_lock);
- batadv_backbone_gw_put(claim->backbone_gw);
+ remove_crc = true;
}
- /* set (new) backbone gw */
+
+ /* replace backbone_gw atomically and adjust reference counters */
+ spin_lock_bh(&claim->backbone_lock);
+ old_backbone_gw = claim->backbone_gw;
kref_get(&backbone_gw->refcount);
claim->backbone_gw = backbone_gw;
+ spin_unlock_bh(&claim->backbone_lock);
+ if (remove_crc) {
+ /* remove claim address from old backbone_gw */
+ spin_lock_bh(&old_backbone_gw->crc_lock);
+ old_backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
+ spin_unlock_bh(&old_backbone_gw->crc_lock);
+ }
+
+ batadv_backbone_gw_put(old_backbone_gw);
+
+ /* add claim address to new backbone_gw */
spin_lock_bh(&backbone_gw->crc_lock);
backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
spin_unlock_bh(&backbone_gw->crc_lock);
@@ -700,6 +726,26 @@ claim_free_ref:
}
/**
+ * batadv_bla_claim_get_backbone_gw - Get valid reference for backbone_gw of
+ * claim
+ * @claim: claim whose backbone_gw should be returned
+ *
+ * Return: valid reference to claim::backbone_gw
+ */
+static struct batadv_bla_backbone_gw *
+batadv_bla_claim_get_backbone_gw(struct batadv_bla_claim *claim)
+{
+ struct batadv_bla_backbone_gw *backbone_gw;
+
+ spin_lock_bh(&claim->backbone_lock);
+ backbone_gw = claim->backbone_gw;
+ kref_get(&backbone_gw->refcount);
+ spin_unlock_bh(&claim->backbone_lock);
+
+ return backbone_gw;
+}
+
+/**
* batadv_bla_del_claim - delete a claim from the claim hash
* @bat_priv: the bat priv with all the soft interface information
* @mac: mac address of the claim to be removed
@@ -723,10 +769,6 @@ static void batadv_bla_del_claim(struct batadv_priv *bat_priv,
batadv_choose_claim, claim);
batadv_claim_put(claim); /* reference from the hash is gone */
- spin_lock_bh(&claim->backbone_gw->crc_lock);
- claim->backbone_gw->crc ^= crc16(0, claim->addr, ETH_ALEN);
- spin_unlock_bh(&claim->backbone_gw->crc_lock);
-
/* don't need the reference from hash_find() anymore */
batadv_claim_put(claim);
}
@@ -1175,6 +1217,7 @@ static void batadv_bla_purge_claims(struct batadv_priv *bat_priv,
struct batadv_hard_iface *primary_if,
int now)
{
+ struct batadv_bla_backbone_gw *backbone_gw;
struct batadv_bla_claim *claim;
struct hlist_head *head;
struct batadv_hashtable *hash;
@@ -1189,14 +1232,17 @@ static void batadv_bla_purge_claims(struct batadv_priv *bat_priv,
rcu_read_lock();
hlist_for_each_entry_rcu(claim, head, hash_entry) {
+ backbone_gw = batadv_bla_claim_get_backbone_gw(claim);
if (now)
goto purge_now;
- if (!batadv_compare_eth(claim->backbone_gw->orig,
+
+ if (!batadv_compare_eth(backbone_gw->orig,
primary_if->net_dev->dev_addr))
- continue;
+ goto skip;
+
if (!batadv_has_timed_out(claim->lasttime,
BATADV_BLA_CLAIM_TIMEOUT))
- continue;
+ goto skip;
batadv_dbg(BATADV_DBG_BLA, bat_priv,
"bla_purge_claims(): %pM, vid %d, time out\n",
@@ -1204,8 +1250,10 @@ static void batadv_bla_purge_claims(struct batadv_priv *bat_priv,
purge_now:
batadv_handle_unclaim(bat_priv, primary_if,
- claim->backbone_gw->orig,
+ backbone_gw->orig,
claim->addr, claim->vid);
+skip:
+ batadv_backbone_gw_put(backbone_gw);
}
rcu_read_unlock();
}
@@ -1623,9 +1671,11 @@ void batadv_bla_free(struct batadv_priv *bat_priv)
int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
unsigned short vid, bool is_bcast)
{
+ struct batadv_bla_backbone_gw *backbone_gw;
struct ethhdr *ethhdr;
struct batadv_bla_claim search_claim, *claim = NULL;
struct batadv_hard_iface *primary_if;
+ bool own_claim;
int ret;
ethhdr = eth_hdr(skb);
@@ -1657,8 +1707,12 @@ int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
}
/* if it is our own claim ... */
- if (batadv_compare_eth(claim->backbone_gw->orig,
- primary_if->net_dev->dev_addr)) {
+ backbone_gw = batadv_bla_claim_get_backbone_gw(claim);
+ own_claim = batadv_compare_eth(backbone_gw->orig,
+ primary_if->net_dev->dev_addr);
+ batadv_backbone_gw_put(backbone_gw);
+
+ if (own_claim) {
/* ... allow it in any case */
claim->lasttime = jiffies;
goto allow;
@@ -1722,7 +1776,9 @@ int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
{
struct ethhdr *ethhdr;
struct batadv_bla_claim search_claim, *claim = NULL;
+ struct batadv_bla_backbone_gw *backbone_gw;
struct batadv_hard_iface *primary_if;
+ bool client_roamed;
int ret = 0;
primary_if = batadv_primary_if_get_selected(bat_priv);
@@ -1752,8 +1808,12 @@ int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
goto allow;
/* check if we are responsible. */
- if (batadv_compare_eth(claim->backbone_gw->orig,
- primary_if->net_dev->dev_addr)) {
+ backbone_gw = batadv_bla_claim_get_backbone_gw(claim);
+ client_roamed = batadv_compare_eth(backbone_gw->orig,
+ primary_if->net_dev->dev_addr);
+ batadv_backbone_gw_put(backbone_gw);
+
+ if (client_roamed) {
/* if yes, the client has roamed and we have
* to unclaim it.
*/
@@ -1801,6 +1861,7 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
struct net_device *net_dev = (struct net_device *)seq->private;
struct batadv_priv *bat_priv = netdev_priv(net_dev);
struct batadv_hashtable *hash = bat_priv->bla.claim_hash;
+ struct batadv_bla_backbone_gw *backbone_gw;
struct batadv_bla_claim *claim;
struct batadv_hard_iface *primary_if;
struct hlist_head *head;
@@ -1825,17 +1886,21 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
rcu_read_lock();
hlist_for_each_entry_rcu(claim, head, hash_entry) {
- is_own = batadv_compare_eth(claim->backbone_gw->orig,
+ backbone_gw = batadv_bla_claim_get_backbone_gw(claim);
+
+ is_own = batadv_compare_eth(backbone_gw->orig,
primary_addr);
- spin_lock_bh(&claim->backbone_gw->crc_lock);
- backbone_crc = claim->backbone_gw->crc;
- spin_unlock_bh(&claim->backbone_gw->crc_lock);
+ spin_lock_bh(&backbone_gw->crc_lock);
+ backbone_crc = backbone_gw->crc;
+ spin_unlock_bh(&backbone_gw->crc_lock);
seq_printf(seq, " * %pM on %5d by %pM [%c] (%#.4x)\n",
claim->addr, BATADV_PRINT_VID(claim->vid),
- claim->backbone_gw->orig,
+ backbone_gw->orig,
(is_own ? 'x' : ' '),
backbone_crc);
+
+ batadv_backbone_gw_put(backbone_gw);
}
rcu_read_unlock();
}
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index d75beef..41a85b5 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -1034,6 +1034,7 @@ struct batadv_bla_backbone_gw {
* @addr: mac address of claimed non-mesh client
* @vid: vlan id this client was detected on
* @backbone_gw: pointer to backbone gw claiming this client
+ * @backbone_lock: lock protecting backbone_gw pointer
* @lasttime: last time we heard of claim (locals only)
* @hash_entry: hlist node for batadv_priv_bla::claim_hash
* @refcount: number of contexts the object is used
@@ -1043,6 +1044,7 @@ struct batadv_bla_claim {
u8 addr[ETH_ALEN];
unsigned short vid;
struct batadv_bla_backbone_gw *backbone_gw;
+ spinlock_t backbone_lock; /* protects backbone_gw */
unsigned long lasttime;
struct hlist_node hash_entry;
struct rcu_head rcu;

View file

@ -0,0 +1,120 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Thu, 30 Jun 2016 20:11:34 +0200
Subject: [PATCH] batman-adv: Fix reference leak in batadv_find_router
The replacement of last_bonding_candidate in batadv_orig_node has to be an
atomic operation. Otherwise it is possible that the reference counter of a
batadv_orig_ifinfo is reduced which was no longer the
last_bonding_candidate when the new candidate is added. This can either
lead to an invalid memory access or to reference leaks which make it
impossible to an interface which was added to batman-adv.
Fixes: 797edd9e87ac ("batman-adv: add bonding again")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Acked-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/6ecc711374afd93ee0c2216b38ae52d3ce680c3f
---
net/batman-adv/routing.c | 52 ++++++++++++++++++++++++++++++++++++------------
net/batman-adv/types.h | 4 +++-
2 files changed, 42 insertions(+), 14 deletions(-)
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 27e07dd..694dc74 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -456,6 +456,29 @@ static int batadv_check_unicast_packet(struct batadv_priv *bat_priv,
}
/**
+ * batadv_last_bonding_replace - Replace last_bonding_candidate of orig_node
+ * @orig_node: originator node whose bonding candidates should be replaced
+ * @new_candidate: new bonding candidate or NULL
+ */
+static void
+batadv_last_bonding_replace(struct batadv_orig_node *orig_node,
+ struct batadv_orig_ifinfo *new_candidate)
+{
+ struct batadv_orig_ifinfo *old_candidate;
+
+ spin_lock_bh(&orig_node->neigh_list_lock);
+ old_candidate = orig_node->last_bonding_candidate;
+
+ if (new_candidate)
+ kref_get(&new_candidate->refcount);
+ orig_node->last_bonding_candidate = new_candidate;
+ spin_unlock_bh(&orig_node->neigh_list_lock);
+
+ if (old_candidate)
+ batadv_orig_ifinfo_put(old_candidate);
+}
+
+/**
* batadv_find_router - find a suitable router for this originator
* @bat_priv: the bat priv with all the soft interface information
* @orig_node: the destination node
@@ -562,10 +585,6 @@ next:
}
rcu_read_unlock();
- /* last_bonding_candidate is reset below, remove the old reference. */
- if (orig_node->last_bonding_candidate)
- batadv_orig_ifinfo_put(orig_node->last_bonding_candidate);
-
/* After finding candidates, handle the three cases:
* 1) there is a next candidate, use that
* 2) there is no next candidate, use the first of the list
@@ -574,21 +593,28 @@ next:
if (next_candidate) {
batadv_neigh_node_put(router);
- /* remove references to first candidate, we don't need it. */
- if (first_candidate) {
- batadv_neigh_node_put(first_candidate_router);
- batadv_orig_ifinfo_put(first_candidate);
- }
+ kref_get(&next_candidate_router->refcount);
router = next_candidate_router;
- orig_node->last_bonding_candidate = next_candidate;
+ batadv_last_bonding_replace(orig_node, next_candidate);
} else if (first_candidate) {
batadv_neigh_node_put(router);
- /* refcounting has already been done in the loop above. */
+ kref_get(&first_candidate_router->refcount);
router = first_candidate_router;
- orig_node->last_bonding_candidate = first_candidate;
+ batadv_last_bonding_replace(orig_node, first_candidate);
} else {
- orig_node->last_bonding_candidate = NULL;
+ batadv_last_bonding_replace(orig_node, NULL);
+ }
+
+ /* cleanup of candidates */
+ if (first_candidate) {
+ batadv_neigh_node_put(first_candidate_router);
+ batadv_orig_ifinfo_put(first_candidate);
+ }
+
+ if (next_candidate) {
+ batadv_neigh_node_put(next_candidate_router);
+ batadv_orig_ifinfo_put(next_candidate);
}
return router;
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 41a85b5..c143649 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -330,7 +330,9 @@ struct batadv_orig_node {
DECLARE_BITMAP(bcast_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
u32 last_bcast_seqno;
struct hlist_head neigh_list;
- /* neigh_list_lock protects: neigh_list and router */
+ /* neigh_list_lock protects: neigh_list, ifinfo_list,
+ * last_bonding_candidate and router
+ */
spinlock_t neigh_list_lock;
struct hlist_node hash_entry;
struct batadv_priv *bat_priv;

View file

@ -0,0 +1,45 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Thu, 30 Jun 2016 21:41:13 +0200
Subject: [PATCH] batman-adv: Free last_bonding_candidate on release of orig_node
The orig_ifinfo reference counter for last_bonding_candidate in
batadv_orig_node has to be reduced when an originator node is released.
Otherwise the orig_ifinfo is leaked and the reference counter the netdevice
is not reduced correctly.
Fixes: 797edd9e87ac ("batman-adv: add bonding again")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/20df5c53865a90095099f0af80536b8abfea303b
---
net/batman-adv/originator.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 3a3948a..7594afd 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -782,6 +782,7 @@ static void batadv_orig_node_release(struct kref *ref)
struct batadv_orig_node *orig_node;
struct batadv_orig_ifinfo *orig_ifinfo;
struct batadv_orig_node_vlan *vlan;
+ struct batadv_orig_ifinfo *last_candidate;
orig_node = container_of(ref, struct batadv_orig_node, refcount);
@@ -799,8 +800,14 @@ static void batadv_orig_node_release(struct kref *ref)
hlist_del_rcu(&orig_ifinfo->list);
batadv_orig_ifinfo_put(orig_ifinfo);
}
+
+ last_candidate = orig_node->last_bonding_candidate;
+ orig_node->last_bonding_candidate = NULL;
spin_unlock_bh(&orig_node->neigh_list_lock);
+ if (last_candidate)
+ batadv_orig_ifinfo_put(last_candidate);
+
spin_lock_bh(&orig_node->vlan_list_lock);
hlist_for_each_entry_safe(vlan, node_tmp, &orig_node->vlan_list, list) {
hlist_del_rcu(&vlan->list);

View file

@ -0,0 +1,35 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Sun, 12 Jun 2016 10:43:19 +0200
Subject: [PATCH] batman-adv: Fix speedy join in gateway client mode
Speedy join only works when the received packet is either broadcast or an
4addr unicast packet. Thus packets converted from broadcast to unicast via
the gateway handling code have to be converted to 4addr packets to allow
the receiving gateway server to add the sender address as temporary entry
to the translation table.
Not doing it will make the batman-adv gateway server drop the DHCP response
in many situations because it doesn't yet have the TT entry for the
destination of the DHCP response.
Fixes: 9cbc67d9da47 ("batman-adv: change interface_rx to get orig node")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
net/batman-adv/send.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index 7641785..e5be212 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -423,8 +423,8 @@ int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb,
struct batadv_orig_node *orig_node;
orig_node = batadv_gw_get_selected_orig(bat_priv);
- return batadv_send_skb_unicast(bat_priv, skb, BATADV_UNICAST, 0,
- orig_node, vid);
+ return batadv_send_skb_unicast(bat_priv, skb, BATADV_UNICAST_4ADDR,
+ BATADV_P_DATA, orig_node, vid);
}
void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface)

View file

@ -1,121 +0,0 @@
/* Please avoid adding hacks here - instead add it to mac80211/backports.git */
#undef CONFIG_MODULE_STRIPPED
#include <linux/version.h> /* LINUX_VERSION_CODE */
#include <linux/types.h>
#if LINUX_VERSION_IS_LESS(6, 0, 0)
#define __vstring(item, fmt, ap) __dynamic_array(char, item, 256)
#define __assign_vstr(dst, fmt, va) \
WARN_ON_ONCE(vsnprintf(__get_dynamic_array(dst), 256, fmt, *va) >= 256)
#endif /* LINUX_VERSION_IS_LESS(6, 0, 0) */
#if LINUX_VERSION_IS_LESS(6, 2, 0)
#include <linux/random.h>
#define genl_split_ops genl_ops
static inline u32 batadv_get_random_u32_below(u32 ep_ro)
{
return prandom_u32_max(ep_ro);
}
#define get_random_u32_below batadv_get_random_u32_below
#endif /* LINUX_VERSION_IS_LESS(6, 2, 0) */
#if LINUX_VERSION_IS_LESS(6, 4, 0) && \
!(LINUX_VERSION_IS_GEQ(5, 10, 205) && LINUX_VERSION_IS_LESS(5, 11, 0)) && \
!(LINUX_VERSION_IS_GEQ(5, 15, 144) && LINUX_VERSION_IS_LESS(5, 16, 0)) && \
!(LINUX_VERSION_IS_GEQ(6, 1, 69) && LINUX_VERSION_IS_LESS(6, 2, 0))
#include <linux/if_vlan.h>
/* Prefer this version in TX path, instead of
* skb_reset_mac_header() + vlan_eth_hdr()
*/
static inline struct vlan_ethhdr *skb_vlan_eth_hdr(const struct sk_buff *skb)
{
return (struct vlan_ethhdr *)skb->data;
}
#endif /* LINUX_VERSION_IS_LESS(6, 4, 0) */
/* <DECLARE_EWMA> */
#include <linux/version.h>
#include_next <linux/average.h>
#include <linux/bug.h>
#ifdef DECLARE_EWMA
#undef DECLARE_EWMA
#endif /* DECLARE_EWMA */
/*
* Exponentially weighted moving average (EWMA)
*
* This implements a fixed-precision EWMA algorithm, with both the
* precision and fall-off coefficient determined at compile-time
* and built into the generated helper funtions.
*
* The first argument to the macro is the name that will be used
* for the struct and helper functions.
*
* The second argument, the precision, expresses how many bits are
* used for the fractional part of the fixed-precision values.
*
* The third argument, the weight reciprocal, determines how the
* new values will be weighed vs. the old state, new values will
* get weight 1/weight_rcp and old values 1-1/weight_rcp. Note
* that this parameter must be a power of two for efficiency.
*/
#define DECLARE_EWMA(name, _precision, _weight_rcp) \
struct ewma_##name { \
unsigned long internal; \
}; \
static inline void ewma_##name##_init(struct ewma_##name *e) \
{ \
BUILD_BUG_ON(!__builtin_constant_p(_precision)); \
BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \
/* \
* Even if you want to feed it just 0/1 you should have \
* some bits for the non-fractional part... \
*/ \
BUILD_BUG_ON((_precision) > 30); \
BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \
e->internal = 0; \
} \
static inline unsigned long \
ewma_##name##_read(struct ewma_##name *e) \
{ \
BUILD_BUG_ON(!__builtin_constant_p(_precision)); \
BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \
BUILD_BUG_ON((_precision) > 30); \
BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \
return e->internal >> (_precision); \
} \
static inline void ewma_##name##_add(struct ewma_##name *e, \
unsigned long val) \
{ \
unsigned long internal = READ_ONCE(e->internal); \
unsigned long weight_rcp = ilog2(_weight_rcp); \
unsigned long precision = _precision; \
\
BUILD_BUG_ON(!__builtin_constant_p(_precision)); \
BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \
BUILD_BUG_ON((_precision) > 30); \
BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \
\
WRITE_ONCE(e->internal, internal ? \
(((internal << weight_rcp) - internal) + \
(val << precision)) >> weight_rcp : \
(val << precision)); \
}
/* </DECLARE_EWMA> */

View file

@ -6,29 +6,35 @@
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=batmand
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://git.open-mesh.org/batmand.git
PKG_SOURCE_URL:=git://git.open-mesh.org/batmand.git
PKG_REV:=b67a7087b51d7a5e90d27ac39116d1f57257c86e
PKG_VERSION:=1440
PKG_RELEASE:=1
PKG_RELEASE:=0
PKG_LICENSE:=GPL-2.0
PKG_SOURCE_VERSION:=$(PKG_REV)
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
PKG_MIRROR_HASH:=ceb8e0e399f79b1b663594fcf9642e1efc40e696a7604daf709c77da9b6ec52f
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SOURCE_SUBDIR)
PKG_BUILD_PARALLEL:=1
PKG_EXTRA_CFLAGS=-DDEBUG_MALLOC -DMEMORY_USAGE -DPROFILE_DATA -DREVISION_VERSION=\"\ rv$(PKG_REV)\" -D_GNU_SOURCE
PKG_KMOD_BUILD_DIR:=$(PKG_BUILD_DIR)/linux/modules
include $(INCLUDE_DIR)/package.mk
define Package/batmand
define Package/batmand/Default
URL:=https://www.open-mesh.org/
MAINTAINER:=Corinna "Elektra" Aichele <onelektra@gmx.net>
endef
define Package/batmand
$(call Package/batmand/Default)
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
@ -40,16 +46,61 @@ define Package/batmand/description
B.A.T.M.A.N. layer 3 routing daemon
endef
MAKE_FLAGS += \
EXTRA_CFLAGS='-DDEBUG_MALLOC -DMEMORY_USAGE -DPROFILE_DATA -DREVISION_VERSION=\"\ rv$(PKG_REV)\" -D_GNU_SOURCE' \
define KernelPackage/batgat
$(call Package/batmand/Default)
SUBMENU:=Network Support
DEPENDS:=+batmand @BROKEN
TITLE:=B.A.T.M.A.N. gateway module
FILES:=$(PKG_KMOD_BUILD_DIR)/batgat.$(LINUX_KMOD_SUFFIX)
AUTOLOAD:=$(call AutoLoad,50,batgat)
endef
define KernelPackage/batgat/description
Kernel gateway module for B.A.T.M.A.N. for better tunnel performance
endef
MAKE_BATMAND_ARGS += \
EXTRA_CFLAGS='$(TARGET_CFLAGS) $(PKG_EXTRA_CFLAGS)' \
CCFLAGS="$(TARGET_CFLAGS)" \
OFLAGS="$(TARGET_CFLAGS)" \
REVISION="$(PKG_REV)" \
CC="$(TARGET_CC)" \
NODEBUG=1 \
UNAME="Linux" \
batmand
INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
STRIP="/bin/true" \
batmand install
MAKE_BATGAT_ARGS += \
CROSS_COMPILE="$(TARGET_CROSS)" \
ARCH="$(LINUX_KARCH)" \
PATH="$(TARGET_PATH)" \
SUBDIRS="$(PKG_KMOD_BUILD_DIR)" \
LINUX_VERSION="$(LINUX_VERSION)" \
REVISION="$(PKG_REV)" modules
define Build/Configure
endef
ifneq ($(DEVELOPER)$(CONFIG_PACKAGE_batmand),)
BUILD_BATMAND := $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_BATMAND_ARGS)
endif
ifneq ($(DEVELOPER)$(CONFIG_PACKAGE_kmod-batgat),)
BUILD_BATGAT := $(MAKE) -C "$(LINUX_DIR)" $(MAKE_BATGAT_ARGS)
endif
define Build/Compile
$(BUILD_BATMAND)
cp $(PKG_KMOD_BUILD_DIR)/Makefile.kbuild $(PKG_KMOD_BUILD_DIR)/Makefile
$(BUILD_BATGAT)
endef
define Package/batmand/install
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/batmand $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/batmand $(1)/usr/sbin/
$(INSTALL_BIN) ./files/etc/init.d/batmand $(1)/etc/init.d
$(INSTALL_DATA) ./files/etc/config/batmand $(1)/etc/config
endef
@ -59,3 +110,4 @@ define Package/batmand/conffiles
endef
$(eval $(call BuildPackage,batmand))
$(eval $(call KernelPackage,batgat))

View file

@ -9,3 +9,4 @@ config batmand general
option policy_routing_script
option disable_client_nat
option disable_aggregation

View file

@ -1,44 +1,27 @@
#!/bin/sh /etc/rc.common
START=90
USE_PROCD=1
batmand_start() {
local config="$1"
local batman_args
local interface
local hnas
local gateway_class
local originator_interval
local preferred_gateway
local routing_class
local visualisation_srv
local local policy_routing_script
local disable_client_nat
local disable_aggregation
[ "$config" = "general" ] || return 1
config_get interface "$config" interface
start () {
interface=$(uci get batmand.general.interface)
if [ "$interface" = "" ]; then
echo $1 Error, you must specify at least a network interface
return 1
exit
fi
config_get hnas "$config" hna
config_get gateway_class "$config" gateway_class
config_get originator_interval "$config" originator_interval
config_get preferred_gateway "$config" preferred_gateway
config_get routing_class "$config" routing_class
config_get visualisation_srv "$config" visualisation_srv
config_get policy_routing_script "$config" policy_routing_script
config_get disable_client_nat "$config" disable_client_nat
config_get disable_aggregation "$config" disable_aggregation
hnas=$(uci get batmand.general.hna)
gateway_class=$(uci get batmand.general.gateway_class)
originator_interval=$(uci get batmand.general.originator_interval)
preferred_gateway=$(uci get batmand.general.preferred_gateway)
routing_class=$(uci get batmand.general.routing_class)
visualisation_srv=$(uci get batmand.general.visualisation_srv)
policy_routing_script=$(uci get batmand.general.policy_routing_script)
disable_client_nat=$(uci get batmand.general.disable_client_nat)
disable_aggregation=$(uci get batmand.general.disable_aggregation)
batman_args=""
for hna in $hnas; do
batman_args=${batman_args}'-a '$hna' '
done
for hna in $hnas
do
batman_args=${batman_args}'-a '$hna' '
done
if [ $gateway_class ]; then
batman_args=${batman_args}'-g '$gateway_class' '
@ -72,20 +55,12 @@ batmand_start() {
batman_args=${batman_args}'--disable-aggregation '
fi
procd_open_instance "${config}"
procd_set_param command /usr/sbin/batmand
procd_append_param command --no-detach
procd_append_param command ${batman_args}
procd_append_param command ${interface}
procd_set_param netdev ${interface}
procd_close_instance
batman_args=${batman_args}$interface
batmand $batman_args >/dev/null 2>&1
}
start_service() {
config_load "batmand"
config_foreach batmand_start batmand
stop () {
killall batmand
}
service_triggers() {
procd_add_reload_trigger "batmand"
}

View file

@ -1,66 +0,0 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Sun, 1 Dec 2013 14:39:00 +0100
Subject: Allow one to disable forking to background in debug_mode 0
---
posix/init.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
--- a/posix/init.c
+++ b/posix/init.c
@@ -44,6 +44,7 @@
#define IOCSETDEV 1
int8_t stop;
+int no_detach = 0;
@@ -159,6 +160,7 @@ void apply_init_args( int argc, char *ar
{"purge-timeout", required_argument, 0, 'q'},
{"disable-aggregation", no_argument, 0, 'x'},
{"disable-client-nat", no_argument, 0, 'z'},
+ {"no-detach", no_argument, 0, 'D'},
{0, 0, 0, 0}
};
@@ -169,7 +171,7 @@ void apply_init_args( int argc, char *ar
if ( strstr( SOURCE_VERSION, "-" ) != NULL )
printf( "WARNING: You are using the unstable batman branch. If you are interested in *using* batman get the latest stable release !\n" );
- while ( ( optchar = getopt_long( argc, argv, "a:A:bcd:hHio:g:p:r:s:vV", long_options, &option_index ) ) != -1 ) {
+ while ( ( optchar = getopt_long( argc, argv, "a:A:bcd:hHio:g:p:r:s:vVD", long_options, &option_index ) ) != -1 ) {
switch ( optchar ) {
@@ -381,6 +383,11 @@ void apply_init_args( int argc, char *ar
found_args++;
break;
+ case 'D':
+ no_detach = 1;
+ found_args++;
+ break;
+
case 'h':
default:
usage();
@@ -539,12 +546,14 @@ void apply_init_args( int argc, char *ar
/* daemonize */
if (debug_level == 0) {
- if (my_daemon() < 0) {
+ if (!no_detach) {
+ if (my_daemon() < 0) {
- printf("Error - can't fork to background: %s\n", strerror(errno));
- restore_defaults();
- exit(EXIT_FAILURE);
+ printf("Error - can't fork to background: %s\n", strerror(errno));
+ restore_defaults();
+ exit(EXIT_FAILURE);
+ }
}
openlog("batmand", LOG_PID, LOG_DAEMON);

View file

@ -0,0 +1,47 @@
---
batman/linux/modules/gateway.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
--- batmand-r1439.orig/linux/modules/gateway.c
+++ batmand-r1439/linux/modules/gateway.c
@@ -29,6 +29,7 @@ static struct class *batman_class;
static int batgat_open(struct inode *inode, struct file *filp);
static int batgat_release(struct inode *inode, struct file *file);
static int batgat_ioctl( struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg );
+static long batgat_ioctl_unlocked(struct file *file, unsigned int cmd, unsigned long arg );
static void udp_data_ready(struct sock *sk, int len);
@@ -53,7 +54,11 @@ static int proc_clients_read(char *buf,
static struct file_operations fops = {
.open = batgat_open,
.release = batgat_release,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
+ .unlocked_ioctl = batgat_ioctl_unlocked,
+#else
.ioctl = batgat_ioctl,
+#endif
};
@@ -166,6 +171,20 @@ static int batgat_release(struct inode *
}
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
+#include <linux/smp_lock.h>
+static long batgat_ioctl_unlocked(struct file *file, unsigned int cmd, unsigned long arg )
+{
+ int ret;
+
+ lock_kernel();
+ ret = batgat_ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
+ unlock_kernel();
+
+ return ret;
+}
+#endif
+
static int batgat_ioctl( struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg )
{
uint8_t tmp_ip[4];

531
bird-openwrt/DOCUMENTATION Normal file
View file

@ -0,0 +1,531 @@
---------------------------------------------------------------------
Copyright (C) 2014 - Eloi Carbó Solé (GSoC2014)
BGP/Bird integration with OpenWRT
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
---------------------------------------------------------------------
*** Original documentation for BIRD Daemon can be found here: http://bird.network.cz/?get_doc
*** Some interesting examples are placed in BIRD daemon Gitlab page: https://gitlab.labs.nic.cz/labs/bird/wikis/home
*** If you want to add new options to bird*-openwrt packages,
*** feel free to make a pull request it in: https://github.com/openwrt-routing/packages/bird-openwrt
*** or email me and ask for it: eloicaso@openmailbox.org
- Options used in /etc/config/birdX -
---------------------------------------------------------------------
CONFIGURATION SECTION 1: 'bird'
---------------------------------------------------------------------
Example
--
config bird 'bird'
option use_UCI_config '1'
option UCI_config_file '/tmp/bird4.conf'
--
* use_UCI_config: Boolean
This option allows you to use UCI configuration translation file instead of the original Bird one. If true/1, birdX init.d script will use the translation placed in "UCI_config_file". Otherwise, it will use the default "/etc/birdX.conf" configuration.
[Hint] This could be used to allow multiple configurations and swap them easily.
Default: 0
* UCI_config_file: String (File path)
This option sets where will be placed the translation of the UCI configuration file.
Default: /tmp/birdX.conf
---------------------------------------------------------------------
CONFIGURATION SECTION 2: 'global NAME'
---------------------------------------------------------------------
Example
--
config global 'global'
option log_file '/tmp/bird4.log'
option log 'all'
option debug 'off'
option router_id '172.16.1.6'
--
* log_file: String (File path)
This option sets the path of the file used to save Bird Log and Debug's information.
Default: /tmp/birdX.log
* log: String/Enumeration (all/off, info, warning, error, fatal, debug, trace, remote, auth, bug)
This option allows you to set which information you want to save in the
[HINT] Use the enumeration like: { info, waning, error }
Default: all
* debug: String/Enumeration ( all/off, states, routes, filters, interfaces, events, packets)
This option allows you to set which debug information will be saved in the "log_file" file.
[HINT] Use the enumeration like: { info, waning, error }
Default: off
* router_id: IP Address
This option sets which will be the Router ID. Usually is the lowest IP address (not loopback) among the existing interfaces.
[HINT] In IPv4 this field is optional. In IPv6 is mandatory.
* listen_bgp_addr: IP Address
This option sets the IP address that Bird BGP instances will listen by default.
Default: 0.0.0.0
* listen_bgp_port: Integer (Port)
This option sets the port that Bird BGP instances will listen by default.
Default: 179
[IPv6 only]
* listen_bgp_dual: Boolean
This option sets if Bird6 BGP instances will listen only to IPv6 or IPv4/6 BGP routes.
---------------------------------------------------------------------
CONFIGURATION SECTION 3: 'table'
---------------------------------------------------------------------
Example
--
config table
option name 'aux'
--
* name: String
This option allows you to set the name of the auxiliar kernel tables used for Bird.
---------------------------------------------------------------------
CONFIGURATION SECTION 4: 'kernel NAME'
---------------------------------------------------------------------
Example
--
config kernel kernel1
option table 'aux'
option import 'all'
option export 'all'
option kernel_table '100'
option scan_time '10'
option learn '1'
option persist '0'
option disabled '0'
--
* table: String
Set an auxiliary table for the current kernel routing instance. This table MUST exist as a SECTION 3 instance.
[HINT] If there is an Kernel protocol instance that uses the "main" kernel table (not using table/kernel_table options), this should be included before the rest of Kernel instances (which will use auxiliary tables).
* import: String/Filter function
This option delimits which routes coming from other protocols will be accepted. This option allows filters in different manners:
1. All/none: allows to import all the routes or none of them.
2. Filter name: [import 'bgp_filter_in'] the protocol will use the filter with the Filter name. (Needs an existing filter declared in the UCI configuration file)
* export: String/Filter function
This option delimits which routes going out from the protocol. This option allows filters in different manners:
1. All/none: allows to export all the routes or none of them.
2. Filter name: [export 'bgp_filter_out'] the protocol will use the filter with the 'Filter name'. (Needs an existing filter declared in the UCI configuration file)
* kernel_table: Integer
This option sets the identification number of the Kernel table that will be used instead of the main one.
Default: main table (254)
* scan_time: Integer
This option sets the time between checks to the selected kernel table.
* learn: Boolean
Set if the kernel table will add the routes from other routing protocols or the system administrator.
* persist: Boolean
Set if Bird Daemon will save the known routes when exiting or if it will clean the routing table.
* disable: Boolean
This option sets if the protocol will be used or dismissed.
Default: 0
---------------------------------------------------------------------
CONFIGURATION SECTION 5: 'device NAME'
---------------------------------------------------------------------
Example
--
config device device1
option scan_time '10'
option disabled '0'
--
* scan_time: Integer
This option sets the time between checks to the selected kernel table.
* disable: Boolean
This option sets if the protocol will be used or dismissed.
Default: 0
CONFIGURATION SECTION 6: 'static NAME'
Example
--
config static static1
option table 'aux'
option disabled '0'
--
* table: String
Set an auxiliary table for the current static instance. This table MUST exist as a SECTION 3 instance.
[HINT] If there is an static instance that uses the "main" kernel table (not using table/kernel_table options), this should be included before the rest of static instances (which will use auxiliary tables).
* disable: Boolean
This option sets if the protocol will be used or dismissed.
Default: 0
---------------------------------------------------------------------
CONFIGURATION SECTION 7 & 8: 'bgp NAME' & 'bgp_template NAME'
---------------------------------------------------------------------
This section merges two different configuration sections: bgp instances and templates. The first one is the basic bgp configuration part and the second one is the template used to minimize the number of options written in the configuration file. Both configuration sections has the same options, but when Bird found duplicities, the bgp instance has priority over the template.
Examples
-- instance --
config bgp bgp1
option template 'bgp_common'
option description 'Description of the BGP instance'
option neighbor_address '172.16.1.5'
option neighbor_as '65530'
option source_address '172.16.1.6'
option next_hop_self '0'
option next_hop_keep '0'
option rr_client '1'
option rr_cluster_id '172.16.1.6'
--
-- template --
config bgp_template bgp_common
option table 'aux'
option import 'all'
option export 'all'
option local_address '172.16.1.6'
option local_as '65001'
option import_limit '100'
option import_limit_action 'warn'
option export_limit '100'
option export_limit_action 'warn'
option receive_limit '100'
option receive_limit_action 'warn'
option disabled '0'
--
* template: String
This option states the template used for current BGP instance. This template MUST exist as a SECTION 8 instance.
* description: String
This option allows to add a description of the bgp instance and its function
* local_addr: IP address
This optional option allows to set the IP source of our Autonomous System (AS).
* local_as: Integer
This option allows to set the identification number of our AS number. This option is mandatory for each BGP instance.
* neighbor_addr: IP address
Each BGP instance has a neighbor connected to. This option allows to set its IP address
* neighbor_as: Integer
Each BGP instance has a neighbor connected to. This option allows to set its AS ID.
* next_hop_self: Boolean
If this option is true, BGP protocol will avoid to calculate the next hop and always advertise own "Router id" IP .
Default: 0
* next_hop_keep: Boolean
If this option is true, BGP will always use the received next_hop information to redirect the route.
Default: 0
* rr_client: Boolean
IF this option is true, the router will be set as Route Reflector and will treat the rest of the routers as RR clients.
Default: 0
* rr_cluster_id: Integer
This option sets the identification number of the RR cluster. All the nodes in a cluster needs this option and share the same number.
Default: Router id
* import_limit: Integer
This option sets the limit of routes that a protocol can import until take the action indicated in the import_limit_action.
import_limit also counts filtered routes (even dropped).
Default: 0 (no limit)
* import_limit_action: String
This option allows to decide the action to take when reached the limit of imported routes.
Actions are: warn, block, restart, disable
* export_limit: Integer
This option sets the limit of routes that a protocol can export until take the action indicated in the export_limit_action.
Default: 0 (no limit)
* export_limit_action: String
This option allows to decide the action to take when reached the limit of exported routes.
Actions are: warn, block, restart, disable
* receive_limit: Integer
This option sets the limit of routes that a protocol can receive until take the action indicated in the receive_limit_action. receive_limit only counts accepted routes from the protocol.
Default: 0 (no limit)
* receive_limit_action: String
This option allows to decide the action to take when reached the limit of received routes.
Actions are: warn, block, restart, disable
* disable: Boolean
This option sets if the protocol will be used or dismissed.
Default: 0
---------------------------------------------------------------------
CONFIGURATION SECTION 9: 'route'
---------------------------------------------------------------------
Example
--
config route
option instance 'static1'
option type 'router'
option prefix '192.168.9.0/24'
option via '10.99.105.159'
config route
option instance 'static1'
option type 'special'
option prefix '192.168.2.0/24'
option attribute 'unreachable'
config route
option instance 'static1'
option type 'iface'
option prefix '192.168.3.0/24'
option iface 'mgmt0'
config route
option instance 'static1'
option type 'recursive'
option prefix '192.168.4.0/24'
option ip '192.168.1.1'
config route
option instance 'static1'
option type 'multipath'
option prefix '192.168.30.0/24'
list l_via '172.16.1.5'
list l_via '172.16.1.6'
--
* instance: String
This option indicates the route that the static protocol instance will apply.
* type: String
This option states the type of route that will be applied. Also defines the options available for it.
Types are: 'router', 'special', 'iface', 'recursive' or 'multipath'.
* prefix: IP address/network
This option allows to define the network that you want to define.
[router only]
* via: IP Address
This option indicates the IP address of the neighbor router where the routes will pass through.
[special only]
* attribute: String
This option will mark the behaviour of the route.
Attribures are: 'blackhole', 'unreachable' or 'prohibit'.
[iface only]
* iface: String
This option indicates the interface used to redirect the BGP routes. Careful, the interface MUST exist, or Bird will fail to start.
[recursive only]
* ip: IP address
This option states the IP address which the next hop will depend on.
[multipath only][This is a list, not an option. Use it as in the example, or check the UCI configuration documentation.]
* l_via: IP address
This list of IPs specifies the list (following the sequence) of routers that the route will follow as next hops.
---------------------------------------------------------------------
CONFIGURATION SECTION 10: 'filter NAME'
---------------------------------------------------------------------
Filters are written in separated files. Its syntax can be found in http://bird.network.cz/?get_doc&f=bird-5.html
The content of each filter file is copied in the birdX.conf file without checking its syntax.
Example
--
config filter 'firstFilter'
option type 'bgp'
option instance 'bgp1'
option file_path '/var/filters/f1'
--
* type: String
The type indicates to which routing protocol is the filter directed to. Currently only BGP is available.
* instance: String
This option indicates the filter that the routing protocol instance will apply.
* file_path: String (File path)
This option specifies the path to the filter file to be used in the routing protocol.
---------------------------------------------------------------------
COMPLETE CONFIGURATION EXAMPLE:
---------------------------------------------------------------------
config bird 'bird'
option use_UCI_config '1'
#Caution! Enabling this option, Bird will translate this
#UCI file and use it instead of /etc/bird4.conf
option UCI_config_file '/tmp/bird4.conf'
#If you enable useUCIconfig, UCIconfigFile will be Bird's
#configuration file location.
config global 'global'
option log_file '/tmp/bird4.log'
option log 'all'
option debug 'off'
option router_id '172.16.1.6'
config table
option name 'aux'
config kernel kernel1
option table 'aux'
option import 'all'
option export 'all'
option kernel_table '100'
option scan_time '10'
option learn '1'
option persist '0'
option disabled '0'
config device device1
option scan_time '10'
option disabled '0'
config static static1
option table 'aux'
option disabled '0'
config bgp bgp1
option template 'bgp_common'
option description 'Description of the BGP instance'
option neighbor_address '172.16.1.5'
option neighbor_as '65530'
option source_address '172.16.1.6'
option next_hop_self '0'
option next_hop_keep '0'
option rr_client '1'
option rr_cluster_id '172.16.1.6'
config bgp_template bgp_common
option table 'aux'
option import 'all'
option export 'all'
option local_address '172.16.1.6'
option local_as '65001'
option import_limit '100'
option import_limit_action 'warn'
option export_limit '100'
option export_limit_action 'warn'
option receive_limit '100'
option receive_limit_action 'warn'
option disabled '0'
#config ospf ospf1
# option cfg1583compat '1'
#
#config ospf_area '0.0.0.0'
# option instance 'ospf1'
# option stub '0'
#
#config ospf_interface '*'
# option area '0.0.0.0'
# option cost '100'
# option type 'broadcast'
# option hello '5'
# option password '1'
#
#config ospf_password '1'
# option authentication 'cryptographic'
# option passphrase '1234'
#
#config ospf_networks
# option area '0.0.0.0'
# list prefix '10.0.0.0/24'
#
#config ospf_hidden_networks
# option area '0.0.0.0'
# option prefix '12.0.0.0/24'
#
#config ospf_stubnet '11.0.0.0/24'
# option area '0.0.0.0'
# option hidden '0'
# option summary '0'
# option cost '101'
#
config route
option instance 'static1'
option type 'router'
option prefix '192.168.9.0/24'
option via '10.99.105.159'
config route
option instance 'static1'
option type 'special'
option prefix '192.168.2.0/24'
option attribute 'unreachable'
config route
option instance 'static1'
option type 'iface'
option prefix '192.168.3.0/24'
option iface 'mgmt0'
config route
option instance 'static1'
option type 'recursive'
option prefix '192.168.4.0/24'
option ip '192.168.1.1'
config route
option instance 'static1'
option type 'multipath'
option prefix '192.168.30.0/24'
list l_via '172.16.1.5'
list l_via '172.16.1.6'
config filter 'firstFilter'
option type 'bgp'
option instance 'bgp1'
option file_path '/var/filters/f1'

View file

@ -0,0 +1,91 @@
# Copyright (C) 2014 - Eloi Carbó Solé (GSoC2014)
# BGP/Bird integration with OpenWRT and QMP
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
BIRD:=bird4
PKG_NAME:=$(BIRD)-openwrt
PKG_RELEASE:=0.2
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
PKG_LICENSE:=GPL-3.0+
uci:=$(BIRD)-uci
luci:=luci-app-$(BIRD)
include $(INCLUDE_DIR)/package.mk
define Build/Prepare
endef
define Build/Compile
endef
define Package/$(uci)
TITLE:=The BIRD UCI module
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
MAINTAINER:=Eloi Carbo <eloicaso@openmailbox.org>
URL:=https://github.com/eloicaso/bird4-openwrt/
DEPENDS:=+$(BIRD) +libuci +uci
endef
define Package/$(uci)/description
$(BIRD) UCI integration module
endef
define Package/$(uci)/install
$(INSTALL_DIR) $(1)/etc/$(BIRD)/init.d
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_BIN) ./src/init.d/$(BIRD) $(1)/etc/$(BIRD)/init.d/
$(CP) ./src/uci-defaults/$(uci)-install-init.d $(1)/etc/$(BIRD)/init.d/
$(CP) ./src/config/$(BIRD) $(1)/etc/config/
endef
define Package/$(uci)/postinst
#!/bin/sh
if [ -z $${IPKG_INSTROOT} ]; then
( . /etc/bird4/init.d/bird4-uci-install-init.d ) && rm -f /etc/bird4/init.d/bird4-uci-install-init.d
fi
endef
$(eval $(call BuildPackage,$(uci)))
define Package/$(luci)
TITLE:=LuCI support for $(BIRD)
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=3. Applications
MAINTAINER:=Eloi Carbo <eloicaso@openmailbox.org>
URL:=https://github.com/eloicaso/bird4-openwrt/
DEPENDS:=+$(BIRD)-uci +luci-base
endef
define Package/$(luci)/description
$(BIRD) application for LuCI
endef
define Package/$(luci)/install
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller/
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/$(BIRD)/
$(CP) ./src/model/* $(1)/usr/lib/lua/luci/model/cbi/$(BIRD)/
$(CP) ./src/controller/* $(1)/usr/lib/lua/luci/controller/
endef
$(eval $(call BuildPackage,$(luci)))

View file

@ -0,0 +1,67 @@
config bird 'bird'
option use_UCI_config '1'
#Caution! Enabling this option, Bird will translate this
#UCI file and use it instead of /etc/bird4.conf
option UCI_config_file '/tmp/bird4.conf'
#If you enable useUCIconfig, UCIconfigFile will be Bird's
#configuration file location.
config global 'global'
option log_file '/tmp/bird4.log'
option log 'all'
option debug 'off'
option router_id '172.16.1.6'
config table
option name 'aux'
config kernel kernel1
option table 'aux'
option import 'all'
option export 'all'
option kernel_table '100'
option scan_time '10'
option learn '1'
option persist '0'
option disabled '0'
config device device1
option scan_time '10'
option disabled '0'
config static static1
option table 'aux'
option disabled '0'
config bgp bgp1
option template 'bgp_common'
option description 'Description of the BGP instance'
option neighbor_address '172.16.1.5'
option neighbor_as '65530'
option source_address '172.16.1.6'
option next_hop_self '0'
option next_hop_keep '0'
option rr_client '1'
option rr_cluster_id '172.16.1.6'
config bgp_template bgp_common
option table 'aux'
option import 'all'
option export 'all'
option local_address '172.16.1.6'
option local_as '65001'
option import_limit '100'
option import_limit_action 'warn'
option export_limit '100'
option export_limit_action 'warn'
option receive_limit '100'
option receive_limit_action 'warn'
option disabled '0'
config route
option instance 'static1'
option type 'router'
option prefix '192.168.9.0/24'
option via '10.99.105.159'

View file

@ -0,0 +1,27 @@
--[[
Copyright (C) 2014 - Eloi Carbó Solé (GSoC2014)
BGP/Bird integration with OpenWRT and QMP
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
--]]
module("luci.controller.bird4", package.seeall)
function index()
entry({"admin","network","bird4"}, cbi("bird4/overview"), "Bird4", 0).dependent=false
entry({"admin","network","bird4","overview"}, cbi("bird4/overview"), "Overview", 1).dependent=false
entry({"admin","network","bird4","proto_general"}, cbi("bird4/gen_proto"), "General protocols", 3).dependent=false
entry({"admin","network","bird4","proto_bgp"}, cbi("bird4/bgp_proto"), "BGP Protocol", 4).dependent=false
end

View file

@ -0,0 +1,411 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2014 - Eloi Carbó Solé (GSoC2014)
# BGP/Bird integration with OpenWRT and QMP
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
BIRD="bird4"
BIRD_CONFIG="/etc/$BIRD.conf"
START=99
STOP=10
SERVICE_DAEMONIZE=1
SERVICE_USE_PID=1
SERVICE_PID_FILE="/var/run/$BIRD.pid"
BIRD_BIN="/usr/sbin/$BIRD"
# Function: writeToConfig $1
# $1 string.
# Allows to write in the $BIRD_CONFIG file, the string $1. This function does not check the $1 string.
# Example: writeToConfig "value: $N"
writeToConfig() {
echo "$1" >> $BIRD_CONFIG
}
# Function: write $1 $2
# $1 string. $2 string.
# This function checks if $2 is empty. If not, it writes the string $1 in the $BIRD_CONFIG file.
# Use write function to check if $1, value found inside $2, is not empty and can be written in the configuration file.
# Example: N=""; write "value: $N" $N;
write() {
[ -n "$2" ] && writeToConfig "$1"
}
#Function: write_bool $1 $2
# $1 string; $2 boolean
# This function checks if $2 is true or false and write the $1 string into $BIRD_CONFIG file.
# The function writes a # before the $2 string if its false.
# Example: local N=0; write_bool $N
write_bool() {
[ "$2" == 0 ] && writeToConfig "# $1;" || writeToConfig " $1;"
}
# Function: get $1 $2
# $1 string. $2 string
# This function uses the external UCI function "config_get $result $section $option" to obtain a string value from UCI config file.
# To use this function, use the same name of the UCI option for the variable.
# Example: UCI (option id 'abcd'); local id; get id $section
get() {
config_get $1 $2 $1
}
# Function: get_bool $1 $2
# $1 boolean. $2 string
# This function uses the external UCI function "config_get_bool $result $section $option" to obtain a boolean value from UCI config file.
# To use this function, use the same name of the UCI option for the variable $1.
# Example: UCI (option use_ipv6 '1'); local use_ipv6; get use_ipv6 $section
get_bool() {
config_get_bool $1 $2 $1
}
# Function: multipath_list $1
# $1 string
# This function writes the $1 string in the multipath routes.
multipath_list() {
write " via $1" $1
}
# Function: prepare_tables $1
# $1 string
# This function gets each "table" section in the UCI configuration and sets each option in the bird4.conf file.
# $1 is set as the ID of the current UCI table section
prepare_tables() {
local section="$1"; local name
get name $section
write "table $name;" $name
}
# Function: prepare_global $1
# $1 string
# This function gets each "global" section in the UCI configuration and sets each option in the bird4.conf file.
# $1 is set as the ID of the current UCI global section. prepare_global is the first configuration set in the bird4.conf and removes the old file.
prepare_global () {
local section="$1"
local log_file; local log; local debug; local router_id; local table
# Remove old configuration file
rm -f "$BIRD_CONFIG"
get log_file $section
get log $section
get debug $section
get router_id $section
get table $section
# First line of the NEW configuration file
echo "#Bird4 configuration using UCI:" > $BIRD_CONFIG
writeToConfig " "
[ -n "$log_file" -a -n "$log" ] && writeToConfig 'log "'$log_file'" '$log';'
write "debug protocols $debug;" $debug
writeToConfig " "
writeToConfig "#Router ID"
write "router id $router_id;" $router_id
writeToConfig " "
writeToConfig "#Secondary tables"
config_foreach prepare_tables 'table'
writeToConfig " "
}
# Function: prepare_routes $1
# $1 string
# This function gets each "route" section in the UCI configuration and sets each option in the bird4.conf file.
# $1 is set as the ID of the current UCI route section. Each type of route has its own treatment.
prepare_routes() {
local instance; local prefix; local via; local type
local section="$1"
local protoInstance="$2"
get instance $section
if [ "$instance" = "$protoInstance" ]; then
get type $section
case "$type" in
"router")
get prefix $section
get via $section
[ -n "$prefix" -a -n "$via" ] && writeToConfig " route $prefix via $via;"
;;
"special")
get prefix $section
get attribute $section
[ -n "$prefix" -a -n "$attribute" ] && writeToConfig " route $prefix $attribute;"
;;
"iface")
get prefix $section
get iface $section
[ -n "$prefix" -a -n "$iface" ] && writeToConfig ' route '$prefix' via "'$iface'";'
;;
"multipath")
get prefix $section
write " route $prefix multipath" $prefix
config_list_foreach $section l_via multipath_list
writeToConfig " ;"
;;
esac
fi
}
# Function: prepare_kernel $1
# $1 string
# This function gets each "kernel" protocol section in the UCI configuration and sets each option in the bird6.conf file.
# $1 is set as the ID of the current UCI kernel section.
prepare_kernel() {
local section="$1"
write "#$section configuration:" $section
local disabled; local table; local kernel_table; local import; local export; local scan_time; local persist; local learn
get_bool disabled $section
get table $section
get import $section
get export $section
get scan_time $section
get kernel_table $section
get learn $section
get persist $section
writeToConfig "protocol kernel {"
write_bool disabled $disabled
write " table $table;" $table
write " kernel table $kernel_table;" $kernel_table
write_bool learn $learn
write_bool persist $persist
write " scan time $scan_time;" $scan_time
write " import $import;" $import
write " export $export;" $export
writeToConfig "}"
writeToConfig " "
}
# Function: prepare_static $1
# $1 string
# This function gets each "static" protocol section in the UCI configuration and sets each option in the bird6.conf file.
# $1 is set as the ID of the current UCI static section.
prepare_static() {
local section="$1"
local disabled
get disabled $section
if [ "$disabled" -eq 0 ]; then
local table
get table $section
writeToConfig "#$section configration:" $section
writeToConfig "protocol static {"
write " table $table;" $table
config_foreach prepare_routes 'route' $section
writeToConfig "}"
writeToConfig " "
fi
}
# Function: prepare_device $1
# $1 string
# This function gets each "device" protocol section in the UCI configuration and sets each option in the bird4.conf file.
# $1 is set as the ID of the current UCI device section.
prepare_device() {
local section="$1"
local disabled; local scan_time
get disabled $section
get scan_time $section
write "#$section configuration:" $section
writeToConfig "protocol device {"
write_bool disabled $disabled
write " scan time $scan_time;" $scan_time
writeToConfig "}"
writeToConfig " "
}
# Function: prepare_bgp_template $1
# $1 string
# This function gets each "bgp_template" protocol section in the UCI configuration and sets each option in the bird4.conf file.
# $1 is set as the ID of the current UCI bgp_template section.
# Careful! Template options will be replaced by "instance" options if there is any match.
prepare_bgp_template() {
local section="$1"
local disabled; local table; local import; local export; local local_address; local local_as; local neighbor_address; local neighbor_as; local source_address; local next_hop_self; local next_hop_keep; local rr_client; local rr_cluster_id; local import_limit; local import_limit_action; local export_limit; local export_limit_action; local receive_limit; local receive_limit_action
get_bool disabled $section
get_bool next_hop_self $section
get_bool next_hop_keep $section
get table $section
get import $section
get export $section
get local_address $section
get local_as $section
get rr_client $section
get rr_cluster_id $section
get import_limit $section
get import_limit_action $section
get export_limit $section
get export_limit_action $section
get receive_limit $section
get receive_limit_action $section
get neighbor_address $section
get neighbor_as $section
writeToConfig "#$section template:"
writeToConfig "template bgp $section {"
[ -n "$disabled" ] && write_bool disabled $disabled
write " table $table;" $table
write " local as $local_as;" $local_as
write " source address $local_address;" $local_address
write " import $import;" $import
write " export $export;" $export
if [ -n "$next_hop_self" ]; then
[ "$next_hop_self" = "1" ] && writeToConfig " next hop self;" || writeToConfig "# next hop self;"
fi
if [ -n "$next_hop_keep" ]; then
[ "$next_hop_keep" = "1" ] && writeToConfig " next hop keep;" || writeToConfig "# next hop keep;"
fi
[ "$rr_client" = "1" ] && writeToConfig " rr client;" || writeToConfig "# rr client;"
write " rr cluster id $rr_cluster_id;" $rr_cluster_id
if [ -n "$import_limit" -a "$import_limit" > "0" ]; then
[ -z "$import_limit_action" ] && $import_limit_action = "warn"
writeToConfig " import limit $import_limit action $import_limit_action;"
fi
if [ -n "$export_limit" -a "$export_limit" > "0" ]; then
[ -z "$export_limit_action" ] && $export_limit_action = "warn"
writeToConfig " export limit $export_limit action $export_limit_action;"
fi
if [ -n "$receive_limit" -a "$receive_limit" > "0" ]; then
[ -z "$receive_limit_action" ] && $receive_limit_action = "warn"
writeToConfig " receive limit $receive_limit action $receive_limit_action;"
fi
[ -n "$neighbor_address" -a -n "$neighbor_as" ] && writeToConfig " neighbor $neighbor_address as $neighbor_as;"
writeToConfig "}"
writeToConfig " "
}
# Function: prepare_bgp $1
# $1 string
# This function gets each "bgp" protocol section in the UCI configuration and sets each option in the bird6.conf file.
# $1 is set as the ID of the current UCI bgp section.
# Careful! The options set in bgp instances overlap bgp_template ones.
prepare_bgp() {
local section="$1"
local disabled; local table; local template; local description; local import; local export; local local_address; local local_as; local neighbor_address; local neighbor_as; local rr_client; local rr_cluster_id; local import_limit; local import_limit_action; local export_limit; local export_limit_action; local receive_limit; local receive_limit_action
get disabled $section
get table $section
get template $section
get description $section
get import $section
get export $section
get local_address $section
get local_as $section
get rr_client $section
get rr_cluster_id $section
get import_limit $section
get import_limit_action $section
get export_limit $section
get export_limit_action $section
get receive_limit $section
get receive_limit_action $section
get neighbor_address $section
get neighbor_as $section
writeToConfig "#$section configuration:"
[ -n "$template" ] && writeToConfig "protocol bgp $section from $template {" || writeToConfig "protocol bgp $section {"
[ -n "$disabled" ] && write_bool disabled $disabled
write " table $table;" $table
# [ -n "$description" ] && writeToConfig ' description "'$description'";'
write " local as $local_as;" $local_as
write " source address $local_address;" $local_address
write " import $import;" $import
write " export $export;" $export
if [ -n "$next_hop_self" ]; then
[ "$next_hop_self" = "1" ] && writeToConfig " next hop self;" || writeToConfig "# next hop self;"
fi
if [ -n "$next_hop_keep" ]; then
[ "$next_hop_keep" = "1" ] && writeToConfig " next hop keep;" || writeToConfig "# next hop keep;"
fi
[ "$rr_client" = "1" ] && writeToConfig " rr client;" || writeToConfig "# rr client;"
write " rr cluster id $rr_cluster_id;" $rr_cluster_id
if [ -n "$import_limit" -a "$import_limit" > "0" ]; then
[ -z "$import_limit_action" ] && $import_limit_action = "warn"
writeToConfig " import limit $import_limit action $import_limit_action;"
fi
if [ -n "$export_limit" -a "$export_limit" > "0" ]; then
[ -z "$export_limit_action" ] && $export_limit_action = "warn"
writeToConfig " export limit $export_limit action $export_limit_action;"
fi
if [ -n "$receive_limit" -a "$receive_limit" > "0" ]; then
[ -z "$receive_limit_action" ] && $receive_limit_action = "warn"
writeToConfig " receive limit $receive_limit action $receive_limit_action;"
fi
[ -n "$neighbor_address" -a -n "$neighbor_as" ] && writeToConfig " neighbor $neighbor_address as $neighbor_as;"
writeToConfig "}"
writeToConfig " "
}
# Function: prepare_bgp_filters $1
# $1 string
# This function gets each "bgp_filter" protocol section in the UCI configuration and sets each option in the bird4.conf file.
# $1 is set as the ID of the current UCI bgp_filter section.
# This function checks if the filter file exists and, in that case, it writes its content to the configuration file.
prepare_bgp_filters() {
local section="$1"
local type
local file_path
get type $section
get file_path $section
if [ -e "$file_path" ]; then
local filter_content=`cat $file_path`
if [ -n "$type" -a "$type" = "bgp" ]; then
writeToConfig "#Filter $section:"
writeToConfig "${filter_content}"
writeToConfig " "
fi
fi
}
start() {
config_load bird4
local use_UCI_config
get use_UCI_config 'bird'
if [ -z "$use_UCI_config" -o "$use_UCI_config" = "0" ]; then
service_start $BIRD_BIN -d -c $BIRD_CONFIG -P $SERVICE_PID_FILE
else
#Set Bird4 configuration location:
local UCI_config_File
get UCI_config_File 'bird'
BIRD_CONFIG=${UCI_config_File:-/tmp/bird4.conf}
#Setup the basic configuration
prepare_global 'global'
config_foreach prepare_kernel 'kernel'
config_foreach prepare_static 'static'
config_foreach prepare_device 'device'
#config_foreach prepare_direct 'direct'
#Setup the protocols configuration (currently BGP only)
config_foreach prepare_bgp_template 'bgp_template'
config_foreach prepare_bgp 'bgp'
config_foreach prepare_bgp_filters 'filter'
#Start the service
service_start $BIRD_BIN -d -c $BIRD_CONFIG -P $SERVICE_PID_FILE
fi
}
stop() {
service_stop $BIRD_BIN
}
restart() {
stop
start
}
reload() {
service_reload $BIRD_BIN
}

View file

@ -0,0 +1,239 @@
--[[
Copyright (C) 2014 - Eloi Carbó Solé (GSoC2014)
BGP/Bird integration with OpenWRT and QMP
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
--]]
require("luci.sys")
local http = require "luci.http"
local uci = require "luci.model.uci"
local uciout = uci.cursor()
m=Map("bird4", "Bird4 BGP protocol's configuration")
tab_templates = {}
uciout:foreach('bird4', 'bgp_template', function (s)
local name = s[".name"]
if (name ~= nil) then
table.insert(tab_templates, name)
end
end)
-- Section BGP Templates
sect_templates = m:section(TypedSection, "bgp_template", "BGP Templates", "Configuration of the templates used in BGP instances.")
sect_templates.addremove = true
sect_templates.anonymous = false
disabled = sect_templates:option(Flag, "disabled", "Disabled", "Enable/Disable BGP Protocol")
disabled.optional=true
table = sect_templates:option(ListValue, "table", "Table", "Set the table used for BGP Routing")
table.optional=true
uciout:foreach("bird4", "table",
function (s)
table:value(s.name)
end)
table:value("")
import = sect_templates:option(Value, "import", "Import","")
import.optional=true
export = sect_templates:option(Value, "export", "Export", "")
export.optional=true
source_addr = sect_templates:option(Value, "source_address", "Source Address", "Source address for BGP routing. By default uses Router ID")
source_addr.optional = true
description = sect_templates:option(TextValue, "description", "Description", "Description of the current BGP instance")
description.optional = true
next_hop_self = sect_templates:option(Flag, "next_hop_self", "Next hop self", "Avoid next hop calculation and advertise own source address as next hop")
next_hop_self.default = nil
next_hop_self.optional = true
next_hop_keep = sect_templates:option(Flag, "next_hop_keep", "Next hop keep", "Forward the received Next Hop attribute event in situations where the local address should be used instead, like subneting")
next_hop_keep.default = nil
next_hop_keep.optional = true
rr_client = sect_templates:option(Flag, "rr_client", "Route Reflector server", "This router serves as a Route Reflector server and treats neighbors as clients")
rr_client.default = nil
rr_client.optional = true
rr_cluster_id = sect_templates:option(Value, "rr_cluster_id", "Route Reflector Cluster ID", "Identificator of the RR cluster. By default uses the Router ID")
rr_cluster_id.optional = true
import_limit = sect_templates:option(Value, "import_limit", "Routes import limit", "Specify an import route limit. By default is disabled '0'")
import_limit.default= "0"
import_limit.optional = true
import_limit_action = sect_templates:option(ListValue, "import_limit_action", "Routes import limit action", "Action to take when import routes limit ir reached")
import_limit_action:value("warn")
import_limit_action:value("block")
import_limit_action:value("disable")
import_limit_action:value("restart")
import_limit_action.default = "warn"
import_limit_action.optional = true
export_limit = sect_templates:option(Value, "export_limit", "Routes export limit", "Specify an export route limit. By default is disabled '0'")
export_limit.default="0"
export_limit.optional = true
export_limit_action = sect_templates:option(ListValue, "export_limit_action", "Routes export limit action", "Action to take when export routes limit is reached")
export_limit_action:value("warn")
export_limit_action:value("block")
export_limit_action:value("disable")
export_limit_action:value("restart")
export_limit_action.default = "warn"
export_limit_action.optional = true
receive_limit = sect_templates:option(Value, "receive_limit", "Routes received limit", "Specify a received route limit. By default is disabled '0'")
receive_limit.default="0"
receive_limit.optional = true
receive_limit_action = sect_templates:option(ListValue, "receive_limit_action", "Routes received limit action", "Action to take when received routes limit is reached")
receive_limit_action:value("warn")
receive_limit_action:value("block")
receive_limit_action:value("disable")
receive_limit_action:value("restart")
receive_limit_action.default = "warn"
receive_limit_action.optional = true
local_address = sect_templates:option(Value, "local_address", "Local BGP address", "")
local_address.optional=true
local_as = sect_templates:option(Value, "local_as", "Local AS", "")
local_as.optional=true
-- Section BGP Instances:
sect_instances = m:section(TypedSection, "bgp", "BGP Instances", "Configuration of the BGP protocol instances")
sect_instances.addremove = true
sect_instances.anonymous = false
templates = sect_instances:option(ListValue, "template", "Templates", "Available BGP templates")
uciout:foreach("bird4", "bgp_template",
function(s)
templates:value(s[".name"])
end)
templates:value("")
source_addr = sect_instances:option(Value, "source_address", "Source Address", "Source address for BGP routing. By default uses Router ID")
source_addr.optional = true
description = sect_instances:option(TextValue, "description", "Description", "Description of the current BGP instance")
description.optional = true
next_hop_self = sect_instances:option(Flag, "next_hop_self", "Next hop self", "Avoid next hop calculation and advertise own source address as next hop")
next_hop_self.default = nil
next_hop_self.optional = true
next_hop_keep = sect_instances:option(Flag, "next_hop_keep", "Next hop keep", "Forward the received Next Hop attribute event in situations where the local address should be used instead, like subneting")
next_hop_keep.default = nil
next_hop_keep.optional = true
rr_client = sect_instances:option(Flag, "rr_client", "Route Reflector server", "This router serves as a Route Reflector server and treats neighbors as clients")
rr_client.default = nil
rr_client.optional = true
rr_cluster_id = sect_instances:option(Value, "rr_cluster_id", "Route Reflector Cluster ID", "Identificator of the RR cluster. By default uses the Router ID")
rr_cluster_id.optional = true
import_limit = sect_instances:option(Value, "import_limit", "Routes import limit", "Specify an import route limit. By default is disabled '0'")
import_limit.default="0"
import_limit.optional = true
import_limit_action = sect_instances:option(ListValue, "import_limit_action", "Routes import limit action", "Action to take when import routes limit ir reached")
import_limit_action:value("warn")
import_limit_action:value("block")
import_limit_action:value("disable")
import_limit_action:value("restart")
import_limit_action.default = "warn"
import_limit_action.optional = true
export_limit = sect_instances:option(Value, "export_limit", "Routes export limit", "Specify an export route limit. By default is disabled '0'")
export_limit.default="0"
export_limit.optional = true
export_limit_action = sect_instances:option(ListValue, "export_limit_action", "Routes export limit action", "Action to take when export routes limit is reached")
export_limit_action:value("warn")
export_limit_action:value("block")
export_limit_action:value("disable")
export_limit_action:value("restart")
export_limit_action.default = "warn"
export_limit_action.optional = true
receive_limit = sect_instances:option(Value, "receive_limit", "Routes received limit", "Specify a received route limit. By default is disabled '0'")
receive_limit.default="0"
receive_limit.optional = true
receive_limit_action = sect_instances:option(ListValue, "receive_limit_action", "Routes received limit action", "Action to take when received routes limit is reached")
receive_limit_action:value("warn")
receive_limit_action:value("block")
receive_limit_action:value("disable")
receive_limit_action:value("restart")
receive_limit_action.default = "warn"
receive_limit_action.optional = true
neighbor_address = sect_instances:option(Value, "neighbor_address", "Neighbor IP Address", "")
neighbor_as = sect_instances:option(Value, "neighbor_as", "Neighbor AS", "")
disabled = sect_instances:option(Flag, "disabled", "Disabled", "Enable/Disable BGP Protocol")
disabled.optional=true
disabled.default=nil
table = sect_instances:option(ListValue, "table", "Table", "Set the table used for BGP Routing")
table.optional=true
uciout:foreach("bird4", "table",
function (s)
table:value(s.name)
end)
table:value("")
import = sect_instances:option(Value, "import", "Import","")
import.optional=true
export = sect_instances:option(Value, "export", "Export", "")
export.optional=true
local_address = sect_instances:option(Value, "local_address", "Local BGP address", "")
local_address.optional=true
local_as = sect_instances:option(Value, "local_as", "Local AS", "")
local_as.optional=true
-- Section BGP Filters
sect_filters = m:section(TypedSection, "filter", "BGP Filters", "Filters of the BGP instances")
sect_filters.addremove = true
sect_filters.anonymous = false
sect_filters:depends("type", "bgp")
instance = sect_filters:option(ListValue, "instance", "BGP instance", "Filter's BGP instance")
instance:depends("type", "bgp")
uciout:foreach("bird4", "bgp",
function (s)
instance:value(s[".name"])
end)
type = sect_filters:option(Value, "type", "Filter type", "")
type.default = "bgp"
path = sect_filters:option(Value, "file_path", "Filter's file path", "Path to the Filter's file")
path:depends("type", "bgp")
function m.on_commit(self,map)
luci.sys.call('/etc/init.d/bird4 stop; /etc/init.d/bird4 start')
end
return m

View file

@ -0,0 +1,200 @@
--[[
Copyright (C) 2014 - Eloi Carbó Solé (GSoC2014)
BGP/Bird integration with OpenWRT and QMP
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
--]]
require("luci.sys")
local http = require "luci.http"
local uci = require "luci.model.uci"
local uciout = uci.cursor()
m=Map("bird4", "Bird4 general protocol's configuration.")
-- Optional parameters lists
local protoptions = {
{["name"]="table", ["help"]="Auxiliar table for routing", ["depends"]={"static","kernel"}},
{["name"]="import", ["help"]="Set if the protocol must import routes", ["depends"]={"kernel"}},
{["name"]="export", ["help"]="Set if the protocol must export routes", ["depends"]={"kernel"}},
{["name"]="scan_time", ["help"]="Time between scans", ["depends"]={"kernel","device"}},
{["name"]="kernel_table", ["help"]="Set which table must be used as auxiliar kernel table", ["depends"]={"kernel"}},
{["name"]="learn", ["help"]="Learn routes", ["depends"]={"kernel"}},
{["name"]="persist", ["help"]="Store routes. After a restart, routes will be still configured", ["depends"]={"kernel"}}
}
local routeroptions = {
{["name"]="prefix",["help"]="",["depends"]={"router","special","iface","multipath","recursive"}},
{["name"]="via",["help"]="",["depends"]={"router","multipath"}},
{["name"]="attribute",["help"]="",["depends"]={"special"}},
{["name"]="iface",["help"]="",["depends"]={"iface"}},
{["name"]="ip",["help"]="",["depends"]={"recursive"}}
}
--
-- KERNEL PROTOCOL
--
sect_kernel_protos = m:section(TypedSection, "kernel", "Kernel options", "Configuration of the kernel protocols. First Instance MUST be Primary table (no table or kernel_table fields).")
sect_kernel_protos.addremove = true
sect_kernel_protos.anonymous = false
-- Default kernel parameters
disabled = sect_kernel_protos:option(Flag, "disabled", "Disabled", "If this option is true, the protocol will not be configured.")
disabled.default=0
-- Optional parameters
for _,o in ipairs(protoptions) do
if o.name ~= nil then
for _, d in ipairs(o.depends) do
if d == "kernel" then
if o.name == "learn" or o.name == "persist" then
value = sect_kernel_protos:option(Flag, o.name, translate(o.name), translate(o.help))
elseif o.name == "table" then
value = sect_kernel_protos:option(ListValue, o.name, translate(o.name), translate(o.help))
uciout:foreach("bird4", "table",
function (s)
value:value(s.name)
end)
value:value("")
else
value = sect_kernel_protos:option(Value, o.name, translate(o.name), translate(o.help))
end
value.optional = true
value.rmempty = true
end
end
end
end
--
-- DEVICE PROTOCOL
--
sect_device_protos = m:section(TypedSection, "device", "Device options", "Configuration of the device protocols.")
sect_device_protos.addremove = true
sect_device_protos.anonymous = false
-- Default kernel parameters
disabled = sect_device_protos:option(Flag, "disabled", "Disabled", "If this option is true, the protocol will not be configured.")
disabled.default=0
-- Optional parameters
for _,o in ipairs(protoptions) do
if o.name ~= nil then
for _, d in ipairs(o.depends) do
if d == "device" then
value = sect_device_protos:option(Value, o.name, translate(o.name), translate(o.help))
value.optional = true
value.rmempty = true
end
end
end
end
--
-- STATIC PROTOCOL
--
sect_static_protos = m:section(TypedSection, "static", "Static options", "Configuration of the static protocols.")
sect_static_protos.addremove = true
sect_static_protos.anonymous = false
-- Default kernel parameters
disabled = sect_static_protos:option(Flag, "disabled", "Disabled", "If this option is true, the protocol will not be configured.")
disabled.default=0
-- Optional parameters
for _,o in ipairs(protoptions) do
if o.name ~= nil then
for _, d in ipairs(o.depends) do
if d == "static" then
if o.name == "table" then
value = sect_static_protos:option(ListValue, o.name, translate(o.name), translate(o.help))
uciout:foreach("bird4", "table",
function (s)
value:value(s.name)
end)
value:value("")
else
value = sect_static_protos:option(Value, o.name, translate(o.name), translate(o.help))
end
value.optional = true
value.rmempty = true
end
end
end
end
--
-- ROUTES FOR STATIC PROTOCOL
--
sect_routes = m:section(TypedSection, "route", "Routes configuration", "Configuration of the routes used in static protocols.")
sect_routes.addremove = true
sect_routes.anonymous = true
instance = sect_routes:option(ListValue, "instance", "Route instance", "")
i = 0
uciout:foreach("bird4", "static",
function (s)
instance:value(s[".name"])
end)
prefix = sect_routes:option(Value, "prefix", "Route prefix", "")
type = sect_routes:option(ListValue, "type", "Type of route", "")
type:value("router")
type:value("special")
type:value("iface")
type:value("recursive")
type:value("multipath")
valueVia = sect_routes:option(Value, "via", "Via", "")
valueVia.optional = false
valueVia:depends("type", "router")
valueVia.datatype = "ip4addr"
listVia = sect_routes:option(DynamicList, "l_via", "Via", "")
listVia:depends("type", "multipath")
listVia.optional=false
listVia.datatype = "ip4addr"
attribute = sect_routes:option(Value, "attribute", "Attribute", "Types are: unreachable, prohibit and blackhole")
attribute:depends("type", "special")
iface = sect_routes:option(ListValue, "iface", "Interface", "")
iface:depends("type", "iface")
uciout:foreach("wireless", "wifi-iface",
function(section)
iface:value(section[".name"])
end)
ip = sect_routes:option(Value, "ip", "IP address", "")
ip:depends("type", "ip")
ip.datatype = [[ or"ip4addr", "ip6addr" ]]
function m.on_commit(self,map)
luci.sys.call('/etc/init.d/bird4 stop; /etc/init.d/bird4 start')
end
return m

View file

@ -0,0 +1,77 @@
--[[
Copyright (C) 2014 - Eloi Carbó Solé (GSoC2014)
BGP/Bird integration with OpenWRT and QMP
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
]]--
require("luci.sys")
local http = require "luci.http"
local uci = require "luci.model.uci"
local uciout = uci.cursor()
m=Map("bird4", "Bird4 UCI configuration helper", "")
-- Named section: "bird"
s_bird_uci = m:section(NamedSection, "bird", "bird", "Bird4 file settings", "")
s_bird_uci.addremove = False
uuc = s_bird_uci:option(Flag, "use_UCI_config", "Use UCI configuration", "Use UCI configuration instead of the /etc/bird4.conf file")
ucf = s_bird_uci:option(Value, "UCI_config_File", "UCI File", "Specify the file to place the UCI-translated configuration")
ucf.default = "/tmp/bird4.conf"
-- Named Section: "table"
s_bird_table = m:section(TypedSection, "table", "Tables configuration", "Configuration of the tables used in the protocols")
s_bird_table.addremove = true
s_bird_table.anonymous = true
name = s_bird_table:option(Value, "name", "Table name", "Descriptor ID of the table")
-- Named section: "global"
s_bird_global = m:section(NamedSection, "global", "global", "Global options", "Basic Bird4 settings")
s_bird_global.addremove = False
id = s_bird_global:option(Value, "router_id", "Router ID", "Identification number of the router. By default, is the router's IP.")
lf = s_bird_global:option(Value, "log_file", "Log File", "File used to store log related data.")
l = s_bird_global:option(MultiValue, "log", "Log", "Set which elements do you want to log.")
l:value("all", "All")
l:value("info", "Info")
l:value("warning","Warning")
l:value("error","Error")
l:value("fatal","Fatal")
l:value("debug","Debug")
l:value("trace","Trace")
l:value("remote","Remote")
l:value("auth","Auth")
d = s_bird_global:option(MultiValue, "debug", "Debug", "Set which elements do you want to debug.")
d:value("all", "All")
d:value("states","States")
d:value("routes","Routes")
d:value("filters","Filters")
d:value("interfaces","Interfaces")
d:value("events","Events")
d:value("packets","Packets")
function m.on_commit(self,map)
luci.sys.call('/etc/init.d/bird4 stop; /etc/init.d/bird4 start')
end
return m

View file

@ -0,0 +1,7 @@
#!/bin/sh
EXC=`mount -t overlayfs | grep overlayfs -c`
[ $EXC > 0 ] && rm -r /etc/init.d/bird4 || mv /etc/init.d/bird4 /etc/bird4/init.d/bird4.orig
ln -s /etc/bird4/init.d/bird4 /etc/init.d/bird4

View file

@ -0,0 +1,92 @@
# Copyright (C) 2014 - Eloi Carbó Solé (GSoC2014)
# BGP/Bird integration with OpenWRT and QMP
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
BIRD:=bird6
PKG_NAME:=$(BIRD)-openwrt
PKG_RELEASE:=0.2
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
PKG_LICENSE:=GPL-3.0+
uci:=$(BIRD)-uci
luci:=luci-app-$(BIRD)
include $(INCLUDE_DIR)/package.mk
define Build/Prepare
endef
define Build/Compile
endef
define Package/$(uci)
TITLE:=The BIRD UCI module
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
MAINTAINER:=Eloi Carbo <eloicaso@openmailbox.org>
URL:=https://github.com/eloicaso/bird6-openwrt/
DEPENDS:=+$(BIRD) +libuci +uci
endef
define Package/$(uci)/description
$(BIRD) UCI integration module
endef
define Package/$(uci)/install
$(INSTALL_DIR) $(1)/etc/$(BIRD)/init.d
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_BIN) ./src/init.d/$(BIRD) $(1)/etc/$(BIRD)/init.d/
$(CP) ./src/uci-defaults/$(uci)-install-init.d $(1)/etc/$(BIRD)/init.d/
$(CP) ./src/config/$(BIRD) $(1)/etc/config/
endef
define Package/$(uci)/postinst
#!/bin/sh
if [ -z $${IPKG_INSTROOT} ]; then
( . /etc/bird6/init.d/bird6-uci-install-init.d ) && rm -f /etc/bird6/init.d/bird6-uci-install-init.d
fi
endef
$(eval $(call BuildPackage,$(uci)))
define Package/$(luci)
TITLE:=LuCI support for $(BIRD)
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=3. Applications
MAINTAINER:=Eloi Carbo <eloicaso@openmailbox.org>
URL:=https://github.com/eloicaso/bird6-openwrt/
DEPENDS:=+$(BIRD)-uci +luci-base
endef
define Package/$(luci)/description
$(BIRD) application for LuCI
endef
define Package/$(luci)/install
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller/
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/$(BIRD)/
$(CP) ./src/model/* $(1)/usr/lib/lua/luci/model/cbi/$(BIRD)/
$(CP) ./src/controller/* $(1)/usr/lib/lua/luci/controller/
endef
$(eval $(call BuildPackage,$(luci)))

View file

@ -0,0 +1,80 @@
config bird 'bird'
option use_UCI_config '1'
#Caution! Enabling this option, Bird will translate this
#UCI file and use it instead of /etc/bird6.conf
option UCI_config_file '/tmp/bird6.conf'
#If you enable useUCIconfig, UCIconfigFile will be Bird's
#configuration file location.
config global 'global'
option log_file '/tmp/bird6.log'
option log 'all'
option debug 'off'
option router_id 'fc00::1:5'
option listen_bgp_addr 'fc00::1:5'
option listen_bgp_port '179'
option listen_bgp_dual '1'
config table
option name 'aux'
config kernel kernel1
option table 'aux'
option import 'all'
option export 'all'
option kernel_table '100'
option scan_time '10'
option learn '1'
option persist '0'
option disabled '0'
config device device1
option scan_time '10'
option disabled '0'
config static static1
option table 'aux'
option disabled '0'
config bgp bgp1
option template 'bgp_common'
option description 'Description of the BGP instance'
option neighbor_address 'fc00::1:5'
option neighbor_as '65530'
option next_hop_self '0'
option next_hop_keep '0'
option rr_client '1'
option rr_cluster_id 'fc00::1:5'
config bgp_template bgp_common
option table 'aux'
option import 'all'
option export 'all'
option local_address '2001:B30:1000:19::2'
option local_as '65001'
option import_limit '100'
option import_limit_action 'warn'
option export_limit '100'
option export_limit_action 'warn'
option receive_limit '100'
option receive_limit_action 'warn'
option disabled '0'
config route
option instance 'static1'
option type 'router'
option prefix '2001:db8:0:f103::/64'
option via 'fe80::225:90ff:fe97:a718'
config route
option instance 'static1'
option type 'special'
option prefix '2001:db8:0:f101::/128'
option attribute 'unreachable'
config route
option instance 'static1'
option type 'iface'
option prefix '2001:db8:0:f101::1111/128'
option iface 'eth0'

View file

@ -0,0 +1,27 @@
--[[
Copyright (C) 2014 - Eloi Carbó Solé (GSoC2014)
BGP/Bird integration with OpenWRT and QMP
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
--]]
module("luci.controller.bird6", package.seeall)
function index()
entry({"admin","network","bird6"}, cbi("bird6/overview"), "Bird6", 1).dependent=false
entry({"admin","network","bird6","overview"}, cbi("bird6/overview"), "Overview", 2).dependent=false
entry({"admin","network","bird6","proto_general"}, cbi("bird6/gen_proto"), "General protocols", 3).dependent=false
entry({"admin","network","bird6","proto_bgp"}, cbi("bird6/bgp_proto"), "BGP Protocol", 4).dependent=false
end

View file

@ -0,0 +1,421 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2014 - Eloi Carbó Solé (GSoC2014)
# BGP/Bird integration with OpenWRT and QMP
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
BIRD="bird6"
BIRD_CONFIG="/etc/$BIRD.conf"
START=99
STOP=10
SERVICE_DAEMONIZE=1
SERVICE_USE_PID=1
SERVICE_PID_FILE="/var/run/$BIRD.pid"
BIRD_BIN="/usr/sbin/$BIRD"
# Function: writeToConfig $1
# $1 string.
# Allows to write in the $BIRD_CONFIG file, the string $1. This function does not check the $1 string.
# Example: writeToConfig "value: $N"
writeToConfig() {
echo "$1" >> $BIRD_CONFIG
}
# Function: write $1 $2
# $1 string. $2 string.
# This function checks if $2 is empty. If not, it writes the string $1 in the $BIRD_CONFIG file.
# Use write function to check if $1, value found inside $2, is not empty and can be written in the configuration file.
# Example:
N=""; write "value: $N" $N;
write() {
[ -n "$2" ] && writeToConfig "$1"
}
#Function: write_bool $1 $2
# $1 string; $2 boolean
# This function checks if $2 is true or false and write the $1 string into $BIRD_CONFIG file.
# The function writes a # before the $2 string if its false.
# Example: local N=0; write_bool $N
write_bool() {
[ "$2" == 0 ] && writeToConfig "# $1;" || writeToConfig " $1;"
}
# Function: get $1 $2
# $1 string. $2 string
# This function uses the external UCI function "config_get $result $section $option" to obtain a string value from UCI config file.
# To use this function, use the same name of the UCI option for the variable.
# Example: UCI (option id 'abcd'); local id; get id $section
get() {
config_get $1 $2 $1
}
# Function: get_bool $1 $2
# $1 boolean. $2 string
# This function uses the external UCI function "config_get_bool $result $section $option" to obtain a boolean value from UCI config file.
# To use this function, use the same name of the UCI option for the variable $1.
# Example: UCI (option use_ipv6 '1'); local use_ipv6; get use_ipv6 $section
get_bool() {
config_get_bool $1 $2 $1
}
# Function: multipath_list $1
# $1 string
# This function writes the $1 string in the multipath routes.
multipath_list() {
write " via $1" $1
}
# Function: prepare_tables $1
# $1 string
# This function gets each "table" section in the UCI configuration and sets each option in the bird6.conf file.
# $1 is set as the ID of the current UCI table section
prepare_tables() {
local section="$1"; local name
get name $section
write "table $name;" $name
}
# Function: prepare_global $1
# $1 string
# This function gets each "global" section in the UCI configuration and sets each option in the bird6.conf file.
# $1 is set as the ID of the current UCI global section. prepare_global is the first configuration set in the bird6.conf and removes the old file.
prepare_global () {
local section="$1"
local log_file; local log; local debug; local router_id; local table; local listen_bgp_addr; local listen_bgp_port; local listen_bgp_dual
# Remove old configuration file
rm -f "$BIRD_CONFIG"
get log_file $section
get log $section
get debug $section
get router_id $section
get table $section
get listen_bgp_addr $section
get listen_bgp_port $section
get listen_bgp_dual $section
# First line of the NEW configuration file
echo "#Bird6 configuration using UCI:" > $BIRD_CONFIG
writeToConfig " "
[ -n "$log_file" -a -n "$log" ] && writeToConfig 'log "'$log_file'" '$log';'
write "debug protocols $debug;" $debug
writeToConfig " "
writeToConfig "#Router ID"
write "router id $router_id;" $router_id
writeToConfig " "
writeToConfig "#Secondary tables"
config_foreach prepare_tables 'table'
if [ -n "$listen_bgp_dual" -o "$listen_bgp_dual" = "0" ]; then
writeToConfig "listen bgp $listen_bgp_addr $listen_bgp_port v6only;"
else
writeToConfig "listen bgp $listen_bgp_addr $listen_bgp_port dual;"
fi
writeToConfig " "
}
# Function: prepare_routes $1
# $1 string
# This function gets each "route" section in the UCI configuration and sets each option in the bird6.conf file.
# $1 is set as the ID of the current UCI route section. Each type of route has its own treatment.
prepare_routes() {
local instance; local prefix; local via; local type
local section="$1"
local protoInstance="$2"
get instance $section
if [ "$instance" = "$protoInstance" ]; then
get type $section
case "$type" in
"router")
get prefix $section
get via $section
[ -n "$prefix" -a -n "$via" ] && writeToConfig " route $prefix via $via;"
;;
"special")
get prefix $section
get attribute $section
[ -n "$prefix" -a -n "$attribute" ] && writeToConfig " route $prefix $attribute;"
;;
"iface")
get prefix $section
get iface $section
[ -n "$prefix" -a -n "$iface" ] && writeToConfig ' route '$prefix' via "'$iface'";'
;;
"multipath")
get prefix $section
write " route $prefix multipath" $prefix
config_list_foreach $section l_via multipath_list
writeToConfig " ;"
;;
esac
fi
}
# Function: prepare_kernel $1
# $1 string
# This function gets each "kernel" protocol section in the UCI configuration and sets each option in the bird6.conf file.
# $1 is set as the ID of the current UCI kernel section.
prepare_kernel() {
local section="$1"
write "#$section configuration:" $section
local disabled; local table; local kernel_table; local import; local export; local scan_time; local persist; local learn
get_bool disabled $section
get table $section
get import $section
get export $section
get scan_time $section
get kernel_table $section
get learn $section
get persist $section
writeToConfig "protocol kernel {"
write_bool disabled $disabled
write " table $table;" $table
write " kernel table $kernel_table;" $kernel_table
write_bool learn $learn
write_bool persist $persist
write " scan time $scan_time;" $scan_time
write " import $import;" $import
write " export $export;" $export
writeToConfig "}"
writeToConfig " "
}
# Function: prepare_static $1
# $1 string
# This function gets each "static" protocol section in the UCI configuration and sets each option in the bird6.conf file.
# $1 is set as the ID of the current UCI static section.
prepare_static() {
local section="$1"
local disabled
get disabled $section
if [ "$disabled" -eq 0 ]; then
local table
get table $section
writeToConfig "#$section configration:" $section
writeToConfig "protocol static {"
write " table $table;" $table
config_foreach prepare_routes 'route' $section
writeToConfig "}"
writeToConfig " "
fi
}
# Function: prepare_device $1
# $1 string
# This function gets each "device" protocol section in the UCI configuration and sets each option in the bird6.conf file.
# $1 is set as the ID of the current UCI device section.
prepare_device() {
local section="$1"
local disabled; local scan_time
get disabled $section
get scan_time $section
write "#$section configuration:" $section
writeToConfig "protocol device {"
write_bool disabled $disabled
write " scan time $scan_time;" $scan_time
writeToConfig "}"
writeToConfig " "
}
# Function: prepare_bgp_template $1
# $1 string
# This function gets each "bgp_template" protocol section in the UCI configuration and sets each option in the bird6.conf file.
# $1 is set as the ID of the current UCI bgp_template section.
# Careful! Template options will be replaced by "instance" options if there is any match.
prepare_bgp_template() {
local section="$1"
local disabled; local table; local import; local export; local local_address; local local_as; local neighbor_address; local neighbor_as; local source_address; local next_hop_self; local next_hop_keep; local rr_client; local rr_cluster_id; local import_limit; local import_limit_action; local export_limit; local export_limit_action; local receive_limit; local receive_limit_action
get_bool disabled $section
get_bool next_hop_self $section
get_bool next_hop_keep $section
get table $section
get import $section
get export $section
get local_address $section
get local_as $section
get rr_client $section
get rr_cluster_id $section
get import_limit $section
get import_limit_action $section
get export_limit $section
get export_limit_action $section
get receive_limit $section
get receive_limit_action $section
get neighbor_address $section
get neighbor_as $section
writeToConfig "#$section template:"
writeToConfig "template bgp $section {"
[ -n "$disabled" ] && write_bool disabled $disabled
write " table $table;" $table
write " local as $local_as;" $local_as
write " source address $local_address;" $local_address
write " import $import;" $import
write " export $export;" $export
if [ -n "$next_hop_self" ]; then
[ "$next_hop_self" = "1" ] && writeToConfig " next hop self;" || writeToConfig "# next hop self;"
fi
if [ -n "$next_hop_keep" ]; then
[ "$next_hop_keep" = "1" ] && writeToConfig " next hop keep;" || writeToConfig "# next hop keep;"
fi
[ "$rr_client" = "1" ] && writeToConfig " rr client;" || writeToConfig "# rr client;"
write " rr cluster id $rr_cluster_id;" $rr_cluster_id
if [ -n "$import_limit" -a "$import_limit" > "0" ]; then
[ -z "$import_limit_action" ] && $import_limit_action = "warn"
writeToConfig " import limit $import_limit action $import_limit_action;"
fi
if [ -n "$export_limit" -a "$export_limit" > "0" ]; then
[ -z "$export_limit_action" ] && $export_limit_action = "warn"
writeToConfig " export limit $export_limit action $export_limit_action;"
fi
if [ -n "$receive_limit" -a "$receive_limit" > "0" ]; then
[ -z "$receive_limit_action" ] && $receive_limit_action = "warn"
writeToConfig " receive limit $receive_limit action $receive_limit_action;"
fi
[ -n "$neighbor_address" -a -n "$neighbor_as" ] && writeToConfig " neighbor $neighbor_address as $neighbor_as;"
writeToConfig "}"
writeToConfig " "
}
# Function: prepare_bgp $1
# $1 string
# This function gets each "bgp" protocol section in the UCI configuration and sets each option in the bird6.conf file.
# $1 is set as the ID of the current UCI bgp section.
# Careful! The options set in bgp instances overlap bgp_template ones.
prepare_bgp() {
local section="$1"
local disabled; local table; local template; local description; local import; local export; local local_address; local local_as; local neighbor_address; local neighbor_as; local rr_client; local rr_cluster_id; local import_limit; local import_limit_action; local export_limit; local export_limit_action; local receive_limit; local receive_limit_action
get disabled $section
get table $section
get template $section
get description $section
get import $section
get export $section
get local_address $section
get local_as $section
get rr_client $section
get rr_cluster_id $section
get import_limit $section
get import_limit_action $section
get export_limit $section
get export_limit_action $section
get receive_limit $section
get receive_limit_action $section
get neighbor_address $section
get neighbor_as $section
writeToConfig "#$section configuration:"
[ -n "$template" ] && writeToConfig "protocol bgp $section from $template {" || writeToConfig "protocol bgp $section {"
[ -n "$disabled" ] && write_bool disabled $disabled
write " table $table;" $table
# [ -n "$description" ] && writeToConfig ' description "'$description'";'
write " local as $local_as;" $local_as
write " source address $local_address;" $local_address
write " import $import;" $import
write " export $export;" $export
if [ -n "$next_hop_self" ]; then
[ "$next_hop_self" = "1" ] && writeToConfig " next hop self;" || writeToConfig "# next hop self;"
fi
if [ -n "$next_hop_keep" ]; then
[ "$next_hop_keep" = "1" ] && writeToConfig " next hop keep;" || writeToConfig "# next hop keep;"
fi
[ "$rr_client" = "1" ] && writeToConfig " rr client;" || writeToConfig "# rr client;"
write " rr cluster id $rr_cluster_id;" $rr_cluster_id
if [ -n "$import_limit" -a "$import_limit" > "0" ]; then
[ -z "$import_limit_action" ] && $import_limit_action = "warn"
writeToConfig " import limit $import_limit action $import_limit_action;"
fi
if [ -n "$export_limit" -a "$export_limit" > "0" ]; then
[ -z "$export_limit_action" ] && $export_limit_action = "warn"
writeToConfig " export limit $export_limit action $export_limit_action;"
fi
if [ -n "$receive_limit" -a "$receive_limit" > "0" ]; then
[ -z "$receive_limit_action" ] && $receive_limit_action = "warn"
writeToConfig " receive limit $receive_limit action $receive_limit_action;"
fi
[ -n "$neighbor_address" -a -n "$neighbor_as" ] && writeToConfig " neighbor $neighbor_address as $neighbor_as;"
writeToConfig "}"
writeToConfig " "
}
# Function: prepare_bgp_filters $1
# $1 string
# This function gets each "bgp_filter" protocol section in the UCI configuration and sets each option in the bird6.conf file.
# $1 is set as the ID of the current UCI bgp_filter section.
# This function checks if the filter file exists and, in that case, it writes its content to the configuration file.
prepare_bgp_filters() {
local section="$1"
local type
local file_path
get type $section
get file_path $section
if [ -e "$file_path" ]; then
local filter_content=`cat $file_path`
if [ -n "$type" -a "$type" = "bgp" ]; then
writeToConfig "#Filter $section:"
writeToConfig "${filter_content}"
writeToConfig " "
fi
fi
}
start() {
config_load bird6
local use_UCI_config
get use_UCI_config 'bird'
if [ -z "$use_UCI_config" -o "$use_UCI_config" = "0" ]; then
service_start $BIRD_BIN -d -c $BIRD_CONFIG -P $SERVICE_PID_FILE
else
#Set Bird6 configuration location:
local UCI_config_File
get UCI_config_File 'bird'
BIRD_CONFIG=${UCI_config_File:-/tmp/bird6.conf}
#Setup the basic configuration
prepare_global 'global'
config_foreach prepare_kernel 'kernel'
config_foreach prepare_static 'static'
config_foreach prepare_device 'device'
#config_foreach prepare_direct 'direct'
#Setup the protocols configuration (currently BGP only)
config_foreach prepare_bgp_template 'bgp_template'
config_foreach prepare_bgp 'bgp'
config_foreach prepare_bgp_filters 'filter'
#Start the service
service_start $BIRD_BIN -d -c $BIRD_CONFIG -P $SERVICE_PID_FILE
fi
}
stop() {
service_stop $BIRD_BIN
}
restart() {
stop
start
}
reload() {
service_reload $BIRD_BIN
}

View file

@ -0,0 +1,237 @@
--[[
Copyright (C) 2014 - Eloi Carbó Solé (GSoC2014)
BGP/Bird integration with OpenWRT and QMP
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
--]]
require("luci.sys")
local http = require "luci.http"
local uci = require "luci.model.uci"
local uciout = uci.cursor()
m=Map("bird6", "Bird6 BGP protocol's configuration")
tab_templates = {}
uciout:foreach('bird6', 'bgp_template', function (s)
local name = s[".name"]
if (name ~= nil) then
table.insert(tab_templates, name)
end
end)
-- Section BGP Templates
sect_templates = m:section(TypedSection, "bgp_template", "BGP Templates", "Configuration of the templates used in BGP instances.")
sect_templates.addremove = true
sect_templates.anonymous = false
disabled = sect_templates:option(Flag, "disabled", "Disabled", "Enable/Disable BGP Protocol")
disabled.optional=true
table = sect_templates:option(ListValue, "table", "Table", "Set the table used for BGP Routing")
table.optional=true
uciout:foreach("bird6", "table",
function (s)
table:value(s.name)
end)
table:value("")
import = sect_templates:option(Value, "import", "Import","")
import.optional=true
export = sect_templates:option(Value, "export", "Export", "")
export.optional=true
source_addr = sect_templates:option(Value, "source_address", "Source Address", "Source address for BGP routing. By default uses Router ID")
source_addr.optional = true
description = sect_templates:option(TextValue, "description", "Description", "Description of the current BGP instance")
description.optional = true
next_hop_self = sect_templates:option(Flag, "next_hop_self", "Next hop self", "Avoid next hop calculation and advertise own source address as next hop")
next_hop_self.default = nil
next_hop_self.optional = true
next_hop_keep = sect_templates:option(Flag, "next_hop_keep", "Next hop keep", "Forward the received Next Hop attribute event in situations where the local address should be used instead, like subneting")
next_hop_keep.default = nil
next_hop_keep.optional = true
rr_client = sect_templates:option(Flag, "rr_client", "Route Reflector server", "This router serves as a Route Reflector server and treats neighbors as clients")
rr_client.default = nil
rr_client.optional = true
rr_cluster_id = sect_templates:option(Value, "rr_cluster_id", "Route Reflector Cluster ID", "Identificator of the RR cluster. By default uses the Router ID")
rr_cluster_id.optional = true
import_limit = sect_templates:option(Value, "import_limit", "Routes import limit", "Specify an import route limit. By default is disabled '0'")
import_limit.default= "0"
import_limit.optional = true
import_limit_action = sect_templates:option(ListValue, "import_limit_action", "Routes import limit action", "Action to take when import routes limit ir reached")
import_limit_action:value("warn")
import_limit_action:value("block")
import_limit_action:value("disable")
import_limit_action:value("restart")
import_limit_action.default = "warn"
import_limit_action.optional = true
export_limit = sect_templates:option(Value, "export_limit", "Routes export limit", "Specify an export route limit. By default is disabled '0'")
export_limit.default="0"
export_limit.optional = true
export_limit_action = sect_templates:option(ListValue, "export_limit_action", "Routes export limit action", "Action to take when export routes limit is reached")
export_limit_action:value("warn")
export_limit_action:value("block")
export_limit_action:value("disable")
export_limit_action:value("restart")
export_limit_action.default = "warn"
export_limit_action.optional = true
receive_limit = sect_templates:option(Value, "receive_limit", "Routes received limit", "Specify a received route limit. By default is disabled '0'")
receive_limit.default="0"
receive_limit.optional = true
receive_limit_action = sect_templates:option(ListValue, "receive_limit_action", "Routes received limit action", "Action to take when received routes limit is reached")
receive_limit_action:value("warn")
receive_limit_action:value("block")
receive_limit_action:value("disable")
receive_limit_action:value("restart")
receive_limit_action.default = "warn"
receive_limit_action.optional = true
local_address = sect_templates:option(Value, "local_address", "Local BGP address", "")
local_address.optional=true
local_as = sect_templates:option(Value, "local_as", "Local AS", "")
local_as.optional=true
-- Section BGP Instances:
sect_instances = m:section(TypedSection, "bgp", "BGP Instances", "Configuration of the BGP protocol instances")
sect_instances.addremove = true
sect_instances.anonymous = false
templates = sect_instances:option(ListValue, "template", "Templates", "Available BGP templates")
uciout:foreach("bird6", "bgp_template",
function(s)
templates:value(s[".name"])
end)
templates:value("")
neighbor_address = sect_instances:option(Value, "neighbor_address", "Neighbor IP Address", "")
neighbor_as = sect_instances:option(Value, "neighbor_as", "Neighbor AS", "")
disabled = sect_instances:option(Flag, "disabled", "Disabled", "Enable/Disable BGP Protocol")
disabled.optional=true
disabled.default=nil
table = sect_instances:option(ListValue, "table", "Table", "Set the table used for BGP Routing")
table.optional=true
uciout:foreach("bird6", "table",
function (s)
table:value(s.name)
end)
table:value("")
description = sect_instances:option(TextValue, "description", "Description", "Description of the current BGP instance")
description.optional = true
import = sect_instances:option(Value, "import", "Import","")
import.optional=true
export = sect_instances:option(Value, "export", "Export", "")
export.optional=true
source_addr = sect_instances:option(Value, "source_address", "Source Address", "Source address for BGP routing. By default uses Router ID")
source_addr.optional = true
local_address = sect_instances:option(Value, "local_address", "Local BGP address", "")
local_address.optional=true
local_as = sect_instances:option(Value, "local_as", "Local AS", "")
local_as.optional=true
next_hop_self = sect_instances:option(Flag, "next_hop_self", "Next hop self", "Avoid next hop calculation and advertise own source address as next hop")
next_hop_self.default = nil
next_hop_self.optional = true
next_hop_keep = sect_instances:option(Flag, "next_hop_keep", "Next hop keep", "Forward the received Next Hop attribute event in situations where the local address should be used instead, like subneting")
next_hop_keep.default = nil
next_hop_keep.optional = true
rr_client = sect_instances:option(Flag, "rr_client", "Route Reflector server", "This router serves as a Route Reflector server and treats neighbors as clients")
rr_client.default = nil
rr_client.optional = true
rr_cluster_id = sect_instances:option(Value, "rr_cluster_id", "Route Reflector Cluster ID", "Identificator of the RR cluster. By default uses the Router ID")
rr_cluster_id.optional = true
import_limit = sect_instances:option(Value, "import_limit", "Routes import limit", "Specify an import route limit. By default is disabled '0'")
import_limit.default="0"
import_limit.optional = true
import_limit_action = sect_instances:option(ListValue, "import_limit_action", "Routes import limit action", "Action to take when import routes limit ir reached")
import_limit_action:value("warn")
import_limit_action:value("block")
import_limit_action:value("disable")
import_limit_action:value("restart")
import_limit_action.default = "warn"
import_limit_action.optional = true
export_limit = sect_instances:option(Value, "export_limit", "Routes export limit", "Specify an export route limit. By default is disabled '0'")
export_limit.default="0"
export_limit.optional = true
export_limit_action = sect_instances:option(ListValue, "export_limit_action", "Routes export limit action", "Action to take when export routes limit is reached")
export_limit_action:value("warn")
export_limit_action:value("block")
export_limit_action:value("disable")
export_limit_action:value("restart")
export_limit_action.default = "warn"
export_limit_action.optional = true
receive_limit = sect_instances:option(Value, "receive_limit", "Routes received limit", "Specify a received route limit. By default is disabled '0'")
receive_limit.default="0"
receive_limit.optional = true
receive_limit_action = sect_instances:option(ListValue, "receive_limit_action", "Routes received limit action", "Action to take when received routes limit is reached")
receive_limit_action:value("warn")
receive_limit_action:value("block")
receive_limit_action:value("disable")
receive_limit_action:value("restart")
receive_limit_action.default = "warn"
receive_limit_action.optional = true
-- Section BGP Filters
sect_filters = m:section(TypedSection, "filter", "BGP Filters", "Filters of the BGP instances")
sect_filters.addremove = true
sect_filters.anonymous = false
sect_filters:depends("type", "bgp")
instance = sect_filters:option(ListValue, "instance", "BGP instance", "Filter's BGP instance")
instance:depends("type", "bgp")
uciout:foreach("bird6", "bgp",
function (s)
instance:value(s[".name"])
end)
type = sect_filters:option(Value, "type", "Filter type", "")
type.default = "bgp"
path = sect_filters:option(Value, "file_path", "Filter's file path", "Path to the Filter's file")
path:depends("type", "bgp")
function m.on_commit(self,map)
luci.sys.call('/etc/init.d/bird6 stop; /etc/init.d/bird6 start')
end
return m

View file

@ -0,0 +1,201 @@
--[[
Copyright (C) 2014 - Eloi Carbó Solé (GSoC2014)
BGP/Bird integration with OpenWRT and QMP
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
--]]
require("luci.sys")
local http = require "luci.http"
local uci = require "luci.model.uci"
local uciout = uci.cursor()
m=Map("bird6", "Bird6 general protocol's configuration.")
-- Optional parameters lists
local protoptions = {
{["name"]="table", ["help"]="Auxiliar table for routing", ["depends"]={"static","kernel"}},
{["name"]="import", ["help"]="Set if the protocol must import routes", ["depends"]={"kernel"}},
{["name"]="export", ["help"]="Set if the protocol must export routes", ["depends"]={"kernel"}},
{["name"]="scan_time", ["help"]="Time between scans", ["depends"]={"kernel","device"}},
{["name"]="kernel_table", ["help"]="Set which table must be used as auxiliar kernel table", ["depends"]={"kernel"}},
{["name"]="learn", ["help"]="Learn routes", ["depends"]={"kernel"}},
{["name"]="persist", ["help"]="Store routes. After a restart, routes will be still configured", ["depends"]={"kernel"}}
}
local routeroptions = {
{["name"]="prefix",["help"]="",["depends"]={"router","special","iface","multipath","recursive"}},
{["name"]="via",["help"]="",["depends"]={"router","multipath"}},
{["name"]="attribute",["help"]="",["depends"]={"special"}},
{["name"]="iface",["help"]="",["depends"]={"iface"}},
{["name"]="ip",["help"]="",["depends"]={"recursive"}}
}
--
-- KERNEL PROTOCOL
--
sect_kernel_protos = m:section(TypedSection, "kernel", "Kernel options", "Configuration of the kernel protocols. First Instance MUST be Primary table (no table or kernel_table fields).")
sect_kernel_protos.addremove = true
sect_kernel_protos.anonymous = false
-- Default kernel parameters
disabled = sect_kernel_protos:option(Flag, "disabled", "Disabled", "If this option is true, the protocol will not be configured.")
disabled.default=0
-- Optional parameters
for _,o in ipairs(protoptions) do
if o.name ~= nil then
for _, d in ipairs(o.depends) do
if d == "kernel" then
if o.name == "learn" or o.name == "persist" then
value = sect_kernel_protos:option(Flag, o.name, translate(o.name), translate(o.help))
elseif o.name == "table" then
value = sect_kernel_protos:option(ListValue, o.name, translate(o.name), translate(o.help))
uciout:foreach("bird6", "table",
function (s)
value:value(s.name)
end)
value:value("")
else
value = sect_kernel_protos:option(Value, o.name, translate(o.name), translate(o.help))
end
value.optional = true
value.rmempty = true
end
end
end
end
--
-- DEVICE PROTOCOL
--
sect_device_protos = m:section(TypedSection, "device", "Device options", "Configuration of the device protocols.")
sect_device_protos.addremove = true
sect_device_protos.anonymous = false
-- Default kernel parameters
disabled = sect_device_protos:option(Flag, "disabled", "Disabled", "If this option is true, the protocol will not be configured.")
disabled.default=0
-- Optional parameters
for _,o in ipairs(protoptions) do
if o.name ~= nil then
for _, d in ipairs(o.depends) do
if d == "device" then
value = sect_device_protos:option(Value, o.name, translate(o.name), translate(o.help))
value.optional = true
value.rmempty = true
end
end
end
end
--
-- STATIC PROTOCOL
--
sect_static_protos = m:section(TypedSection, "static", "Static options", "Configuration of the static protocols.")
sect_static_protos.addremove = true
sect_static_protos.anonymous = false
-- Default kernel parameters
disabled = sect_static_protos:option(Flag, "disabled", "Disabled", "If this option is true, the protocol will not be configured.")
disabled.default=0
-- Optional parameters
for _,o in ipairs(protoptions) do
if o.name ~= nil then
for _, d in ipairs(o.depends) do
if d == "static" then
if o.name == "table" then
value = sect_static_protos:option(ListValue, o.name, translate(o.name), translate(o.help))
uciout:foreach("bird6", "table",
function (s)
value:value(s.name)
end)
value:value("")
else
value = sect_static_protos:option(Value, o.name, translate(o.name), translate(o.help))
end
value.optional = true
value.rmempty = true
end
end
end
end
--
-- ROUTES FOR STATIC PROTOCOL
--
sect_routes = m:section(TypedSection, "route", "Routes configuration", "Configuration of the routes used in static protocols.")
sect_routes.addremove = true
sect_routes.anonymous = true
instance = sect_routes:option(ListValue, "instance", "Route instance", "")
i = 0
uciout:foreach("bird6", "static",
function (s)
instance:value(s[".name"])
end)
prefix = sect_routes:option(Value, "prefix", "Route prefix", "")
prefix.datatype = "ip6prefix"
type = sect_routes:option(ListValue, "type", "Type of route", "")
type:value("router")
type:value("special")
type:value("iface")
type:value("recursive")
type:value("multipath")
valueVia = sect_routes:option(Value, "via", "Via", "")
valueVia.optional = false
valueVia:depends("type", "router")
valueVia.datatype = "ip6addr"
listVia = sect_routes:option(DynamicList, "l_via", "Via", "")
listVia:depends("type", "multipath")
listVia.optional=false
listVia.datatype = "ip6addr"
attribute = sect_routes:option(Value, "attribute", "Attribute", "Types are: unreachable, prohibit and blackhole")
attribute:depends("type", "special")
iface = sect_routes:option(ListValue, "iface", "Interface", "")
iface:depends("type", "iface")
uciout:foreach("wireless", "wifi-iface",
function(section)
iface:value(section[".name"])
end)
ip = sect_routes:option(Value, "ip", "IP address", "")
ip:depends("type", "ip")
ip.datatype = [[ or"ip4addr", "ip6addr" ]]
function m.on_commit(self,map)
luci.sys.call('/etc/init.d/bird6 stop; /etc/init.d/bird6 start')
end
return m

View file

@ -0,0 +1,87 @@
--[[
Copyright (C) 2014 - Eloi Carbó Solé (GSoC2014)
BGP/Bird integration with OpenWRT and QMP
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
]]--
require("luci.sys")
local http = require "luci.http"
local uci = require "luci.model.uci"
local uciout = uci.cursor()
m=Map("bird6", "Bird6 UCI configuration helper", "")
-- Named section: "bird"
s_bird_uci = m:section(NamedSection, "bird", "bird", "Bird6 file settings", "")
s_bird_uci.addremove = False
uuc = s_bird_uci:option(Flag, "use_UCI_config", "Use UCI configuration", "Use UCI configuration instead of the /etc/bird6.conf file")
ucf = s_bird_uci:option(Value, "UCI_config_File", "UCI File", "Specify the file to place the UCI-translated configuration")
ucf.default = "/tmp/bird6.conf"
-- Named Section: "table"
s_bird_table = m:section(TypedSection, "table", "Tables configuration", "Configuration of the tables used in the protocols")
s_bird_table.addremove = true
s_bird_table.anonymous = true
name = s_bird_table:option(Value, "name", "Table name", "Descriptor ID of the table")
-- Named section: "global"
s_bird_global = m:section(NamedSection, "global", "global", "Global options", "Basic Bird6 settings")
s_bird_global.addremove = False
id = s_bird_global:option(Value, "router_id", "Router ID", "Identification number of the router. By default, is the router's IP.")
lf = s_bird_global:option(Value, "log_file", "Log File", "File used to store log related data.")
l = s_bird_global:option(MultiValue, "log", "Log", "Set which elements do you want to log.")
l:value("all", "All")
l:value("info", "Info")
l:value("warning","Warning")
l:value("error","Error")
l:value("fatal","Fatal")
l:value("debug","Debug")
l:value("trace","Trace")
l:value("remote","Remote")
l:value("auth","Auth")
d = s_bird_global:option(MultiValue, "debug", "Debug", "Set which elements do you want to debug.")
d:value("all", "All")
d:value("states","States")
d:value("routes","Routes")
d:value("filters","Filters")
d:value("interfaces","Interfaces")
d:value("events","Events")
d:value("packets","Packets")
listen_addr = s_bird_global:option(Value, "listen_bgp_addr", "BGP Address", "Set the Addres that BGP will listen to.")
listen_addr.optional = true
listen_port = s_bird_global:option(Value, "listen_bgp_port", "BGP Port", "Set the port that BGP will listen to.")
listen_port.optional = true
listen_dual = s_bird_global:option(Flag, "listen_bgp_dual", "BGP Dual/ipv6", "Set if BGP connections will listen ipv6 only 'ipv6only' or both ipv4/6 'dual' routes")
listen_dual.optional = true
function m.on_commit(self,map)
luci.sys.call('/etc/init.d/bird6 stop; /etc/init.d/bird6 start')
end
return m

View file

@ -0,0 +1,7 @@
#!/bin/sh
EXC=`mount -t overlayfs | grep overlayfs -c`
[ $EXC > 0 ] && rm -r /etc/init.d/bird6 || mv /etc/init.d/bird6 /etc/bird6/init.d/bird6.orig
ln -s /etc/bird6/init.d/bird6 /etc/init.d/bird6

210
bird/Makefile Normal file
View file

@ -0,0 +1,210 @@
#
# Copyright (C) 2009-2015 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
include $(TOPDIR)/rules.mk
PKG_NAME:=bird
PKG_VERSION:=1.4.5
PKG_RELEASE:=2
PKG_SOURCE:=bird-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=ftp://bird.network.cz/pub/bird
PKG_MD5SUM:=a8e5e0a9129ce30fe6102c593bafb763
PKG_BUILD_DEPENDS:=libncurses libreadline
PKG_LICENSE:=GPL-2.0
include $(INCLUDE_DIR)/package.mk
define Package/bird/Default
TITLE:=The BIRD Internet Routing Daemon
URL:=http://bird.network.cz/
DEPENDS:=+libpthread
endef
define Package/birdc/Default
TITLE:=The BIRD command-line client
URL:=http://bird.network.cz/
DEPENDS:= +libreadline +libncurses
endef
define Package/birdcl/Default
TITLE:=The BIRD lightweight command-line client
URL:=http://bird.network.cz/
endef
define Package/bird/Default/description1
BIRD is an internet routing daemon which manages TCP/IP routing tables
with support of modern routing protocols, easy to use configuration
interface and powerful route filtering language. It is lightweight and
efficient and therefore appropriate for small embedded routers.
endef
define Package/bird/Default/description2
In BGP, BIRD supports communities, multiprotocol extensions, MD5
authentication, 32bit AS numbers and could act as a route server or a
route reflector. BIRD also supports multiple RIBs, multiple kernel
routing tables and redistribution between the protocols with a powerful
configuration syntax.
endef
define Package/bird/Default/description3
This is a BIRD command-line client. It is used to send commands to BIRD,
commands can perform simple actions such as enabling/disabling of
protocols, telling BIRD to show various information, telling it to show
a routing table filtered by a filter, or asking BIRD to reconfigure.
Unless you can't afford dependency on ncurses and readline, you
should install BIRD command-line client together with BIRD.
endef
define Package/bird/Default/description4
This is a BIRD lightweight command-line client. It is used to send commands to BIRD,
commands can perform simple actions such as enabling/disabling of
protocols, telling BIRD to show various information, telling it to show
a routing table filtered by a filter, or asking BIRD to reconfigure.
endef
define Package/bird4
$(call Package/bird/Default)
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
TITLE+= (IPv4)
endef
define Package/birdc4
$(call Package/birdc/Default)
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
TITLE+= (IPv4)
DEPENDS+= +bird4
endef
define Package/birdcl4
$(call Package/birdcl/Default)
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
TITLE+= (IPv4)
DEPENDS+= +bird4
endef
define Package/bird6
$(call Package/bird/Default)
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
TITLE+= (IPv6)
endef
define Package/birdc6
$(call Package/birdc/Default)
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
TITLE+= (IPv6)
DEPENDS+= +bird6
endef
define Package/birdcl6
$(call Package/birdcl/Default)
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
TITLE+= (IPv6)
DEPENDS+= +bird6
endef
define Package/bird4/description
$(call Package/bird/Default/description1)
This is IPv4 version of BIRD, it supports OSPFv2, RIPv2 and BGP
protocols.
$(call Package/bird/Default/description2)
endef
define Package/birdc4/description
$(call Package/bird/Default/description1)
$(call Package/bird/Default/description3)
endef
define Package/birdcl4/description
$(call Package/bird/Default/description1)
$(call Package/bird/Default/description4)
endef
define Package/bird6/description
$(call Package/bird/Default/description1)
This is IPv6 version of BIRD, it supports OSPFv3, RIPng and BGP
protocols.
$(call Package/bird/Default/description2)
endef
define Package/birdc6/description
$(call Package/bird/Default/description1)
$(call Package/bird/Default/description3)
endef
define Package/birdcl6/description
$(call Package/bird/Default/description1)
$(call Package/bird/Default/description4)
endef
CONFIGURE_ARGS += --with-linux-headers="$(LINUX_DIR)"
define Build/Template
$(STAMP_BUILT)-$(2): $(STAMP_PREPARED)
$(call Build/Configure/Default,$(3))
$(call Build/Compile/Default,)
( cd $(PKG_BUILD_DIR); mv -f bird bird$(2); mv -f birdc birdc$(2); mv -f birdcl birdcl$(2) )
-$(MAKE) -C $(PKG_BUILD_DIR) clean
touch $$@
$(STAMP_BUILT): $(STAMP_BUILT)-$(2)
define Package/bird$(2)/install
$(INSTALL_DIR) $$(1)/usr/sbin
$(INSTALL_BIN) $$(PKG_BUILD_DIR)/bird$(2) $$(1)/usr/sbin/
$(INSTALL_DIR) $$(1)/etc
$(INSTALL_DATA) ./files/bird$(2).conf $$(1)/etc/
$(INSTALL_DIR) $$(1)/etc/init.d
$(INSTALL_BIN) ./files/bird$(2).init $$(1)/etc/init.d/bird$(2)
endef
define Package/bird$(2)/conffiles
/etc/bird$(2).conf
endef
define Package/birdc$(2)/install
$(INSTALL_DIR) $$(1)/usr/sbin
$(INSTALL_BIN) $$(PKG_BUILD_DIR)/birdc$(2) $$(1)/usr/sbin/
endef
define Package/birdcl$(2)/install
$(INSTALL_DIR) $$(1)/usr/sbin
$(INSTALL_BIN) $$(PKG_BUILD_DIR)/birdcl$(2) $$(1)/usr/sbin/
endef
endef
$(eval $(call Build/Template,bird4,4, --disable-ipv6))
$(eval $(call Build/Template,bird6,6, --enable-ipv6))
$(eval $(call BuildPackage,bird4))
$(eval $(call BuildPackage,birdc4))
$(eval $(call BuildPackage,birdcl4))
$(eval $(call BuildPackage,bird6))
$(eval $(call BuildPackage,birdc6))
$(eval $(call BuildPackage,birdcl6))

121
bird/files/bird4.conf Normal file
View file

@ -0,0 +1,121 @@
# THIS CONFIG FILE IS NOT A COMPLETE DOCUMENTATION
# PLEASE LOOK IN THE BIRD DOCUMENTATION FOR MORE INFO
# However, most of options used here are just for example
# and will be removed in real-life configs.
log syslog all;
# Override router ID
#router id 192.168.0.1;
# Turn on global debugging of all protocols
#debug protocols all;
# Define a route filter...
# filter test_filter {
# if net ~ 10.0.0.0/16 then accept;
# else reject;
# }
# The direct protocol automatically generates device routes to all network
# interfaces. Can exist in as many instances as you wish if you want to
# populate multiple routing tables with device routes. Because device routes
# are handled by Linux kernel, this protocol is usually not needed.
# protocol direct {
# interface "*"; # Restrict network interfaces it works with
# }
# This pseudo-protocol performs synchronization between BIRD's routing
# tables and the kernel. You can run multiple instances of the kernel
# protocol and synchronize different kernel tables with different BIRD tables.
protocol kernel {
# learn; # Learn all alien routes from the kernel
# persist; # Don't remove routes on bird shutdown
scan time 20; # Scan kernel routing table every 20 seconds
# import none; # Default is import all
# export all; # Default is export none
}
# This pseudo-protocol watches all interface up/down events.
protocol device {
scan time 10; # Scan interfaces every 10 seconds
}
# Static routes (again, there can be multiple instances, so that you
# can disable/enable various groups of static routes on the fly).
protocol static {
# export all; # Default is export none
# route 0.0.0.0/0 via 62.168.0.13;
# route 10.0.0.0/8 reject;
# route 192.168.0.0/16 reject;
}
#protocol rip {
# disabled;
# import all;
# export all;
# export filter test_filter;
# port 1520;
# period 7;
# infinity 16;
# garbage time 60;
# interface "*" { mode broadcast; };
# honor neighbor;
# honor always;
# honor never;
# authentication none;
#}
#protocol ospf {
# disabled;
# import all;
# export all;
# export where source = RTS_STATIC;
# area 0 {
# interface "eth*" {
# cost 10;
# hello 3;
# retransmit 2;
# wait 5;
# dead 20;
# type broadcast;
# authentication simple;
# password "pass";
# };
# };
#}
#protocol bgp {
# disabled;
# import all;
# export all;
# export where source = RTS_STATIC;
# local as 65000;
# neighbor 192.168.1.1 as 65001;
# multihop 20 via 192.168.2.1;
# hold time 240;
# startup hold time 240;
# connect retry time 120;
# keepalive time 80; # defaults to hold time / 3
# start delay time 5; # How long do we wait before initial connect
# error wait time 60, 300;# Minimum and maximum time we wait after an error (when consecutive
# # errors occur, we increase the delay exponentially ...
# error forget time 300; # ... until this timeout expires)
# disable after error; # Disable the protocol automatically when an error occurs
# next hop self; # Disable next hop processing and always advertise our local address as nexthop
# source address 62.168.0.14; # What local address we use for the TCP connection
# password "secret" # Password used for MD5 authentication
# rr client; # I am a route reflector and the neighor is my client
# rr cluster id 1.0.0.1 # Use this value for cluster id instead of my router id
# };
#}

26
bird/files/bird4.init Normal file
View file

@ -0,0 +1,26 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2010-2014 OpenWrt.org
BIRD="bird4"
START=99
STOP=10
SERVICE_DAEMONIZE=1
SERVICE_USE_PID=1
SERVICE_PID_FILE="/var/run/$BIRD.pid"
BIRD_BIN="/usr/sbin/$BIRD"
BIRD_CONF="/etc/$BIRD.conf"
start() {
service_start $BIRD_BIN -d -c $BIRD_CONF -P $SERVICE_PID_FILE
}
stop() {
service_stop $BIRD_BIN
}
reload() {
service_reload $BIRD_BIN
}

121
bird/files/bird6.conf Normal file
View file

@ -0,0 +1,121 @@
# THIS CONFIG FILE IS NOT A COMPLETE DOCUMENTATION
# PLEASE LOOK IN THE BIRD DOCUMENTATION FOR MORE INFO
# However, most of options used here are just for example
# and will be removed in real-life configs.
log syslog all;
# Override router ID
#router id 192.168.0.1;
# Turn on global debugging of all protocols
#debug protocols all;
# Define a route filter...
# filter test_filter {
# if net ~ 10.0.0.0/16 then accept;
# else reject;
# }
# The direct protocol automatically generates device routes to all network
# interfaces. Can exist in as many instances as you wish if you want to
# populate multiple routing tables with device routes. Because device routes
# are handled by Linux kernel, this protocol is usually not needed.
# protocol direct {
# interface "*"; # Restrict network interfaces it works with
# }
# This pseudo-protocol performs synchronization between BIRD's routing
# tables and the kernel. You can run multiple instances of the kernel
# protocol and synchronize different kernel tables with different BIRD tables.
protocol kernel {
# learn; # Learn all alien routes from the kernel
# persist; # Don't remove routes on bird shutdown
scan time 20; # Scan kernel routing table every 20 seconds
# import none; # Default is import all
# export all; # Default is export none
}
# This pseudo-protocol watches all interface up/down events.
protocol device {
scan time 10; # Scan interfaces every 10 seconds
}
# Static routes (again, there can be multiple instances, so that you
# can disable/enable various groups of static routes on the fly).
protocol static {
# export all; # Default is export none
# route 0.0.0.0/0 via 62.168.0.13;
# route 10.0.0.0/8 reject;
# route 192.168.0.0/16 reject;
}
#protocol rip {
# disabled;
# import all;
# export all;
# export filter test_filter;
# port 1520;
# period 7;
# infinity 16;
# garbage time 60;
# interface "*" { mode broadcast; };
# honor neighbor;
# honor always;
# honor never;
# authentication none;
#}
#protocol ospf {
# disabled;
# import all;
# export all;
# export where source = RTS_STATIC;
# area 0 {
# interface "eth*" {
# cost 10;
# hello 3;
# retransmit 2;
# wait 5;
# dead 20;
# type broadcast;
# authentication simple;
# password "pass";
# };
# };
#}
#protocol bgp {
# disabled;
# import all;
# export all;
# export where source = RTS_STATIC;
# local as 65000;
# neighbor 192.168.1.1 as 65001;
# multihop 20 via 192.168.2.1;
# hold time 240;
# startup hold time 240;
# connect retry time 120;
# keepalive time 80; # defaults to hold time / 3
# start delay time 5; # How long do we wait before initial connect
# error wait time 60, 300;# Minimum and maximum time we wait after an error (when consecutive
# # errors occur, we increase the delay exponentially ...
# error forget time 300; # ... until this timeout expires)
# disable after error; # Disable the protocol automatically when an error occurs
# next hop self; # Disable next hop processing and always advertise our local address as nexthop
# source address 62.168.0.14; # What local address we use for the TCP connection
# password "secret" # Password used for MD5 authentication
# rr client; # I am a route reflector and the neighor is my client
# rr cluster id 1.0.0.1 # Use this value for cluster id instead of my router id
# };
#}

26
bird/files/bird6.init Normal file
View file

@ -0,0 +1,26 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2010-2014 OpenWrt.org
BIRD="bird6"
START=99
STOP=10
SERVICE_DAEMONIZE=1
SERVICE_USE_PID=1
SERVICE_PID_FILE="/var/run/$BIRD.pid"
BIRD_BIN="/usr/sbin/$BIRD"
BIRD_CONF="/etc/$BIRD.conf"
start() {
service_start $BIRD_BIN -d -c $BIRD_CONF -P $SERVICE_PID_FILE
}
stop() {
service_stop $BIRD_BIN
}
reload() {
service_reload $BIRD_BIN
}

View file

@ -1,129 +0,0 @@
#
# Copyright (C) 2009-2017 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
include $(TOPDIR)/rules.mk
PKG_NAME:=bird2
PKG_VERSION:=2.14
PKG_RELEASE:=1
PKG_SOURCE:=bird-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=ftp://bird.network.cz/pub/bird
PKG_HASH:=b0b9f6f8566541b9be4af1f0cac675c5a3785601a55667a7ec3d7de29735a786
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
define Package/bird2/Default/description
BIRD is an internet routing daemon which manages TCP/IP routing tables
with support of modern routing protocols, easy to use configuration
interface and powerful route filtering language. It is lightweight and
efficient and therefore appropriate for small embedded routers.
endef
define Package/bird2
TITLE:=The BIRD Internet Routing Daemon (v2)
URL:=http://bird.network.cz/
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
DEPENDS:=+libpthread
CONFLICTS:=bird1-ipv4 bird1-ipv6 bird4 bird6
endef
define Package/bird2c
TITLE:=The BIRD command-line client (v2)
URL:=http://bird.network.cz/
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
DEPENDS:=+bird2 +libreadline +libncurses
CONFLICTS:=bird1c-ipv4 bird1c-ipv6 birdc4 birdc6
endef
define Package/bird2cl
TITLE:=The BIRD lightweight command-line client (v2)
URL:=http://bird.network.cz/
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
DEPENDS:=+bird2
CONFLICTS:=bird1cl-ipv4 bird1cl-ipv6 birdcl4 birdcl6
endef
define Package/bird2/description
$(call Package/bird2/Default/description)
BIRD supports OSPFv2, RIPv2, Babel and BGP protocols for IPv4 and
OSPFv3, RIPng, Babel and BGP protocols for IPv6.
In BGP, BIRD supports communities, multiprotocol extensions, MD5
authentication, 32bit AS numbers and could act as a route server or a
route reflector. BIRD also supports multiple RIBs, multiple kernel
routing tables and redistribution between the protocols with a powerful
configuration syntax.
This is the 2.0 branch of Bird which integrates support for IPv4 and IPv6
into a single branch, and also adds support for the Babel routing protocol.
endef
define Package/bird2c/description
$(call Package/bird2/Default/description)
This is a BIRD command-line client. It is used to send commands to BIRD,
commands can perform simple actions such as enabling/disabling of
protocols, telling BIRD to show various information, telling it to show
a routing table filtered by a filter, or asking BIRD to reconfigure.
Unless you can't afford dependency on ncurses and readline, you
should install BIRD command-line client together with BIRD.
endef
define Package/bird2cl/description
$(call Package/bird2/Default/description)
This is a BIRD lightweight command-line client. It is used to send commands
to BIRD, commands can perform simple actions such as enabling/disabling of
protocols, telling BIRD to show various information, telling it to show
a routing table filtered by a filter, or asking BIRD to reconfigure.
endef
CONFIGURE_ARGS += --disable-libssh
define Package/bird2/conffiles
/etc/bird.conf
/etc/bird4.conf
/etc/bird6.conf
endef
define Package/bird2/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bird $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/etc
$(INSTALL_DATA) ./files/bird.conf $(1)/etc/
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/bird.init $(1)/etc/init.d/bird
endef
define Package/bird2c/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/birdc $(1)/usr/sbin/
endef
define Package/bird2cl/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/birdcl $(1)/usr/sbin/
endef
$(eval $(call BuildPackage,bird2))
$(eval $(call BuildPackage,bird2c))
$(eval $(call BuildPackage,bird2cl))

View file

@ -1,332 +0,0 @@
/*
* This is an example configuration file for MB-BGP setting
*/
log syslog all;
# debug protocols all;
router id 192.168.1.1;
ipv4 table master4;
ipv6 table master6;
ipv4 table mcast4;
ipv6 table mcast6;
ipv4 table mtab4;
ipv6 table mtab6;
vpn4 table vpntab4;
vpn6 table vpntab6;
vpn4 table vpn4mc;
vpn6 table vpn6mc;
flow4 table flowtab4;
flow6 table flowtab6;
protocol device {
}
protocol kernel kernel4 {
ipv4 {
export all;
};
}
protocol kernel kernel6 {
ipv6 {
export all;
};
}
protocol static static4 {
ipv4;
route 10.10.0.0/24 via 192.168.1.2;
route 10.10.1.0/24 via 192.168.1.2 { bgp_large_community.add((10,20,30)); bgp_large_community.add((10,(20*3),10)); };
}
protocol static static6 {
ipv6;
route 2001:db8:10:10::/64 via 2001:db8:1:1::10;
route 2001:db8:10:11::/64 via 2001:db8:1:1::10;
route 2001:db8:1:1::/64 via fe80::ec9b:67ff:fe60:fd5d % ve1;
}
# VPNv4 routes with MPLS labels
protocol static statvpn4 {
vpn4;
route 10:10 10.20.0.0/24 via 192.168.1.2 mpls 210;
route 10:10 10.20.1.0/24 via 192.168.1.2 mpls 210;
route 10:20 10.20.0.0/24 via 192.168.1.2 mpls 220;
route 10:20 10.20.1.0/24 via 192.168.1.2 mpls 220;
}
protocol static statvpn6 {
vpn6;
route 10:10 2001:db8:20:10::/64 via 2001:db8:1:1::10 mpls 200/210;
route 10:10 2001:db8:20:11::/64 via 2001:db8:1:1::10 mpls 200/210;
route 10:20 2001:db8:20:10::/64 via 2001:db8:1:1::10 mpls 200/220;
route 10:20 2001:db8:20:11::/64 via 2001:db8:1:1::10 mpls 200/220;
}
# RFC 5575 flow specification
protocol static flowstat4 {
flow4;
route flow4 {
dst 10.0.0.0/8;
proto = 23;
dport > 24 && < 30 || 40..50,60..70,80;
sport > 24 && < 30 || = 40 || 50,60..70,80;
icmp type 80;
icmp code 90;
tcp flags 0x03/0x0f;
length 2048..65535;
dscp = 63;
fragment dont_fragment, is_fragment || !first_fragment;
};
route flow4 {
dst 11.0.0.0/8;
proto = 0x12;
sport > 0x5678 && < 0x9abc || 0xdef0 || 0x1234,0x5678,0x9abc..0xdef0;
dport = 50;
tcp flags 0x000/0xf00;
};
route flow4 {
dst 12.0.0.0/32;
tcp flags ! 0/0x999;
};
route flow4 {
dst 220.0.254.0/24;
tcp flags 0x99/0x999;
};
route flow4 {
dst 220.0.254.192/28;
tcp flags ! 0xfff/0xfff;
};
route flow4 {
dst 15.0.0.0/8;
tcp flags ! 0x999/0x999;
};
}
protocol static flowstat6 {
flow6;
route flow6 {
dst fec0:1122:3344:5566::1/128;
src 0000:0000:0000:0001:1234:5678:9800:0000/101 offset 63;
next header = 23;
sport 24..30, 42 || 50,60,70..80;
dport = 50;
tcp flags 0x03/0x0f, !0/0xff || 0x33/0x33;
fragment !is_fragment || !first_fragment;
label 0xaaaa/0xaaaa && 0x33/0x33;
};
route flow6 {
dst fec0:1122:3344:5566::1/128;
src ::1:1234:5678:9800:0/101 offset 63;
next header = 23;
dport = 50;
sport > 24 && < 30 || = 40 || = 50 || = 60 || >= 70 && <= 80;
tcp flags 0x3/0x3 && 0x0/0xc;
};
}
protocol pipe {
table master4;
peer table mcast4;
import none;
export where source = RTS_OSPF;
}
protocol pipe {
table master6;
peer table mcast6;
import none;
export where source = RTS_OSPF;
}
protocol ospf v2 ospf4 {
ipv4 {
import all;
# export where source = RTS_STATIC;
};
area 0 {
interface "ve0" { stub; };
interface "ve1" { hello 5; type ptp; };
interface "ve2" { hello 5; type bcast; ttl security; };
interface "ve3" { hello 5; type bcast; ttl security; };
};
}
protocol ospf v3 ospf6 {
ipv6 {
import all;
# export where source = RTS_STATIC;
};
area 0 {
interface "ve0" { stub; };
interface "ve1" { hello 5; type ptp; };
interface "ve2" { hello 5; type bcast; };
};
}
protocol bgp {
local 192.168.11.1 as 1000;
neighbor 192.168.11.2 as 2000;
# local 192.168.1.1 as 1000;
# neighbor 192.168.2.1 as 2000;
# multihop;
# rr client;
# strict bind;
# debug all;
# regular IPv4 unicast (1/1)
ipv4 {
# connects to master4 table by default
import all;
export where source ~ [ RTS_STATIC, RTS_BGP ];
};
# regular IPv6 unicast (2/1)
ipv6 {
# connects to master6 table by default
import all;
export where source ~ [ RTS_STATIC, RTS_BGP ];
# next hop address 2001:db8:1:1::1;
};
# IPv4 multicast topology (1/2)
ipv4 multicast {
# explicit IPv4 table
table mcast4;
import all;
export all;
};
# IPv6 multicast topology (2/2)
ipv6 multicast {
# explicit IPv6 table
table mcast6;
import all;
export all;
# next hop address 2001:db8:1:1::1;
};
# IPv4 with MPLS labels (1/4)
ipv4 mpls {
# explicit IPv4 table
table mtab4;
import all;
export all;
};
# IPv6 with MPLS labels (2/4)
ipv6 mpls {
# explicit IPv6 table
table mtab6;
import all;
export all;
# allows IPv4 next hops (6PE)
# extended next hop;
};
# VPNv4 with MPLS labels (1/128)
vpn4 mpls {
# connects to vpntab4 table by default
import all;
export all;
};
# VPNv6 with MPLS labels (2/128)
vpn6 mpls {
# connects to vpntab6 table by default
import all;
export all;
};
# VPNv4 multicast topology (1/129)
vpn4 multicast {
table vpn4mc;
import all;
export all;
};
# VPNv6 multicast topology (2/129)
vpn6 multicast {
table vpn6mc;
import all;
export all;
};
# IPv4 Flowspec (1/133)
flow4 {
# connects to flowtab4 table by default
import all;
export all;
};
# IPv6 Flowspec (2/133)
flow6 {
# connects to flowtab6 table by default
import all;
export all;
};
}
protocol bgp {
local 192.168.1.1 as 1000;
neighbor 192.168.3.1 as 1000;
multihop;
rr client;
ipv4 {
import all;
export where source ~ [ RTS_STATIC, RTS_BGP ];
};
ipv6 {
import all;
export where source ~ [ RTS_STATIC, RTS_BGP ];
next hop address 2001:db8:1:1::1;
};
}
protocol bgp {
local 2001:db8:1:1::1 as 1000;
neighbor 2001:db8:4:1::1 as 1000;
multihop;
rr client;
ipv4 {
import all;
export where source ~ [ RTS_STATIC, RTS_BGP ];
next hop address 192.168.4.1;
};
ipv6 {
import all;
export where source ~ [ RTS_STATIC, RTS_BGP ];
};
}

View file

@ -1,25 +0,0 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2010-2017 OpenWrt.org
USE_PROCD=1
START=70
STOP=10
BIRD_BIN="/usr/sbin/bird"
BIRD_CONF="/etc/bird.conf"
BIRD_PID_FILE="/var/run/bird.pid"
start_service() {
mkdir -p /var/run
procd_open_instance
procd_set_param command $BIRD_BIN -f -c $BIRD_CONF -P $BIRD_PID_FILE
procd_set_param file "$BIRD_CONF"
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param respawn
procd_close_instance
}
reload_service() {
procd_send_signal bird
}

View file

@ -1,11 +0,0 @@
--- a/proto/ospf/topology.h
+++ b/proto/ospf/topology.h
@@ -41,7 +41,7 @@ struct top_hash_entry
u8 mode; /* LSA generated during RT calculation (LSA_RTCALC or LSA_STALE)*/
u8 nhs_reuse; /* Whether nhs nodes can be reused during merging.
See a note in rt.c:add_cand() */
-};
+} PACKED;
/* Prevents ospf_hash_find() to ignore the entry, for p->lsrqh and p->lsrth */

156
bmx6/Makefile Normal file
View file

@ -0,0 +1,156 @@
# Copyright (C) 2011 Fundacio Privada per a la Xarxa Oberta, Lliure i Neutral guifi.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# The full GNU General Public License is included in this distribution in
# the file called "COPYING".
#
# Contibutors:
# Axel Neumann, Simó Albert i Beltran, Pau Escrich
#
include $(TOPDIR)/rules.mk
PKG_NAME:=bmx6
PKG_SOURCE_PROTO:=git
#PKG_SOURCE_URL:=git://bmx6.net/bmx6.git
PKG_SOURCE_URL:=git://github.com/axn/bmx6.git
PKG_REV:=2a87b770d3f9c254e3927dc159e2f425f2e0e83a
PKG_VERSION:=r2015080701
PKG_RELEASE:=4
PKG_LICENSE:=GPL-2.0
PKG_SOURCE_VERSION:=$(PKG_REV)
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SOURCE_SUBDIR)
include $(INCLUDE_DIR)/package.mk
TARGET_CFLAGS += $(FPIC)
MAKE_ARGS += \
EXTRA_CFLAGS="$(TARGET_CFLAGS) -I. -I$(STAGING_DIR)/usr/include -DNO_DEBUG_ALL -DNO_DEBUG_DUMP" \
EXTRA_LDFLAGS="-L$(STAGING_DIR)/usr/lib " \
GIT_REV="$(PKG_REV)" \
CC="$(TARGET_CC)" \
INSTALL_DIR="$(PKG_INSTALL_DIR)" \
STRIP="/bin/false" \
build_all
define Package/bmx6/Default
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
TITLE:=BMX6 layer 3 routing daemon
URL:=http://bmx6.net/
MAINTAINER:=Axel Neumann <neumann@cgws.de>
DEPENDS:=+kmod-ip6-tunnel +kmod-iptunnel6 +kmod-tun
endef
define Package/bmx6/description
BMX6 layer 3 routing daemon supporting IPv4, IPv6, and IPv4 over IPv6
endef
define Package/bmx6
$(call Package/bmx6/Default)
MENU:=1
endef
define Package/bmx6-uci-config
$(call Package/bmx6/Default)
DEPENDS:=bmx6 +libuci
TITLE:=configuration plugin based on uci (recommended!)
endef
define Package/bmx6-json
$(call Package/bmx6/Default)
DEPENDS:=bmx6 +libjson-c
TITLE:=json plugin based on json-c
endef
define Package/bmx6-sms
$(call Package/bmx6/Default)
DEPENDS:=bmx6
TITLE:=sms plugin
endef
#define Package/bmx6-quagga
# $(call Package/bmx6/Default)
# DEPENDS:=bmx6 +qmp-quagga @BROKEN
# TITLE:=bmx6 quagga plugin to redistribute/export routes (needs manet/bmx6 patched quagga 0.99.21)
#endef
define Package/bmx6-table
$(call Package/bmx6/Default)
DEPENDS:=bmx6
TITLE:=bmx6 table plugin to automatic announce routing-table routes via ip6ip tunnels
endef
define Build/Configure
mkdir -p $(PKG_INSTALL_DIR)
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_ARGS)
endef
define Package/bmx6/install
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bmx6 $(1)/usr/sbin/bmx6
endef
define Package/bmx6-uci-config/conffiles
/etc/config/bmx6
endef
define Package/bmx6-uci-config/install
$(INSTALL_DIR) $(1)/usr/lib $(1)/etc/config $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx6_uci_config/bmx6_config.so $(1)/usr/lib/bmx6_config.so
$(INSTALL_BIN) ./files/etc/init.d/bmx6 $(1)/etc/init.d/bmx6
$(INSTALL_DATA) ./files/etc/config/bmx6 $(1)/etc/config/bmx6
endef
define Package/bmx6-json/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx6_json/bmx6_json.so $(1)/usr/lib/bmx6_json.so
endef
define Package/bmx6-sms/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx6_sms/bmx6_sms.so $(1)/usr/lib/bmx6_sms.so
endef
define Package/bmx6-table/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx6_table/bmx6_table.so $(1)/usr/lib/bmx6_table.so
endef
#define Package/bmx6-quagga/install
# $(INSTALL_DIR) $(1)/usr/lib
# $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx6_quagga/bmx6_quagga.so $(1)/usr/lib/bmx6_quagga.so
#endef
$(eval $(call BuildPackage,bmx6))
$(eval $(call BuildPackage,bmx6-uci-config))
$(eval $(call BuildPackage,bmx6-json))
$(eval $(call BuildPackage,bmx6-sms))
#$(eval $(call BuildPackage,bmx6-quagga))
$(eval $(call BuildPackage,bmx6-table))

View file

@ -0,0 +1,82 @@
# for more information:
# http://bmx6.net/projects/bmx6/wiki
# options execute: bmx6 --help
config 'bmx6' 'general'
# option 'runtimeDir' '/var/run/bmx6'
# option 'tun4Address' '10.202.0.116/32'
# option 'tun4Address' '10.254.10.0/32'
# option 'tun6Address' '2012:0:0:1000::1/64'
#config 'ipVersion' 'ipVersion'
# option 'ipVersion' '6' # default is 4
# option 'throwRules' '0'
#config 'plugin'
# option 'plugin' 'bmx6_config.so'
#config 'plugin'
# option 'plugin' 'bmx6_json.so'
#config 'plugin'
# option 'plugin' 'bmx6_sms.so'
config 'dev' 'mesh_1'
option 'dev' 'eth0.12'
config 'dev' 'mesh_2'
option 'dev' 'ath0.12'
#config 'hna' 'my_global_prefix'
# option 'hna' '2012:0:0:74:0:0:0:0/64'
#config 'tunOut'
# option 'tunOut' 'ip6'
# option 'network' '2012::/16'
# option 'exportDistance' '0'
#config 'tunOut'
# option 'tunOut' 'ip4'
# option 'network' '10.254.0.0/16'
# option 'exportDistance' '0' # requires quagga plugin !
# option 'minPrefixLen' '27'
#config 'plugin'
# option 'plugin' 'bmx6_quagga.so'
#config 'redistribute'
# option 'redistribute' 'ospf6'
# option 'network' '10.0.0.0/8'
# option 'minPrefixLen' '10'
# option 'bandwidth' '10000000'
# option 'ospf6' '1'
# option 'aggregatePrefixLen' '16'
#config 'redistribute'
# option 'redistribute' 'bgp'
# option 'network' '0.0.0.0/0'
# option 'minPrefixLen' '0'
# option 'maxPrefixLen' '24'
# option 'bandwidth' '10000000'
# option 'bgp' '1'
# option 'aggregatePrefixLen' '8'

41
bmx6/files/etc/init.d/bmx6 Executable file
View file

@ -0,0 +1,41 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2011 Fundacio Privada per a la Xarxa Oberta, Lliure i Neutral guifi.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# The full GNU General Public License is included in this distribution in
# the file called "COPYING".
START=91
BIN=/usr/sbin/bmx6
CONF=/etc/config/bmx6
PID=/var/run/bmx6/pid
start() {
cd /root/
while pgrep -f mac80211.sh ; do sleep 1; done
ulimit -c 20000
$BIN -f $CONF -d0 > /dev/null &
}
stop() {
start-stop-daemon -p $PID -K
}
restart() {
stop; sleep 3; start
}

View file

@ -0,0 +1,13 @@
Index: bmx6-r2014112401/lib/bmx6_json/json.c
===================================================================
--- bmx6-r2014112401.orig/lib/bmx6_json/json.c
+++ bmx6-r2014112401/lib/bmx6_json/json.c
@@ -27,7 +27,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <stdint.h>
-#include <json/json.h>
+#include <json-c/json.h>
//#include <dirent.h>
//#include <sys/inotify.h>

View file

@ -1,51 +1,71 @@
# Copyright (C) 2011 Fundacio Privada per a la Xarxa Oberta, Lliure i Neutral guifi.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# The full GNU General Public License is included in this distribution in
# the file called "COPYING".
#
# Contibutors:
# Axel Neumann, Simó Albert i Beltran, Pau Escrich
#
include $(TOPDIR)/rules.mk
PKG_NAME:=bmx7
PKG_VERSION:=7.1.1
PKG_RELEASE:=5
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/bmx-routing/bmx7/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=5f88df1c95e5cb842a6016bb1604e3e7f6097c63c5c9916edc3c84e96d4f5f65
PKG_SOURCE_PROTO:=git
PKG_MAINTAINER:=Axel Neumann <neumann@cgws.de>
PKG_LICENSE:=GPL-2.0-or-later
PKG_LICENSE_FILES:=LICENSE
#PKG_SOURCE_URL:=git://bmx6.net/bmx6.git
PKG_SOURCE_URL:=git://github.com/axn/bmx6.git
#PKG_SOURCE_URL:=file:///usr/src/bmx6/bmx6.git
PKG_BUILD_PARALLEL:=1
PKG_REV:=379110ae442f80755b5788c527e722f9551b14eb
PKG_VERSION:=r2016072001
PKG_RELEASE:=4
PKG_LICENSE:=GPL-2.0
PKG_SOURCE_VERSION:=$(PKG_REV)
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SOURCE_SUBDIR)
include $(INCLUDE_DIR)/package.mk
TARGET_CFLAGS += $(FPIC)
MAKE_ARGS += EXTRA_CFLAGS="$(TARGET_CFLAGS) \
-I. \
-I$(STAGING_DIR)/usr/include \
-DCRYPTLIB=MBEDTLS_2_8_0 \
-DCORE_LIMIT=20000 \
-DTRAFFIC_DUMP \
-DNO_TRACE_FUNCTION_CALLS \
-DBMX7_LIB_IWINFO" \
EXTRA_LDFLAGS="$(TARGET_LDFLAGS) \
-L$(STAGING_DIR)/usr/lib -liwinfo" \
GIT_REV="$(PKG_REV)" \
CC="$(TARGET_CC)" \
INSTALL_DIR="$(PKG_INSTALL_DIR)" \
build_all
MAKE_PATH:=src
MAKE_ARGS += \
EXTRA_CFLAGS="$(TARGET_CFLAGS) -I. -I$(STAGING_DIR)/usr/include -DCRYPTLIB=POLARSSL_1_3_4 -DCORE_LIMIT=20000 -DTRAFFIC_DUMP -DNO_TRACE_FUNCTION_CALLS -DBMX7_LIB_IWINFO" \
EXTRA_LDFLAGS="$(TARGET_LDFLAGS) -L$(STAGING_DIR)/usr/lib -liwinfo" \
GIT_REV="$(PKG_REV)" \
CC="$(TARGET_CC)" \
INSTALL_DIR="$(PKG_INSTALL_DIR)" \
build_all
define Package/bmx7/Default
SECTION:=net
CATEGORY:=Network
SUBMENU:=Routing and Redirection
TITLE:=BMX7 layer 3 routing daemon
URL:=https://github.com/bmx-routing/bmx7
DEPENDS:=+zlib +libmbedtls +libiwinfo
URL:=http://bmx6.net/
MAINTAINER:=Axel Neumann <neumann@cgws.de>
DEPENDS:=+zlib +libpolarssl +libiwinfo
endef
define Package/bmx7/description
BMX7 routing daemon supporting securely-entrusted IPv6 (and IPv4in6) routing
BMX7 routing daemon supporting securely-entrusted IPv6 (and IPv4in6) routing
endef
define Package/bmx7
@ -62,7 +82,7 @@ endef
define Package/bmx7-iwinfo
$(call Package/bmx7/Default)
DEPENDS:=bmx7 +libiwinfo
TITLE:=link characteristics plugin via libiwinfo (recommended!)
TITLE:=link characteristics plugin based on libiwinfo (recommended!)
endef
define Package/bmx7-topology
@ -95,64 +115,72 @@ define Package/bmx7-table
TITLE:=plugin to announce routes from tables via tunnels
endef
define Package/bmx7/install
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/bmx7 $(1)/usr/sbin/bmx7
define Build/Configure
mkdir -p $(PKG_INSTALL_DIR)
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) $(MAKE_ARGS)
$(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_ARGS)
endef
define Package/bmx7/install
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bmx7 $(1)/usr/sbin/bmx7
endef
define Package/bmx7/postinst
#!/bin/sh
# # check if we are on real system
if [ -z "$${IPKG_INSTROOT}" ]; then
if [ -f /etc/sysupgrade.conf ] && ! grep bmx7 /etc/sysupgrade.conf; then
echo /etc/bmx7 >> /etc/sysupgrade.conf
fi
fi
endef
define Package/bmx7-uci-config/conffiles
/etc/config/bmx7
/etc/bmx7
endef
define Package/bmx7-uci-config/install
$(INSTALL_DIR) $(1)/usr/lib $(1)/etc/config $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/lib/bmx7_uci_config/bmx7_config.so \
$(1)/usr/lib/bmx7_config.so
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx7_uci_config/bmx7_config.so $(1)/usr/lib/bmx7_config.so
$(INSTALL_BIN) ./files/etc/init.d/bmx7 $(1)/etc/init.d/bmx7
$(INSTALL_DATA) ./files/etc/config/bmx7 $(1)/etc/config/bmx7
endef
define Package/bmx7-iwinfo/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/lib/bmx7_iwinfo/bmx7_iwinfo.so \
$(1)/usr/lib/bmx7_iwinfo.so
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx7_iwinfo/bmx7_iwinfo.so $(1)/usr/lib/bmx7_iwinfo.so
endef
define Package/bmx7-topology/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/lib/bmx7_topology/bmx7_topology.so \
$(1)/usr/lib/bmx7_topology.so
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx7_topology/bmx7_topology.so $(1)/usr/lib/bmx7_topology.so
endef
define Package/bmx7-json/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/lib/bmx7_json/bmx7_json.so \
$(1)/usr/lib/bmx7_json.so
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx7_json/bmx7_json.so $(1)/usr/lib/bmx7_json.so
endef
define Package/bmx7-sms/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/lib/bmx7_sms/bmx7_sms.so \
$(1)/usr/lib/bmx7_sms.so
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx7_sms/bmx7_sms.so $(1)/usr/lib/bmx7_sms.so
endef
define Package/bmx7-tun/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/lib/bmx7_tun/bmx7_tun.so \
$(1)/usr/lib/bmx7_tun.so
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx7_tun/bmx7_tun.so $(1)/usr/lib/bmx7_tun.so
endef
define Package/bmx7-table/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/lib/bmx7_table/bmx7_table.so \
$(1)/usr/lib/bmx7_table.so
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx7_table/bmx7_table.so $(1)/usr/lib/bmx7_table.so
endef
$(eval $(call BuildPackage,bmx7))
$(eval $(call BuildPackage,bmx7-uci-config))
$(eval $(call BuildPackage,bmx7-iwinfo))

View file

@ -1,10 +1,11 @@
# for more information:
# https://github.com/bmx-routing/bmx7/
# http://bmx6.net/projects/bmx6/wiki
# options execute: bmx7 --help
config 'bmx7' 'general'
# option 'runtimeDir' '/var/run/bmx7'
# option 'trustedNodesDir' '/etc/bmx7/trustedNodes'
# option 'runtimeDir' '/var/run/bmx7'
# option 'trustedNodesDir' '/etc/bmx7/trustedNodes'
#config 'plugin'
# option 'plugin' 'bmx7_config.so'
@ -18,18 +19,22 @@ config 'bmx7' 'general'
#config 'plugin'
# option 'plugin' 'bmx7_iwinfo.so'
config 'dev' 'mesh_1'
option 'dev' 'br-lan'
config 'dev' 'mesh_2'
option 'dev' 'wlan0'
#config 'plugin'
# option 'plugin' 'bmx7_tun.so'
#config 'plugin'
# option 'plugin' 'bmx7_table.so'
#config 'tunDev' default
# option 'tunDev' 'default'
# option 'tun6Address' '2012:0:0:6666::1/64'
@ -45,3 +50,8 @@ config 'dev' 'mesh_2'
# option 'tunOut' 'ip4'
# option 'network' '10.0.0.0/9'
# option 'minPrefixLen' '27'

View file

@ -1,28 +1,41 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2011 Fundacio Privada per a la Xarxa Oberta, Lliure i Neutral guifi.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# The full GNU General Public License is included in this distribution in
# the file called "COPYING".
START=91
USE_PROCD=1
BIN=/usr/sbin/bmx7
CONF=/etc/config/bmx7
PID=/var/run/bmx7/pid
start_service() {
cd /root/ || return
start() {
cd /root/
while pgrep -f mac80211.sh ; do sleep 1; done
procd_open_instance "bmx7"
procd_set_param command "$BIN"
procd_append_param command -f "$CONF" -d0
procd_set_param limits core=20000
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param respawn
procd_close_instance
ulimit -c 20000
$BIN -f $CONF -d0 > /dev/null &
}
reload_service() {
"$BIN" -c configReload
stop() {
start-stop-daemon -p $PID -K
}
service_triggers() {
procd_add_reload_trigger "bmx7"
restart() {
stop; sleep 3; start
}

View file

@ -0,0 +1,13 @@
Index: bmx7-r2014112401/lib/bmx7_json/json.c
===================================================================
--- bmx7-r2014112401.orig/lib/bmx7_json/json.c
+++ bmx7-r2014112401/lib/bmx7_json/json.c
@@ -27,7 +27,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <stdint.h>
-#include <json/json.h>
+#include <json-c/json.h>
//#include <dirent.h>
//#include <sys/inotify.h>

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