Discussion:
Post_Routing hook with encapsulated packets (forwarding scenario)
Hugo Alves
2014-08-14 00:42:42 UTC
Permalink
Hi all,

I've written a small kernel module to measure packet processing times.
This module registers itself in a netfilter hook, more specifically
the NF_INET_POST_ROUTING. After that it uses the information in skb
struct to calculate some metrics for each packet.
My setup have 3 nodes, a sender, a receiver and a router where the
module is installed.

The router have two network interfaces, eth0 connected to a lan where
the sender is and the other(eth1) connected to the lan where the
receiver is. Lets assume that the traffic only flows from the sender
to the receiver.
The router has also an tunnel "interface"(ip6tnl1) that is connected
to the receiver. All traffic that goes to the receiver passes through
the tunnel.

_____________
| Sender |
|_____________|
|
|
|(eth0)
___|_________
| Router |
|_____________|
|(eth1)
|
|
| |
| |
| | (ip6tnl1)
| |
|
|
___|________
| Receiver |
|___________ |

First I've tested my module in a 3.2 kernel.
In this kernel for each packet forwarded I get two calls in my
callback function of the hook. One for the original packet that is
routed from eth0 to ip6tnl1. And the other is the encapsulated packet
that goes from ip6tnl1 to eth1.
In both I have the same skb->tstamp, meaning that even when the kernel
creates the encapsulated packet it preservers the original timestamp
from when the packet entered the system. Is this assumption about the
time correct?

Then I've tested the same module in kernel 3.15.9, and in this case I
only see the encapsulated packet in the Post_routing hook. In this
case the tstamp in skb struct is the time when the original packet
entered the system or is the time when the kernel created the new
encapsulated packet? I am not sure about this tstamp.

The behaviour of the hooks have changed recently in the kernel?


The code of the module: https://gist.github.com/e646eba4765478fbd9c2.git

Regards
Hugo Alves
--
To unsubscribe from this list: send the line "unsubscribe netfilter" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Loading...