Skip to content

Commit

Permalink
sample mismatched server id in tpr stats bpf program
Browse files Browse the repository at this point in the history
Summary: for easier debugging

Reviewed By: avasylev

Differential Revision: D65948620

fbshipit-source-id: 80a2005302b6c994c60a34859b48df9907e81bc7
  • Loading branch information
Fei Chen authored and facebook-github-bot committed Nov 22, 2024
1 parent 0797b52 commit 41de049
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions katran/decap/tc_bpf/tc_decap_stats.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ __attribute__((__always_inline__)) static inline void validate_tpr_server_id(
data_stats->tpr_total += 1;
if (*server_id_host != server_id) {
data_stats->tpr_misrouted += 1;
__u32 sid_sample_key = 0;
__u64* server_id_sample =
bpf_map_lookup_elem(&tpr_mism_sid, &sid_sample_key);
if (server_id_sample) {
*server_id_sample = server_id;
}
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions katran/decap/tc_bpf/tc_decap_stats_maps.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,13 @@ struct {
__uint(map_flags, NO_FLAGS);
} tpr_server_id SEC(".maps");

// map for sampled tpr mismatched server ids
struct {
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
__type(key, __u32);
__type(value, __u64);
__uint(max_entries, DECAP_STATS_MAP_SIZE);
__uint(map_flags, NO_FLAGS);
} tpr_mism_sid SEC(".maps");

#endif // of __DECAP_STATS_MAPS_H

0 comments on commit 41de049

Please sign in to comment.