diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2007-11-14 00:43:11 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:53:48 -0500 |
commit | 862b82c6f960cc61274d370aa78ce1112f92a83e (patch) | |
tree | 51e252e1525dd7d02a695d428890a4c37fae2442 /net/ipv6 | |
parent | ef76bc23ef2acf20c8f7f841a542d8ab74c827c6 (diff) |
[IPSEC]: Merge most of the output path
As part of the work on asynchrnous cryptographic operations, we need
to be able to resume from the spot where they occur. As such, it
helps if we isolate them to one spot.
This patch moves most of the remaining family-specific processing into
the common output code.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/route.c | 1 | ||||
-rw-r--r-- | net/ipv6/xfrm6_output.c | 77 | ||||
-rw-r--r-- | net/ipv6/xfrm6_policy.c | 1 | ||||
-rw-r--r-- | net/ipv6/xfrm6_state.c | 2 |
4 files changed, 11 insertions, 70 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index ac70e2d3b10c..4ef2cfaa3467 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -113,6 +113,7 @@ static struct dst_ops ip6_dst_ops = { | |||
113 | .negative_advice = ip6_negative_advice, | 113 | .negative_advice = ip6_negative_advice, |
114 | .link_failure = ip6_link_failure, | 114 | .link_failure = ip6_link_failure, |
115 | .update_pmtu = ip6_rt_update_pmtu, | 115 | .update_pmtu = ip6_rt_update_pmtu, |
116 | .local_out = ip6_local_out, | ||
116 | .entry_size = sizeof(struct rt6_info), | 117 | .entry_size = sizeof(struct rt6_info), |
117 | }; | 118 | }; |
118 | 119 | ||
diff --git a/net/ipv6/xfrm6_output.c b/net/ipv6/xfrm6_output.c index 0f0ff51f6dba..a0a924991c4f 100644 --- a/net/ipv6/xfrm6_output.c +++ b/net/ipv6/xfrm6_output.c | |||
@@ -66,6 +66,9 @@ int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb) | |||
66 | return err; | 66 | return err; |
67 | 67 | ||
68 | memset(IP6CB(skb), 0, sizeof(*IP6CB(skb))); | 68 | memset(IP6CB(skb), 0, sizeof(*IP6CB(skb))); |
69 | #ifdef CONFIG_NETFILTER | ||
70 | IP6CB(skb)->flags |= IP6SKB_XFRM_TRANSFORMED; | ||
71 | #endif | ||
69 | 72 | ||
70 | skb->protocol = htons(ETH_P_IPV6); | 73 | skb->protocol = htons(ETH_P_IPV6); |
71 | 74 | ||
@@ -73,80 +76,14 @@ int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb) | |||
73 | } | 76 | } |
74 | EXPORT_SYMBOL(xfrm6_prepare_output); | 77 | EXPORT_SYMBOL(xfrm6_prepare_output); |
75 | 78 | ||
76 | static inline int xfrm6_output_one(struct sk_buff *skb) | ||
77 | { | ||
78 | int err; | ||
79 | |||
80 | err = xfrm_output(skb); | ||
81 | if (err) | ||
82 | goto error_nolock; | ||
83 | |||
84 | IP6CB(skb)->flags |= IP6SKB_XFRM_TRANSFORMED; | ||
85 | err = 0; | ||
86 | |||
87 | out_exit: | ||
88 | return err; | ||
89 | error_nolock: | ||
90 | kfree_skb(skb); | ||
91 | goto out_exit; | ||
92 | } | ||
93 | |||
94 | static int xfrm6_output_finish2(struct sk_buff *skb) | ||
95 | { | ||
96 | int err; | ||
97 | |||
98 | while (likely((err = xfrm6_output_one(skb)) == 0)) { | ||
99 | nf_reset(skb); | ||
100 | |||
101 | err = __ip6_local_out(skb); | ||
102 | if (unlikely(err != 1)) | ||
103 | break; | ||
104 | |||
105 | if (!skb->dst->xfrm) | ||
106 | return dst_output(skb); | ||
107 | |||
108 | err = nf_hook(PF_INET6, NF_IP6_POST_ROUTING, skb, NULL, | ||
109 | skb->dst->dev, xfrm6_output_finish2); | ||
110 | if (unlikely(err != 1)) | ||
111 | break; | ||
112 | } | ||
113 | |||
114 | return err; | ||
115 | } | ||
116 | |||
117 | static int xfrm6_output_finish(struct sk_buff *skb) | 79 | static int xfrm6_output_finish(struct sk_buff *skb) |
118 | { | 80 | { |
119 | struct sk_buff *segs; | 81 | #ifdef CONFIG_NETFILTER |
120 | 82 | IP6CB(skb)->flags |= IP6SKB_XFRM_TRANSFORMED; | |
121 | if (!skb_is_gso(skb)) | 83 | #endif |
122 | return xfrm6_output_finish2(skb); | ||
123 | 84 | ||
124 | skb->protocol = htons(ETH_P_IPV6); | 85 | skb->protocol = htons(ETH_P_IPV6); |
125 | segs = skb_gso_segment(skb, 0); | 86 | return xfrm_output(skb); |
126 | kfree_skb(skb); | ||
127 | if (unlikely(IS_ERR(segs))) | ||
128 | return PTR_ERR(segs); | ||
129 | |||
130 | do { | ||
131 | struct sk_buff *nskb = segs->next; | ||
132 | int err; | ||
133 | |||
134 | segs->next = NULL; | ||
135 | err = xfrm6_output_finish2(segs); | ||
136 | |||
137 | if (unlikely(err)) { | ||
138 | while ((segs = nskb)) { | ||
139 | nskb = segs->next; | ||
140 | segs->next = NULL; | ||
141 | kfree_skb(segs); | ||
142 | } | ||
143 | return err; | ||
144 | } | ||
145 | |||
146 | segs = nskb; | ||
147 | } while (segs); | ||
148 | |||
149 | return 0; | ||
150 | } | 87 | } |
151 | 88 | ||
152 | int xfrm6_output(struct sk_buff *skb) | 89 | int xfrm6_output(struct sk_buff *skb) |
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c index 63932c5fd3c7..a31dd531e191 100644 --- a/net/ipv6/xfrm6_policy.c +++ b/net/ipv6/xfrm6_policy.c | |||
@@ -252,6 +252,7 @@ static struct dst_ops xfrm6_dst_ops = { | |||
252 | .update_pmtu = xfrm6_update_pmtu, | 252 | .update_pmtu = xfrm6_update_pmtu, |
253 | .destroy = xfrm6_dst_destroy, | 253 | .destroy = xfrm6_dst_destroy, |
254 | .ifdown = xfrm6_dst_ifdown, | 254 | .ifdown = xfrm6_dst_ifdown, |
255 | .local_out = __ip6_local_out, | ||
255 | .gc_thresh = 1024, | 256 | .gc_thresh = 1024, |
256 | .entry_size = sizeof(struct xfrm_dst), | 257 | .entry_size = sizeof(struct xfrm_dst), |
257 | }; | 258 | }; |
diff --git a/net/ipv6/xfrm6_state.c b/net/ipv6/xfrm6_state.c index 90fef0a4726f..bb09e85a336d 100644 --- a/net/ipv6/xfrm6_state.c +++ b/net/ipv6/xfrm6_state.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <net/xfrm.h> | 14 | #include <net/xfrm.h> |
15 | #include <linux/pfkeyv2.h> | 15 | #include <linux/pfkeyv2.h> |
16 | #include <linux/ipsec.h> | 16 | #include <linux/ipsec.h> |
17 | #include <linux/netfilter_ipv6.h> | ||
17 | #include <net/dsfield.h> | 18 | #include <net/dsfield.h> |
18 | #include <net/ipv6.h> | 19 | #include <net/ipv6.h> |
19 | #include <net/addrconf.h> | 20 | #include <net/addrconf.h> |
@@ -189,6 +190,7 @@ static struct xfrm_state_afinfo xfrm6_state_afinfo = { | |||
189 | .family = AF_INET6, | 190 | .family = AF_INET6, |
190 | .proto = IPPROTO_IPV6, | 191 | .proto = IPPROTO_IPV6, |
191 | .eth_proto = htons(ETH_P_IPV6), | 192 | .eth_proto = htons(ETH_P_IPV6), |
193 | .nf_post_routing = NF_IP6_POST_ROUTING, | ||
192 | .owner = THIS_MODULE, | 194 | .owner = THIS_MODULE, |
193 | .init_tempsel = __xfrm6_init_tempsel, | 195 | .init_tempsel = __xfrm6_init_tempsel, |
194 | .tmpl_sort = __xfrm6_tmpl_sort, | 196 | .tmpl_sort = __xfrm6_tmpl_sort, |