retis-org / retis

Tracing packets in the Linux networking stack & friends
https://retis.readthedocs.io/en/stable/
100 stars 14 forks source link

retis doesn't work on coreOS container #207

Closed msherif1234 closed 1 year ago

msherif1234 commented 1 year ago
[root@ci-ln-d67lwq2-72292-jrtjc-worker-a-xj7p4 /]# retis -p dropmon collect
13:38:24 [WARN] Could not parse kernel configuration in either /proc/config.gz nor /boot/config-5.14.0-284.18.1.el9_2.x86_64
Error: Can't access kernel configuration:

Retis uses libbpf and conditionals on the kernel configuration in the BPF part, which requires access to kernel configuration file but neither /boot/config-5.14.0-284.18.1.el9_2.x86_64 and /proc/config.gz are accessible on this system.

kernel

[root@ci-ln-d67lwq2-72292-jrtjc-worker-a-xj7p4 /]# uname -a
Linux ci-ln-d67lwq2-72292-jrtjc-worker-a-xj7p4 5.14.0-284.18.1.el9_2.x86_64 #1 SMP PREEMPT_DYNAMIC Wed May 31 10:39:18 EDT 2023 x86_64 x86_64 x86_64 GNU/Linux

config

[root@ci-ln-d67lwq2-72292-jrtjc-worker-a-xj7p4 /]# ls /lib/modules/5.14.0-284.18.1.el9_2.x86_64/config 
/lib/modules/5.14.0-284.18.1.el9_2.x86_64/config

dump the boot folder

[root@ci-ln-d67lwq2-72292-jrtjc-worker-a-xj7p4 /]# ls -R /boot/
/boot/:
boot  bootupd-state.json  coreos  efi  grub2  loader  loader.1  lost+found  ostree

/boot/coreos:
platforms.json

/boot/efi:

/boot/grub2:
bootuuid.cfg  fonts  grub.cfg  grubenv  i386-pc  locale

/boot/grub2/fonts:
unicode.pf2

/boot/grub2/i386-pc:
acpi.mod                     cmp.mod         fs.lst                  hello.mod                 memrw.mod       part_sun.mod         search_label.mod    usb.mod
adler32.mod                  cmp_test.mod    fshelp.mod              help.mod                  minicmd.mod     part_sunpc.mod       sendkey.mod         usb_keyboard.mod
affs.mod                     command.lst     functional_test.mod     hexdump.mod               minix.mod       partmap.lst          serial.mod          usbms.mod
afs.mod                      configfile.mod  gcry_arcfour.mod        hfs.mod                   minix2.mod      parttool.lst         setjmp.mod          usbserial_common.mod
afsplitter.mod               core.img        gcry_blowfish.mod       hfsplus.mod               minix2_be.mod   parttool.mod         setjmp_test.mod     usbserial_ftdi.mod
ahci.mod                     cpio.mod        gcry_camellia.mod       hfspluscomp.mod           minix3.mod      password.mod         setpci.mod          usbserial_pl2303.mod
all_video.mod                cpio_be.mod     gcry_cast5.mod          http.mod                  minix3_be.mod   password_pbkdf2.mod  sfs.mod             usbserial_usbdebug.mod
aout.mod                     cpuid.mod       gcry_crc.mod            increment.mod             minix_be.mod    pata.mod             shift_test.mod      usbtest.mod
appended_signature_test.mod  crc64.mod       gcry_des.mod            iorw.mod                  mmap.mod        pbkdf2.mod           signature_test.mod  vbe.mod
appendedsig.mod              crypto.lst      gcry_dsa.mod            iso9660.mod               moddep.lst      pbkdf2_test.mod      sleep.mod           version.mod
archelp.mod                  crypto.mod      gcry_idea.mod           jfs.mod                   modinfo.sh      pci.mod              sleep_test.mod      vga.mod
asn1.mod                     cryptodisk.mod  gcry_md4.mod            jpeg.mod                  morse.mod       pcidump.mod          smbios.mod          vga_text.mod
at_keyboard.mod              cs5536.mod      gcry_md5.mod            json.mod                  mpi.mod         pgp.mod              spkmodem.mod        video.lst
ata.mod                      ctz_test.mod    gcry_rfc2268.mod        keylayouts.mod            msdospart.mod   pkcs1_v15.mod        squash4.mod         video.mod
backtrace.mod                date.mod        gcry_rijndael.mod       keystatus.mod             mul_test.mod    plan9.mod            strtoull_test.mod   video_bochs.mod
bfs.mod                      datehook.mod    gcry_rmd160.mod         ldm.mod                   multiboot.mod   play.mod             syslinuxcfg.mod     video_cirrus.mod
biosdisk.mod                 datetime.mod    gcry_rsa.mod            legacy_password_test.mod  multiboot2.mod  png.mod              tar.mod             video_colors.mod
bitmap.mod                   disk.mod        gcry_seed.mod           legacycfg.mod             nativedisk.mod  priority_queue.mod   terminal.lst        video_fb.mod
bitmap_scale.mod             diskfilter.mod  gcry_serpent.mod        linux.mod                 net.mod         probe.mod            terminal.mod        videoinfo.mod
blocklist.mod                div.mod         gcry_sha1.mod           loadenv.mod               newc.mod        procfs.mod           terminfo.mod        videotest.mod
blscfg.mod                   div_test.mod    gcry_sha256.mod         loopback.mod              nilfs2.mod      progress.mod         test.mod            videotest_checksum.mod
boot.img                     dm_nv.mod       gcry_sha512.mod         ls.mod                    normal.mod      pxe.mod              test_asn1.mod       wrmsr.mod
boot.mod                     drivemap.mod    gcry_tiger.mod          lsacpi.mod                ntfs.mod        pxechain.mod         test_blockarg.mod   xfs.mod
bsd.mod                      echo.mod        gcry_twofish.mod        lsapm.mod                 ntfscomp.mod    raid5rec.mod         testload.mod        xnu.mod
bswap_test.mod               efiemu.mod      gcry_whirlpool.mod      lsmmap.mod                ntldr.mod       raid6rec.mod         testspeed.mod       xnu_uuid.mod
btrfs.mod                    ehci.mod        gdb.mod                 lspci.mod                 odc.mod         random.mod           tftp.mod            xnu_uuid_test.mod
bufio.mod                    elf.mod         geli.mod                luks.mod                  offsetio.mod    rdmsr.mod            tga.mod             xzio.mod
cat.mod                      eval.mod        gettext.mod             luks2.mod                 ohci.mod        read.mod             time.mod            zfs.mod
cbfs.mod                     exfat.mod       gfxmenu.mod             lvm.mod                   part_acorn.mod  reboot.mod           tr.mod              zfscrypt.mod
cbls.mod                     exfctest.mod    gfxterm.mod             lzopio.mod                part_amiga.mod  regexp.mod           trig.mod            zfsinfo.mod
cbmemc.mod                   ext2.mod        gfxterm_background.mod  macbless.mod              part_apple.mod  reiserfs.mod         true.mod            zstd.mod
cbtable.mod                  extcmd.mod      gfxterm_menu.mod        macho.mod                 part_bsd.mod    relocator.mod        truecrypt.mod
cbtime.mod                   f2fs.mod        gptsync.mod             mda_text.mod              part_dfly.mod   romfs.mod            udf.mod
chain.mod                    fat.mod         gzio.mod                mdraid09.mod              part_dvh.mod    scsi.mod             ufs1.mod
cmdline_cat_test.mod         file.mod        halt.mod                mdraid09_be.mod           part_gpt.mod    search.mod           ufs1_be.mod
cmosdump.mod                 font.mod        hashsum.mod             mdraid1x.mod              part_msdos.mod  search_fs_file.mod   ufs2.mod
cmostest.mod                 freedos.mod     hdparm.mod              memdisk.mod               part_plan.mod   search_fs_uuid.mod   uhci.mod

/boot/grub2/locale:
ast.mo  de.mo         en@arabic.mo    en@hebrew.mo    eo.mo  fr.mo  hu.mo  ja.mo  lt.mo  pa.mo  pt_BR.mo  sl.mo  tr.mo  zh_CN.mo
ca.mo   de@hebrew.mo  en@cyrillic.mo  en@piglatin.mo  es.mo  gl.mo  id.mo  ko.mo  nb.mo  pl.mo  ro.mo     sr.mo  uk.mo  zh_TW.mo
da.mo   de_CH.mo      en@greek.mo     en@quot.mo      fi.mo  hr.mo  it.mo  lg.mo  nl.mo  pt.mo  ru.mo     sv.mo  vi.mo

/boot/loader.1:
entries

/boot/loader.1/entries:
ostree-1-rhcos.conf

/boot/lost+found:

/boot/ostree:
rhcos-353ad99849be5cf195639721a85a054859022207721ace133e4bdb1a2b034c2c

/boot/ostree/rhcos-353ad99849be5cf195639721a85a054859022207721ace133e4bdb1a2b034c2c:
initramfs-5.14.0-284.18.1.el9_2.x86_64.img  vmlinuz-5.14.0-284.18.1.el9_2.x86_64
atenart commented 1 year ago

Neither /proc/config.gz and /boot/config-$(uname -r) are available on CoreOS. It seems to be in /lib/modules/$(uname -r)/config.

Additionally evaluate adding an option to give a path to the kernel config.

amorenoz commented 1 year ago

Neither /proc/config.gz and /boot/config-$(uname -r) are available on CoreOS. It seems to be in /lib/modules/$(uname -r)/config.

Additionally evaluate adding an option to give a path to the kernel config.

Maybe an ENV var that we can set in the container?

atenart commented 1 year ago

Neither /proc/config.gz and /boot/config-$(uname -r) are available on CoreOS. It seems to be in /lib/modules/$(uname -r)/config. Additionally evaluate adding an option to give a path to the kernel config.

Maybe an ENV var that we can set in the container?

Could be too.

I quickly looked into the above and while we can easily fix Retis to check for an extra path, it seems to me libbpf is only looking in those two paths (hard coded). There might be some ways but I didn't see anything that would be acceptable for an easy fix, and the potential solutions all looked a bit complex and would need some thinking. @vlrpl does this ring a bell (asking as you played a bit more with libbpf IIRC)?

In the meantime I would suggest to use the Retis container image with -v /lib/modules/$(uname -r)/config:/boot/config-$(uname -r):ro instead of -v /boot:/boot:ro for CoreOS.

vlrpl commented 1 year ago

Neither /proc/config.gz and /boot/config-$(uname -r) are available on CoreOS. It seems to be in /lib/modules/$(uname -r)/config. Additionally evaluate adding an option to give a path to the kernel config.

Maybe an ENV var that we can set in the container?

Could be too.

I quickly looked into the above and while we can easily fix Retis to check for an extra path, it seems to me libbpf is only looking in those two paths (hard coded). There might be some ways but I didn't see anything that would be acceptable for an easy fix, and the potential solutions all looked a bit complex and would need some thinking. @vlrpl does this ring a bell (asking as you played a bit more with libbpf IIRC)?

libbpf side, it seems to me the same. I was hoping that bpf_object_open_opts { kconfig, ..default() } could have been a good candidate (passing down the mem), but looking at the code, unless I'm missing something, that should not work. It is just strictly intended to augment the existing config.

In the meantime I would suggest to use the Retis container image with -v /lib/modules/$(uname -r)/config:/boot/config-$(uname -r):ro instead of -v /boot:/boot:ro for CoreOS.

this is confirmed to work