mirror of
https://github.com/xdp-project/bpf-examples.git
synced 2024-05-06 15:54:53 +00:00
pping: Add warnings for failing to create map entry
Send a warning notifying the user that PPing failed to create a flow/timestamp entry due to the corresponding map being full. To avoid sending a warning for every packet, only emit warnings every WARN_MAP_FULL_INTERVAL (which is currently hard-coded to 1s). Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
This commit is contained in:
@@ -821,6 +821,15 @@ static void print_event_json(const union pping_event *e)
|
||||
jsonw_end_object(json_ctx);
|
||||
}
|
||||
|
||||
static void warn_map_full(const struct map_full_event *e)
|
||||
{
|
||||
print_ns_datetime(stderr, e->timestamp);
|
||||
fprintf(stderr, " Warning: Unable to create %s entry for flow ",
|
||||
e->map == PPING_MAP_FLOWSTATE ? "flow" : "timestamp");
|
||||
print_flow_ppvizformat(stderr, &e->flow);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
static void handle_event(void *ctx, int cpu, void *data, __u32 data_size)
|
||||
{
|
||||
const union pping_event *e = data;
|
||||
@@ -829,6 +838,9 @@ static void handle_event(void *ctx, int cpu, void *data, __u32 data_size)
|
||||
return;
|
||||
|
||||
switch (e->event_type) {
|
||||
case EVENT_TYPE_MAP_FULL:
|
||||
warn_map_full(&e->map_event);
|
||||
break;
|
||||
case EVENT_TYPE_RTT:
|
||||
case EVENT_TYPE_FLOW:
|
||||
print_event_func(e);
|
||||
|
Reference in New Issue
Block a user