Bug 678582

Summary: ping traffic (icmp) sends xfrm ACQUIRE msgs with protocol 17 (UDP)
Product: Red Hat Enterprise Linux 6 Reporter: Avesh Agarwal <avagarwa>
Component: kernelAssignee: Herbert Xu <herbert.xu>
Status: CLOSED NOTABUG QA Contact: Red Hat Kernel QE team <kernel-qe>
Severity: high Docs Contact:
Priority: urgent    
Version: 6.1CC: iboverma, latten, sgrubb
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-03-09 14:17:20 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 584498, 846801, 846802    

Description Avesh Agarwal 2011-02-18 14:18:36 UTC
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):

How reproducible:

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 
Actual results:
ACQUIRE mesgs with protocol UDP

Expected results:
ACQUIRE mesgs with protocol ICMP

Additional info:

Comment 3 Joy Latten 2011-02-22 18:07:19 UTC
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 
icmp-echo-request pkt.
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.

Comment 4 Avesh Agarwal 2011-02-23 12:48:59 UTC
> 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.

Comment 5 Avesh Agarwal 2011-02-23 14:57:09 UTC
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.

Comment 6 Joy Latten 2011-02-23 18:59:31 UTC
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...


Comment 7 Herbert Xu 2011-03-04 07:15:14 UTC
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.