Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix port mirror rejection in intproxy #2998

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/+mirrord-policy-rejection.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a bug where port mirroring block (due to active mirrord policies) would terminate the mirrord session.
26 changes: 17 additions & 9 deletions mirrord/intproxy/src/proxies/incoming/subscriptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ impl SubscriptionsManager {

Ok(subscription.confirm())
}

Err(ResponseError::PortAlreadyStolen(port)) => {
let Some(subscription) = self.subscriptions.remove(&port) else {
return Ok(vec![]);
Expand All @@ -255,23 +256,30 @@ impl SubscriptionsManager {
}
}
}

Err(
ref response_err @ ResponseError::Forbidden {
blocked_action: BlockedAction::Steal(ref steal_type),
..
ref response_error @ ResponseError::Forbidden {
ref blocked_action, ..
},
) => {
tracing::warn!("Port subscribe blocked by policy: {response_err}");
let Some(subscription) = self.subscriptions.remove(&steal_type.get_port()) else {
tracing::warn!(%response_error, "Port subscribe blocked by policy");

let port = match blocked_action {
BlockedAction::Steal(steal_type) => steal_type.get_port(),
BlockedAction::Mirror(port) => *port,
};
let Some(subscription) = self.subscriptions.remove(&port) else {
return Ok(vec![]);
};

subscription
.reject(response_err.clone())
.map_err(|sub|{
tracing::error!("Subscription {sub:?} was confirmed before, then requested again and blocked by a policy.");
IncomingProxyError::SubscriptionFailed(response_err.clone())
.reject(response_error.clone())
.map_err(|subscription|{
tracing::error!(?subscription, "Subscription was confirmed before, then requested again and blocked by a policy.");
IncomingProxyError::SubscriptionFailed(response_error.clone())
})
}

Err(err) => Err(IncomingProxyError::SubscriptionFailed(err)),
}
}
Expand Down
Loading