Skip to content

Commit

Permalink
bpf: fixing dirty cb state from the kernel
Browse files Browse the repository at this point in the history
Signed-off-by: André Martins <andre@cilium.io>
  • Loading branch information
aanm committed Feb 7, 2017
1 parent 011f048 commit 3195992
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bpf/bpf_lb.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ int from_netdev(struct __sk_buff *skb)
{
int ret;

bpf_clear_cb(skb);

switch (skb->protocol) {
#ifndef LB_DISABLE_IPV6
case __constant_htons(ETH_P_IPV6):
Expand Down
2 changes: 2 additions & 0 deletions bpf/bpf_lxc.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,8 @@ int handle_ingress(struct __sk_buff *skb)
{
int ret;

bpf_clear_cb(skb);

cilium_trace_capture(skb, DBG_CAPTURE_FROM_LXC, skb->ingress_ifindex);

switch (skb->protocol) {
Expand Down
2 changes: 2 additions & 0 deletions bpf/bpf_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ int from_netdev(struct __sk_buff *skb)
{
int ret;

bpf_clear_cb(skb);

cilium_trace_capture(skb, DBG_CAPTURE_FROM_NETDEV, skb->ingress_ifindex);

switch (skb->protocol) {
Expand Down
2 changes: 2 additions & 0 deletions bpf/bpf_overlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ int from_overlay(struct __sk_buff *skb)
{
int ret;

bpf_clear_cb(skb);

cilium_trace_capture(skb, DBG_CAPTURE_FROM_OVERLAY, skb->ingress_ifindex);

switch (skb->protocol) {
Expand Down
11 changes: 11 additions & 0 deletions bpf/lib/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,15 @@
_x > _y ? _x : _y; \
})

/* Clear CB values */
static inline void bpf_clear_cb(struct __sk_buff *skb)
{
__u32 zero = 0;
skb->cb[0] = zero;
skb->cb[1] = zero;
skb->cb[2] = zero;
skb->cb[3] = zero;
skb->cb[4] = zero;
}

#endif

0 comments on commit 3195992

Please sign in to comment.