Skip to content

Commit

Permalink
fix(iroh_net): track recv_data_ipv4 & recv_data_ipv6 (#2243)
Browse files Browse the repository at this point in the history
## Description
Now tracks `Magicsock::Metrics::recv_data_ipv4` and
`Magicsock::Metrics::recv_data_ivp6`.

closes #2184

## Change checklist

- [x] Self-review.
  • Loading branch information
ramfox authored Apr 26, 2024
1 parent 5329927 commit f8ff3bc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions iroh-net/src/magicsock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,19 +501,19 @@ impl Inner {
}

// order of polling is: UDPv4, UDPv6, relay
let msgs = match self.pconn4.poll_recv(cx, bufs, metas)? {
let (msgs, from_ipv4) = match self.pconn4.poll_recv(cx, bufs, metas)? {
Poll::Pending | Poll::Ready(0) => match &self.pconn6 {
Some(conn) => match conn.poll_recv(cx, bufs, metas)? {
Poll::Pending | Poll::Ready(0) => {
return self.poll_recv_relay(cx, bufs, metas);
}
Poll::Ready(n) => n,
Poll::Ready(n) => (n, false),
},
None => {
return self.poll_recv_relay(cx, bufs, metas);
}
},
Poll::Ready(n) => n,
Poll::Ready(n) => (n, true),
};

let dst_ip = self.normalized_local_addr().ok().map(|addr| addr.ip());
Expand Down Expand Up @@ -548,6 +548,11 @@ impl Inner {
false
} else {
trace!(src = %meta.addr, len = %meta.stride, "UDP recv: quic packet");
if from_ipv4 {
inc_by!(MagicsockMetrics, recv_data_ipv4, buf.len() as _);
} else {
inc_by!(MagicsockMetrics, recv_data_ipv6, buf.len() as _);
}
true
};

Expand Down

0 comments on commit f8ff3bc

Please sign in to comment.