in nfm-common/src/sock_ops_handler.rs [982:1024]
fn test_ebpf_sock_op_max_connections() {
let mut mock_ktime_us: u64 = 99;
let mut cookie: u64 = 197;
let mut mock_ebpf_maps = MockEbpfMaps::new();
let effective_max = MAX_ENTRIES_SK_PROPS_HI.min(MAX_ENTRIES_SK_STATS_HI);
for _ in 0..effective_max {
run_sock_ops_test(
cookie,
BPF_SOCK_OPS_TCP_CONNECT_CB,
&mut mock_ebpf_maps,
mock_ktime_us,
Ok(()),
);
run_sock_ops_test_with_args(
cookie,
BPF_TCP_SYN_SENT,
BPF_SOCK_OPS_STATE_CB,
[BPF_TCP_SYN_SENT, BPF_TCP_ESTABLISHED],
&mut mock_ebpf_maps,
mock_ktime_us + 10,
Ok(()),
);
cookie += 3;
mock_ktime_us += 10;
}
// Validate results.
assert!(effective_max > 0);
assert_eq!(
mock_ebpf_maps.counters().active_connect_events,
effective_max.try_into().unwrap(),
);
assert_eq!(
mock_ebpf_maps.NFM_SK_PROPS.data.len(),
effective_max.try_into().unwrap()
);
assert_eq!(
mock_ebpf_maps.NFM_SK_STATS.data.len(),
effective_max.try_into().unwrap()
);
}