Split logging logic from XDP program into its own files.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <common/all.h>
|
||||
|
||||
#include <xdp/utils/rl.h>
|
||||
#include <xdp/utils/logging.h>
|
||||
#include <xdp/utils/helpers.h>
|
||||
|
||||
#include <xdp/utils/maps.h>
|
||||
@@ -538,33 +539,7 @@ int xdp_prog_main(struct xdp_md *ctx)
|
||||
#ifdef ENABLE_FILTER_LOGGING
|
||||
if (filter->log > 0)
|
||||
{
|
||||
filter_log_event_t* e = bpf_ringbuf_reserve(&filter_log_map, sizeof(*e), 0);
|
||||
|
||||
if (e)
|
||||
{
|
||||
e->ts = now;
|
||||
e->filter_id = i;
|
||||
|
||||
if (iph)
|
||||
{
|
||||
e->src_ip = iph->saddr;
|
||||
e->dst_ip = iph->daddr;
|
||||
} else if (iph6)
|
||||
{
|
||||
memcpy(&e->src_ip6, iph6->saddr.in6_u.u6_addr32, 4);
|
||||
memcpy(&e->dst_ip6, iph6->daddr.in6_u.u6_addr32, 4);
|
||||
}
|
||||
|
||||
e->src_port = src_port;
|
||||
e->dst_port = dst_port;
|
||||
|
||||
e->protocol = protocol;
|
||||
|
||||
e->pps = pps;
|
||||
e->bps = bps;
|
||||
|
||||
bpf_ringbuf_submit(e, 0);
|
||||
}
|
||||
LogFilterMsg(iph, iph6, src_port, dst_port, protocol, now, pps, bps, i);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user