[PATCH] [package] babeld: update to 0.98, fix scripts

Gabriel Kerneis kerneis at pps.jussieu.fr
Mon Feb 15 18:21:39 UTC 2010


- Full-featured UCI configuration file (no need for babeld.conf).
- Do not check the pid file (useless) and ahcpd script (harmful).
- 8 February 2010: babeld 0.98:
  * Implement the ability to prefer Babel routes to external routes
    according to the kernel priority (-A).
  * Implement the ability to redistribute "boot" routes when the
    protocol is explicitly specified on the "redistribute" line.
  * Allow trailing whitespace in config file.

Signed-off-by: Gabriel Kerneis <kerneis at pps.jussieu.fr>
---
 net/babel/Makefile            |    4 +-
 net/babel/files/babeld.conf   |   20 +++++-
 net/babel/files/babeld.config |   71 +++++++++++++++++++++-
 net/babel/files/babeld.init   |  131 ++++++++++++++++++++++++++++++++++-------
 4 files changed, 197 insertions(+), 29 deletions(-)

diff --git a/net/babel/Makefile b/net/babel/Makefile
index 144bf9e..763e32d 100644
--- a/net/babel/Makefile
+++ b/net/babel/Makefile
@@ -8,12 +8,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=babeld
-PKG_VERSION:=0.97
+PKG_VERSION:=0.98
 PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=http://www.pps.jussieu.fr/~jch/software/files/
-PKG_MD5SUM:=be0748c382dfe60bd35aa6b661e6077d
+PKG_MD5SUM:=85af76e90914b82d9ece497e15df252f
 
 include $(INCLUDE_DIR)/package.mk
 
diff --git a/net/babel/files/babeld.conf b/net/babel/files/babeld.conf
index 07fcbe1..fd488f9 100644
--- a/net/babel/files/babeld.conf
+++ b/net/babel/files/babeld.conf
@@ -1,11 +1,15 @@
 # babel config file
-# Copyright (C) 2008 Juliusz Chroboczek, L. Aaron Kaplan
+# Copyright (C) 2008-2010 Juliusz Chroboczek, L. Aaron Kaplan
 #   <jch at pps.jussieu.fr> , <aaron at lo-res.org>
 #
 # This config file simply documents sample entries. 
-# "redistribute" means: redistribute routes from other 
-#  routing protocols into babel. "local" means addresses assigned to local interfaces.
+# "redistribute" means: redistribute routes from other routing protocols
+# into babel. "local" means addresses assigned to local interfaces.
 #
+# You do not need to edit this file: you can use /etc/config/babeld
+# instead (sections "interface" and "filter").  Both files can be used
+# simultaneously (the rules of this file are executed first).
+
 # the default rules are:
 #
 ## redistribute local 
@@ -14,15 +18,23 @@
 # this says, redistribute local addresses but no other routes
 
 
-
 # redistribute IPv4 default route into babel 
 ## redistribute local ip 0.0.0.0/0 le 0 metric 128
 
 # same but for IPv6
 ## redistribute local ip ::/0 le 0 metric 128
 
+
 # don't redistribute all local addresses, only selected ones
 # after the first line, the "deny" rules kicks in. After the "deny"
 # no redistribute local rules are going to match
 ## redistribute local ip 192.160.4.0/24 
 ## redistribute local deny
+
+
+# Babel refuses to redistribute routes with a protocol number of "boot";
+# this is standard practice, and means that you cannot easily
+# redistribute the default route installed by dhcp.  It is however
+# possible to redistribute such route by explicitly specifying "proto 3"
+# on the redistribute line.
+## redistribute ip 0.0.0.0/0 le 0 proto 3 metric 128
diff --git a/net/babel/files/babeld.config b/net/babel/files/babeld.config
index 3b0fb38..ab6a639 100644
--- a/net/babel/files/babeld.config
+++ b/net/babel/files/babeld.config
@@ -1,2 +1,69 @@
-config babeld
-	#list 'interface' 'wlan'
+config general
+	option 'multicast_address' 'ff02::cca6:c0f9:e182:5373'
+	option 'port' '8475'
+	option 'state_file' '/var/lib/babel-state'
+	option 'hello_interval' '4'
+	option 'wired_hello_interval' '20'
+	# Enable  detection of idle networks.  This functonality is
+	# experimental, don't use it unless you know what you are doing.
+	## option 'idle_hello_interval' '0'
+	option 'kernel_priority' '0'
+	# Do not use this option unless you know what you are doing, as it can
+	# cause persistent route flapping.
+	## option 'duplication_priority' '0'
+	option 'carrier_sense' 'false'
+	option 'assume_wireless' 'false'
+	option 'no_split_horizon' 'false'
+	option 'parasitic' 'false'
+	option 'debug' '0'
+	# Listen for connections from a front-end, e.g. on port 33123.
+	## option 'local_server' '33123'
+	# Use the given kernel routing table for routes inserted by babeld.
+	## option 'export_table' '0'
+	# Export routes from the given kernel routing table.
+	## option 'import_table' '0'
+	# The configuration file is not necessary since you can do everything
+	# from this file.
+	option 'conffile' '/etc/babeld.conf'
+	option 'logfile' '/var/log/babeld.log'
+	option 'pidfile' '/var/run/babeld.pid'
+
+# You can use aliases (like lan, wlan) or real names (like eth0.0).
+# If you use an alias, it must be already defined when babeld starts.
+# Otherwise, the name is taken literally and the interface can be
+# brought up later (useful for tunnels for instance).
+config interface wlan
+	# Change this line to enable babeld on this interface
+	option 'enable' 'false'
+	option 'wired' 'auto'
+	option 'link_quality' 'auto'
+	option 'split_horizon' 'auto'
+	# The default is 96 for wired interfaces, and 256 for wireless ones
+	## option 'rxcost' '256'
+	# The  default  is  specified with the -h and -H command-line flags.
+	## option 'hello_interval' '4'
+	# This can be set to a  fairly  large  value,  unless significant
+	# packet loss is expected.  The default is four times the hello
+	# interval.
+	## option 'update_interval' '16'
+
+config interface lan
+	option 'enable' 'false'
+
+# A filter consists in a type ('in', 'out' or 'redistribute'), an action
+# ('allow', 'deny' or 'metric xxx') and a set of selectors ('ip', 'eq',
+# etc.).  See /etc/babeld.conf 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 'enable' 'false'
+	# Type
+	option 'type' 'redistribute'
+	# Selectors: ip, eq, le, ge, neigh, id, proto, local, if
+	option 'ip' '0.0.0.0/0' 
+	option 'le' '0'
+	option 'proto' '3'
+	# Action 
+	option 'action' 'metric 128'
+
diff --git a/net/babel/files/babeld.init b/net/babel/files/babeld.init
index a7e4587..3bba6cc 100755
--- a/net/babel/files/babeld.init
+++ b/net/babel/files/babeld.init
@@ -2,37 +2,126 @@
 
 START=70
 
+listen_ifname() {
+	local name="$1"
+	local switch="$2"
+	local _uciname=`uci get -q -P /var/state network.$name.ifname`
+	append args "$switch ${_uciname:-$name}"
+	append interfaces "${_uciname:-$name}"
+}
+
+append_ifname() {
+	local section="$1"
+	local option="$2"
+	local switch="$3"
+	local _name
+	config_get _name "$section" "$option"
+	[ -z "$name" ] && return 0
+	local _uciname=`uci get -q -P /var/state network.$_name.ifname`
+	append args "$switch ${_uciname:-$_name}"
+}
+
+append_bool() {
+	local section="$1"
+	local option="$2"
+	local value="$3"
+	local _loctmp
+	config_get_bool _loctmp "$section" "$option"
+	[ "$_loctmp" -gt 0 ] && append args "$value"
+}
+
+append_parm() {
+	local section="$1"
+	local option="$2"
+	local switch="$3"
+	local _loctmp
+	config_get _loctmp "$section" "$option"
+	[ -z "$_loctmp" ] && return 0
+	append args "$switch $_loctmp"
+}
+
+babel_filter() {
+	local cfg="$1"
+	local _loctmp
+
+	local _enabled
+	config_get_bool _enabled "$cfg" 'enable' 1
+	[ "$_enabled" -eq 0 ] && return 0
+	
+	append args "-C '"
+
+	append_parm "$cfg" 'type' ''
+
+	append_parm "$cfg" 'ip' 'ip'
+	append_parm "$cfg" 'le' 'le'
+	append_parm "$cfg" 'ge' 'ge'
+	append_parm "$cfg" 'neigh' 'neigh'
+	append_parm "$cfg" 'id' 'id'
+	append_parm "$cfg" 'proto' 'proto'
+
+	append_ifname "$cfg" 'if' 'if'
+
+	append_bool "$cfg" 'local' 'local'
+
+	append args ' ' "'"
+}
+
 babel_addif() {
-	config_get ifname $1 ifname
-	append interfaces "$ifname"
+	local cfg="$1"
+
+	local _enabled
+	config_get_bool _enabled "$cfg" 'enable' 1
+	[ "$_enabled" -eq 0 ] && return 0
+	
+	listen_ifname "$cfg" "-C 'interface"
+
+	append_parm "$cfg" 'wired' 'wired'
+	append_parm "$cfg" 'link_quality' 'link-quality'
+	append_parm "$cfg" 'split_horizon' 'split-horizon'
+	append_parm "$cfg" 'rxcost' 'rxcost'
+	append_parm "$cfg" 'hello_interval' 'hello-interval'
+	append_parm "$cfg" 'update_interval' 'update-interval'
+
+	append args ' ' "'"
 }
 
 babel_config() {
 	local cfg="$1"
-	interfaces=
-	config_list_foreach "$cfg" interface babel_addif
-	pidfile=/var/run/babeld-"$cfg".pid
-	[ -z "$interfaces" ] && return 0
-	if [ -e $pidfile ] ; then
-		echo "$pidfile exists -- not starting babel." >&2
-	else
-		/usr/sbin/babeld -D -I $pidfile $interfaces
-	fi
+
+	append_bool "$cfg" 'carrier_sense' '-l'
+	append_bool "$cfg" 'assume_wireless' '-w'
+	append_bool "$cfg" 'no_split_horizon' '-s'
+	append_bool "$cfg" 'parasitic' '-P'
+
+	append_parm "$cfg" 'multicast_address' '-m'
+	append_parm "$cfg" 'port' '-p'
+	append_parm "$cfg" 'state_file' '-S'
+	append_parm "$cfg" 'hello_interval' '-h'
+	append_parm "$cfg" 'wired_hello_interval' '-H'
+	append_parm "$cfg" 'idle_hello_interval' '-i'
+	append_parm "$cfg" 'kernel_priority' '-k'
+	append_parm "$cfg" 'duplication_priority' '-A'
+	append_parm "$cfg" 'debug' '-d'
+	append_parm "$cfg" 'local_server' '-g'
+	append_parm "$cfg" 'export_table' '-t'
+	append_parm "$cfg" 'import_table' '-T'
+	append_parm "$cfg" 'conffile' '-c'
+	append_parm "$cfg" 'logfile' '-L'
+	append_parm "$cfg" 'pidfile' '-I'
 }
 
 start() {
-	if [ -x /etc/init.d/ahcpd ] && /etc/init.d/ahcpd enabled; then
-		echo 'Not starting babel -- will be started by ahcpd.'
-		exit 0
-	fi
-	include /lib/network
-	scan_interfaces
-	config_load babeld
 	mkdir -p /var/lib
-	config_foreach babel_config babeld
+	config_load babeld
+	unset args
+	unset interfaces
+	config_foreach babel_config general
+	config_foreach babel_addif interface
+	config_foreach babel_filter filter
+	[ -z "$interfaces" ] && return 0
+	eval "/usr/sbin/babeld -D $args $interfaces"
 }
 
 stop() {
-	kill $(cat /var/run/babeld-*.pid)
-	rm -f /var/run/babeld-*.pid
+	killall babeld
 }
-- 
1.6.6


--K8nIJk4ghYZn606h--



More information about the Babel-users mailing list