]> git.proxmox.com Git - mirror_frr.git/commit
bgpd: Don't try to recursively hold peer io mutex
authorDonald Sharp <sharpd@nvidia.com>
Thu, 2 Feb 2023 19:13:12 +0000 (14:13 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Thu, 2 Feb 2023 21:39:01 +0000 (16:39 -0500)
commitf1b1efdefc6b2141ed7de892d6f648a32c7718af
tree1d462e5930591644bc0a6a24ad1a913e68477599
parent73fb874e0aaff37b417e7a1d167e251d98a6daa1
bgpd: Don't try to recursively hold peer io mutex

BGP was modified in a0b937de428e14e869b8541f0b7810113d619c2e
to grab the peer->io_mtx before validating the header to ensure
that the input Queue was not being modified by anyone else at that
moment in time.  Unfortunately validate_header can detect a problem
and attempt to relock the mutex, which deadlocks.  This deadlock in
the bgp_io pthread is the lone deadlock at first, eventually though
bgp attempts to write another packet to the peer( say when the
it's time to send the next packet ) and the main pthread of bgpd
becomes deadlocked and then the whole bgpd process is stuck at that
point in time leaving us dead in the water.

The point of locking the mutex earlier was to ensure that the input
Queue wasn't being modified by anyone else, (Say reading off it )
as that we wanted to ensure that we don't hold more packets then necessary.

Let's grab the mutex long enough to look at the input Q size, this
ensure that we have room and then we can validate_header and do the right
thing from there.  We'll need to lock the mutex when we actually move it
into the input Q as well.

Fixes: #12725
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
bgpd/bgp_io.c