Skip to content

Commit 639a90b

Browse files
p-shah256meta-codesync[bot]
authored andcommitted
remove bpf_redirect from healthchecking.bpf.c
Summary: With the introduction of namespaces, the use of bpf_redirect has become redundant. To keep things scoped properly, we now use ifdef to avoid including bpf_redirect only for the new BPF object healthchecking_kern_no_redirect, since other programs might still depend on it. Reviewed By: avasylev Differential Revision: D83278023 fbshipit-source-id: 2e21ab0660109a08b866246b4e6f870383652ad7
1 parent e4d43f2 commit 639a90b

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

katran/lib/bpf/healthchecking.bpf.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
#include "katran/lib/bpf/healthchecking_maps.h"
3131
#include "katran/lib/bpf/healthchecking_structs.h"
3232

33+
#ifndef HC_WITH_REDIRECT
34+
#define HC_WITH_REDIRECT 1
35+
#endif
36+
3337
SEC("tc")
3438
int healthcheck_encap(struct __sk_buff* skb) {
3539
__u32 stats_key = GENERIC_STATS_INDEX;
@@ -70,6 +74,7 @@ int healthcheck_encap(struct __sk_buff* skb) {
7074
}
7175
#endif
7276

77+
#if HC_WITH_REDIRECT
7378
__u32* intf_ifindex = bpf_map_lookup_elem(&hc_ctrl_map, &key);
7479
if (!intf_ifindex) {
7580
// we dont have ifindex for main interface
@@ -91,6 +96,7 @@ int healthcheck_encap(struct __sk_buff* skb) {
9196
prog_stats->pckts_dropped += 1;
9297
return TC_ACT_SHOT;
9398
}
99+
#endif /* HC_WITH_REDIRECT */
94100

95101
if ((skb->data + sizeof(struct ethhdr)) > skb->data_end) {
96102
prog_stats->pckts_dropped += 1;
@@ -118,9 +124,11 @@ int healthcheck_encap(struct __sk_buff* skb) {
118124
return TC_ACT_SHOT;
119125
}
120126

127+
#if HC_WITH_REDIRECT
121128
ethh = (void*)(long)skb->data;
122129
memcpy(ethh->h_source, esrc->mac, 6);
123130
memcpy(ethh->h_dest, edst->mac, 6);
131+
#endif /* HC_WITH_REDIRECT */
124132

125133
prog_stats->pckts_processed += 1;
126134

@@ -135,7 +143,11 @@ int healthcheck_encap(struct __sk_buff* skb) {
135143
}
136144
}
137145

146+
#if HC_WITH_REDIRECT
138147
return bpf_redirect(*intf_ifindex, REDIRECT_EGRESS);
148+
#else
149+
return TC_ACT_OK;
150+
#endif /* HC_WITH_REDIRECT */
139151
}
140152

141153
char _license[] SEC("license") = "GPL";

0 commit comments

Comments
 (0)