Skip to content

Commit

Permalink
Merge tag 'babeld-1.8.4' into cherry-pickers
Browse files Browse the repository at this point in the history
  • Loading branch information
thosmos committed Aug 17, 2021
2 parents 51f0cec + 8627b6f commit abfd61d
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 38 deletions.
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
9 November 2018: babeld-1.8.4

* Fixed a bug that discarded pipelined commands received on the local
configuration interface.
* Added the per-interface option rfc6126-compatible.

24 September 2018: babeld-1.8.3

* Fixed a read-only two byte buffer overflow in the packet parser.
Expand Down
8 changes: 8 additions & 0 deletions babeld.man
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,14 @@ for tunnel interfaces, and
.B false
otherwise.
.TP
.BR rfc6126\-compatible " {" true | false }
Only send TLVs that are defined by RFC 6126, the older version of Babel.
The default is
.BR false .
This option does nothing in this version of
.BR babeld ,
it is provided for compatiblity with future versions.
.TP
.BI rtt\-decay " decay"
This specifies the decay factor for the exponential moving average of
RTT samples, in units of 1/256. Must be between 1 and 256, inclusive.
Expand Down
7 changes: 7 additions & 0 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,12 @@ parse_anonymous_ifconf(int c, gnc_t gnc, void *closure,
if(c < -1)
goto error;
if_conf->enable_timestamps = v;
} else if(strcmp(token, "rfc6126-compatible") == 0) {
int v;
c = getbool(c, &v, gnc, closure);
if(c < -1)
goto error;
if_conf->rfc6126 = v;
} else if(strcmp(token, "rtt-decay") == 0) {
int decay;
c = getint(c, &decay, gnc, closure);
Expand Down Expand Up @@ -728,6 +734,7 @@ merge_ifconf(struct interface_conf *dest,
MERGE(faraway);
MERGE(channel);
MERGE(enable_timestamps);
MERGE(rfc6126);
MERGE(rtt_decay);
MERGE(rtt_min);
MERGE(rtt_max);
Expand Down
5 changes: 5 additions & 0 deletions interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,11 @@ interface_up(struct interface *ifp, int up)
"but timestamps are disabled on interface %s.\n",
ifp->name);

if(IF_CONF(ifp, rfc6126) == CONFIG_YES)
ifp->flags |= IF_RFC6126;
else
ifp->flags &= ~IF_RFC6126;

rc = check_link_local_addresses(ifp);
if(rc < 0) {
goto fail;
Expand Down
3 changes: 3 additions & 0 deletions interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ struct interface_conf {
char faraway;
int channel;
int enable_timestamps;
int rfc6126;
unsigned int rtt_decay;
unsigned int rtt_min;
unsigned int rtt_max;
Expand All @@ -70,6 +71,8 @@ struct interface_conf {
#define IF_FARAWAY (1 << 4)
/* Send timestamps in Hello and IHU. */
#define IF_TIMESTAMPS (1 << 5)
/* Remain compatible with RFC 6126. */
#define IF_RFC6126 (1 << 6)

/* Only INTERFERING can appear on the wire. */
#define IF_CHANNEL_UNKNOWN 0
Expand Down
79 changes: 41 additions & 38 deletions local.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ local_notify_all_1(struct local_socket *s)
int
local_read(struct local_socket *s)
{
int rc;
int rc, n;
char *eol;
char reply[100] = "ok\n";
const char *message = NULL;
Expand All @@ -384,47 +384,50 @@ local_read(struct local_socket *s)
return rc;
s->n += rc;

eol = memchr(s->buf, '\n', s->n);
if(eol == NULL)
return 1;
while(s->n > 0) {
eol = memchr(s->buf, '\n', s->n);
if(eol == NULL)
break;
n = eol + 1 - s->buf;

rc = parse_config_from_string(s->buf, eol + 1 - s->buf, &message);
switch(rc) {
case CONFIG_ACTION_DONE:
break;
case CONFIG_ACTION_QUIT:
shutdown(s->fd, 1);
reply[0] = '\0';
break;
case CONFIG_ACTION_DUMP:
local_notify_all_1(s);
break;
case CONFIG_ACTION_MONITOR:
local_notify_all_1(s);
s->monitor = 1;
break;
case CONFIG_ACTION_UNMONITOR:
s->monitor = 0;
break;
case CONFIG_ACTION_NO:
snprintf(reply, sizeof(reply), "no%s%s\n",
message ? " " : "", message ? message : "");
break;
default:
snprintf(reply, sizeof(reply), "bad\n");
}
rc = parse_config_from_string(s->buf, n, &message);
switch(rc) {
case CONFIG_ACTION_DONE:
break;
case CONFIG_ACTION_QUIT:
shutdown(s->fd, 1);
reply[0] = '\0';
break;
case CONFIG_ACTION_DUMP:
local_notify_all_1(s);
break;
case CONFIG_ACTION_MONITOR:
local_notify_all_1(s);
s->monitor = 1;
break;
case CONFIG_ACTION_UNMONITOR:
s->monitor = 0;
break;
case CONFIG_ACTION_NO:
snprintf(reply, sizeof(reply), "no%s%s\n",
message ? " " : "", message ? message : "");
break;
default:
snprintf(reply, sizeof(reply), "bad\n");
}

if(reply[0] != '\0') {
rc = write_timeout(s->fd, reply, strlen(reply));
if(rc < 0)
goto fail;
if(reply[0] != '\0') {
rc = write_timeout(s->fd, reply, strlen(reply));
if(rc < 0) {
goto fail;
}
}
if(s->n > n)
memmove(s->buf, s->buf + n, s->n - n);
s->n -= n;
}

if(s->n > eol + 1 - s->buf) {
memmove(s->buf, eol + 1, s->n - (eol + 1 - s->buf));
s->n -= (eol + 1 - s->buf);
} else {
s->n = 0;
if(s->n == 0) {
free(s->buf);
s->buf = NULL;
}
Expand Down

0 comments on commit abfd61d

Please sign in to comment.