sapcc / asr1k-neutron-l3

Cisco ASR 1000 Neutron L3 driver
Apache License 2.0
4 stars 1 forks source link

Reduce likelyhood to reuse BDI ids to reduce risk of race condition #35

Closed swagner-de closed 4 years ago

swagner-de commented 4 years ago

In order to avoid a race condition in the ASR firmware, we reduce the likelyhood of BDI ids beeing reused soon after they have been deleted. We do that by randomly picking a seconddot1q id (which is later set as BDI id) from all free seconddot1q ids. Hence, BDI id reuse probability is 1/len(free_seconddot1qs).

The former implementations went by numeric order and just selected the next available id thus having a much larger risk of reuse.

In this PR we also move the fetch of the available seconddot1qs into the database transaction, removing the possibilty of another thread then executing a dirty read.