balena-os / meta-balena

A collection of Yocto layers used to build balenaOS images
https://www.balena.io/os
971 stars 115 forks source link

networkmanager: remove race condition from shared dispatcher script #3428

Closed alexgg closed 1 month ago

alexgg commented 1 month ago

The shared dispatcher script runs when a shared iptables rules is identified and it moves it to the last place in the forward chain to avoid race conditions with the engine rule addition.

This commit refactors the script to remove the possibility of a rule changing positions between being identified by line number and removing it.

The script now only fetches the rule line number once and then uses its description to both append and remove.

It also has a final check to make sure the rule has been moved to the last position of the forward chain, and tries a series of times if that is not the case.

Change-type: patch


Contributor checklist

Reviewer Guidelines

alexgg commented 1 month ago

Duplicated in https://github.com/balena-os/meta-balena/pull/3429