aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/xfrm4_input.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2007-11-19 21:47:58 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 17:53:53 -0500
commit60d5fcfb19d8a958fc563e52240cd05ec23f36c9 (patch)
treef1bb64a18b1b183ad1cdf84f88a42a0b643af720 /net/ipv4/xfrm4_input.c
parentd26f398400311982d2433debae85746c348b7d58 (diff)
[IPSEC]: Remove nhoff from xfrm_input
The nhoff field isn't actually necessary in xfrm_input. For tunnel mode transforms we now throw away the output IP header so it makes no sense to fill in the nexthdr field. For transport mode we can now let the function transport_finish do the setting and it knows where the nexthdr field is. The only other thing that needs the nexthdr field to be set is the header extraction code. However, we can simply move the protocol extraction out of the generic header extraction. We want to minimise the amount of info we have to carry around between transforms as this simplifies the resumption process for async crypto. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/xfrm4_input.c')
-rw-r--r--net/ipv4/xfrm4_input.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/net/ipv4/xfrm4_input.c b/net/ipv4/xfrm4_input.c
index e374903dacdf..662d1e86cfbf 100644
--- a/net/ipv4/xfrm4_input.c
+++ b/net/ipv4/xfrm4_input.c
@@ -21,7 +21,6 @@ int xfrm4_extract_input(struct xfrm_state *x, struct sk_buff *skb)
21 return xfrm4_extract_header(skb); 21 return xfrm4_extract_header(skb);
22} 22}
23 23
24#ifdef CONFIG_NETFILTER
25static inline int xfrm4_rcv_encap_finish(struct sk_buff *skb) 24static inline int xfrm4_rcv_encap_finish(struct sk_buff *skb)
26{ 25{
27 if (skb->dst == NULL) { 26 if (skb->dst == NULL) {
@@ -36,12 +35,10 @@ drop:
36 kfree_skb(skb); 35 kfree_skb(skb);
37 return NET_RX_DROP; 36 return NET_RX_DROP;
38} 37}
39#endif
40 38
41int xfrm4_rcv_encap(struct sk_buff *skb, int nexthdr, __be32 spi, 39int xfrm4_rcv_encap(struct sk_buff *skb, int nexthdr, __be32 spi,
42 int encap_type) 40 int encap_type)
43{ 41{
44 XFRM_SPI_SKB_CB(skb)->nhoff = offsetof(struct iphdr, protocol);
45 XFRM_SPI_SKB_CB(skb)->daddroff = offsetof(struct iphdr, daddr); 42 XFRM_SPI_SKB_CB(skb)->daddroff = offsetof(struct iphdr, daddr);
46 return xfrm_input(skb, nexthdr, spi, encap_type); 43 return xfrm_input(skb, nexthdr, spi, encap_type);
47} 44}
@@ -49,16 +46,20 @@ EXPORT_SYMBOL(xfrm4_rcv_encap);
49 46
50int xfrm4_transport_finish(struct sk_buff *skb, int async) 47int xfrm4_transport_finish(struct sk_buff *skb, int async)
51{ 48{
49 struct iphdr *iph = ip_hdr(skb);
50
51 iph->protocol = XFRM_MODE_SKB_CB(skb)->protocol;
52
52#ifdef CONFIG_NETFILTER 53#ifdef CONFIG_NETFILTER
53 __skb_push(skb, skb->data - skb_network_header(skb)); 54 __skb_push(skb, skb->data - skb_network_header(skb));
54 ip_hdr(skb)->tot_len = htons(skb->len); 55 iph->tot_len = htons(skb->len);
55 ip_send_check(ip_hdr(skb)); 56 ip_send_check(iph);
56 57
57 NF_HOOK(PF_INET, NF_IP_PRE_ROUTING, skb, skb->dev, NULL, 58 NF_HOOK(PF_INET, NF_IP_PRE_ROUTING, skb, skb->dev, NULL,
58 xfrm4_rcv_encap_finish); 59 xfrm4_rcv_encap_finish);
59 return 0; 60 return 0;
60#else 61#else
61 return -ip_hdr(skb)->protocol; 62 return -iph->protocol;
62#endif 63#endif
63} 64}
64 65