This concludes backport of core#19760 [4/4]
https://github.com/bitcoin/bitcoin/pull/19760/commits/d5800da5199527a366024bc80cad7fcca17d5c4a
There is a minor change to a comment that is missing in p2p_permissions.py because of a new test that is not yet backported.