Skip to content

Commit 485d404

Browse files
committed
review feedback from @jgallagher
1 parent e74ed21 commit 485d404

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

faux-mgs/src/main.rs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,12 @@ struct Args {
9393
#[clap(long)]
9494
listen_port: Option<u16>,
9595

96-
/// Ereport port to bind to locally [default: 0 for client commands, 22223
97-
/// for server commands]
98-
#[clap(long)]
99-
ereport_port: Option<u16>,
96+
/// Ereport port to bind to locally
97+
// Note that, unlike `listen_port`, this always defaults to 0, because we
98+
// don't need to act as a server with a known port for the ereport
99+
// protocol.
100+
#[clap(long, default_value_t = 0)]
101+
ereport_port: u16,
100102

101103
/// Address to use to discover the SP. May be a specific SP's address to
102104
/// bypass multicast discovery.
@@ -549,15 +551,6 @@ impl Command {
549551
_ => 0,
550552
}
551553
}
552-
553-
fn default_ereport_port(&self) -> u16 {
554-
match self {
555-
// Server commands; use standard MGS port
556-
Command::ServeHostPhase2 { .. } => ereport::MGS_PORT,
557-
// Client commands: use port 0
558-
_ => 0,
559-
}
560-
}
561554
}
562555

563556
fn parse_tlvc_key(key: &str) -> Result<[u8; 4]> {
@@ -708,8 +701,6 @@ async fn main() -> Result<()> {
708701

709702
let listen_port =
710703
args.listen_port.unwrap_or_else(|| args.command.default_listen_port());
711-
let ereport_port =
712-
args.listen_port.unwrap_or_else(|| args.command.default_ereport_port());
713704

714705
// For faux-mgs, we'll serve all images present in the directory the user
715706
// requests, so don't cap the LRU cache size.
@@ -725,7 +716,7 @@ async fn main() -> Result<()> {
725716
.context("SharedSocket:bind() failed")?;
726717
let ereport_socket = {
727718
SharedSocket::bind(
728-
ereport_port,
719+
args.ereport_port,
729720
ereport::EreportHandler::default(),
730721
log.new(slog::o!("socket" => "ereport")),
731722
)

gateway-sp-comms/src/ereport.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ use thiserror::Error;
3030
use tokio::sync::mpsc;
3131
use tokio::sync::oneshot;
3232

33-
pub const SP_PORT: u16 = 0xDEAD;
34-
pub const MGS_PORT: u16 = 0xDEAF;
33+
pub const SP_PORT: u16 = 57005; // 0xDEAD
34+
pub const MGS_PORT: u16 = 57007; // 0xDEAF
3535

3636
#[derive(Debug, Default)]
3737
pub struct EreportHandler {}
@@ -95,10 +95,19 @@ where
9595
match self.request_ereports(RestartId(0), Ena(0), 0, None).await
9696
{
9797
Ok((restart_id, ereports)) => {
98-
debug_assert!(
99-
ereports.is_empty(),
100-
"we asked for limit 0..."
101-
);
98+
if !ereports.is_empty() {
99+
// The SP was told not to send ereports in this
100+
// request, just metadata. If it sends us ereports,
101+
// that could indicate a bug on the SP side, but we
102+
// assume the metadata is still valid regardless.
103+
warn!(
104+
self.log(),
105+
"received ereports in response to a request \
106+
with limit 0, seems weird";
107+
"restart_id" => ?restart_id,
108+
"ereports" => ?ereports
109+
);
110+
}
102111
debug!(
103112
self.log(),
104113
"received initial SP metadata";

0 commit comments

Comments
 (0)