Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix map name #200

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions katran/lib/KatranLb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ void KatranLb::initialSanityChecking(bool flowDebug, bool globalLru) {
maps.push_back("lru_mapping");
maps.push_back("server_id_map");
maps.push_back("lru_miss_stats");
maps.push_back("lru_miss_stats_vip");
maps.push_back("vip_miss_stats");

if (flowDebug) {
maps.push_back(kFlowDebugParentMapName.data());
Expand Down Expand Up @@ -827,7 +827,7 @@ void KatranLb::loadBpfProgs() {
memset(&vip_def, 0, sizeof(vip_definition));
uint32_t key = 0;
res = bpfAdapter_->bpfUpdateMap(
bpfAdapter_->getMapFdByName("lru_miss_stats_vip"), &key, &vip_def);
bpfAdapter_->getMapFdByName("vip_miss_stats"), &key, &vip_def);
if (res) {
LOG(ERROR) << "can't update lru miss stat vip, error: "
<< folly::errnoStr(errno);
Expand Down Expand Up @@ -1950,7 +1950,7 @@ bool KatranLb::logVipLruMissStats(VipKey& vip) {
vip_definition vip_def = vipKeyToVipDefinition(vip);
uint32_t vip_key = 0;
auto res = bpfAdapter_->bpfUpdateMap(
bpfAdapter_->getMapFdByName("lru_miss_stats_vip"), &vip_key, &vip_def);
bpfAdapter_->getMapFdByName("vip_miss_stats"), &vip_key, &vip_def);
if (res != 0) {
LOG(ERROR) << "can't update lru miss stat vip, error: "
<< folly::errnoStr(errno);
Expand Down Expand Up @@ -2060,7 +2060,7 @@ lb_quic_packets_stats KatranLb::getLbQuicPacketsStats() {
if (!config_.testing) {
int position = 0;
auto res = bpfAdapter_->bpfMapLookupElement(
bpfAdapter_->getMapFdByName("quic_packets_stats_map"),
bpfAdapter_->getMapFdByName("quic_stats_map"),
&position,
stats);
if (!res) {
Expand Down Expand Up @@ -2112,7 +2112,7 @@ lb_tpr_packets_stats KatranLb::getTcpServerIdRoutingStats() {
if (!config_.testing) {
int position = 0;
auto res = bpfAdapter_->bpfMapLookupElement(
bpfAdapter_->getMapFdByName("tpr_packets_stats_map"), &position, stats);
bpfAdapter_->getMapFdByName("tpr_stats_map"), &position, stats);
if (!res) {
for (auto& stat : stats) {
sum_stat.ch_routed += stat.ch_routed;
Expand Down Expand Up @@ -2595,7 +2595,7 @@ lb_stats KatranLb::getSidRoutingStatsForVip(const VipKey& vip) {
return lb_stats{};
}
auto vipNum = vip_iter->second.getVipNum();
return getLbStats(vipNum, "server_id_routing_stats");
return getLbStats(vipNum, "server_id_stats");
}

} // namespace katran
14 changes: 7 additions & 7 deletions katran/lib/bpf/balancer.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,10 @@ __attribute__((__always_inline__)) static inline int update_vip_lru_miss_stats(
struct packet_description* pckt,
struct vip_meta* vip_info,
bool is_ipv6) {
// track the lru miss counter of vip in lru_miss_stats_vip
__u32 lru_miss_stats_vip_key = 0;
// track the lru miss counter of vip in vip_miss_stats
__u32 vip_miss_stats_key = 0;
struct vip_definition* lru_miss_stat_vip =
bpf_map_lookup_elem(&lru_miss_stats_vip, &lru_miss_stats_vip_key);
bpf_map_lookup_elem(&vip_miss_stats, &vip_miss_stats_key);
if (!lru_miss_stat_vip) {
return XDP_DROP;
}
Expand Down Expand Up @@ -573,7 +573,7 @@ check_and_update_real_index_in_lru(
__attribute__((__always_inline__)) static inline void
incr_server_id_routing_stats(__u32 vip_num, bool newConn, bool misMatchInLRU) {
struct lb_stats* per_vip_stats =
bpf_map_lookup_elem(&server_id_routing_stats, &vip_num);
bpf_map_lookup_elem(&server_id_stats, &vip_num);
if (!per_vip_stats) {
return;
}
Expand Down Expand Up @@ -774,7 +774,7 @@ process_packet(struct xdp_md* xdp, __u64 off, bool is_ipv6) {
} else {
__u32 quic_packets_stats_key = 0;
struct lb_quic_packets_stats* quic_packets_stats =
bpf_map_lookup_elem(&quic_packets_stats_map, &quic_packets_stats_key);
bpf_map_lookup_elem(&quic_stats_map, &quic_packets_stats_key);
if (!quic_packets_stats) {
return XDP_DROP;
}
Expand Down Expand Up @@ -843,7 +843,7 @@ process_packet(struct xdp_md* xdp, __u64 off, bool is_ipv6) {
if (pckt.flow.proto == IPPROTO_TCP) {
__u32 tpr_packets_stats_key = 0;
struct lb_tpr_packets_stats* tpr_packets_stats =
bpf_map_lookup_elem(&tpr_packets_stats_map, &tpr_packets_stats_key);
bpf_map_lookup_elem(&tpr_stats_map, &tpr_packets_stats_key);
if (!tpr_packets_stats) {
return XDP_DROP;
}
Expand Down Expand Up @@ -913,7 +913,7 @@ process_packet(struct xdp_md* xdp, __u64 off, bool is_ipv6) {
return XDP_DROP;
}

// track the lru miss counter of vip in lru_miss_stats_vip
// track the lru miss counter of vip in vip_miss_stats
if (update_vip_lru_miss_stats(&vip, &pckt, vip_info, is_ipv6) >= 0) {
return XDP_DROP;
}
Expand Down
8 changes: 4 additions & 4 deletions katran/lib/bpf/balancer_maps.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ struct {
__type(value, struct vip_definition);
__uint(max_entries, 1);
__uint(map_flags, NO_FLAGS);
} lru_miss_stats_vip SEC(".maps");
} vip_miss_stats SEC(".maps");

// map w/ per vip statistics
struct {
Expand All @@ -123,7 +123,7 @@ struct {
__type(value, struct lb_quic_packets_stats);
__uint(max_entries, QUIC_STATS_MAP_SIZE);
__uint(map_flags, NO_FLAGS);
} quic_packets_stats_map SEC(".maps");
} quic_stats_map SEC(".maps");

// map for server-id to real's id mapping. The ids can be embedded in header of
// QUIC or TCP (if enabled) packets for routing of packets for existing flows
Expand Down Expand Up @@ -199,14 +199,14 @@ struct {
__type(value, struct lb_tpr_packets_stats);
__uint(max_entries, TPR_STATS_MAP_SIZE);
__uint(map_flags, NO_FLAGS);
} tpr_packets_stats_map SEC(".maps");
} tpr_stats_map SEC(".maps");

struct {
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
__type(key, __u32);
__type(value, struct lb_stats);
__uint(max_entries, MAX_VIPS);
__uint(map_flags, NO_FLAGS);
} server_id_routing_stats SEC(".maps");
} server_id_stats SEC(".maps");

#endif // of _BALANCER_MAPS
Loading