From 3d30065c172c56713c2959fdc1d02e3d19cc3161 Mon Sep 17 00:00:00 2001 From: DavadDi Date: Thu, 29 Jul 2021 11:45:27 +0800 Subject: [PATCH] Create tcp_mss.py --- kprobe_ko_ex/tcp_mss.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 kprobe_ko_ex/tcp_mss.py diff --git a/kprobe_ko_ex/tcp_mss.py b/kprobe_ko_ex/tcp_mss.py new file mode 100644 index 0000000..9cc24df --- /dev/null +++ b/kprobe_ko_ex/tcp_mss.py @@ -0,0 +1,28 @@ +#!/usr/bin/python + +from bcc import BPF + +text=""" +#ifndef KBUILD_MODNAME +#define KBUILD_MODNAME "bcc" +#endif +#include +#include +#include +#include + +int kretprobe__tcp_current_mss(struct pt_regs *ctx) { + struct sock *sk = (void *)PT_REGS_PARM1(ctx); + u32 mss = PT_REGS_RC(ctx); + + if (!sk) { + return 0; + } + + bpf_trace_printk("sk 0x%lx mss: %d\\n", sk, mss); + + return 0; +} +""" + +BPF(text=text).trace_print()