bpf: provide helper that indicates eBPF was migrated
[deliverable/linux.git] / include / linux / filter.h
index 69d00555ce35239e8b93aa4b2a46fdb8171ca390..6b025491120d17e5a3bb676712100dc091e8a8de 100644 (file)
@@ -354,6 +354,16 @@ static inline unsigned int bpf_prog_size(unsigned int proglen)
                   offsetof(struct bpf_prog, insns[proglen]));
 }
 
+static inline bool bpf_prog_was_classic(const struct bpf_prog *prog)
+{
+       /* When classic BPF programs have been loaded and the arch
+        * does not have a classic BPF JIT (anymore), they have been
+        * converted via bpf_migrate_filter() to eBPF and thus always
+        * have an unspec program type.
+        */
+       return prog->type == BPF_PROG_TYPE_UNSPEC;
+}
+
 #define bpf_classic_proglen(fprog) (fprog->len * sizeof(fprog->filter[0]))
 
 #ifdef CONFIG_DEBUG_SET_MODULE_RONX
This page took 0.035435 seconds and 5 git commands to generate.