@@ -90,6 +90,7 @@ static const char *libbpf_strerror_table[NR_ERRNO] = {
90
90
[ERRCODE_OFFSET (VERIFY )] = "Kernel verifier blocks program loading" ,
91
91
[ERRCODE_OFFSET (PROG2BIG )] = "Program too big" ,
92
92
[ERRCODE_OFFSET (KVER )] = "Incorrect kernel version" ,
93
+ [ERRCODE_OFFSET (PROGTYPE )] = "Kernel doesn't support this program type" ,
93
94
};
94
95
95
96
int libbpf_strerror (int err , char * buf , size_t size )
@@ -926,15 +927,27 @@ load_program(enum bpf_prog_type type, struct bpf_insn *insns,
926
927
pr_warning ("-- BEGIN DUMP LOG ---\n" );
927
928
pr_warning ("\n%s\n" , log_buf );
928
929
pr_warning ("-- END LOG --\n" );
930
+ } else if (insns_cnt >= BPF_MAXINSNS ) {
931
+ pr_warning ("Program too large (%d insns), at most %d insns\n" ,
932
+ insns_cnt , BPF_MAXINSNS );
933
+ ret = - LIBBPF_ERRNO__PROG2BIG ;
929
934
} else {
930
- if (insns_cnt >= BPF_MAXINSNS ) {
931
- pr_warning ("Program too large (%d insns), at most %d insns\n" ,
932
- insns_cnt , BPF_MAXINSNS );
933
- ret = - LIBBPF_ERRNO__PROG2BIG ;
934
- } else if (log_buf ) {
935
- pr_warning ("log buffer is empty\n" );
936
- ret = - LIBBPF_ERRNO__KVER ;
935
+ /* Wrong program type? */
936
+ if (type != BPF_PROG_TYPE_KPROBE ) {
937
+ int fd ;
938
+
939
+ fd = bpf_load_program (BPF_PROG_TYPE_KPROBE , insns ,
940
+ insns_cnt , license , kern_version ,
941
+ NULL , 0 );
942
+ if (fd >= 0 ) {
943
+ close (fd );
944
+ ret = - LIBBPF_ERRNO__PROGTYPE ;
945
+ goto out ;
946
+ }
937
947
}
948
+
949
+ if (log_buf )
950
+ ret = - LIBBPF_ERRNO__KVER ;
938
951
}
939
952
940
953
out :
0 commit comments