Last active
April 19, 2017 22:29
-
-
Save williamtu/070a29e2fa8a15e512f26ea4ea9cffeb to your computer and use it in GitHub Desktop.
BPF array initialization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
make[1]: Leaving directory '/root/net-next' | |
bpf_load_program() err=13 | |
0: (bf) r6 = r1 | |
1: (30) r0 = *(u8 *)skb[23] | |
2: (63) *(u32 *)(r10 -4) = r0 | |
3: (18) r1 = 0x9ffe7000 | |
5: (79) r2 = *(u64 *)(r1 +8) | |
R1 invalid mem access 'map_ptr' | |
--- | |
Disassembly of section socket1: | |
bpf_prog1: | |
; { | |
0: bf 16 00 00 00 00 00 00 r6 = r1 | |
; int index = load_byte(skb, ETH_HLEN + offsetof(struct iphdr, protocol)); | |
1: 30 00 00 00 17 00 00 00 r0 = *(u8 *)skb[23] | |
2: 63 0a fc ff 00 00 00 00 *(u32 *)(r10 - 4) = r0 | |
; struct bpf_flow_keys flow_mask_array[2] = { | |
3: 18 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 r1 = 0ll | |
5: 79 12 08 00 00 00 00 00 r2 = *(u64 *)(r1 + 8) | |
6: 7b 2a e8 ff 00 00 00 00 *(u64 *)(r10 - 24) = r2 | |
7: 79 11 00 00 00 00 00 00 r1 = *(u64 *)(r1 + 0) | |
8: 7b 1a e0 ff 00 00 00 00 *(u64 *)(r10 - 32) = r1 | |
; if (skb->pkt_type != PACKET_OUTGOING) | |
9: 61 61 04 00 00 00 00 00 r1 = *(u32 *)(r6 + 4) | |
10: 55 01 08 00 04 00 00 00 if r1 != 4 goto 8 | |
11: bf a2 00 00 00 00 00 00 r2 = r10 | |
12: 07 02 00 00 fc ff ff ff r2 += -4 | |
; bpf_map_update_elem(&my_map, &index, &(flow_mask_array[1].src), BPF_ANY); | |
13: bf a3 00 00 00 00 00 00 r3 = r10 | |
14: 07 03 00 00 e8 ff ff ff r3 += -24 | |
15: 18 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 r1 = 0ll | |
17: b7 04 00 00 00 00 00 00 r4 = 0 | |
18: 85 00 00 00 02 00 00 00 call 2 | |
LBB0_2: | |
; } | |
19: b7 00 00 00 00 00 00 00 r0 = 0 | |
20: 95 00 00 00 00 00 00 00 exit | |
~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Disassembly of section socket1: | |
bpf_prog1: | |
; { | |
0: bf 16 00 00 00 00 00 00 r6 = r1 | |
; int index = load_byte(skb, ETH_HLEN + offsetof(struct iphdr, protocol)); | |
1: 30 00 00 00 17 00 00 00 r0 = *(u8 *)skb[23] | |
2: 63 0a fc ff 00 00 00 00 *(u32 *)(r10 - 4) = r0 | |
; flow_mask_array[0].src = 0xf00; | |
3: b7 01 00 00 5c 11 00 00 r1 = 4444 | |
4: 7b 1a e8 ff 00 00 00 00 *(u64 *)(r10 - 24) = r1 | |
5: b7 01 00 00 00 0f 00 00 r1 = 3840 | |
6: 7b 1a e0 ff 00 00 00 00 *(u64 *)(r10 - 32) = r1 | |
; if (skb->pkt_type != PACKET_OUTGOING) | |
7: 61 61 04 00 00 00 00 00 r1 = *(u32 *)(r6 + 4) | |
8: 55 01 08 00 04 00 00 00 if r1 != 4 goto 8 | |
9: bf a2 00 00 00 00 00 00 r2 = r10 | |
10: 07 02 00 00 fc ff ff ff r2 += -4 | |
; flow_mask_array[1].src = 4444; | |
11: bf a3 00 00 00 00 00 00 r3 = r10 | |
12: 07 03 00 00 e8 ff ff ff r3 += -24 | |
; bpf_map_update_elem(&my_map, &index, &(flow_mask_array[1].src), BPF_ANY); | |
13: 18 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 r1 = 0ll | |
15: b7 04 00 00 00 00 00 00 r4 = 0 | |
16: 85 00 00 00 02 00 00 00 call 2 | |
LBB0_2: | |
; } | |
17: b7 00 00 00 00 00 00 00 r0 = 0 | |
18: 95 00 00 00 00 00 00 00 exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <uapi/linux/bpf.h> | |
#include <uapi/linux/if_ether.h> | |
#include <uapi/linux/if_packet.h> | |
#include <uapi/linux/ip.h> | |
#include "bpf_helpers.h" | |
struct bpf_flow_keys { | |
long src; | |
}; | |
struct bpf_map_def SEC("maps") my_map = { | |
.type = BPF_MAP_TYPE_ARRAY, | |
.key_size = sizeof(u32), | |
.value_size = sizeof(long), | |
.max_entries = 256, | |
}; | |
SEC("socket1") | |
int bpf_prog1(struct __sk_buff *skb) | |
{ | |
int index = load_byte(skb, ETH_HLEN + offsetof(struct iphdr, protocol)); | |
long *value; | |
#if 1// WORK | |
struct bpf_flow_keys flow_mask_array[2]; | |
flow_mask_array[0].src = 0xf00; | |
flow_mask_array[1].src = 4444; | |
#else //NOT WORK! | |
struct bpf_flow_keys flow_mask_array[] = { | |
{.src = 5555}, | |
{.src = 4444}, | |
}; | |
#endif | |
if (skb->pkt_type != PACKET_OUTGOING) | |
return 0; | |
bpf_map_update_elem(&my_map, &index, &(flow_mask_array[1].src), BPF_ANY); | |
return 0; | |
} | |
char _license[] SEC("license") = "GPL"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ModuleID = 'sockex1_kern.bc' | |
source_filename = "sockex1_kern.bc" | |
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" | |
target triple = "x86_64-pc-linux-gnu" | |
%struct.bpf_map_def = type { i32, i32, i32, i32, i32 } | |
%struct.bpf_flow_keys = type { i64 } | |
%struct.__sk_buff = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [5 x i32], i32, i32, i32, i32 } | |
@my_map = global %struct.bpf_map_def { i32 2, i32 4, i32 8, i32 256, i32 0 }, section "maps", align 4, !dbg !0 | |
@bpf_prog1.flow_mask_array = private unnamed_addr constant [2 x %struct.bpf_flow_keys] [%struct.bpf_flow_keys { i64 57005 }, %struct.bpf_flow_keys { i64 4444 }], align 16 | |
@_license = global [4 x i8] c"GPL\00", section "license", align 1, !dbg !30 | |
@llvm.used = appending global [3 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @_license, i32 0, i32 0), i8* bitcast (i32 (%struct.__sk_buff*)* @bpf_prog1 to i8*), i8* bitcast (%struct.bpf_map_def* @my_map to i8*)], section "llvm.metadata" | |
; Function Attrs: nounwind uwtable | |
define i32 @bpf_prog1(%struct.__sk_buff* %skb) #0 section "socket1" !dbg !34 { | |
%index = alloca i32, align 4 | |
%flow_mask_array = alloca [2 x %struct.bpf_flow_keys], align 16 | |
tail call void @llvm.dbg.value(metadata %struct.__sk_buff* %skb, i64 0, metadata !64, metadata !76), !dbg !77 | |
%1 = bitcast i32* %index to i8*, !dbg !78 | |
call void @llvm.lifetime.start(i64 4, i8* %1) #4, !dbg !78 | |
%2 = bitcast %struct.__sk_buff* %skb to i8*, !dbg !79 | |
%3 = tail call i64 @llvm.bpf.load.byte(i8* %2, i64 23), !dbg !80 | |
%4 = trunc i64 %3 to i32, !dbg !82 | |
tail call void @llvm.dbg.value(metadata i32 %4, i64 0, metadata !65, metadata !76), !dbg !83 | |
store i32 %4, i32* %index, align 4, !dbg !83, !tbaa !84 | |
%5 = bitcast [2 x %struct.bpf_flow_keys]* %flow_mask_array to i8*, !dbg !88 | |
call void @llvm.lifetime.start(i64 16, i8* %5) #4, !dbg !88 | |
tail call void @llvm.dbg.declare(metadata [2 x %struct.bpf_flow_keys]* %flow_mask_array, metadata !69, metadata !76), !dbg !89 | |
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %5, i8* bitcast ([2 x %struct.bpf_flow_keys]* @bpf_prog1.flow_mask_array to i8*), i64 16, i32 16, i1 false), !dbg !90 | |
%6 = getelementptr inbounds %struct.__sk_buff, %struct.__sk_buff* %skb, i64 0, i32 1, !dbg !91 | |
%7 = load i32, i32* %6, align 4, !dbg !91, !tbaa !93 | |
%8 = icmp eq i32 %7, 4, !dbg !95 | |
br i1 %8, label %9, label %13, !dbg !96 | |
; <label>:9: ; preds = %0 | |
%10 = getelementptr inbounds [2 x %struct.bpf_flow_keys], [2 x %struct.bpf_flow_keys]* %flow_mask_array, i64 0, i64 1, i32 0, !dbg !97 | |
%11 = bitcast i64* %10 to i8*, !dbg !98 | |
%12 = call i32 inttoptr (i64 2 to i32 (i8*, i8*, i8*, i64)*)(i8* nonnull bitcast (%struct.bpf_map_def* @my_map to i8*), i8* %1, i8* %11, i64 0) #4, !dbg !99 | |
br label %13, !dbg !100 | |
; <label>:13: ; preds = %0, %9 | |
call void @llvm.lifetime.end(i64 16, i8* %5) #4, !dbg !101 | |
call void @llvm.lifetime.end(i64 4, i8* %1) #4, !dbg !102 | |
ret i32 0, !dbg !101 | |
} | |
; Function Attrs: nounwind readnone | |
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 | |
; Function Attrs: argmemonly nounwind | |
declare void @llvm.lifetime.start(i64, i8* nocapture) #2 | |
; Function Attrs: nounwind readonly | |
declare i64 @llvm.bpf.load.byte(i8*, i64) #3 | |
; Function Attrs: argmemonly nounwind | |
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i32, i1) #2 | |
; Function Attrs: argmemonly nounwind | |
declare void @llvm.lifetime.end(i64, i8* nocapture) #2 | |
; Function Attrs: nounwind readnone | |
declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1 | |
attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" } | |
attributes #1 = { nounwind readnone } | |
attributes #2 = { argmemonly nounwind } | |
attributes #3 = { nounwind readonly } | |
attributes #4 = { nounwind } | |
!llvm.dbg.cu = !{!2} | |
!llvm.module.flags = !{!31, !32} | |
!llvm.ident = !{!33} | |
!0 = distinct !DIGlobalVariableExpression(var: !1) | |
!1 = !DIGlobalVariable(name: "my_map", scope: !2, file: !3, line: 11, type: !22, isLocal: false, isDefinition: true) | |
!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5) | |
!3 = !DIFile(filename: "/root/net-next/samples/bpf/sockex1_kern.c", directory: "/root/net-next") | |
!4 = !{} | |
!5 = !{!6, !7, !13} | |
!6 = distinct !DIGlobalVariableExpression(var: !1) | |
!7 = distinct !DIGlobalVariableExpression(var: !8) | |
!8 = !DIGlobalVariable(name: "_license", scope: !2, file: !3, line: 43, type: !9, isLocal: false, isDefinition: true) | |
!9 = !DICompositeType(tag: DW_TAG_array_type, baseType: !10, size: 32, align: 8, elements: !11) | |
!10 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char) | |
!11 = !{!12} | |
!12 = !DISubrange(count: 4) | |
!13 = distinct !DIGlobalVariableExpression(var: !14) | |
!14 = !DIGlobalVariable(name: "bpf_map_update_elem", scope: !2, file: !15, line: 13, type: !16, isLocal: true, isDefinition: true) | |
!15 = !DIFile(filename: "/root/net-next/samples/bpf/bpf_helpers.h", directory: "/root/net-next") | |
!16 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !17, size: 64, align: 64) | |
!17 = !DISubroutineType(types: !18) | |
!18 = !{!19, !20, !20, !20, !21} | |
!19 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) | |
!20 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64, align: 64) | |
!21 = !DIBasicType(name: "long long unsigned int", size: 64, align: 64, encoding: DW_ATE_unsigned) | |
!22 = !DICompositeType(tag: DW_TAG_structure_type, name: "bpf_map_def", file: !15, line: 77, size: 160, align: 32, elements: !23) | |
!23 = !{!24, !26, !27, !28, !29} | |
!24 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !22, file: !15, line: 78, baseType: !25, size: 32, align: 32) | |
!25 = !DIBasicType(name: "unsigned int", size: 32, align: 32, encoding: DW_ATE_unsigned) | |
!26 = !DIDerivedType(tag: DW_TAG_member, name: "key_size", scope: !22, file: !15, line: 79, baseType: !25, size: 32, align: 32, offset: 32) | |
!27 = !DIDerivedType(tag: DW_TAG_member, name: "value_size", scope: !22, file: !15, line: 80, baseType: !25, size: 32, align: 32, offset: 64) | |
!28 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !22, file: !15, line: 81, baseType: !25, size: 32, align: 32, offset: 96) | |
!29 = !DIDerivedType(tag: DW_TAG_member, name: "map_flags", scope: !22, file: !15, line: 82, baseType: !25, size: 32, align: 32, offset: 128) | |
!30 = distinct !DIGlobalVariableExpression(var: !8) | |
!31 = !{i32 2, !"Dwarf Version", i32 4} | |
!32 = !{i32 2, !"Debug Info Version", i32 3} | |
!33 = !{!"clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)"} | |
!34 = distinct !DISubprogram(name: "bpf_prog1", scope: !3, file: !3, line: 19, type: !35, isLocal: false, isDefinition: true, scopeLine: 20, flags: DIFlagPrototyped, isOptimized: true, unit: !2, variables: !63) | |
!35 = !DISubroutineType(types: !36) | |
!36 = !{!19, !37} | |
!37 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !38, size: 64, align: 64) | |
!38 = !DICompositeType(tag: DW_TAG_structure_type, name: "__sk_buff", file: !39, line: 559, size: 672, align: 32, elements: !40) | |
!39 = !DIFile(filename: "./include/uapi/linux/bpf.h", directory: "/root/net-next") | |
!40 = !{!41, !44, !45, !46, !47, !48, !49, !50, !51, !52, !53, !54, !55, !59, !60, !61, !62} | |
!41 = !DIDerivedType(tag: DW_TAG_member, name: "len", scope: !38, file: !39, line: 560, baseType: !42, size: 32, align: 32) | |
!42 = !DIDerivedType(tag: DW_TAG_typedef, name: "__u32", file: !43, line: 26, baseType: !25) | |
!43 = !DIFile(filename: "./include/uapi/asm-generic/int-ll64.h", directory: "/root/net-next") | |
!44 = !DIDerivedType(tag: DW_TAG_member, name: "pkt_type", scope: !38, file: !39, line: 561, baseType: !42, size: 32, align: 32, offset: 32) | |
!45 = !DIDerivedType(tag: DW_TAG_member, name: "mark", scope: !38, file: !39, line: 562, baseType: !42, size: 32, align: 32, offset: 64) | |
!46 = !DIDerivedType(tag: DW_TAG_member, name: "queue_mapping", scope: !38, file: !39, line: 563, baseType: !42, size: 32, align: 32, offset: 96) | |
!47 = !DIDerivedType(tag: DW_TAG_member, name: "protocol", scope: !38, file: !39, line: 564, baseType: !42, size: 32, align: 32, offset: 128) | |
!48 = !DIDerivedType(tag: DW_TAG_member, name: "vlan_present", scope: !38, file: !39, line: 565, baseType: !42, size: 32, align: 32, offset: 160) | |
!49 = !DIDerivedType(tag: DW_TAG_member, name: "vlan_tci", scope: !38, file: !39, line: 566, baseType: !42, size: 32, align: 32, offset: 192) | |
!50 = !DIDerivedType(tag: DW_TAG_member, name: "vlan_proto", scope: !38, file: !39, line: 567, baseType: !42, size: 32, align: 32, offset: 224) | |
!51 = !DIDerivedType(tag: DW_TAG_member, name: "priority", scope: !38, file: !39, line: 568, baseType: !42, size: 32, align: 32, offset: 256) | |
!52 = !DIDerivedType(tag: DW_TAG_member, name: "ingress_ifindex", scope: !38, file: !39, line: 569, baseType: !42, size: 32, align: 32, offset: 288) | |
!53 = !DIDerivedType(tag: DW_TAG_member, name: "ifindex", scope: !38, file: !39, line: 570, baseType: !42, size: 32, align: 32, offset: 320) | |
!54 = !DIDerivedType(tag: DW_TAG_member, name: "tc_index", scope: !38, file: !39, line: 571, baseType: !42, size: 32, align: 32, offset: 352) | |
!55 = !DIDerivedType(tag: DW_TAG_member, name: "cb", scope: !38, file: !39, line: 572, baseType: !56, size: 160, align: 32, offset: 384) | |
!56 = !DICompositeType(tag: DW_TAG_array_type, baseType: !42, size: 160, align: 32, elements: !57) | |
!57 = !{!58} | |
!58 = !DISubrange(count: 5) | |
!59 = !DIDerivedType(tag: DW_TAG_member, name: "hash", scope: !38, file: !39, line: 573, baseType: !42, size: 32, align: 32, offset: 544) | |
!60 = !DIDerivedType(tag: DW_TAG_member, name: "tc_classid", scope: !38, file: !39, line: 574, baseType: !42, size: 32, align: 32, offset: 576) | |
!61 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !38, file: !39, line: 575, baseType: !42, size: 32, align: 32, offset: 608) | |
!62 = !DIDerivedType(tag: DW_TAG_member, name: "data_end", scope: !38, file: !39, line: 576, baseType: !42, size: 32, align: 32, offset: 640) | |
!63 = !{!64, !65, !66, !69} | |
!64 = !DILocalVariable(name: "skb", arg: 1, scope: !34, file: !3, line: 19, type: !37) | |
!65 = !DILocalVariable(name: "index", scope: !34, file: !3, line: 21, type: !19) | |
!66 = !DILocalVariable(name: "value", scope: !34, file: !3, line: 22, type: !67) | |
!67 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !68, size: 64, align: 64) | |
!68 = !DIBasicType(name: "long int", size: 64, align: 64, encoding: DW_ATE_signed) | |
!69 = !DILocalVariable(name: "flow_mask_array", scope: !34, file: !3, line: 30, type: !70) | |
!70 = !DICompositeType(tag: DW_TAG_array_type, baseType: !71, size: 128, align: 64, elements: !74) | |
!71 = !DICompositeType(tag: DW_TAG_structure_type, name: "bpf_flow_keys", file: !3, line: 7, size: 64, align: 64, elements: !72) | |
!72 = !{!73} | |
!73 = !DIDerivedType(tag: DW_TAG_member, name: "src", scope: !71, file: !3, line: 8, baseType: !68, size: 64, align: 64) | |
!74 = !{!75} | |
!75 = !DISubrange(count: 2) | |
!76 = !DIExpression() | |
!77 = !DILocation(line: 19, column: 33, scope: !34) | |
!78 = !DILocation(line: 21, column: 2, scope: !34) | |
!79 = !DILocation(line: 21, column: 24, scope: !34) | |
!80 = !DILocation(line: 21, column: 14, scope: !81) | |
!81 = !DILexicalBlockFile(scope: !34, file: !3, discriminator: 1) | |
!82 = !DILocation(line: 21, column: 14, scope: !34) | |
!83 = !DILocation(line: 21, column: 6, scope: !34) | |
!84 = !{!85, !85, i64 0} | |
!85 = !{!"int", !86, i64 0} | |
!86 = !{!"omnipotent char", !87, i64 0} | |
!87 = !{!"Simple C/C++ TBAA"} | |
!88 = !DILocation(line: 30, column: 4, scope: !34) | |
!89 = !DILocation(line: 30, column: 25, scope: !34) | |
!90 = !DILocation(line: 30, column: 25, scope: !81) | |
!91 = !DILocation(line: 36, column: 11, scope: !92) | |
!92 = distinct !DILexicalBlock(scope: !34, file: !3, line: 36, column: 6) | |
!93 = !{!94, !85, i64 4} | |
!94 = !{!"__sk_buff", !85, i64 0, !85, i64 4, !85, i64 8, !85, i64 12, !85, i64 16, !85, i64 20, !85, i64 24, !85, i64 28, !85, i64 32, !85, i64 36, !85, i64 40, !85, i64 44, !86, i64 48, !85, i64 68, !85, i64 72, !85, i64 76, !85, i64 80} | |
!95 = !DILocation(line: 36, column: 20, scope: !92) | |
!96 = !DILocation(line: 36, column: 6, scope: !34) | |
!97 = !DILocation(line: 39, column: 63, scope: !34) | |
!98 = !DILocation(line: 39, column: 42, scope: !34) | |
!99 = !DILocation(line: 39, column: 5, scope: !34) | |
!100 = !DILocation(line: 41, column: 2, scope: !34) | |
!101 = !DILocation(line: 42, column: 1, scope: !34) | |
!102 = !DILocation(line: 42, column: 1, scope: !103) | |
!103 = !DILexicalBlockFile(scope: !34, file: !3, discriminator: 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ModuleID = 'sockex1_kern.bc' | |
source_filename = "sockex1_kern.bc" | |
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" | |
target triple = "x86_64-pc-linux-gnu" | |
%struct.bpf_map_def = type { i32, i32, i32, i32, i32 } | |
%struct.__sk_buff = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [5 x i32], i32, i32, i32, i32 } | |
%struct.bpf_flow_keys = type { i64 } | |
@my_map = global %struct.bpf_map_def { i32 2, i32 4, i32 8, i32 256, i32 0 }, section "maps", align 4, !dbg !0 | |
@_license = global [4 x i8] c"GPL\00", section "license", align 1, !dbg !30 | |
@llvm.used = appending global [3 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @_license, i32 0, i32 0), i8* bitcast (i32 (%struct.__sk_buff*)* @bpf_prog1 to i8*), i8* bitcast (%struct.bpf_map_def* @my_map to i8*)], section "llvm.metadata" | |
; Function Attrs: nounwind uwtable | |
define i32 @bpf_prog1(%struct.__sk_buff* %skb) #0 section "socket1" !dbg !34 { | |
%index = alloca i32, align 4 | |
%flow_mask_array = alloca <2 x i64>, align 16 | |
tail call void @llvm.dbg.value(metadata %struct.__sk_buff* %skb, i64 0, metadata !64, metadata !76), !dbg !77 | |
%1 = bitcast i32* %index to i8*, !dbg !78 | |
call void @llvm.lifetime.start(i64 4, i8* %1) #4, !dbg !78 | |
%2 = bitcast %struct.__sk_buff* %skb to i8*, !dbg !79 | |
%3 = tail call i64 @llvm.bpf.load.byte(i8* %2, i64 23), !dbg !80 | |
%4 = trunc i64 %3 to i32, !dbg !82 | |
tail call void @llvm.dbg.value(metadata i32 %4, i64 0, metadata !65, metadata !76), !dbg !83 | |
store i32 %4, i32* %index, align 4, !dbg !83, !tbaa !84 | |
%5 = bitcast <2 x i64>* %flow_mask_array to i8*, !dbg !88 | |
call void @llvm.lifetime.start(i64 16, i8* %5) #4, !dbg !88 | |
tail call void @llvm.dbg.declare(metadata [2 x %struct.bpf_flow_keys]* %tmpcast, metadata !69, metadata !76), !dbg !89 | |
store <2 x i64> <i64 3840, i64 4444>, <2 x i64>* %flow_mask_array, align 16, !dbg !90, !tbaa !91 | |
%6 = getelementptr inbounds %struct.__sk_buff, %struct.__sk_buff* %skb, i64 0, i32 1, !dbg !94 | |
%7 = load i32, i32* %6, align 4, !dbg !94, !tbaa !96 | |
%8 = icmp eq i32 %7, 4, !dbg !98 | |
br i1 %8, label %9, label %13, !dbg !99 | |
; <label>:9: ; preds = %0 | |
%tmpcast = bitcast <2 x i64>* %flow_mask_array to [2 x %struct.bpf_flow_keys]* | |
%10 = getelementptr inbounds [2 x %struct.bpf_flow_keys], [2 x %struct.bpf_flow_keys]* %tmpcast, i64 0, i64 1, i32 0, !dbg !100 | |
%11 = bitcast i64* %10 to i8*, !dbg !101 | |
%12 = call i32 inttoptr (i64 2 to i32 (i8*, i8*, i8*, i64)*)(i8* nonnull bitcast (%struct.bpf_map_def* @my_map to i8*), i8* %1, i8* %11, i64 0) #4, !dbg !102 | |
br label %13, !dbg !103 | |
; <label>:13: ; preds = %0, %9 | |
call void @llvm.lifetime.end(i64 16, i8* %5) #4, !dbg !104 | |
call void @llvm.lifetime.end(i64 4, i8* %1) #4, !dbg !105 | |
ret i32 0, !dbg !104 | |
} | |
; Function Attrs: nounwind readnone | |
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 | |
; Function Attrs: argmemonly nounwind | |
declare void @llvm.lifetime.start(i64, i8* nocapture) #2 | |
; Function Attrs: nounwind readonly | |
declare i64 @llvm.bpf.load.byte(i8*, i64) #3 | |
; Function Attrs: argmemonly nounwind | |
declare void @llvm.lifetime.end(i64, i8* nocapture) #2 | |
; Function Attrs: nounwind readnone | |
declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1 | |
attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" } | |
attributes #1 = { nounwind readnone } | |
attributes #2 = { argmemonly nounwind } | |
attributes #3 = { nounwind readonly } | |
attributes #4 = { nounwind } | |
!llvm.dbg.cu = !{!2} | |
!llvm.module.flags = !{!31, !32} | |
!llvm.ident = !{!33} | |
!0 = distinct !DIGlobalVariableExpression(var: !1) | |
!1 = !DIGlobalVariable(name: "my_map", scope: !2, file: !3, line: 11, type: !22, isLocal: false, isDefinition: true) | |
!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5) | |
!3 = !DIFile(filename: "/root/net-next/samples/bpf/sockex1_kern.c", directory: "/root/net-next") | |
!4 = !{} | |
!5 = !{!6, !7, !13} | |
!6 = distinct !DIGlobalVariableExpression(var: !1) | |
!7 = distinct !DIGlobalVariableExpression(var: !8) | |
!8 = !DIGlobalVariable(name: "_license", scope: !2, file: !3, line: 43, type: !9, isLocal: false, isDefinition: true) | |
!9 = !DICompositeType(tag: DW_TAG_array_type, baseType: !10, size: 32, align: 8, elements: !11) | |
!10 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char) | |
!11 = !{!12} | |
!12 = !DISubrange(count: 4) | |
!13 = distinct !DIGlobalVariableExpression(var: !14) | |
!14 = !DIGlobalVariable(name: "bpf_map_update_elem", scope: !2, file: !15, line: 13, type: !16, isLocal: true, isDefinition: true) | |
!15 = !DIFile(filename: "/root/net-next/samples/bpf/bpf_helpers.h", directory: "/root/net-next") | |
!16 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !17, size: 64, align: 64) | |
!17 = !DISubroutineType(types: !18) | |
!18 = !{!19, !20, !20, !20, !21} | |
!19 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) | |
!20 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64, align: 64) | |
!21 = !DIBasicType(name: "long long unsigned int", size: 64, align: 64, encoding: DW_ATE_unsigned) | |
!22 = !DICompositeType(tag: DW_TAG_structure_type, name: "bpf_map_def", file: !15, line: 77, size: 160, align: 32, elements: !23) | |
!23 = !{!24, !26, !27, !28, !29} | |
!24 = !DIDerivedType(tag: DW_TAG_member, name: "type", scope: !22, file: !15, line: 78, baseType: !25, size: 32, align: 32) | |
!25 = !DIBasicType(name: "unsigned int", size: 32, align: 32, encoding: DW_ATE_unsigned) | |
!26 = !DIDerivedType(tag: DW_TAG_member, name: "key_size", scope: !22, file: !15, line: 79, baseType: !25, size: 32, align: 32, offset: 32) | |
!27 = !DIDerivedType(tag: DW_TAG_member, name: "value_size", scope: !22, file: !15, line: 80, baseType: !25, size: 32, align: 32, offset: 64) | |
!28 = !DIDerivedType(tag: DW_TAG_member, name: "max_entries", scope: !22, file: !15, line: 81, baseType: !25, size: 32, align: 32, offset: 96) | |
!29 = !DIDerivedType(tag: DW_TAG_member, name: "map_flags", scope: !22, file: !15, line: 82, baseType: !25, size: 32, align: 32, offset: 128) | |
!30 = distinct !DIGlobalVariableExpression(var: !8) | |
!31 = !{i32 2, !"Dwarf Version", i32 4} | |
!32 = !{i32 2, !"Debug Info Version", i32 3} | |
!33 = !{!"clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)"} | |
!34 = distinct !DISubprogram(name: "bpf_prog1", scope: !3, file: !3, line: 19, type: !35, isLocal: false, isDefinition: true, scopeLine: 20, flags: DIFlagPrototyped, isOptimized: true, unit: !2, variables: !63) | |
!35 = !DISubroutineType(types: !36) | |
!36 = !{!19, !37} | |
!37 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !38, size: 64, align: 64) | |
!38 = !DICompositeType(tag: DW_TAG_structure_type, name: "__sk_buff", file: !39, line: 559, size: 672, align: 32, elements: !40) | |
!39 = !DIFile(filename: "./include/uapi/linux/bpf.h", directory: "/root/net-next") | |
!40 = !{!41, !44, !45, !46, !47, !48, !49, !50, !51, !52, !53, !54, !55, !59, !60, !61, !62} | |
!41 = !DIDerivedType(tag: DW_TAG_member, name: "len", scope: !38, file: !39, line: 560, baseType: !42, size: 32, align: 32) | |
!42 = !DIDerivedType(tag: DW_TAG_typedef, name: "__u32", file: !43, line: 26, baseType: !25) | |
!43 = !DIFile(filename: "./include/uapi/asm-generic/int-ll64.h", directory: "/root/net-next") | |
!44 = !DIDerivedType(tag: DW_TAG_member, name: "pkt_type", scope: !38, file: !39, line: 561, baseType: !42, size: 32, align: 32, offset: 32) | |
!45 = !DIDerivedType(tag: DW_TAG_member, name: "mark", scope: !38, file: !39, line: 562, baseType: !42, size: 32, align: 32, offset: 64) | |
!46 = !DIDerivedType(tag: DW_TAG_member, name: "queue_mapping", scope: !38, file: !39, line: 563, baseType: !42, size: 32, align: 32, offset: 96) | |
!47 = !DIDerivedType(tag: DW_TAG_member, name: "protocol", scope: !38, file: !39, line: 564, baseType: !42, size: 32, align: 32, offset: 128) | |
!48 = !DIDerivedType(tag: DW_TAG_member, name: "vlan_present", scope: !38, file: !39, line: 565, baseType: !42, size: 32, align: 32, offset: 160) | |
!49 = !DIDerivedType(tag: DW_TAG_member, name: "vlan_tci", scope: !38, file: !39, line: 566, baseType: !42, size: 32, align: 32, offset: 192) | |
!50 = !DIDerivedType(tag: DW_TAG_member, name: "vlan_proto", scope: !38, file: !39, line: 567, baseType: !42, size: 32, align: 32, offset: 224) | |
!51 = !DIDerivedType(tag: DW_TAG_member, name: "priority", scope: !38, file: !39, line: 568, baseType: !42, size: 32, align: 32, offset: 256) | |
!52 = !DIDerivedType(tag: DW_TAG_member, name: "ingress_ifindex", scope: !38, file: !39, line: 569, baseType: !42, size: 32, align: 32, offset: 288) | |
!53 = !DIDerivedType(tag: DW_TAG_member, name: "ifindex", scope: !38, file: !39, line: 570, baseType: !42, size: 32, align: 32, offset: 320) | |
!54 = !DIDerivedType(tag: DW_TAG_member, name: "tc_index", scope: !38, file: !39, line: 571, baseType: !42, size: 32, align: 32, offset: 352) | |
!55 = !DIDerivedType(tag: DW_TAG_member, name: "cb", scope: !38, file: !39, line: 572, baseType: !56, size: 160, align: 32, offset: 384) | |
!56 = !DICompositeType(tag: DW_TAG_array_type, baseType: !42, size: 160, align: 32, elements: !57) | |
!57 = !{!58} | |
!58 = !DISubrange(count: 5) | |
!59 = !DIDerivedType(tag: DW_TAG_member, name: "hash", scope: !38, file: !39, line: 573, baseType: !42, size: 32, align: 32, offset: 544) | |
!60 = !DIDerivedType(tag: DW_TAG_member, name: "tc_classid", scope: !38, file: !39, line: 574, baseType: !42, size: 32, align: 32, offset: 576) | |
!61 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !38, file: !39, line: 575, baseType: !42, size: 32, align: 32, offset: 608) | |
!62 = !DIDerivedType(tag: DW_TAG_member, name: "data_end", scope: !38, file: !39, line: 576, baseType: !42, size: 32, align: 32, offset: 640) | |
!63 = !{!64, !65, !66, !69} | |
!64 = !DILocalVariable(name: "skb", arg: 1, scope: !34, file: !3, line: 19, type: !37) | |
!65 = !DILocalVariable(name: "index", scope: !34, file: !3, line: 21, type: !19) | |
!66 = !DILocalVariable(name: "value", scope: !34, file: !3, line: 22, type: !67) | |
!67 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !68, size: 64, align: 64) | |
!68 = !DIBasicType(name: "long int", size: 64, align: 64, encoding: DW_ATE_signed) | |
!69 = !DILocalVariable(name: "flow_mask_array", scope: !34, file: !3, line: 25, type: !70) | |
!70 = !DICompositeType(tag: DW_TAG_array_type, baseType: !71, size: 128, align: 64, elements: !74) | |
!71 = !DICompositeType(tag: DW_TAG_structure_type, name: "bpf_flow_keys", file: !3, line: 7, size: 64, align: 64, elements: !72) | |
!72 = !{!73} | |
!73 = !DIDerivedType(tag: DW_TAG_member, name: "src", scope: !71, file: !3, line: 8, baseType: !68, size: 64, align: 64) | |
!74 = !{!75} | |
!75 = !DISubrange(count: 2) | |
!76 = !DIExpression() | |
!77 = !DILocation(line: 19, column: 33, scope: !34) | |
!78 = !DILocation(line: 21, column: 2, scope: !34) | |
!79 = !DILocation(line: 21, column: 24, scope: !34) | |
!80 = !DILocation(line: 21, column: 14, scope: !81) | |
!81 = !DILexicalBlockFile(scope: !34, file: !3, discriminator: 1) | |
!82 = !DILocation(line: 21, column: 14, scope: !34) | |
!83 = !DILocation(line: 21, column: 6, scope: !34) | |
!84 = !{!85, !85, i64 0} | |
!85 = !{!"int", !86, i64 0} | |
!86 = !{!"omnipotent char", !87, i64 0} | |
!87 = !{!"Simple C/C++ TBAA"} | |
!88 = !DILocation(line: 25, column: 2, scope: !34) | |
!89 = !DILocation(line: 25, column: 23, scope: !34) | |
!90 = !DILocation(line: 26, column: 25, scope: !34) | |
!91 = !{!92, !93, i64 0} | |
!92 = !{!"bpf_flow_keys", !93, i64 0} | |
!93 = !{!"long", !86, i64 0} | |
!94 = !DILocation(line: 36, column: 11, scope: !95) | |
!95 = distinct !DILexicalBlock(scope: !34, file: !3, line: 36, column: 6) | |
!96 = !{!97, !85, i64 4} | |
!97 = !{!"__sk_buff", !85, i64 0, !85, i64 4, !85, i64 8, !85, i64 12, !85, i64 16, !85, i64 20, !85, i64 24, !85, i64 28, !85, i64 32, !85, i64 36, !85, i64 40, !85, i64 44, !86, i64 48, !85, i64 68, !85, i64 72, !85, i64 76, !85, i64 80} | |
!98 = !DILocation(line: 36, column: 20, scope: !95) | |
!99 = !DILocation(line: 36, column: 6, scope: !34) | |
!100 = !DILocation(line: 27, column: 21, scope: !34) | |
!101 = !DILocation(line: 39, column: 42, scope: !34) | |
!102 = !DILocation(line: 39, column: 5, scope: !34) | |
!103 = !DILocation(line: 41, column: 2, scope: !34) | |
!104 = !DILocation(line: 42, column: 1, scope: !34) | |
!105 = !DILocation(line: 42, column: 1, scope: !106) | |
!106 = !DILexicalBlockFile(scope: !34, file: !3, discriminator: 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment