Commit 794863e9 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Merge commit 'babeld-1.1.3' into babelz

Conflicts:
	CHANGES
	babeld.c
	kernel_socket.c
	network.c
	route.c
	route.h
parents 890990d7 b8170648
.gitignore export-ignore
.gitattributes export-ignore
*.o
babeld
babeld.html
babeld 1.1.2 (unreleased): 3 August 2011: babeld 1.1.3
* Implemented an option -u to keep unfeasible routes; this is useful
for giving more data to front-end interfaces.
* Fixed a number of minor bugs in the front-end interface.
* Fixed incorrect handling of interfaces with multiple link-local
addresses (thanks to Matthieu Boutier).
27 July 2011: babeld 1.1.2:
* Changed the strategy used to tweak an installed route in a way that * Changed the strategy used to tweak an installed route in a way that
should avoid packet loss (thanks to Dave Taht). should avoid packet loss (thanks to Dave Taht).
......
...@@ -9,10 +9,10 @@ CFLAGS = $(CDEBUGFLAGS) $(DEFINES) $(EXTRA_DEFINES) ...@@ -9,10 +9,10 @@ CFLAGS = $(CDEBUGFLAGS) $(DEFINES) $(EXTRA_DEFINES)
LDLIBS = -lrt LDLIBS = -lrt
SRCS = babeld.c net.c kernel.c util.c network.c source.c neighbour.c \ SRCS = babeld.c net.c kernel.c util.c network.c source.c neighbour.c \
route.c xroute.c message.c resend.c config.c local.c route.c xroute.c message.c resend.c configuration.c local.c
OBJS = babeld.o net.o kernel.o util.o network.o source.o neighbour.o \ OBJS = babeld.o net.o kernel.o util.o network.o source.o neighbour.o \
route.o xroute.o message.o resend.o config.o local.o route.o xroute.o message.o resend.o configuration.o local.o
babeld: $(OBJS) babeld: $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o babeld $(OBJS) $(LDLIBS) $(CC) $(CFLAGS) $(LDFLAGS) -o babeld $(OBJS) $(LDLIBS)
......
...@@ -50,7 +50,7 @@ THE SOFTWARE. ...@@ -50,7 +50,7 @@ THE SOFTWARE.
#include "xroute.h" #include "xroute.h"
#include "message.h" #include "message.h"
#include "resend.h" #include "resend.h"
#include "config.h" #include "configuration.h"
#include "local.h" #include "local.h"
struct timeval now; struct timeval now;
...@@ -125,7 +125,7 @@ main(int argc, char **argv) ...@@ -125,7 +125,7 @@ main(int argc, char **argv)
protocol_port = 6697; protocol_port = 6697;
while(1) { while(1) {
opt = getopt(argc, argv, "m:p:h:H:i:k:A:PsS:d:g:lwz:t:T:c:C:DL:I:"); opt = getopt(argc, argv, "m:p:h:H:i:k:A:PsuS:d:g:lwz:t:T:c:C:DL:I:");
if(opt < 0) if(opt < 0)
break; break;
...@@ -180,6 +180,9 @@ main(int argc, char **argv) ...@@ -180,6 +180,9 @@ main(int argc, char **argv)
case 's': case 's':
split_horizon = 0; split_horizon = 0;
break; break;
case 'u':
keep_unfeasible = 1;
break;
case 'S': case 'S':
state_file = optarg; state_file = optarg;
break; break;
...@@ -788,11 +791,11 @@ main(int argc, char **argv) ...@@ -788,11 +791,11 @@ main(int argc, char **argv)
" " " "
"[-h hello] [-H wired_hello] [-i idle_hello] [-z kind[,factor]]\n" "[-h hello] [-H wired_hello] [-i idle_hello] [-z kind[,factor]]\n"
" " " "
"[-k metric] [-A metric] [-s] [-P] [-l] [-w] [-d level] [-g port]\n" "[-k metric] [-A metric] [-s] [-P] [-l] [-w] [-u] [-g port]\n"
" " " "
"[-t table] [-T table] [-c file] [-C statement]\n" "[-t table] [-T table] [-c file] [-C statement]\n"
" " " "
"[-D] [-L logfile] [-I pidfile]\n" "[-d level] [-D] [-L logfile] [-I pidfile]\n"
" " " "
"[id] interface...\n", "[id] interface...\n",
argv[0]); argv[0]);
......
...@@ -90,6 +90,11 @@ explicitly overridden in the configuration file. ...@@ -90,6 +90,11 @@ explicitly overridden in the configuration file.
Do not perform split-horizon processing on wired interfaces. Do not perform split-horizon processing on wired interfaces.
Split-horizon is not performed on wireless interfaces. Split-horizon is not performed on wireless interfaces.
.TP .TP
.B \-u
Do not flush unfeasible (useless) routes. This is useful in order to
announce more information to a front-end (see
.BR \-g ).
.TP
.B \-P .B \-P
Run in parasitic (passive) mode. The daemon will only announce Run in parasitic (passive) mode. The daemon will only announce
redistributed routes. redistributed routes.
......
...@@ -35,7 +35,7 @@ THE SOFTWARE. ...@@ -35,7 +35,7 @@ THE SOFTWARE.
#include "babeld.h" #include "babeld.h"
#include "util.h" #include "util.h"
#include "network.h" #include "network.h"
#include "config.h" #include "configuration.h"
struct filter *input_filters = NULL; struct filter *input_filters = NULL;
struct filter *output_filters = NULL; struct filter *output_filters = NULL;
......
...@@ -328,8 +328,7 @@ netlink_read(struct netlink *nl, struct netlink *nl_ignore, int answer, ...@@ -328,8 +328,7 @@ netlink_read(struct netlink *nl, struct netlink *nl_ignore, int answer,
kdebugf("(ACK)\n"); kdebugf("(ACK)\n");
return 0; return 0;
} else { } else {
errno = -err->error; kdebugf("netlink_read: %s\n", strerror(-err->error));
perror("netlink_read");
errno = -err->error; errno = -err->error;
return -1; return -1;
} }
......
...@@ -39,7 +39,7 @@ THE SOFTWARE. ...@@ -39,7 +39,7 @@ THE SOFTWARE.
#include "xroute.h" #include "xroute.h"
#include "resend.h" #include "resend.h"
#include "message.h" #include "message.h"
#include "config.h" #include "configuration.h"
#include "kernel.h" #include "kernel.h"
unsigned char packet_header[4] = {42, 2}; unsigned char packet_header[4] = {42, 2};
...@@ -254,8 +254,7 @@ parse_packet(const unsigned char *from, struct network *net, ...@@ -254,8 +254,7 @@ parse_packet(const unsigned char *from, struct network *net,
net->activity_time = now.tv_sec; net->activity_time = now.tv_sec;
update_hello_interval(net); update_hello_interval(net);
changed = update_neighbour(neigh, seqno, interval); changed = update_neighbour(neigh, seqno, interval);
if(changed) update_neighbour_metric(neigh, changed);
update_neighbour_metric(neigh);
if(interval > 0) if(interval > 0)
schedule_neighbours_check(interval * 10, 0); schedule_neighbours_check(interval * 10, 0);
} else if(type == MESSAGE_IHU) { } else if(type == MESSAGE_IHU) {
...@@ -272,10 +271,11 @@ parse_packet(const unsigned char *from, struct network *net, ...@@ -272,10 +271,11 @@ parse_packet(const unsigned char *from, struct network *net,
format_address(from), net->ifname, format_address(from), net->ifname,
format_address(address)); format_address(address));
if(message[2] == 0 || network_ll_address(net, address)) { if(message[2] == 0 || network_ll_address(net, address)) {
int changed = txcost != neigh->txcost;
neigh->txcost = txcost; neigh->txcost = txcost;
neigh->ihu_time = now; neigh->ihu_time = now;
neigh->ihu_interval = interval; neigh->ihu_interval = interval;
update_neighbour_metric(neigh); update_neighbour_metric(neigh, changed);
if(interval > 0) if(interval > 0)
schedule_neighbours_check(interval * 10 * 3, 0); schedule_neighbours_check(interval * 10 * 3, 0);
} }
......
...@@ -105,7 +105,8 @@ find_neighbour(const unsigned char *address, struct network *net) ...@@ -105,7 +105,8 @@ find_neighbour(const unsigned char *address, struct network *net)
return neigh; return neigh;
} }
/* Recompute a neighbour's rxcost. Return true if anything changed. */ /* Recompute a neighbour's rxcost. Return true if anything changed.
This does not call local_notify_neighbour, see update_neighbour_metric. */
int int
update_neighbour(struct neighbour *neigh, int hello, int hello_interval) update_neighbour(struct neighbour *neigh, int hello, int hello_interval)
{ {
...@@ -190,8 +191,6 @@ update_neighbour(struct neighbour *neigh, int hello, int hello_interval) ...@@ -190,8 +191,6 @@ update_neighbour(struct neighbour *neigh, int hello, int hello_interval)
send_unicast_request(neigh, NULL, 0); send_unicast_request(neigh, NULL, 0);
send_ihu(neigh, NULL); send_ihu(neigh, NULL);
} }
if(rc)
local_notify_neighbour(neigh, LOCAL_CHANGE);
return rc; return rc;
} }
...@@ -248,10 +247,7 @@ check_neighbours() ...@@ -248,10 +247,7 @@ check_neighbours()
rc = reset_txcost(neigh); rc = reset_txcost(neigh);
changed = changed || rc; changed = changed || rc;
if(changed) { update_neighbour_metric(neigh, changed);
update_neighbour_metric(neigh);
local_notify_neighbour(neigh, LOCAL_CHANGE);
}
if(neigh->hello_interval > 0) if(neigh->hello_interval > 0)
msecs = MIN(msecs, neigh->hello_interval * 10); msecs = MIN(msecs, neigh->hello_interval * 10);
......
...@@ -38,7 +38,7 @@ THE SOFTWARE. ...@@ -38,7 +38,7 @@ THE SOFTWARE.
#include "neighbour.h" #include "neighbour.h"
#include "message.h" #include "message.h"
#include "route.h" #include "route.h"
#include "config.h" #include "configuration.h"
struct network *networks = NULL; struct network *networks = NULL;
...@@ -356,7 +356,6 @@ network_up(struct network *net, int up) ...@@ -356,7 +356,6 @@ network_up(struct network *net, int up)
for(i = 0; i < rc; i++) for(i = 0; i < rc; i++)
memcpy(net->ll[i], ll[i].prefix, 16); memcpy(net->ll[i], ll[i].prefix, 16);
net->numll = rc; net->numll = rc;
memcpy(net->ll, ll, rc * 16);
} }
} }
set_timeout(&net->hello_timeout, net->hello_interval); set_timeout(&net->hello_timeout, net->hello_interval);
......
...@@ -31,7 +31,7 @@ THE SOFTWARE. ...@@ -31,7 +31,7 @@ THE SOFTWARE.
#include "resend.h" #include "resend.h"
#include "message.h" #include "message.h"
#include "network.h" #include "network.h"
#include "config.h" #include "configuration.h"
struct timeval resend_time = {0, 0}; struct timeval resend_time = {0, 0};
struct resend *to_resend = NULL; struct resend *to_resend = NULL;
......
...@@ -37,7 +37,7 @@ THE SOFTWARE. ...@@ -37,7 +37,7 @@ THE SOFTWARE.
#include "xroute.h" #include "xroute.h"
#include "message.h" #include "message.h"
#include "resend.h" #include "resend.h"
#include "config.h" #include "configuration.h"
#include "local.h" #include "local.h"
struct route *routes = NULL; struct route *routes = NULL;
...@@ -46,6 +46,7 @@ int kernel_metric = 0; ...@@ -46,6 +46,7 @@ int kernel_metric = 0;
int allow_duplicates = -1; int allow_duplicates = -1;
int diversity_kind = DIVERSITY_NONE; int diversity_kind = DIVERSITY_NONE;
int diversity_factor = 256; /* in units of 1/256 */ int diversity_factor = 256; /* in units of 1/256 */
int keep_unfeasible = 0;
struct route * struct route *
find_route(const unsigned char *prefix, unsigned char plen, find_route(const unsigned char *prefix, unsigned char plen,
...@@ -398,17 +399,24 @@ update_route_metric(struct route *route) ...@@ -398,17 +399,24 @@ update_route_metric(struct route *route)
} }
} }
/* Called whenever a neighbour's cost changes, to update the metric of
all routes through that neighbour. Calls local_notify_neighbour. */
void void
update_neighbour_metric(struct neighbour *neigh) update_neighbour_metric(struct neighbour *neigh, int changed)
{ {
int i;
i = 0; if(changed) {
while(i < numroutes) { int i;
if(routes[i].neigh == neigh)
update_route_metric(&routes[i]); i = 0;
i++; while(i < numroutes) {
if(routes[i].neigh == neigh)
update_route_metric(&routes[i]);
i++;
}
} }
local_notify_neighbour(neigh, LOCAL_CHANGE);
} }
void void
...@@ -485,7 +493,7 @@ update_route(const unsigned char *a, const unsigned char *p, unsigned char plen, ...@@ -485,7 +493,7 @@ update_route(const unsigned char *a, const unsigned char *p, unsigned char plen,
} }
route->src = src; route->src = src;
if(feasible && refmetric < INFINITY) if((feasible || keep_unfeasible) && refmetric < INFINITY)
route->time = now.tv_sec; route->time = now.tv_sec;
route->seqno = seqno; route->seqno = seqno;
change_route_metric(route, change_route_metric(route,
...@@ -505,8 +513,10 @@ update_route(const unsigned char *a, const unsigned char *p, unsigned char plen, ...@@ -505,8 +513,10 @@ update_route(const unsigned char *a, const unsigned char *p, unsigned char plen,
return NULL; return NULL;
if(!feasible) { if(!feasible) {
send_unfeasible_request(neigh, 0, seqno, metric, src); send_unfeasible_request(neigh, 0, seqno, metric, src);
return NULL; if(!keep_unfeasible)
return NULL;
} }
if(numroutes >= maxroutes) { if(numroutes >= maxroutes) {
struct route *new_routes; struct route *new_routes;
int n = maxroutes < 1 ? 8 : 2 * maxroutes; int n = maxroutes < 1 ? 8 : 2 * maxroutes;
......
...@@ -52,6 +52,7 @@ extern struct route *routes; ...@@ -52,6 +52,7 @@ extern struct route *routes;
extern int numroutes, maxroutes; extern int numroutes, maxroutes;
extern int kernel_metric, allow_duplicates; extern int kernel_metric, allow_duplicates;
extern int diversity_kind, diversity_factor; extern int diversity_kind, diversity_factor;
extern int keep_unfeasible;
struct route *find_route(const unsigned char *prefix, unsigned char plen, struct route *find_route(const unsigned char *prefix, unsigned char plen,
struct neighbour *neigh, const unsigned char *nexthop); struct neighbour *neigh, const unsigned char *nexthop);
...@@ -73,7 +74,7 @@ struct route *find_best_route(const unsigned char *prefix, unsigned char plen, ...@@ -73,7 +74,7 @@ struct route *find_best_route(const unsigned char *prefix, unsigned char plen,
int feasible, struct neighbour *exclude); int feasible, struct neighbour *exclude);
struct route *install_best_route(const unsigned char prefix[16], struct route *install_best_route(const unsigned char prefix[16],
unsigned char plen); unsigned char plen);
void update_neighbour_metric(struct neighbour *neigh); void update_neighbour_metric(struct neighbour *neigh, int changed);
void update_network_metric(struct network *net); void update_network_metric(struct network *net);
void update_route_metric(struct route *route); void update_route_metric(struct route *route);
struct route *update_route(const unsigned char *a, struct route *update_route(const unsigned char *a,
......
...@@ -35,7 +35,7 @@ THE SOFTWARE. ...@@ -35,7 +35,7 @@ THE SOFTWARE.
#include "route.h" #include "route.h"
#include "xroute.h" #include "xroute.h"
#include "util.h" #include "util.h"
#include "config.h" #include "configuration.h"
#include "network.h" #include "network.h"
#include "local.h" #include "local.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment