Change default log file path and clean up some code.

This commit is contained in:
Christian Deacon
2025-02-27 07:03:41 -05:00
parent c631266061
commit 47753af3d5
7 changed files with 17 additions and 19 deletions

View File

@@ -45,7 +45,7 @@ int xdp_prog_main(struct xdp_md *ctx)
}
u8 action = 0;
u64 blocktime = 1;
u64 block_time = 1;
// Initialize IP headers.
struct iphdr *iph = NULL;
@@ -539,7 +539,7 @@ int xdp_prog_main(struct xdp_md *ctx)
// Matched.
action = filter->action;
blocktime = filter->blocktime;
block_time = filter->block_time;
goto matched;
}
@@ -555,17 +555,17 @@ int xdp_prog_main(struct xdp_md *ctx)
if (action == 0)
{
// Before dropping, update the blacklist map.
if (blocktime > 0)
if (block_time > 0)
{
u64 newTime = now + (blocktime * NANO_TO_SEC);
u64 new_time = now + (block_time * NANO_TO_SEC);
if (iph6)
{
bpf_map_update_elem(&ip6_blacklist_map, &src_ip6, &newTime, BPF_ANY);
bpf_map_update_elem(&ip6_blacklist_map, &src_ip6, &new_time, BPF_ANY);
}
else if (iph)
{
bpf_map_update_elem(&ip_blacklist_map, &iph->saddr, &newTime, BPF_ANY);
bpf_map_update_elem(&ip_blacklist_map, &iph->saddr, &new_time, BPF_ANY);
}
}