|
- #include "linux/kprobes.h"
-
- #include <linux/inet_diag.h>
- #include <net/tcp.h>
-
- /* Include the struct of the ROCCET congestion control algorithm. */
- #include "tcp_roccet.h"
-
- // Handler for the pre-call probe
- static int handler_pre(struct kprobe *p, struct pt_regs *regs)
- {
- /* System V ABI for x86_64 Linux:
- * arg0: di,
- * arg1: si,
- * arg2: dx,
- * ...
- */
-
- /* Get the first argument of the probed function */
- struct sock *sk = (struct sock *)regs->di;
- struct roccettcp *ca = inet_csk_ca(sk);
-
- u32 ack = (u32)regs->si;
- u32 acked = (u32)regs->dx;
-
- /* Use `trace_printk` to print debug information to the
- * `/sys/kernel/tracing/trace buffer`.
- * This buffer can be read using the debug trace interface of the kernel.
- */
- trace_printk(
- "roccettcp_cong_avoid: sk=%p ca=%p cnt=%u last_max_cwnd=%u, "
- "last_congestion_event=%u\n",
- sk, ca, ca->cnt, ca->last_max_cwnd,
- ca->roccet_last_event_time_us);
- trace_printk("ack: %u acked: %u\n", ack, acked);
-
- return 0;
- }
-
- static struct kprobe kp = {
-
- /* Define which function to probe. */
- .symbol_name = "roccettcp_cong_avoid",
- .pre_handler = handler_pre, /* Runs before the probed function. */
- .post_handler = NULL, /* Runs after the probed function. */
-
- };
-
- static int __init kprobe_init(void)
- {
- return register_kprobe(&kp);
- }
- static void __exit kprobe_exit(void)
- {
- unregister_kprobe(&kp);
- }
-
- module_init(kprobe_init);
- module_exit(kprobe_exit);
-
- MODULE_LICENSE("GPL");
- MODULE_DESCRIPTION("Makes it possible to probe the ROCCET Congestion "
- "Control Algrithm with kprobes. This enabled Debugging via a "
- "loadable kernel module.");
- MODULE_AUTHOR("Tim Füchsel");
- MODULE_VERSION("0.1");
|