forward original peer info in ospf route (#589)

prost doesn't support unknown field, and these info may be lost when
they go through a old version node.
This commit is contained in:
Sijie.Sun
2025-01-27 20:38:22 +08:00
committed by GitHub
parent 08546925cc
commit 4aea0821dd
10 changed files with 318 additions and 37 deletions
+10 -3
View File
@@ -192,7 +192,7 @@ impl Client {
async fn call(
&self,
ctrl: Self::Controller,
mut ctrl: Self::Controller,
method: <Self::Descriptor as ServiceDescriptor>::Method,
input: bytes::Bytes,
) -> Result<bytes::Bytes> {
@@ -224,7 +224,11 @@ impl Client {
};
let rpc_req = RpcRequest {
request: input.into(),
request: if let Some(raw_input) = ctrl.get_raw_input() {
raw_input.into()
} else {
input.into()
},
timeout_ms: ctrl.timeout_ms(),
..Default::default()
};
@@ -280,7 +284,10 @@ impl Client {
return Err(err.into());
}
Ok(bytes::Bytes::from(rpc_resp.response))
let raw_output = Bytes::from(rpc_resp.response.clone());
ctrl.set_raw_output(raw_output.clone());
Ok(raw_output)
}
}
+12 -9
View File
@@ -13,7 +13,7 @@ use crate::{
common::{join_joinset_background, PeerId},
proto::{
common::{self, CompressionAlgoPb, RpcCompressionInfo, RpcPacket, RpcRequest, RpcResponse},
rpc_types::error::Result,
rpc_types::{controller::Controller, error::Result},
},
tunnel::{
mpsc::{MpscTunnel, MpscTunnelSender},
@@ -155,16 +155,19 @@ impl Server {
};
let rpc_request = RpcRequest::decode(Bytes::from(body))?;
let timeout_duration = std::time::Duration::from_millis(rpc_request.timeout_ms as u64);
let ctrl = RpcController::default();
Ok(timeout(
let mut ctrl = RpcController::default();
let raw_req = Bytes::from(rpc_request.request);
ctrl.set_raw_input(raw_req.clone());
let ret = timeout(
timeout_duration,
reg.call_method(
packet.descriptor.unwrap(),
ctrl,
Bytes::from(rpc_request.request),
),
reg.call_method(packet.descriptor.unwrap(), ctrl.clone(), raw_req),
)
.await??)
.await??;
if let Some(raw_output) = ctrl.get_raw_output() {
Ok(raw_output)
} else {
Ok(ret)
}
}
async fn handle_rpc(sender: MpscTunnelSender, packet: RpcPacket, reg: Arc<ServiceRegistry>) {