]> git.ipfire.org Git - thirdparty/bird.git/commit
Table: fix a race condition in export
authorMaria Matejka <mq@ucw.cz>
Fri, 23 May 2025 17:17:53 +0000 (19:17 +0200)
committerMaria Matejka <mq@ucw.cz>
Sun, 25 May 2025 19:01:49 +0000 (21:01 +0200)
commita392c9e106c166f30ed9d41746c4bd14b02ae404
treeb1ffad4553b998f9599d3c599204c9bbf83ce1f7
parenteda1a87f6e01bddd013b4d0db6a753430158f80f
Table: fix a race condition in export

The race condition happens as follows:

- channel A starts feeding
- channel B imports a route ahead of the feeding pointer
- channel A exports this route and continues feeding from the pointer
- no other import hits this specific prefix
- there is at least one channel C which has not cleared this export
- channel A computes ecnt=0 for this prefix because all exports
  have been already cleared
- the condition e >= ecnt mistakenly triggers retry

If the birdloops involved get assigned to the same thread, this race
condition then can't recover and the thread is stuck in an infinite
loop.

Fixed the race condition by moving the consistency check after actually
checking eligibility of the export, not before.

Found by randomly observing performance tests.
nest/rt-table.c