CVPN-2519: Expresslane and InsidePktCodec mutually exclusive#412
CVPN-2519: Expresslane and InsidePktCodec mutually exclusive#412kp-weiwen-goh wants to merge 4 commits into
Conversation
|
Code coverage summary for f20a316: ✅ Region coverage 69% passes |
e06fd74 to
e26ecea
Compare
e26ecea to
ad00391
Compare
| if self.expresslane.state == new_state { | ||
| return; | ||
| } | ||
| if new_state == ExpresslaneState::Active | ||
| && self.data_path_mode == DataPathMode::InsidePktCodec | ||
| { | ||
| warn!("Blocking expresslane activation: InsidePktCodec is active"); | ||
| return; | ||
| } | ||
| self.expresslane.state = new_state; | ||
| self.event(Event::ExpresslaneStateChanged(new_state)); | ||
|
|
||
| if new_state == ExpresslaneState::Active { | ||
| self.set_data_path_mode(DataPathMode::ExpressLane); | ||
| } else if self.data_path_mode == DataPathMode::ExpressLane { | ||
| self.set_data_path_mode(DataPathMode::Standard); | ||
| } |
There was a problem hiding this comment.
May we use match here, such that compiler can help us to go through each state, and also future proof, when a new state comes in.
match (new_state, self.data_path_mode) {
(_, _) if self.expresslane.state == new_state => return,
(ExpresslaneState::Active, DataPathMode::InsidePktCodec) => {
warn!("Blocking expresslane activation: InsidePktCodec is active");
return;
}
(ExpresslaneState::Active, ) => {
self.set_data_path_mode(DataPathMode::ExpressLane);
}
(, DataPathMode::ExpressLane) => {
self.set_data_path_mode(DataPathMode::Standard);
}
(ExpresslaneState::Disabled, _)
| (ExpresslaneState::WaitingForClient, _)
| (ExpresslaneState::Inactive, _)
| (ExpresslaneState::Degraded, _) => {}
}
self.expresslane.state = new_state;
self.event(Event::ExpresslaneStateChanged(new_state));There was a problem hiding this comment.
I replaced the second branch with a match, but kept the first check to maintain the same order (set new state and emit event, then set data path).
This way, if there is a new state, it will cause a compile error.
There was a problem hiding this comment.
Yeh, that is what I means, If there is a new state, then compile error, and developer will take a look on the function, and make sure the logic is correct. Do agree with this?
ad00391 to
ca0e94c
Compare
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. |
Description
Adds a
DataPathModeenum that enforces that ExpressLane and InsidePktCodec are never both enabled.ExpressLane cannot be enabled if
DataPathModeisInsidePktCodec.If ExpressLane is enabled when an encoding request is sent or received, ExpressLane is set to
Inactiveand is only re-enabled when encoding is then disabled.Motivation and Context
They are mutually exclusive. Previously, this was not enforced by code and relies on correct user configuration.
How Has This Been Tested?
Types of changes
Checklist:
main