You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

89 lines
938 B

  1. # This filter is compiled to all_instructions.bpf by the `bpf_asm`
  2. # tool, which can be found in the linux kernel source tree under
  3. # tools/bpf.
  4. # Load immediate
  5. ld #42
  6. ldx #42
  7. # Load scratch
  8. ld M[3]
  9. ldx M[3]
  10. # Load absolute
  11. ldb [42]
  12. ldh [42]
  13. ld [42]
  14. # Load indirect
  15. ldb [x + 42]
  16. ldh [x + 42]
  17. ld [x + 42]
  18. # Load IPv4 header length
  19. ldx 4*([42]&0xf)
  20. # Run extension function
  21. ld #len
  22. ld #proto
  23. ld #type
  24. ld #rand
  25. # Store scratch
  26. st M[3]
  27. stx M[3]
  28. # A <op> constant
  29. add #42
  30. sub #42
  31. mul #42
  32. div #42
  33. or #42
  34. and #42
  35. lsh #42
  36. rsh #42
  37. mod #42
  38. xor #42
  39. # A <op> X
  40. add x
  41. sub x
  42. mul x
  43. div x
  44. or x
  45. and x
  46. lsh x
  47. rsh x
  48. mod x
  49. xor x
  50. # !A
  51. neg
  52. # Jump A <op> constant
  53. ja end
  54. jeq #42,prev,end
  55. jne #42,end
  56. jlt #42,end
  57. jle #42,end
  58. jgt #42,prev,end
  59. jge #42,prev,end
  60. jset #42,prev,end
  61. # Jump A <op> X
  62. jeq x,prev,end
  63. jne x,end
  64. jlt x,end
  65. jle x,end
  66. jgt x,prev,end
  67. jge x,prev,end
  68. jset x,prev,end
  69. # Register transfers
  70. tax
  71. txa
  72. # Returns
  73. prev: ret a
  74. end: ret #42