Skip to content

Commit 07b892f

Browse files
Fredi-raspallqmonnet
authored andcommitted
feat(stateless-nat): add debug traces for lookups
Be more explicit in the stateless NAT lookups, especially if those do not provide a value. Signed-off-by: Fredi Raspall <fredi@githedgehog.com> Signed-off-by: Quentin Monnet <qmo@qmon.net>
1 parent 297c2fa commit 07b892f

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

nat/src/stateless/setup/tables.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,14 @@ impl PerVniTable {
8282
dst_vni: Vni,
8383
) -> Option<(IpAddr, Option<u16>)> {
8484
debug!("Looking up source mapping for address: {addr}, port: {port:?}, dst_vni: {dst_vni}");
85-
Self::find_mapping(addr, port, self.src_nat.get(&dst_vni)?)
85+
let result = Self::find_mapping(addr, port, self.src_nat.get(&dst_vni)?);
86+
match result {
87+
None => debug!("No src mapping found for {addr}:{port:?}, dst_vni: {dst_vni}"),
88+
Some((ipaddr, opt_port)) => {
89+
debug!("Found src mapping; ipdaddr: {ipaddr} port: {opt_port:?}");
90+
}
91+
}
92+
result
8693
}
8794

8895
#[must_use]
@@ -92,7 +99,14 @@ impl PerVniTable {
9299
port: Option<u16>,
93100
) -> Option<(IpAddr, Option<u16>)> {
94101
debug!("Looking up destination mapping for address: {addr}, port: {port:?}");
95-
Self::find_mapping(addr, port, &self.dst_nat)
102+
let result = Self::find_mapping(addr, port, &self.dst_nat);
103+
match result {
104+
None => debug!("No dst mapping found for {addr}:{port:?}"),
105+
Some((ipaddr, opt_port)) => {
106+
debug!("Found dst mapping; ipdaddr: {ipaddr} port: {opt_port:?}");
107+
}
108+
}
109+
result
96110
}
97111

98112
fn find_mapping(

0 commit comments

Comments
 (0)