Skip to content

Instantly share code, notes, and snippets.

@larsks
Last active August 23, 2024 05:04
Show Gist options
  • Save larsks/bb9e7d046a5a6fe87baae44720d4866b to your computer and use it in GitHub Desktop.
Save larsks/bb9e7d046a5a6fe87baae44720d4866b 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