Skip to contentSkip to conversation

Issue on input process of Linux native IPsec

Ipsec Park Lee 2 participants 5 messages Dec 23, 2004 – Dec 25, 2004 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Park Lee

author
#1 lore raw
Quoted 28 lines · Kausty
Quoted 5 lines · Park Lee

Hi,
We know that the output process of Linux native IPsec fully uses the XFRM architecture. The order of primal functions are xfrm_lookup(), xfrm_tmpl_resolve(), xfrm_bundle_create() and

Quoted 8 lines

dst_output().
The input process for IPsec is more simple than output. The order of primal functions (in IPv4) are xfrm4_rcv(), xfrm4_rcv_encap(), xfrm4_parse_spi(), xfrm4_policy_check().
But, Why should the input process also go
throught xfrm_lookup(), xfrm_tmpl_resolve(), xfrm_bundle_create()? What's the purpose of this?

i havent gone through the code flow as u mentioned but this is my general idea.

these are generic lookup functions irrespective of ipv6/v4.
the purpose is to ensure that all the SA's are applied hence a bundle needs to be created everytime a packet is recieved.
If no bundle is created then a seperate search needs to be done for ESP/AH/Transport/Tunnel

Quoted 1 line

is this what u were looking for ??

Thanks.
But, After a packet was received, It has already been processed by xfrm4_rcv(), xfrm4_rcv_encap(), ah_input(), esp_input(),etc. so, I think that there is no need to search(or created) a bundle everytime a packet is recieved, since it has already been processed. Am I right?

=====
Best Regards,
Park Lee

__________________________________
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.
http://promotions.yahoo.com/new_mail

#2 lore raw
Quoted 7 lines · Park Lee

Thanks.
But, After a packet was received, It has already been processed by xfrm4_rcv(), xfrm4_rcv_encap(), ah_input(), esp_input(),etc. so, I think that there is no need to search(or created) a bundle everytime a packet is recieved, since it has already been processed. Am I right?

Are you sure you're not seeing the creation of a reply packet? Unless you're testing with UDP and a listening socket on the receiver, you're going to get a response packet if the incoming packet makes it through the iptables rules. You were testing with ICMP echo requests (ping), if I recall.

I think either you're basing your idea of the packet flow on printk()'s, or I'm just too tired and missing where xfrm_lookup() gets called on the rx path... (yes, sk can be NULL there, but I was wrong about it being called for Rx'd packets, I think).

However, if your NIC driver does NAPI, you can see an xfrm_lookup() on the reply packet when the driver calls netif_receive_skb() -- this bit me recently...

Signature · 1 line
David Dillow <[email protected]>
author
#3 lore raw
Quoted 16 lines · David Dillow
Quoted 7 lines · Park Lee

Thanks.
But, After a packet was received, It has already been processed by xfrm4_rcv(), xfrm4_rcv_encap(), ah_input(), esp_input(),etc. so, I think that there is no need to search(or created) a bundle everytime a packet is recieved, since it has already been processed. Am I right?

Are you sure you're not seeing the creation of a reply packet? Unless you're testing with UDP and a listening socket on the receiver, you're going to get a response packet if the incoming packet makes it through the iptables rules. You were testing with ICMP echo requests (ping), if I recall.

Quoted 4 lines

I think either you're basing your idea of the packet flow on printk()'s,or I'm just too tired and missing where xfrm_lookup() gets called on the rx path...

Yes, I'm testing with ping and basing my idea of the packet flow on printk().

Quoted 2 lines

(yes, sk can be NULL there, but I was wrong about it being called for Rx'd packets, I think).

Does this mean that when the reply (response) packet is sending out through xfrm_lookup(), the sk parameter of xfrm_lookup() will not be NULL? and When the incoming packet itself goes through xfrm_lookup(), the sk parameter will be NULL?

Thank you
and
Merry Christmas.

=====
Best Regards,
Park Lee

__________________________________
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.
http://promotions.yahoo.com/new_mail

#4 lore raw

[ Trimmed cc list to non-moderated lists.]

Quoted 7 lines · Park Lee
Quoted 4 lines

I think either you're basing your idea of the packet flow on printk()'s,or I'm just too tired and missing where xfrm_lookup() gets called on the rx path...

Yes, I'm testing with ping and basing my idea of the packet flow on printk().

In the work I've been doing, I've found it very helpful to open a text editor, and make a call graph for the task I'm interested in -- in your case, a graph of every function that gets called upon receive, starting with your network driver's receive function.

Doing a similar one for Tx would be useful for you as well, though I'd start with the UDP output path, as it was pretty simple.

Quoted 8 lines
Quoted 2 lines

(yes, sk can be NULL there, but I was wrong about it being called for Rx'd packets, I think).

Does this mean that when the reply (response) packet is sending out through xfrm_lookup(), the sk parameter of xfrm_lookup() will not be NULL? and When the incoming packet itself goes through xfrm_lookup(), the sk parameter will be NULL?

xfrm_lookup() is only called for outgoing packets, not for received packets. I don't think ping replies (ICMP echo replies) will ever have a non-NULL sk, as they are not associated with a socket.

Signature · 1 line
David Dillow <[email protected]>
author
#5 lore raw
Quoted 10 lines · David Dillow

In the work I've been doing, I've found it very helpful to open a text editor, and make a call graph for the task I'm interested in -- in your case, a graph of every function that gets called upon receive, starting with your network driver's receive function.

Doing a similar one for Tx would be useful for you as well, though I'd start with the UDP output path, as it was pretty simple.

I'll try it.
Thank you very much.

=====
Best Regards,
Park Lee

__________________________________
Do you Yahoo!?
Dress up your holiday email, Hollywood style. Learn more.
http://celebrity.mail.yahoo.com