Skip to content

Commit

Permalink
Remove diversity routing (Babel-Z).
Browse files Browse the repository at this point in the history
  • Loading branch information
jech committed Jun 1, 2022
1 parent fe9407b commit a081608
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 394 deletions.
5 changes: 5 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
babeld-1.13 (unreleased):

* Remove diversity support and related configuration file directives.
This is an incompatible change.

18 May 2022: babeld-1.12.1

* Implement separate PC values for unicast and multicast, which avoids
Expand Down
38 changes: 3 additions & 35 deletions babeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ main(int argc, char **argv)

while(1) {
opt = getopt(argc, argv,
"m:p:h:H:i:k:A:srS:d:g:G:lwz:M:t:T:c:C:DL:I:V");
"m:p:h:H:i:k:A:srS:d:g:G:lwM:t:T:c:C:DL:I:V");
if(opt < 0)
break;

Expand Down Expand Up @@ -242,20 +242,6 @@ main(int argc, char **argv)
case 'w':
all_wireless = 1;
break;
case 'z':
{
char *comma;
diversity_kind = (int)strtol(optarg, &comma, 0);
if(*comma == '\0')
diversity_factor = 128;
else if(*comma == ',')
diversity_factor = parse_nat(comma + 1);
else
goto usage;
if(diversity_factor <= 0 || diversity_factor > 256)
goto usage;
}
break;
case 'M': {
int l = parse_nat(optarg);
if(l < 0 || l > 3600)
Expand Down Expand Up @@ -1040,31 +1026,14 @@ dump_route(FILE *out, struct babel_route *route)
const unsigned char *nexthop =
memcmp(route->nexthop, route->neigh->address, 16) == 0 ?
NULL : route->nexthop;
char channels[100];

if(route->channels_len == 0) {
channels[0] = '\0';
} else {
int k, j = 0;
snprintf(channels, 100, " chan (");
j = strlen(channels);
for(k = 0; k < route->channels_len; k++) {
if(k > 0)
channels[j++] = ',';
snprintf(channels + j, 100 - j, "%u", (unsigned)route->channels[k]);
j = strlen(channels);
}
snprintf(channels + j, 100 - j, ")");
}

fprintf(out, "%s from %s metric %d (%d) refmetric %d id %s "
"seqno %d%s age %d via %s neigh %s%s%s%s\n",
"seqno %d age %d via %s neigh %s%s%s%s\n",
format_prefix(route->src->prefix, route->src->plen),
format_prefix(route->src->src_prefix, route->src->src_plen),
route_metric(route), route_smoothed_metric(route), route->refmetric,
format_eui64(route->src->id),
(int)route->seqno,
channels,
(int)(now.tv_sec - route->time),
route->neigh->ifp->name,
format_address(route->neigh->address),
Expand Down Expand Up @@ -1096,7 +1065,7 @@ dump_tables(FILE *out)

FOR_ALL_NEIGHBOURS(neigh) {
fprintf(out, "Neighbour %s dev %s reach %04x ureach %04x "
"rxcost %u txcost %d rtt %s rttcost %u chan %d%s.\n",
"rxcost %u txcost %d rtt %s rttcost %u%s.\n",
format_address(neigh->address),
neigh->ifp->name,
neigh->hello.reach,
Expand All @@ -1105,7 +1074,6 @@ dump_tables(FILE *out)
neigh->txcost,
format_thousands(neigh->rtt),
neighbour_rttcost(neigh),
neigh->ifp->channel,
if_up(neigh->ifp) ? "" : " (down)");
}

Expand Down
48 changes: 0 additions & 48 deletions babeld.man
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,6 @@ sent on wireless interfaces. The default is 4 seconds.
Specify the interval in seconds at which scheduled hello packets are
sent on wired interfaces. The default is 4 seconds.
.TP
.BI \-z " kind" " \fR[\fB," factor "\fR]"
Enable diversity-sensitive routing. The value
.B kind
defines the diversity algorithm used, and can be one of
.B 0
(no diversity),
.B 1
(per-interface diversity with no memory),
.B 2
(per-channel diversity with no memory),
or
.B 3
(per-channel diversity with memory).
The value
.B factor
specifies by how much the cost of non-interfering routes is multiplied,
in units of 1/256; the default is 128 (i.e. division by 2).
.TP
.BI \-M " half-time"
Specify the half-time in seconds of the exponential decay used for
smoothing metrics for performing route selection; the value 0 disables
Expand Down Expand Up @@ -258,19 +240,6 @@ This specifies whether to use carrier sense for determining interface
availability, and is equivalent to the command-line option
.BR \-l .
.TP
.BR diversity " {" true | false | "\fIkind\fB" }
This specifies the diversity algorithm to use;
.B true
is equivalent to
.I kind
3. The default is
.B false
(do not use any diversity algorithm).
.TP
.BI diversity-factor " factor"
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).
.TP
.BI smoothing-half-life " seconds"
This specifies the half-life in seconds of the exponential decay used
for smoothing metrics for performing route selection, and is
Expand Down Expand Up @@ -383,23 +352,6 @@ used for computing metrics of routes going through this interface depends
on whether link quality estimation is being done. The default is 256 if
the interface is wireless, and 96 otherwise.
.TP
.BI channel " channel"
Sets the channel for this interface. The value
.I channel
can be either an integer, or one of the strings
.B interfering
or
.BR noninterfering .
The default is to autodetect the channel number for wireless interfaces,
and
.B noninterfering
for other interfaces.
.TP
.BR faraway " {" true | false }
This specifies whether the network is "far away", in the sense that
networks behind it don't interfere with networks in front of it. By
default, networks are not far away.
.TP
.BI hello\-interval " interval"
This defines the interval between hello packets sent on this interface.
The default is specified with the
Expand Down
46 changes: 0 additions & 46 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,28 +622,6 @@ parse_anonymous_ifconf(int c, gnc_t gnc, void *closure,
if(c < -1)
goto error;
if_conf->split_horizon = v;
} else if(strcmp(token, "channel") == 0) {
char *t, *end;

c = getword(c, &t, gnc, closure);
if(c < -1)
goto error;

if(strcmp(t, "noninterfering") == 0)
if_conf->channel = IF_CHANNEL_NONINTERFERING;
else if(strcmp(t, "interfering") == 0)
if_conf->channel = IF_CHANNEL_INTERFERING;
else {
if_conf->channel = strtol(t, &end, 0);
if(*end != '\0')
goto error;
}

free(t);

if((if_conf->channel < 1 || if_conf->channel > 255) &&
if_conf->channel != IF_CHANNEL_NONINTERFERING)
goto error;
} else if(strcmp(token, "enable-timestamps") == 0) {
int v;
c = getbool(c, &v, gnc, closure);
Expand Down Expand Up @@ -916,7 +894,6 @@ merge_ifconf(struct interface_conf *dest,
MERGE(faraway);
MERGE(unicast);
MERGE(accept_bad_signatures);
MERGE(channel);
MERGE(enable_timestamps);
MERGE(rfc6126);
MERGE(rtt_decay);
Expand Down Expand Up @@ -991,8 +968,6 @@ parse_option(int c, gnc_t gnc, void *closure, char *token)
if(config_finalised) {
if(strcmp(token, "link-detect") != 0 &&
strcmp(token, "log-file") != 0 &&
strcmp(token, "diversity") != 0 &&
strcmp(token, "diversity-factor") != 0 &&
strcmp(token, "smoothing-half-life") != 0)
goto error;
}
Expand Down Expand Up @@ -1098,27 +1073,6 @@ parse_option(int c, gnc_t gnc, void *closure, char *token)
if(c < -1 || d < 0)
goto error;
debug = d;
} else if(strcmp(token, "diversity") == 0) {
int d;
c = skip_whitespace(c, gnc, closure);
if(c >= '0' && c <= '9') {
c = getint(c, &d, gnc, closure);
if(c < -1)
goto error;
} else {
int b;
c = getbool(c, &b, gnc, closure);
if(c < -1)
goto error;
d = (b == CONFIG_YES) ? 3 : 0;
}
diversity_kind = d;
} else if(strcmp(token, "diversity-factor") == 0) {
int f;
c = getint(c, &f, gnc, closure);
if(c < -1 || f < 0 || f > 256)
goto error;
diversity_factor = f;
} else if(strcmp(token, "smoothing-half-life") == 0) {
int h;
c = getint(c, &h, gnc, closure);
Expand Down
34 changes: 1 addition & 33 deletions interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,31 +196,6 @@ check_interface_ipv4(struct interface *ifp)
return 0;
}

static int
check_interface_channel(struct interface *ifp)
{
int channel = IF_CONF(ifp, channel);
int rc = 1;

if(channel == IF_CHANNEL_UNKNOWN) {
/* IF_WIRELESS merely means that we know for sure that the
interface is wireless, so check unconditionally. */
channel = kernel_interface_channel(ifp->name, ifp->ifindex);
if(channel < 0) {
if((ifp->flags & IF_WIRELESS))
rc = -1;
channel = (ifp->flags & IF_WIRELESS) ?
IF_CHANNEL_INTERFERING : IF_CHANNEL_NONINTERFERING;
}
}

if(ifp->channel != channel) {
ifp->channel = channel;
return rc;
}
return 0;
}

static int
check_link_local_addresses(struct interface *ifp)
{
Expand Down Expand Up @@ -485,11 +460,6 @@ interface_updown(struct interface *ifp, int up)
goto fail;
}

rc = check_interface_channel(ifp);
if(rc < 0)
fprintf(stderr,
"Warning: couldn't determine channel of interface %s.\n",
ifp->name);
update_interface_metric(ifp);
rc = check_interface_ipv4(ifp);

Expand All @@ -502,10 +472,9 @@ interface_updown(struct interface *ifp, int up)
ifp->key = NULL;
}

debugf("Upped interface %s (cost=%d, channel=%d%s).\n",
debugf("Upped interface %s (cost=%d%s).\n",
ifp->name,
ifp->cost,
ifp->channel,
ifp->ipv4 ? ", IPv4" : "");

set_timeout(&ifp->hello_timeout, ifp->hello_interval);
Expand Down Expand Up @@ -597,7 +566,6 @@ check_interfaces(void)
/* Bother, said Pooh. We should probably check for a change
in IPv4 addresses at this point. */
check_link_local_addresses(ifp);
check_interface_channel(ifp);
rc = check_interface_ipv4(ifp);
if(rc > 0) {
send_multicast_request(ifp, NULL, 0, NULL, 0);
Expand Down
2 changes: 0 additions & 2 deletions interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ struct interface_conf {
char rfc6126;
char accept_bad_signatures;
char v4viav6;
int channel;
unsigned int rtt_decay;
unsigned int rtt_min;
unsigned int rtt_max;
Expand Down Expand Up @@ -124,7 +123,6 @@ struct interface {
unsigned int ifindex;
unsigned short flags;
unsigned short cost;
int channel;
struct timeval hello_timeout;
struct timeval update_timeout;
struct timeval update_flush_timeout;
Expand Down
1 change: 0 additions & 1 deletion kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ int kernel_interface_ipv4(const char *ifname, int ifindex,
unsigned char *addr_r);
int kernel_interface_mtu(const char *ifname, int ifindex);
int kernel_interface_wireless(const char *ifname, int ifindex);
int kernel_interface_channel(const char *ifname, int ifindex);
int kernel_route(int operation, int table,
const unsigned char *dest, unsigned short plen,
const unsigned char *src, unsigned short src_plen,
Expand Down
53 changes: 0 additions & 53 deletions kernel_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -943,59 +943,6 @@ struct iwreq_subset {
} u;
};

static int
freq_to_chan(struct iw_freq *freq)
{
int m = freq->m, e = freq->e;

/* If exponent is 0, assume the channel is encoded directly in m. */
if(e == 0 && m > 0 && m < 254)
return m;

if(e <= 6) {
int mega, step, c, i;

/* This encodes 1 MHz */
mega = 1000000;
for(i = 0; i < e; i++)
mega /= 10;

/* Channels 1 through 13 are 5 MHz apart, with channel 1 at 2412. */
step = 5 * mega;
c = 1 + (m - 2412 * mega + step / 2) / step;
if(c >= 1 && c <= 13)
return c;

/* Channel 14 is at 2484 MHz */
if(c >= 14 && m < 2484 * mega + step / 2)
return 14;

/* 802.11a channel 36 is at 5180 MHz */
c = 36 + (m - 5180 * mega + step / 2) / step;
if(c >= 34 && c <= 165)
return c;
}

errno = ENOENT;
return -1;
}

int
kernel_interface_channel(const char *ifname, int ifindex)
{
struct iwreq_subset iwreq;
int rc;

memset(&iwreq, 0, sizeof(iwreq));
strncpy(iwreq.ifr_ifrn.ifrn_name, ifname, IFNAMSIZ);

rc = ioctl(dgram_socket, SIOCGIWFREQ, &iwreq);
if(rc >= 0)
return freq_to_chan(&iwreq.u.freq);
else
return -1;
}

int
kernel_has_ipv6_subtrees(void)
{
Expand Down
7 changes: 0 additions & 7 deletions kernel_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,6 @@ kernel_interface_wireless(const char *ifname, int ifindex)
return 0;
}

int
kernel_interface_channel(const char *ifname, int ifindex)
{
errno = ENOSYS;
return -1;
}

int
kernel_has_ipv6_subtrees(void)
{
Expand Down
Loading

0 comments on commit a081608

Please sign in to comment.