nfp: bpf: pass raw data buffer to nfp_bpf_event_output()
In preparation for SKB-less perf event handling make nfp_bpf_event_output() take buffer address and length, not SKB as parameters. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com> Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
parent
79ca38e80c
commit
20c5420421
@ -441,7 +441,10 @@ void nfp_bpf_ctrl_msg_rx(struct nfp_app *app, struct sk_buff *skb)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (nfp_bpf_cmsg_get_type(skb) == CMSG_TYPE_BPF_EVENT) {
|
if (nfp_bpf_cmsg_get_type(skb) == CMSG_TYPE_BPF_EVENT) {
|
||||||
nfp_bpf_event_output(bpf, skb);
|
if (!nfp_bpf_event_output(bpf, skb->data, skb->len))
|
||||||
|
dev_consume_skb_any(skb);
|
||||||
|
else
|
||||||
|
dev_kfree_skb_any(skb);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,7 +501,8 @@ int nfp_bpf_ctrl_lookup_entry(struct bpf_offloaded_map *offmap,
|
|||||||
int nfp_bpf_ctrl_getnext_entry(struct bpf_offloaded_map *offmap,
|
int nfp_bpf_ctrl_getnext_entry(struct bpf_offloaded_map *offmap,
|
||||||
void *key, void *next_key);
|
void *key, void *next_key);
|
||||||
|
|
||||||
int nfp_bpf_event_output(struct nfp_app_bpf *bpf, struct sk_buff *skb);
|
int nfp_bpf_event_output(struct nfp_app_bpf *bpf, const void *data,
|
||||||
|
unsigned int len);
|
||||||
|
|
||||||
void nfp_bpf_ctrl_msg_rx(struct nfp_app *app, struct sk_buff *skb);
|
void nfp_bpf_ctrl_msg_rx(struct nfp_app *app, struct sk_buff *skb);
|
||||||
#endif
|
#endif
|
||||||
|
@ -453,23 +453,24 @@ nfp_bpf_perf_event_copy(void *dst, const void *src,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nfp_bpf_event_output(struct nfp_app_bpf *bpf, struct sk_buff *skb)
|
int nfp_bpf_event_output(struct nfp_app_bpf *bpf, const void *data,
|
||||||
|
unsigned int len)
|
||||||
{
|
{
|
||||||
struct cmsg_bpf_event *cbe = (void *)skb->data;
|
struct cmsg_bpf_event *cbe = (void *)data;
|
||||||
u32 pkt_size, data_size;
|
u32 pkt_size, data_size;
|
||||||
struct bpf_map *map;
|
struct bpf_map *map;
|
||||||
|
|
||||||
if (skb->len < sizeof(struct cmsg_bpf_event))
|
if (len < sizeof(struct cmsg_bpf_event))
|
||||||
goto err_drop;
|
return -EINVAL;
|
||||||
|
|
||||||
pkt_size = be32_to_cpu(cbe->pkt_size);
|
pkt_size = be32_to_cpu(cbe->pkt_size);
|
||||||
data_size = be32_to_cpu(cbe->data_size);
|
data_size = be32_to_cpu(cbe->data_size);
|
||||||
map = (void *)(unsigned long)be64_to_cpu(cbe->map_ptr);
|
map = (void *)(unsigned long)be64_to_cpu(cbe->map_ptr);
|
||||||
|
|
||||||
if (skb->len < sizeof(struct cmsg_bpf_event) + pkt_size + data_size)
|
if (len < sizeof(struct cmsg_bpf_event) + pkt_size + data_size)
|
||||||
goto err_drop;
|
return -EINVAL;
|
||||||
if (cbe->hdr.ver != CMSG_MAP_ABI_VERSION)
|
if (cbe->hdr.ver != CMSG_MAP_ABI_VERSION)
|
||||||
goto err_drop;
|
return -EINVAL;
|
||||||
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
if (!rhashtable_lookup_fast(&bpf->maps_neutral, &map,
|
if (!rhashtable_lookup_fast(&bpf->maps_neutral, &map,
|
||||||
@ -477,7 +478,7 @@ int nfp_bpf_event_output(struct nfp_app_bpf *bpf, struct sk_buff *skb)
|
|||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
pr_warn("perf event: dest map pointer %px not recognized, dropping event\n",
|
pr_warn("perf event: dest map pointer %px not recognized, dropping event\n",
|
||||||
map);
|
map);
|
||||||
goto err_drop;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bpf_event_output(map, be32_to_cpu(cbe->cpu_id),
|
bpf_event_output(map, be32_to_cpu(cbe->cpu_id),
|
||||||
@ -485,11 +486,7 @@ int nfp_bpf_event_output(struct nfp_app_bpf *bpf, struct sk_buff *skb)
|
|||||||
cbe->data, pkt_size, nfp_bpf_perf_event_copy);
|
cbe->data, pkt_size, nfp_bpf_perf_event_copy);
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
|
|
||||||
dev_consume_skb_any(skb);
|
|
||||||
return 0;
|
return 0;
|
||||||
err_drop:
|
|
||||||
dev_kfree_skb_any(skb);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user