Fix issue with updating IPv6 client stats and rename map names.
This commit is contained in:
@@ -305,7 +305,7 @@ int ReadCfg(config__t *cfg, config_overrides_t* overrides)
|
||||
}
|
||||
}
|
||||
|
||||
// Read filters in filters_map structure.
|
||||
// Read filters in map_filters structure.
|
||||
setting = config_lookup(&conf, "filters");
|
||||
|
||||
// Check if filters map is valid. If not, not a biggie since they aren't required.
|
||||
|
||||
@@ -9,13 +9,13 @@ u64 last_passed = 0;
|
||||
/**
|
||||
* Calculates and displays packet counters/stats.
|
||||
*
|
||||
* @param stats_map The stats map BPF FD.
|
||||
* @param map_stats The stats map BPF FD.
|
||||
* @param cpus The amount of CPUs the host has.
|
||||
* @param per_second Calculate packet counters per second (PPS).
|
||||
*
|
||||
* @return 0 on success or 1 on failure.
|
||||
*/
|
||||
int CalculateStats(int stats_map, int cpus, int per_second)
|
||||
int CalculateStats(int map_stats, int cpus, int per_second)
|
||||
{
|
||||
u32 key = 0;
|
||||
|
||||
@@ -26,7 +26,7 @@ int CalculateStats(int stats_map, int cpus, int per_second)
|
||||
u64 dropped = 0;
|
||||
u64 passed = 0;
|
||||
|
||||
if (bpf_map_lookup_elem(stats_map, &key, stats) != 0)
|
||||
if (bpf_map_lookup_elem(map_stats, &key, stats) != 0)
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
@@ -10,4 +10,4 @@
|
||||
|
||||
#include <time.h>
|
||||
|
||||
int CalculateStats(int stats_map, int cpus, int per_second);
|
||||
int CalculateStats(int map_stats, int cpus, int per_second);
|
||||
@@ -179,12 +179,12 @@ int AttachXdp(struct xdp_program *prog, char** mode, int ifidx, u8 detach, cmdli
|
||||
/**
|
||||
* Updates the filter's BPF map with current config settings.
|
||||
*
|
||||
* @param filters_map The filter's BPF map FD.
|
||||
* @param map_filters The filter's BPF map FD.
|
||||
* @param cfg A pointer to the config structure.
|
||||
*
|
||||
* @return Void
|
||||
*/
|
||||
void UpdateFilters(int filters_map, config__t *cfg)
|
||||
void UpdateFilters(int map_filters, config__t *cfg)
|
||||
{
|
||||
int ret;
|
||||
int cur_idx = 0;
|
||||
@@ -198,7 +198,7 @@ void UpdateFilters(int filters_map, config__t *cfg)
|
||||
// We do this in the case rules were edited and were put out of order since the key doesn't uniquely map to a specific rule.
|
||||
u32 key = i;
|
||||
|
||||
bpf_map_delete_elem(filters_map, &key);
|
||||
bpf_map_delete_elem(map_filters, &key);
|
||||
|
||||
// Only insert set and enabled filters.
|
||||
if (!filter->set || !filter->enabled)
|
||||
@@ -216,7 +216,7 @@ void UpdateFilters(int filters_map, config__t *cfg)
|
||||
}
|
||||
|
||||
// Attempt to update BPF map.
|
||||
if ((ret = bpf_map_update_elem(filters_map, &cur_idx, &filter_cpus, BPF_ANY)) != 0)
|
||||
if ((ret = bpf_map_update_elem(map_filters, &cur_idx, &filter_cpus, BPF_ANY)) != 0)
|
||||
{
|
||||
fprintf(stderr, "[WARNING] Failed to update filter #%d due to BPF update error (%d)...\n", i, ret);
|
||||
}
|
||||
|
||||
@@ -14,4 +14,4 @@ int FindMapFd(struct xdp_program *prog, const char *map_name);
|
||||
void SetLibBPFLogMode(int silent);
|
||||
struct xdp_program *LoadBpfObj(const char *file_name);
|
||||
int AttachXdp(struct xdp_program *prog, char** mode, int ifidx, u8 detach, cmdline_t *cmd);
|
||||
void UpdateFilters(int filters_map, config__t *cfg);
|
||||
void UpdateFilters(int map_filters, config__t *cfg);
|
||||
Reference in New Issue
Block a user