From 4c94faac672007fa012b15cb169a622943066b0f Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 19 Sep 2022 16:41:04 +0400 Subject: [PATCH] [#1797] node/control: Verify states in `SetNetmapStatus` RPC server In previous implementation storage node interpreted all status values sent in `SetNetmapStatus` RPC as `OFFLINE` except `ONLINE` and `MAINTENANCE`. This could lead to incorrect processing of new values, and also didn't allow detection of problems with sending garbage values. Make implementation of `NodeState` interface used by Control API server to deny requests with statuses other than protocol-declared enum. Signed-off-by: Leonard Lyubich --- cmd/neofs-node/netmap.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/neofs-node/netmap.go b/cmd/neofs-node/netmap.go index 1fd522c0..a2b62acd 100644 --- a/cmd/neofs-node/netmap.go +++ b/cmd/neofs-node/netmap.go @@ -321,8 +321,12 @@ var errRelayBootstrap = errors.New("setting netmap status is forbidden in relay var errNodeMaintenance = errors.New("node is in maintenance mode") func (c *cfg) SetNetmapStatus(st control.NetmapStatus) error { - if st == control.NetmapStatus_MAINTENANCE { + switch st { + default: + return fmt.Errorf("unsupported status %v", st) + case control.NetmapStatus_MAINTENANCE: return c.cfgObject.cfgLocalStorage.localStorage.BlockExecution(errNodeMaintenance) + case control.NetmapStatus_ONLINE, control.NetmapStatus_OFFLINE: } err := c.cfgObject.cfgLocalStorage.localStorage.ResumeExecution()