bpf: offload: make bpf_offload_dev_match() reject host+host case
authorJakub Kicinski <jakub.kicinski@netronome.com>
Tue, 16 Jan 2018 23:51:45 +0000 (15:51 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 17 Jan 2018 00:15:05 +0000 (01:15 +0100)
Daniel suggests it would be more logical for bpf_offload_dev_match()
to return false is either the program or the map are not offloaded,
rather than treating the both not offloaded case as a "matching
CPU/host device".

This makes no functional difference today, since verifier only calls
bpf_offload_dev_match() when one of the objects is offloaded.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
kernel/bpf/offload.c

index 453785fa1881e38d2ce81c06c7c93aeacab52e18..a88cebf368bfb314e1d501b8bd58d93aadc352ff 100644 (file)
@@ -395,10 +395,8 @@ bool bpf_offload_dev_match(struct bpf_prog *prog, struct bpf_map *map)
        struct bpf_prog_offload *offload;
        bool ret;
 
-       if (!!bpf_prog_is_dev_bound(prog->aux) != !!bpf_map_is_dev_bound(map))
+       if (!bpf_prog_is_dev_bound(prog->aux) || !bpf_map_is_dev_bound(map))
                return false;
-       if (!bpf_prog_is_dev_bound(prog->aux))
-               return true;
 
        down_read(&bpf_devs_lock);
        offload = prog->aux->offload;