diff options
-rw-r--r-- | kernel/bpf/cpumap.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c index 8974b3755670..3c18260403dd 100644 --- a/kernel/bpf/cpumap.c +++ b/kernel/bpf/cpumap.c | |||
@@ -162,10 +162,14 @@ static void cpu_map_kthread_stop(struct work_struct *work) | |||
162 | static struct sk_buff *cpu_map_build_skb(struct bpf_cpu_map_entry *rcpu, | 162 | static struct sk_buff *cpu_map_build_skb(struct bpf_cpu_map_entry *rcpu, |
163 | struct xdp_frame *xdpf) | 163 | struct xdp_frame *xdpf) |
164 | { | 164 | { |
165 | unsigned int hard_start_headroom; | ||
165 | unsigned int frame_size; | 166 | unsigned int frame_size; |
166 | void *pkt_data_start; | 167 | void *pkt_data_start; |
167 | struct sk_buff *skb; | 168 | struct sk_buff *skb; |
168 | 169 | ||
170 | /* Part of headroom was reserved to xdpf */ | ||
171 | hard_start_headroom = sizeof(struct xdp_frame) + xdpf->headroom; | ||
172 | |||
169 | /* build_skb need to place skb_shared_info after SKB end, and | 173 | /* build_skb need to place skb_shared_info after SKB end, and |
170 | * also want to know the memory "truesize". Thus, need to | 174 | * also want to know the memory "truesize". Thus, need to |
171 | * know the memory frame size backing xdp_buff. | 175 | * know the memory frame size backing xdp_buff. |
@@ -183,15 +187,15 @@ static struct sk_buff *cpu_map_build_skb(struct bpf_cpu_map_entry *rcpu, | |||
183 | * is not at a fixed memory location, with mixed length | 187 | * is not at a fixed memory location, with mixed length |
184 | * packets, which is bad for cache-line hotness. | 188 | * packets, which is bad for cache-line hotness. |
185 | */ | 189 | */ |
186 | frame_size = SKB_DATA_ALIGN(xdpf->len + xdpf->headroom) + | 190 | frame_size = SKB_DATA_ALIGN(xdpf->len + hard_start_headroom) + |
187 | SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); | 191 | SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); |
188 | 192 | ||
189 | pkt_data_start = xdpf->data - xdpf->headroom; | 193 | pkt_data_start = xdpf->data - hard_start_headroom; |
190 | skb = build_skb(pkt_data_start, frame_size); | 194 | skb = build_skb(pkt_data_start, frame_size); |
191 | if (!skb) | 195 | if (!skb) |
192 | return NULL; | 196 | return NULL; |
193 | 197 | ||
194 | skb_reserve(skb, xdpf->headroom); | 198 | skb_reserve(skb, hard_start_headroom); |
195 | __skb_put(skb, xdpf->len); | 199 | __skb_put(skb, xdpf->len); |
196 | if (xdpf->metasize) | 200 | if (xdpf->metasize) |
197 | skb_metadata_set(skb, xdpf->metasize); | 201 | skb_metadata_set(skb, xdpf->metasize); |
@@ -205,6 +209,9 @@ static struct sk_buff *cpu_map_build_skb(struct bpf_cpu_map_entry *rcpu, | |||
205 | * - RX ring dev queue index (skb_record_rx_queue) | 209 | * - RX ring dev queue index (skb_record_rx_queue) |
206 | */ | 210 | */ |
207 | 211 | ||
212 | /* Allow SKB to reuse area used by xdp_frame */ | ||
213 | xdp_scrub_frame(xdpf); | ||
214 | |||
208 | return skb; | 215 | return skb; |
209 | } | 216 | } |
210 | 217 | ||