Description

When clearing a BGP session that is not Established you might receive a bad file descriptor error in the messages log.

Symptoms

When you clear a BGP session that is not Established a log message similar to the one below might appear  in the messages log.

Apr  6 19:15:53  chewie rpd[2814]: bgp_mgmt_clear_neighbor: NOTIFICATION sent to 1.1.1.2 (Internal AS 1): code 6 (Cease) subcode 4 (Administratively Reset), Reason: Management session cleared BGP neighbor
Apr  6 19:15:53  chewie rpd[2814]: bgp_send: sending 21 bytes to 1.1.1.2 (Internal AS 1) failed: Bad file descriptor

Solution

This is not a problem.
When you clear a neighbor rpd tries to send a NOTIFICATION to the peer but there is no communications channel (socket) open to send the message. rpd reports this with the "bad file descriptor" error in the messages log.