cmdmon: add onoffline command

The onoffline command tells chronyd to switch all sources to the online
or offline status according to the current network configuration. A
source is considered online if it is possible to send requests to it,
i.e. a route to the network is present.
This commit is contained in:
Miroslav Lichvar
2018-05-24 16:56:56 +02:00
parent 8b9021bf34
commit 34db671b57
5 changed files with 40 additions and 2 deletions

View File

@@ -139,6 +139,7 @@ static const char permissions[] = {
PERMIT_AUTH, /* ADD_SERVER3 */
PERMIT_AUTH, /* ADD_PEER3 */
PERMIT_AUTH, /* SHUTDOWN */
PERMIT_AUTH, /* ONOFFLINE */
};
/* ================================================== */
@@ -443,6 +444,18 @@ handle_offline(CMD_Request *rx_message, CMD_Reply *tx_message)
/* ================================================== */
static void
handle_onoffline(CMD_Request *rx_message, CMD_Reply *tx_message)
{
IPAddr address, mask;
address.family = mask.family = IPADDR_UNSPEC;
if (!NSR_SetConnectivity(&mask, &address, SRC_MAYBE_ONLINE))
;
}
/* ================================================== */
static void
handle_burst(CMD_Request *rx_message, CMD_Reply *tx_message)
{
@@ -1637,6 +1650,10 @@ read_from_cmd_socket(int sock_fd, int event, void *anything)
handle_shutdown(&rx_message, &tx_message);
break;
case REQ_ONOFFLINE:
handle_onoffline(&rx_message, &tx_message);
break;
default:
DEBUG_LOG("Unhandled command %d", rx_command);
tx_message.status = htons(STT_FAILED);