Description of problem:
We have observed an issue with ping (ICMP) traffic. When an ipsec policy specific to UDP protocol is added to kernel (in SPD) and ping traffic is initiated, kernel sends ACQUIRE messages with protocol 17. Due to this, wrong ipsec's security associations (SA) are being established.
I have tested and found this issue on RHEL6.1 kernel (2.6.32-113.el6.x86_64), and also with ipsec-tools too on RHEL5.5/5.6 kernels too.
However, we tested this on upstream kernel 2.6.36, and this issue is not found.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Add an ipsec policy specific to UDP protocol
2. Start ping traffic to the destination
3. Observe ACQUIRE messages in user space
ACQUIRE mesgs with protocol UDP
ACQUIRE mesgs with protocol ICMP
Before sending icmp-echo-request, ping gets the source address via opening a DGRAM socket and doing a connect(). This results in a __xfrm_lookup() in ip_route_output_flow(), which can trigger an ACQUIRE depending on ipsec policy.
However, ping opening this dgram socket, does not result in an outgoing pkt,
just in it acquiring some info it needs to form and then send the
So, this is not a kernel problem, but rather a side effect of ping.
"ping -I <srcaddr> dstaddr" will give ping the src addr and it does
not have to open the dgram socket to get src addr info. And thus an
ACQUIRE won't be triggered.
> However, we tested this on upstream kernel 2.6.36, and this issue is not found.
Also found from discussion with Joy that the behaviour is same with upstream kernel, and the issue is found. However as Joy noted in comment 3 that this seems more likely related to behaviour of Ping command.
I would like to ask that even though it seems its a side effect of Ping command, is the kernel behaviour, of sending ACQUIRE for UDP policy when ping opens a dgram (UDP) socket, right? Because dgram (UDP) socket seems local to the machine and the UDP ipsec policy we have is for a outside box. So I am wondering why the kernel is matching this local dgram stuff with the ipsec policy specific to UDP?
Just curious? If we know that kernel is doing it right, then perhaps we can close this bz.
I had thought about that too.
It's the connect() that ping does after it opens the dgram socket that results in the ACQUIRE. It does something similar to,
connect(socket_fd, dst, sizeof(dst))
since we do the connect with the dst, the guy we want to ping... then
we are planning on querying routes to see which route to use for our source
address using dst. The ip_route_output_flow, calls __xfrm_lookup() which results
in that ACQUIRE.
here is what my dump looked like from upstream kernel...
So I think you guys have figured this out already :)
Ping does a connect to obtain routing information for the actual ICMP packets. It does so using a UDP socket. That's why you end up with a UDP ACQUIRE message.
IOW I don't think we have a bug here at all.