-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ebf7e84
Showing
63 changed files
with
484 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Package: babeld | ||
Source: babeld | ||
Version: 1.9.2-2 | ||
Architecture: mipsel | ||
Maintainer: darkdrgn2k | ||
Section: net | ||
Homepage: https://www.irif.fr/~jch/software/babel/ | ||
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 in the process of becoming an | ||
IETF Standard. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
Project to create a working DEB package for BABELD to use on EdgeMax RouterX (firmware v 1.x only) | ||
|
||
Tested on | ||
- Edgerotuer X | ||
|
||
# Usage | ||
|
||
## To Install | ||
|
||
- Copy deb file over to device | ||
- SSH into the device | ||
- install deb using `sudo dpkg -i <file.deb>` | ||
|
||
## Presist across firmware upgrades | ||
|
||
- Install post-install script (source: https://github.com/britannic/install-edgeos-packages) | ||
|
||
``` | ||
cat <<"EOF"> install-pkgs | ||
#!/usr/bin/env bash | ||
# UniFi Security Gateways and EdgeOS Package Updater | ||
# This script checks /config/data/install-packages/ for downloaded | ||
# packages and installs any that aren't installed | ||
# | ||
# Author: Neil Beadle | ||
downloads=/config/data/install-packages | ||
cd $downloads | ||
for pkg in *; do | ||
dpkg-query -W --showformat='${Status}\n' \ | ||
$(dpkg --info "${pkg}" | \ | ||
grep "Package: " | \ | ||
awk -F' ' '{ print $NF}') > /dev/null 2>&1 || dpkg -i ${pkg} | ||
done | ||
cd - | ||
EOF | ||
sudo mkdir -p /config/scripts/pre-config.d | ||
sudo install -o root -g root -m 0755 install-pkgs /config/scripts/pre-config.d/install-pkgs | ||
rm -rf install-pkgs | ||
sudo mkdir -p /config/data/install-packages | ||
``` | ||
|
||
- Copy deb package into folder | ||
`sudo cp <file.deb> /config/data/install-packages` | ||
|
||
## TODO | ||
|
||
- [x] Create basic VyOS config | ||
- [x] Create init.d files | ||
- [x] Package into working DEB | ||
- [x] Presist across firmware upgrade | ||
- [x] Presist config across upgrades | ||
- [ ] Remove config on delete | ||
|
||
## Configs added | ||
- denydefault | ||
- denydefaultlocal | ||
- interface | ||
- allow-duplicates | ||
- debug | ||
- diversity-factor | ||
- export-table | ||
- first-rule-priority | ||
- first-table-number | ||
- filter | ||
- type (in,out,redistribute) | ||
- action | ||
- eq | ||
- ge | ||
- id | ||
- if | ||
- ip | ||
- le | ||
- local | ||
- neigh | ||
- proto | ||
- src-eq | ||
- src-ge | ||
- src-ip | ||
- import-table | ||
- interface | ||
- channel | ||
- enable-timestamps | ||
- faraway | ||
- hello-interval | ||
- link-quality | ||
- max-rtt-penalty | ||
- rfc6126-compatible | ||
- rtt-decay | ||
- rtt-max | ||
- rtt-min | ||
- rxcost | ||
- split-horizon | ||
- type | ||
- unicast | ||
- update-interval | ||
- ipv6-subtrees | ||
- kernel-priority | ||
- local-path | ||
- local-path-readwrite | ||
- protocol-group | ||
- protocol-port | ||
- random-id | ||
- redistribute | ||
- reflect-kernel-metric | ||
- router-id | ||
- skip-kernel-setup | ||
- smoothing-half-life | ||
- local-port-readwrite | ||
- redistribute | ||
- interface | ||
- local | ||
## Babeld Compile | ||
|
||
Following will compile a binary copy of babeld | ||
Compiled binary exists in /root/usr/bin/babeld | ||
|
||
``` | ||
sudo apt-get install gcc-mipsel-linux-gnu | ||
git clone git://github.com/jech/babeld.git | ||
cd babeld | ||
make CC='mipsel-linux-gnu-gcc -static' | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
rm -rf /tmp/babeld | ||
mkdir /tmp/babeld | ||
cp -R root/* /tmp/babeld | ||
cp -R DEBIAN /tmp/babeld | ||
dpkg-deb --no-uniform-compression --build /tmp/babeld |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/bin/sh | ||
### BEGIN INIT INFO | ||
# Provides: babeld | ||
# Required-Start: $network $remote_fs $syslog | ||
# Required-Stop: $network $remote_fs $syslog | ||
# Default-Start: | ||
# Default-Stop: 0 1 6 | ||
# Description: Stops dnsmasq DHCP and DNS server (start, restart is done by vyatta cli) | ||
### END INIT INFO | ||
|
||
# Don't exit on error status | ||
set +e | ||
|
||
DAEMON=/usr/bin/babeld | ||
NAME=babeld | ||
DESC="Babeld routing service" | ||
|
||
test -x $DAEMON || exit 0 | ||
|
||
# Provide skeleton LSB log functions for backports which don't have LSB functions. | ||
if [ -f /lib/lsb/init-functions ]; then | ||
. /lib/lsb/init-functions | ||
else | ||
log_warning_msg () { | ||
echo "${@}." | ||
} | ||
|
||
log_success_msg () { | ||
echo "${@}." | ||
} | ||
|
||
log_daemon_msg () { | ||
echo -n "${1}: $2" | ||
} | ||
|
||
log_end_msg () { | ||
if [ $1 -eq 0 ]; then | ||
echo "." | ||
elif [ $1 -eq 255 ]; then | ||
/bin/echo -e " (warning)." | ||
else | ||
/bin/echo -e " failed!" | ||
fi | ||
} | ||
fi | ||
|
||
|
||
start() | ||
{ | ||
# Return | ||
# 0 if daemon has been started | ||
# 1 if daemon was already running | ||
# 2 if daemon could not be started | ||
|
||
# /run may be volatile, so we need to ensure that | ||
# /run/dnsmasq exists here as well as in postinst | ||
|
||
if [ -f /var/run/babeld/babeld.pid ]; then | ||
kill "$(cat /var/run/babeld.pid)" 2>&1 > /dev/null | ||
rm -rf /var/run/babeld/babeld.pid > /dev/null | ||
fi | ||
|
||
$DAEMON -c /etc/babeld.conf -D -I /var/run/babeld.pid || return 2 | ||
} | ||
|
||
stop() | ||
{ | ||
|
||
# Return | ||
# 0 if daemon has been stopped | ||
# 1 if daemon was already stopped | ||
# 2 if daemon could not be stopped | ||
# other if a failure occurred | ||
if [ -f /var/run/babeld.pid ]; then | ||
kill "$(cat /var/run/babeld.pid)" 2>&1 > /dev/null | ||
rm -rf /var/run/babeld/babeld.pid > /dev/null | ||
fi | ||
} | ||
|
||
case "$1" in | ||
start) | ||
start | ||
;; | ||
stop) | ||
stop | ||
;; | ||
restart|force-reload) | ||
stop | ||
sleep 1 | ||
start | ||
;; | ||
*) | ||
log_end_msg 1 | ||
exit 1 | ||
;; | ||
esac | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
#!/usr/bin/perl | ||
|
||
#babeld-config.pl | ||
#v0.1 | ||
|
||
use strict; | ||
use lib "/opt/vyatta/share/perl5/"; | ||
use Data::Dumper; | ||
|
||
#config | ||
my $config_path = "/etc/babeld.conf"; | ||
my $init_script = "/etc/init.d/babeld"; | ||
|
||
my $config_out = ''; | ||
|
||
use Vyatta::Config; | ||
my $c = new Vyatta::Config(); | ||
|
||
$c->setLevel('protocols babeld'); | ||
|
||
|
||
open(my $fh, '>', $config_path) || die "Couldn't open $config_path - $!"; | ||
|
||
$config_out = "#\n# autogenerated by $0 on " . `date` . "#\n"; | ||
|
||
if ($c->returnValue("protocol-group") ne "" ) {$config_out .= "protocol-group " . $c->returnValue("protocol-group") . "\n"; } | ||
if ($c->returnValue("protocol-port") ne "" ) {$config_out .= "protocol-port" . $c->returnValue("protocol-port") . "\n"; } | ||
if ($c->returnValue("kernel-priority") ne "" ) {$config_out .= "kernel-priority " . $c->returnValue("kernel-priority") . "\n"; } | ||
if ($c->returnValue("reflect-kernel-metric") ne "" ) {$config_out .= "reflect-kernel-metric " . $c->returnValue("reflect-kernel-metric") . "\n"; } | ||
if ($c->returnValue("allow-duplicates") ne "" ) {$config_out .= "allow-duplicates " . $c->returnValue("allow-duplicates") . "\n"; } | ||
if ($c->returnValue("random-id") ne "" ) {$config_out .= "random-id " . $c->returnValue("random-id") . "\n"; } | ||
if ($c->returnValue("ipv6-subtrees") ne "" ) {$config_out .= "ipv6-subtrees " . $c->returnValue("ipv6-subtrees") . "\n"; } | ||
if ($c->returnValue("debug") ne "" ) {$config_out .= "debug " . $c->returnValue("debug") . "\n"; } | ||
if ($c->returnValue("local-port") ne "" ) {$config_out .= "local-port " . $c->returnValue("local-port") . "\n"; } | ||
if ($c->returnValue("local-port-readwrite") ne "" ) {$config_out .= "local-port-readwrite " . $c->returnValue("local-port-readwrite") . "\n"; } | ||
if ($c->returnValue("local-path") ne "" ) {$config_out .= "local-path " . $c->returnValue("local-path") . "\n"; } | ||
if ($c->returnValue("local-path-readwrite") ne "" ) {$config_out .= "local-path-readwrite " . $c->returnValue("local-path-readwrite") . "\n"; } | ||
if ($c->returnValue("export-table") ne "" ) {$config_out .= "export-table " . $c->returnValue("export-table") . "\n"; } | ||
if ($c->returnValue("import-table") ne "" ) {$config_out .= "import-table " . $c->returnValue("import-table") . "\n"; } | ||
if ($c->returnValue("link-detect") ne "" ) {$config_out .= "link-detect " . $c->returnValue("link-detect") . "\n"; } | ||
if ($c->returnValue("diversity") ne "" ) {$config_out .= "diversity " . $c->returnValue("diversity") . "\n"; } | ||
if ($c->returnValue("diversity-factor") ne "" ) {$config_out .= "diversity-factor " . $c->returnValue("diversity-factor") . "\n"; } | ||
if ($c->returnValue("smoothing-half-life") ne "" ) {$config_out .= "smoothing-half-life " . $c->returnValue("smoothing-half-life") . "\n"; } | ||
if ($c->returnValue("skip-kernel-setup") ne "" ) {$config_out .= "skip-kernel-setup " . $c->returnValue("skip-kernel-setup") . "\n"; } | ||
if ($c->returnValue("router-id") ne "" ) {$config_out .= "router-id " . $c->returnValue("router-id") . "\n"; } | ||
if ($c->returnValue("first-table-number") ne "" ) {$config_out .= "first-table-number " . $c->returnValue("first-table-number"). "\n"; } | ||
if ($c->returnValue("first-rule-priority") ne "" ) {$config_out .= "first-rule-priority " . $c->returnValue("first-rule-priority") . "\n"; } | ||
|
||
|
||
my @listen_interfaces = $c->listNodes('interface'); | ||
foreach my $int (@listen_interfaces) { | ||
|
||
$config_out .= "interface $int "; | ||
if ($c->returnValue("interface $int channel") ne "" ) {$config_out .= "channel " . $c->returnValue("interface $int channel") . " "; } | ||
if ($c->returnValue("interface $int enable-timestamps") ne "" ) {$config_out .= "enable-timestamps " . $c->returnValue("interface $int enable-timestamps") . " "; } | ||
if ($c->returnValue("interface $int faraway") ne "" ) {$config_out .= "faraway " . $c->returnValue("interface $int faraway") . " "; } | ||
if ($c->returnValue("interface $int hello-interval") ne "" ) {$config_out .= "hello-interval " . $c->returnValue("interface $int hello-interval") . " "; } | ||
if ($c->returnValue("interface $int link-quality") ne "" ) {$config_out .= "link-quality " . $c->returnValue("interface $int link-quality") . " "; } | ||
if ($c->returnValue("interface $int max-rtt-penalty") ne "" ) {$config_out .= "max-rtt-penalty " . $c->returnValue("interface $int max-rtt-penalty") . " "; } | ||
if ($c->returnValue("interface $int rfc6126-compatible") ne "" ) {$config_out .= "rfc6126-compatible " . $c->returnValue("interface $int rfc6126-compatible") . " "; } | ||
if ($c->returnValue("interface $int rtt-decay") ne "" ) {$config_out .= "rtt-decay " . $c->returnValue("interface $int rtt-decay") . " "; } | ||
if ($c->returnValue("interface $int rtt-max") ne "" ) {$config_out .= "rtt-max " . $c->returnValue("interface $int rtt-max") . " "; } | ||
if ($c->returnValue("interface $int rtt-min") ne "" ) {$config_out .= "rtt-min " . $c->returnValue("interface $int rtt-min") . " "; } | ||
if ($c->returnValue("interface $int rxcost") ne "" ) {$config_out .= "rxcost " . $c->returnValue("interface $int rxcost") . " "; } | ||
if ($c->returnValue("interface $int split-horizon") ne "" ) {$config_out .= "split-horizon " . $c->returnValue("interface $int split-horizon") . " "; } | ||
if ($c->returnValue("interface $int type") ne "" ) {$config_out .= "type " . $c->returnValue("interface $int type") . " "; } | ||
if ($c->returnValue("interface $int unicast") ne "" ) {$config_out .= "unicast " . $c->returnValue("interface $int unicast") . " "; } | ||
if ($c->returnValue("interface $int update-interval") ne "" ) {$config_out .= "update-interval " . $c->returnValue("interface $int update-interval") . " "; } | ||
$config_out .= "\n"; | ||
} | ||
|
||
my @filters = $c->listNodes('filter'); | ||
foreach my $id (@filters) { | ||
|
||
$config_out .= $c->returnValue("filter $id type") . " "; | ||
if ($c->returnValue("filter $id ip") ne "" ) {$config_out .= "ip " . $c->returnValue("filter $id ip") . " ";} | ||
if ($c->returnValue("filter $id eq") ne "" ) {$config_out .= "eq " . $c->returnValue("filter $id eq") . " ";} | ||
if ($c->returnValue("filter $id le") ne "" ) {$config_out .= "le " . $c->returnValue("filter $id le") . " ";} | ||
if ($c->returnValue("filter $id ge") ne "" ) {$config_out .= "ge " . $c->returnValue("filter $id ge") . " ";} | ||
if ($c->returnValue("filter $id src-ip") ne "" ) {$config_out .= "src-ip " . $c->returnValue("filter $id src-ip") . " ";} | ||
if ($c->returnValue("filter $id src-eq") ne "" ) {$config_out .= "src-eq " . $c->returnValue("filter $id src-eq") . " ";} | ||
if ($c->returnValue("filter $id src-le") ne "" ) {$config_out .= "src-le " . $c->returnValue("filter $id src-le") . " ";} | ||
if ($c->returnValue("filter $id src-ge") ne "" ) {$config_out .= "src-ge " . $c->returnValue("filter $id src-ge") . " ";} | ||
if ($c->returnValue("filter $id neigh") ne "" ) {$config_out .= "neigh " . $c->returnValue("filter $id neigh") . " ";} | ||
if ($c->returnValue("filter $id id") ne "" ) {$config_out .= "id " . $c->returnValue("filter $id id") . " ";} | ||
if ($c->returnValue("filter $id proto") ne "" ) {$config_out .= "proto " . $c->returnValue("filter $id proto") . " ";} | ||
if ($c->returnValue("filter $id local") eq "true" ) {$config_out .= "local ";} | ||
if ($c->returnValue("filter $id if") ne "" ) {$config_out .= "if " . $c->returnValue("filter $id if") . " ";} | ||
if ($c->returnValue("filter $id action") ne "" ) {$config_out .= $c->returnValue("filter $id action") . " ";} | ||
|
||
$config_out .= "\n"; | ||
} | ||
|
||
my @redistributeIF = $c->listNodes('redistribute interface'); | ||
foreach my $int (@redistributeIF) { | ||
my $local=""; | ||
my $res=$c->returnValue("redistribute interface $int local"); | ||
|
||
if ( $res eq "false" ) { | ||
$local=""; | ||
} else { | ||
$local=" local "; | ||
} | ||
$config_out .= "redistribute $local if $int\n"; | ||
} | ||
if ( $c->returnValue('denydefault') eq "true" ) { $config_out .= "redistribute deny\n"; } | ||
if ( $c->returnValue('denydefaultlocal') eq "true" ) { $config_out .= "redistribute local deny\n"; } | ||
|
||
|
||
print $fh $config_out; | ||
close $fh; | ||
|
||
# Restart babeld | ||
system("/etc/init.d/babeld stop >&/dev/null"); | ||
system("/etc/init.d/babeld start >&/dev/null"); |
2 changes: 2 additions & 0 deletions
2
root/opt/vyatta/share/vyatta-cfg/templates/protocols/babeld/allow-duplicates/node.def
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
type: txt | ||
help: This allows duplicating external routes when their kernel priority is at least priority. Do not use this option unless you know what you are doing, as it can cause persistent route flapping. |
2 changes: 2 additions & 0 deletions
2
root/opt/vyatta/share/vyatta-cfg/templates/protocols/babeld/debug/node.def
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
type: txt | ||
help: This specifies the debugging level, and is equivalent to the command-line option -d. |
2 changes: 2 additions & 0 deletions
2
root/opt/vyatta/share/vyatta-cfg/templates/protocols/babeld/denydefault/node.def
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
type: bool | ||
help: Deny all unspecified redistributions |
2 changes: 2 additions & 0 deletions
2
root/opt/vyatta/share/vyatta-cfg/templates/protocols/babeld/denydefaultlocal/node.def
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
type: bool | ||
help: Deny all unspecified local redistributions |
2 changes: 2 additions & 0 deletions
2
root/opt/vyatta/share/vyatta-cfg/templates/protocols/babeld/diversity-factor/node.def
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
type: txt | ||
help: This specifies by how much the cost of non-interfering routes should be multiplied, in units of 1/256. The default is 128 (division by 2). |
2 changes: 2 additions & 0 deletions
2
root/opt/vyatta/share/vyatta-cfg/templates/protocols/babeld/export-table/node.def
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
type: txt | ||
help: This specifies the kernel routing table to use for routes inserted by babeld, and is equivalent to the command-line option -t. |
3 changes: 3 additions & 0 deletions
3
root/opt/vyatta/share/vyatta-cfg/templates/protocols/babeld/filter/node.def
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
tag: | ||
type: txt | ||
help: A filtering rule is defined by a single line INDEX |
2 changes: 2 additions & 0 deletions
2
root/opt/vyatta/share/vyatta-cfg/templates/protocols/babeld/filter/node.tag/action/node.def
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
type: txt | ||
help: Action specifies the action to be taken when this entry matches. It can have one of the following values: allow, deny, metric [value], src-prefix [prefix], table [table], pref-src [ip] |
2 changes: 2 additions & 0 deletions
2
root/opt/vyatta/share/vyatta-cfg/templates/protocols/babeld/filter/node.tag/eq/node.def
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
type: txt | ||
help: This entry only applies to routes with a prefix length equal |
2 changes: 2 additions & 0 deletions
2
root/opt/vyatta/share/vyatta-cfg/templates/protocols/babeld/filter/node.tag/ge/node.def
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
type: txt | ||
help: This entry only applies to routes with a prefix length greater or equal |
Oops, something went wrong.