浏览代码

Skip BPF_F_XDP_HAS_FRAGS tests on unsupported kernels

Tamir Duberstein 1 年之前
父节点
当前提交
b8252f46d9
共有 3 个文件被更改,包括 10 次插入2 次删除
  1. 2 0
      test/integration-ebpf/src/pass.rs
  2. 2 2
      test/integration-test/tests/load.rs
  3. 6 0
      test/integration-test/tests/smoke.rs

+ 2 - 0
test/integration-ebpf/src/pass.rs

@@ -3,6 +3,8 @@
 
 use aya_bpf::{bindings::xdp_action, macros::xdp, programs::XdpContext};
 
+// Note: the `frags` attribute causes this probe to be incompatible with kernel versions < 5.18.0.
+// See https://github.com/torvalds/linux/commit/c2f2cdb.
 #[xdp(name = "pass", frags = "true")]
 pub fn pass(ctx: XdpContext) -> u32 {
     match unsafe { try_pass(ctx) } {

+ 2 - 2
test/integration-test/tests/load.rs

@@ -168,8 +168,8 @@ fn pin_link() {
 #[test]
 fn pin_lifecycle() {
     let kernel_version = KernelVersion::current().unwrap();
-    if kernel_version < KernelVersion::new(5, 9, 0) {
-        eprintln!("skipping test on kernel {kernel_version:?}, XDP uses netlink");
+    if kernel_version < KernelVersion::new(5, 18, 0) {
+        eprintln!("skipping test on kernel {kernel_version:?}, support for BPF_F_XDP_HAS_FRAGS was added in 5.18.0; see https://github.com/torvalds/linux/commit/c2f2cdb");
         return;
     }
 

+ 6 - 0
test/integration-test/tests/smoke.rs

@@ -8,6 +8,12 @@ use aya::{
 
 #[test]
 fn xdp() {
+    let kernel_version = KernelVersion::current().unwrap();
+    if kernel_version < KernelVersion::new(5, 18, 0) {
+        eprintln!("skipping test on kernel {kernel_version:?}, support for BPF_F_XDP_HAS_FRAGS was added in 5.18.0; see https://github.com/torvalds/linux/commit/c2f2cdb");
+        return;
+    }
+
     let bytes = include_bytes_aligned!("../../../target/bpfel-unknown-none/release/pass");
     let mut bpf = Bpf::load(bytes).unwrap();
     let dispatcher: &mut Xdp = bpf.program_mut("pass").unwrap().try_into().unwrap();