Skip to content

Commit 3fb11e9

Browse files
committed
feat(nat): align method names with types and vars
Signed-off-by: Fredi Raspall <[email protected]>
1 parent c22f9fc commit 3fb11e9

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

nat/src/stateful/mod.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl StatefulNat {
150150
let value = flow_info.locked.read().unwrap();
151151
let state = value.nat_state.as_ref()?.extract_ref::<NatFlowState<I>>()?;
152152
flow_info.reset_expiry(state.idle_timeout).ok()?;
153-
let translation_data = Self::get_translation_info(&state.src_alloc, &state.dst_alloc);
153+
let translation_data = Self::get_translation_data(&state.src_alloc, &state.dst_alloc);
154154
Some(translation_data)
155155
}
156156

@@ -177,7 +177,7 @@ impl StatefulNat {
177177
let flow_info = self.sessions.lookup(&flow_key)?;
178178
let value = flow_info.locked.read().unwrap();
179179
let state = value.nat_state.as_ref()?.extract_ref::<NatFlowState<I>>()?;
180-
let translation_data = Self::get_translation_info(&state.src_alloc, &state.dst_alloc);
180+
let translation_data = Self::get_translation_data(&state.src_alloc, &state.dst_alloc);
181181
Some((translation_data, state.idle_timeout))
182182
}
183183

@@ -312,7 +312,7 @@ impl StatefulNat {
312312
}
313313

314314
#[allow(clippy::ref_option)]
315-
fn get_translation_info<I: NatIpWithBitmap>(
315+
fn get_translation_data<I: NatIpWithBitmap>(
316316
src_alloc: &Option<AllocatedIpPort<I>>,
317317
dst_alloc: &Option<AllocatedIpPort<I>>,
318318
) -> NatTranslationData {
@@ -481,7 +481,7 @@ impl StatefulNat {
481481
);
482482

483483
// Swap back source and destination for the inner packet
484-
let translation_data = Self::get_translation_info(&state.dst_alloc, &state.src_alloc);
484+
let translation_data = Self::get_translation_data(&state.dst_alloc, &state.src_alloc);
485485
Some(translation_data)
486486
}
487487

@@ -585,7 +585,9 @@ impl StatefulNat {
585585
let flow_key =
586586
FlowKey::try_from(Uni(&*packet)).map_err(|_| StatefulNatError::TupleParseError)?;
587587

588-
if I::is_exempt(allocator.clone(), &flow_key).map_err(StatefulNatError::AllocationFailure)? {
588+
if I::is_exempt(allocator.clone(), &flow_key)
589+
.map_err(StatefulNatError::AllocationFailure)?
590+
{
589591
// Packet is allowed to go through without NAT, leave it unchanged
590592
debug!("{}: Packet exempt from NAT", self.name());
591593
return Ok(false);
@@ -610,7 +612,7 @@ impl StatefulNat {
610612
// least one timeout set.
611613
let idle_timeout = alloc.idle_timeout().unwrap_or_else(|| unreachable!());
612614

613-
let translation_info = Self::get_translation_info(&alloc.src, &alloc.dst);
615+
let translation_data = Self::get_translation_data(&alloc.src, &alloc.dst);
614616
let mut reverse_flow_key =
615617
Self::new_reverse_session(&flow_key, &alloc, src_vpc_id, dst_vpc_id)?;
616618
let (forward_state, reverse_state) = Self::new_states_from_alloc(alloc, idle_timeout);
@@ -628,7 +630,7 @@ impl StatefulNat {
628630
idle_timeout,
629631
);
630632

631-
Self::stateful_translate::<Buf>(self.name(), packet, &translation_info).and(Ok(true))
633+
Self::stateful_translate::<Buf>(self.name(), packet, &translation_data).and(Ok(true))
632634
}
633635

634636
fn nat_packet<Buf: PacketBufferMut>(

0 commit comments

Comments
 (0)