Skip to content

Instantly share code, notes, and snippets.

@ql-owo-lp
Forked from larsks/fibtrace.bt
Created August 23, 2024 05:04
Show Gist options
  • Save ql-owo-lp/ebe5e292bc8cf3765695112f009fd2dc to your computer and use it in GitHub Desktop.
Save ql-owo-lp/ebe5e292bc8cf3765695112f009fd2dc to your computer and use it in GitHub Desktop.
Track routing decisions made by fib_validate_source
kprobe:fib_validate_source {
$skb = (struct sk_buff*) arg0;
@skb[tid] = $skb;
@ipheader[tid] = ((struct iphdr *) ($skb->head + $skb->network_header));
}
kretprobe:fib_validate_source {
$skb = @skb[tid];
$ipheader = @ipheader[tid];
$version = $ipheader->version;
// 0xe9051eac is "172.30.5.233" in little-endian byte order. Replace this with an appropriate
// value.
if ((uint32)$ipheader->daddr == 0xe9051eac) {
printf("%dv%d | %s:%s -> %d\n", $ipheader->protocol, $version,
ntop($ipheader->saddr), ntop($ipheader->daddr), retval);
}
delete(@ipheader[tid]);
delete(@skb[tid]);
}
END {
clear(@ipheader);
clear(@skb);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment