diff options
author | Masahide NAKAMURA <nakam@linux-ipv6.org> | 2006-09-22 18:05:15 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2006-09-22 18:05:15 -0400 |
commit | 7e49e6de30efa716614e280d97963c570f3acf29 (patch) | |
tree | 8eaef9d40300d16a7675722e082c5d8ab2a53d40 /net/ipv4 | |
parent | 77d16f450ae0452d7d4b009f78debb1294fb435c (diff) |
[XFRM]: Add XFRM_MODE_xxx for future use.
Transformation mode is used as either IPsec transport or tunnel.
It is required to add two more items, route optimization and inbound trigger
for Mobile IPv6.
Based on MIPL2 kernel patch.
This patch was also written by: Ville Nuorvala <vnuorval@tcs.hut.fi>
Signed-off-by: Masahide NAKAMURA <nakam@linux-ipv6.org>
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/ah4.c | 2 | ||||
-rw-r--r-- | net/ipv4/esp4.c | 6 | ||||
-rw-r--r-- | net/ipv4/ipcomp.c | 8 | ||||
-rw-r--r-- | net/ipv4/xfrm4_input.c | 2 | ||||
-rw-r--r-- | net/ipv4/xfrm4_output.c | 4 | ||||
-rw-r--r-- | net/ipv4/xfrm4_policy.c | 2 | ||||
-rw-r--r-- | net/ipv4/xfrm4_state.c | 2 | ||||
-rw-r--r-- | net/ipv4/xfrm4_tunnel.c | 2 |
8 files changed, 14 insertions, 14 deletions
diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c index 008e69d2e423..99542977e47e 100644 --- a/net/ipv4/ah4.c +++ b/net/ipv4/ah4.c | |||
@@ -265,7 +265,7 @@ static int ah_init_state(struct xfrm_state *x) | |||
265 | goto error; | 265 | goto error; |
266 | 266 | ||
267 | x->props.header_len = XFRM_ALIGN8(sizeof(struct ip_auth_hdr) + ahp->icv_trunc_len); | 267 | x->props.header_len = XFRM_ALIGN8(sizeof(struct ip_auth_hdr) + ahp->icv_trunc_len); |
268 | if (x->props.mode) | 268 | if (x->props.mode == XFRM_MODE_TUNNEL) |
269 | x->props.header_len += sizeof(struct iphdr); | 269 | x->props.header_len += sizeof(struct iphdr); |
270 | x->data = ahp; | 270 | x->data = ahp; |
271 | 271 | ||
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c index b428489f6ccd..e87377e1d6b6 100644 --- a/net/ipv4/esp4.c +++ b/net/ipv4/esp4.c | |||
@@ -248,7 +248,7 @@ static int esp_input(struct xfrm_state *x, struct sk_buff *skb) | |||
248 | * as per draft-ietf-ipsec-udp-encaps-06, | 248 | * as per draft-ietf-ipsec-udp-encaps-06, |
249 | * section 3.1.2 | 249 | * section 3.1.2 |
250 | */ | 250 | */ |
251 | if (!x->props.mode) | 251 | if (x->props.mode == XFRM_MODE_TRANSPORT) |
252 | skb->ip_summed = CHECKSUM_UNNECESSARY; | 252 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
253 | } | 253 | } |
254 | 254 | ||
@@ -267,7 +267,7 @@ static u32 esp4_get_max_size(struct xfrm_state *x, int mtu) | |||
267 | struct esp_data *esp = x->data; | 267 | struct esp_data *esp = x->data; |
268 | u32 blksize = ALIGN(crypto_blkcipher_blocksize(esp->conf.tfm), 4); | 268 | u32 blksize = ALIGN(crypto_blkcipher_blocksize(esp->conf.tfm), 4); |
269 | 269 | ||
270 | if (x->props.mode) { | 270 | if (x->props.mode == XFRM_MODE_TUNNEL) { |
271 | mtu = ALIGN(mtu + 2, blksize); | 271 | mtu = ALIGN(mtu + 2, blksize); |
272 | } else { | 272 | } else { |
273 | /* The worst case. */ | 273 | /* The worst case. */ |
@@ -383,7 +383,7 @@ static int esp_init_state(struct xfrm_state *x) | |||
383 | if (crypto_blkcipher_setkey(tfm, esp->conf.key, esp->conf.key_len)) | 383 | if (crypto_blkcipher_setkey(tfm, esp->conf.key, esp->conf.key_len)) |
384 | goto error; | 384 | goto error; |
385 | x->props.header_len = sizeof(struct ip_esp_hdr) + esp->conf.ivlen; | 385 | x->props.header_len = sizeof(struct ip_esp_hdr) + esp->conf.ivlen; |
386 | if (x->props.mode) | 386 | if (x->props.mode == XFRM_MODE_TUNNEL) |
387 | x->props.header_len += sizeof(struct iphdr); | 387 | x->props.header_len += sizeof(struct iphdr); |
388 | if (x->encap) { | 388 | if (x->encap) { |
389 | struct xfrm_encap_tmpl *encap = x->encap; | 389 | struct xfrm_encap_tmpl *encap = x->encap; |
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c index 5bb9c9f03fb6..17342430a843 100644 --- a/net/ipv4/ipcomp.c +++ b/net/ipv4/ipcomp.c | |||
@@ -176,7 +176,7 @@ static int ipcomp_output(struct xfrm_state *x, struct sk_buff *skb) | |||
176 | return 0; | 176 | return 0; |
177 | 177 | ||
178 | out_ok: | 178 | out_ok: |
179 | if (x->props.mode) | 179 | if (x->props.mode == XFRM_MODE_TUNNEL) |
180 | ip_send_check(iph); | 180 | ip_send_check(iph); |
181 | return 0; | 181 | return 0; |
182 | } | 182 | } |
@@ -216,7 +216,7 @@ static struct xfrm_state *ipcomp_tunnel_create(struct xfrm_state *x) | |||
216 | t->id.daddr.a4 = x->id.daddr.a4; | 216 | t->id.daddr.a4 = x->id.daddr.a4; |
217 | memcpy(&t->sel, &x->sel, sizeof(t->sel)); | 217 | memcpy(&t->sel, &x->sel, sizeof(t->sel)); |
218 | t->props.family = AF_INET; | 218 | t->props.family = AF_INET; |
219 | t->props.mode = 1; | 219 | t->props.mode = XFRM_MODE_TUNNEL; |
220 | t->props.saddr.a4 = x->props.saddr.a4; | 220 | t->props.saddr.a4 = x->props.saddr.a4; |
221 | t->props.flags = x->props.flags; | 221 | t->props.flags = x->props.flags; |
222 | 222 | ||
@@ -416,7 +416,7 @@ static int ipcomp_init_state(struct xfrm_state *x) | |||
416 | goto out; | 416 | goto out; |
417 | 417 | ||
418 | x->props.header_len = 0; | 418 | x->props.header_len = 0; |
419 | if (x->props.mode) | 419 | if (x->props.mode == XFRM_MODE_TUNNEL) |
420 | x->props.header_len += sizeof(struct iphdr); | 420 | x->props.header_len += sizeof(struct iphdr); |
421 | 421 | ||
422 | mutex_lock(&ipcomp_resource_mutex); | 422 | mutex_lock(&ipcomp_resource_mutex); |
@@ -428,7 +428,7 @@ static int ipcomp_init_state(struct xfrm_state *x) | |||
428 | goto error; | 428 | goto error; |
429 | mutex_unlock(&ipcomp_resource_mutex); | 429 | mutex_unlock(&ipcomp_resource_mutex); |
430 | 430 | ||
431 | if (x->props.mode) { | 431 | if (x->props.mode == XFRM_MODE_TUNNEL) { |
432 | err = ipcomp_tunnel_attach(x); | 432 | err = ipcomp_tunnel_attach(x); |
433 | if (err) | 433 | if (err) |
434 | goto error_tunnel; | 434 | goto error_tunnel; |
diff --git a/net/ipv4/xfrm4_input.c b/net/ipv4/xfrm4_input.c index 817ed84511a6..040e8475f295 100644 --- a/net/ipv4/xfrm4_input.c +++ b/net/ipv4/xfrm4_input.c | |||
@@ -106,7 +106,7 @@ int xfrm4_rcv_encap(struct sk_buff *skb, __u16 encap_type) | |||
106 | if (x->mode->input(x, skb)) | 106 | if (x->mode->input(x, skb)) |
107 | goto drop; | 107 | goto drop; |
108 | 108 | ||
109 | if (x->props.mode) { | 109 | if (x->props.mode == XFRM_MODE_TUNNEL) { |
110 | decaps = 1; | 110 | decaps = 1; |
111 | break; | 111 | break; |
112 | } | 112 | } |
diff --git a/net/ipv4/xfrm4_output.c b/net/ipv4/xfrm4_output.c index 4a96a9e3ef3b..5fd115f0c547 100644 --- a/net/ipv4/xfrm4_output.c +++ b/net/ipv4/xfrm4_output.c | |||
@@ -54,7 +54,7 @@ static int xfrm4_output_one(struct sk_buff *skb) | |||
54 | goto error_nolock; | 54 | goto error_nolock; |
55 | } | 55 | } |
56 | 56 | ||
57 | if (x->props.mode) { | 57 | if (x->props.mode == XFRM_MODE_TUNNEL) { |
58 | err = xfrm4_tunnel_check_size(skb); | 58 | err = xfrm4_tunnel_check_size(skb); |
59 | if (err) | 59 | if (err) |
60 | goto error_nolock; | 60 | goto error_nolock; |
@@ -85,7 +85,7 @@ static int xfrm4_output_one(struct sk_buff *skb) | |||
85 | } | 85 | } |
86 | dst = skb->dst; | 86 | dst = skb->dst; |
87 | x = dst->xfrm; | 87 | x = dst->xfrm; |
88 | } while (x && !x->props.mode); | 88 | } while (x && (x->props.mode != XFRM_MODE_TUNNEL)); |
89 | 89 | ||
90 | IPCB(skb)->flags |= IPSKB_XFRM_TRANSFORMED; | 90 | IPCB(skb)->flags |= IPSKB_XFRM_TRANSFORMED; |
91 | err = 0; | 91 | err = 0; |
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c index 8f50eae47d03..a5bed741de2c 100644 --- a/net/ipv4/xfrm4_policy.c +++ b/net/ipv4/xfrm4_policy.c | |||
@@ -96,7 +96,7 @@ __xfrm4_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int | |||
96 | 96 | ||
97 | dst1->next = dst_prev; | 97 | dst1->next = dst_prev; |
98 | dst_prev = dst1; | 98 | dst_prev = dst1; |
99 | if (xfrm[i]->props.mode) { | 99 | if (xfrm[i]->props.mode != XFRM_MODE_TRANSPORT) { |
100 | remote = xfrm[i]->id.daddr.a4; | 100 | remote = xfrm[i]->id.daddr.a4; |
101 | local = xfrm[i]->props.saddr.a4; | 101 | local = xfrm[i]->props.saddr.a4; |
102 | tunnel = 1; | 102 | tunnel = 1; |
diff --git a/net/ipv4/xfrm4_state.c b/net/ipv4/xfrm4_state.c index 81e1751c966e..97b0c7589711 100644 --- a/net/ipv4/xfrm4_state.c +++ b/net/ipv4/xfrm4_state.c | |||
@@ -42,7 +42,7 @@ __xfrm4_init_tempsel(struct xfrm_state *x, struct flowi *fl, | |||
42 | x->props.saddr = tmpl->saddr; | 42 | x->props.saddr = tmpl->saddr; |
43 | if (x->props.saddr.a4 == 0) | 43 | if (x->props.saddr.a4 == 0) |
44 | x->props.saddr.a4 = saddr->a4; | 44 | x->props.saddr.a4 = saddr->a4; |
45 | if (tmpl->mode && x->props.saddr.a4 == 0) { | 45 | if (tmpl->mode == XFRM_MODE_TUNNEL && x->props.saddr.a4 == 0) { |
46 | struct rtable *rt; | 46 | struct rtable *rt; |
47 | struct flowi fl_tunnel = { | 47 | struct flowi fl_tunnel = { |
48 | .nl_u = { | 48 | .nl_u = { |
diff --git a/net/ipv4/xfrm4_tunnel.c b/net/ipv4/xfrm4_tunnel.c index f8ceaa127c83..f110af5b1319 100644 --- a/net/ipv4/xfrm4_tunnel.c +++ b/net/ipv4/xfrm4_tunnel.c | |||
@@ -28,7 +28,7 @@ static int ipip_xfrm_rcv(struct xfrm_state *x, struct sk_buff *skb) | |||
28 | 28 | ||
29 | static int ipip_init_state(struct xfrm_state *x) | 29 | static int ipip_init_state(struct xfrm_state *x) |
30 | { | 30 | { |
31 | if (!x->props.mode) | 31 | if (x->props.mode != XFRM_MODE_TUNNEL) |
32 | return -EINVAL; | 32 | return -EINVAL; |
33 | 33 | ||
34 | if (x->encap) | 34 | if (x->encap) |