diff options
Diffstat (limited to 'kernel/bpf/sockmap.c')
-rw-r--r-- | kernel/bpf/sockmap.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c index eef843c3b419..de8f66cad882 100644 --- a/kernel/bpf/sockmap.c +++ b/kernel/bpf/sockmap.c | |||
@@ -96,6 +96,14 @@ static inline struct smap_psock *smap_psock_sk(const struct sock *sk) | |||
96 | return rcu_dereference_sk_user_data(sk); | 96 | return rcu_dereference_sk_user_data(sk); |
97 | } | 97 | } |
98 | 98 | ||
99 | /* compute the linear packet data range [data, data_end) for skb when | ||
100 | * sk_skb type programs are in use. | ||
101 | */ | ||
102 | static inline void bpf_compute_data_end_sk_skb(struct sk_buff *skb) | ||
103 | { | ||
104 | TCP_SKB_CB(skb)->bpf.data_end = skb->data + skb_headlen(skb); | ||
105 | } | ||
106 | |||
99 | static int smap_verdict_func(struct smap_psock *psock, struct sk_buff *skb) | 107 | static int smap_verdict_func(struct smap_psock *psock, struct sk_buff *skb) |
100 | { | 108 | { |
101 | struct bpf_prog *prog = READ_ONCE(psock->bpf_verdict); | 109 | struct bpf_prog *prog = READ_ONCE(psock->bpf_verdict); |
@@ -117,7 +125,8 @@ static int smap_verdict_func(struct smap_psock *psock, struct sk_buff *skb) | |||
117 | preempt_enable(); | 125 | preempt_enable(); |
118 | skb->sk = NULL; | 126 | skb->sk = NULL; |
119 | 127 | ||
120 | return rc; | 128 | return rc == SK_PASS ? |
129 | (TCP_SKB_CB(skb)->bpf.map ? SK_REDIRECT : SK_PASS) : SK_DROP; | ||
121 | } | 130 | } |
122 | 131 | ||
123 | static void smap_do_verdict(struct smap_psock *psock, struct sk_buff *skb) | 132 | static void smap_do_verdict(struct smap_psock *psock, struct sk_buff *skb) |