[PATCH] babel: Fix missing modulo comparison of seqnos

Juliusz Chroboczek jch at irif.fr
Tue Jan 31 01:11:06 CET 2023


> Introduce a strict-inequality version of the modulo-comparison for this
> purpose.

Thanks.

I'm a little worried about the code around line 1017:

      struct babel_source *s = babel_get_source(p, e, e->router_id);
      s->expires = current_time() + BABEL_GARBAGE_INTERVAL;

      if (gt_mod64k(msg.update.seqno, s->seqno) ||
	  ((msg.update.seqno == s->seqno) && (msg.update.metric < s->metric)))
      {
	s->seqno = msg.update.seqno;
	s->metric = msg.update.metric;
      }

If the source is just being created, then the function babel_get_source
will initialise s->seqno to 0.  If msg.update.seqno happens to be in the
interval [0x8000,0xFFFF], then the conditional at line 1020 will fail to
trigger, and s->seqno will not be updated until msg.updae.seqno catches up
with 0.

I think that babel_get_source should take an extra argument, the initial
seqno in case the source does not exist, and it should be called with
msg.update.seqno.  This corresponds to RFC 8966 Section 3.5.3.

-- Juliusz


More information about the Bird-users mailing list