Skip to content

Commit

Permalink
fix: introduce RATE_ESTIMATOR constant and update packet processing l…
Browse files Browse the repository at this point in the history
…ogic

Signed-off-by: Dengfeng Liu <[email protected]>
  • Loading branch information
liudf0716 committed Feb 4, 2025
1 parent 42e656b commit 017e430
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions ebpf/aw-bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ static inline void update_stats(struct counters *cnt, __u32 len, __u32 est_slot)

static inline void process_packet(struct __sk_buff *skb) {
__u32 current_time = get_current_time();
__u32 est_slot = current_time / RATE_ESTIMATOR;
void *data = (void *)(long)skb->data;
void *data_end = (void *)(long)skb->data_end;

Expand Down
4 changes: 3 additions & 1 deletion ebpf/aw-bpf.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* aw-bpf.h - Header file for WiFiDog eBPF traffic statistics
* aw-bpf.h - Header file for apfree wifidog eBPF traffic statistics
* Copyright (C) 2025 Dengfeng Liu <[email protected]>
*/

Expand All @@ -12,6 +12,8 @@
#include <stdint.h>
#endif

#define RATE_ESTIMATOR 4

/**
* @struct counters
* @brief Structure to hold network traffic counters
Expand Down
1 change: 0 additions & 1 deletion ebpf/aw-bpfctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ static uint32_t
calc_rate_estimator(struct traffic_stats *val, bool is_incoming)
{
#define SMOOTH_VALUE 10
#define RATE_ESTIMATOR 4
uint32_t now = aw_bpf_gettime();
uint32_t est_slot = now / RATE_ESTIMATOR;
uint32_t rate = 0;
Expand Down

0 comments on commit 017e430

Please sign in to comment.