为了追查为什么 nat POSTROUTING 不会处理同一 skb 两次,我今天写了以下 bpftrace 脚本
k:nf_nat_inet_fn {
$skb=(struct sk_buff*)reg("si");
$data=$skb->network_header+$skb->head;
if (*(uint8[4]*)((uint8*)$data+16)==pton("1.1.1.1") || *(uint8[4]*)((uint8*)$data+16)==pton("1.0.0.1")) {
$state=(struct nf_hook_state*)reg("dx");
printf("%d@%s nfct=%llx ", $state->hook, $skb->dev->name, $skb->_nfct);
$ct=(struct nf_conn*)($skb->_nfct & ~7);
printf("ct->status=%llx nf_nat_initialized=%d do_nf_nat_manip_pkt?=%d\n", $ct->status, $ct->status & (1
k:nf_nat_inet_fn {
$skb=(struct sk_buff*)reg("si");
$data=$skb->network_header+$skb->head;
if (*(uint8[4]*)((uint8*)$data+16)==pton("1.1.1.1") || *(uint8[4]*)((uint8*)$data+16)==pton("1.0.0.1")) {
$state=(struct nf_hook_state*)reg("dx");
printf("%d@%s nfct=%llx ", $state->hook, $skb->dev->name, $skb->_nfct);
$ct=(struct nf_conn*)($skb->_nfct & ~7);
printf("ct->status=%llx nf_nat_initialized=%d do_nf_nat_manip_pkt?=%d\n", $ct->status, $ct->status & (1