What is the duration of a ban? I read somewhere that a node is banned for 24 hours.

However I found the Misbehaving() function which makes state-&gt;fShouldBan = true;. But I could not find any other function that makes state-&gt;fShouldBan = false;. It seems that banning is forever.

If banning is forever, I guess the node also removes the misbehaving peer from its neighbor list, right? But I could not find it.
When state-&gt;fShouldBan is set, the network thread will disconnect the node, and cleanup memory. As a result, the state object disappears entirely. Because of that, there is no need to ever unset fShouldBan.

What does happen is that when the actual ban happens (not just the setting of the fShouldBan field), it is added to the ban table (which is IP based). Entries in this table have an expiration time. The default expiration time for newly banned nodes is controlled by the -bantime option and defaults to 24 hours in the future.