On 16/08/18 17:44, Petar Penkov wrote:
> From: Petar Penkov <[email protected]>
>
> Adds a hook for programs of type BPF_PROG_TYPE_FLOW_DISSECTOR and
> attach type BPF_FLOW_DISSECTOR that is executed in the flow dissector
> path. The BPF program is kept as a global variable so it is
> accessible to all flow dissectors.
>
> Signed-off-by: Petar Penkov <[email protected]>
> Signed-off-by: Willem de Bruijn <[email protected]>
> ---
This looks really great.
> +int skb_flow_dissector_bpf_prog_detach(const union bpf_attr *attr)
> +{
> + struct bpf_prog *attached;
> +
> + mutex_lock(&flow_dissector_mutex);
> + attached = rcu_dereference_protected(flow_dissector_prog,
> +
> lockdep_is_held(&flow_dissector_mutex));
> + if (!flow_dissector_prog) {
> + mutex_unlock(&flow_dissector_mutex);
> + return -EINVAL;
Wouldn't -ENOENT be more usual here (as the counterpart to -EEXIST in
the skb_flow_dissector_bpf_prog_attach() version just above)?
-Ed