[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>
This commit is contained in:

committed by
David S. Miller

parent
77d16f450a
commit
7e49e6de30
@@ -398,7 +398,7 @@ static int ah6_init_state(struct xfrm_state *x)
|
||||
goto error;
|
||||
|
||||
x->props.header_len = XFRM_ALIGN8(sizeof(struct ipv6_auth_hdr) + ahp->icv_trunc_len);
|
||||
if (x->props.mode)
|
||||
if (x->props.mode == XFRM_MODE_TUNNEL)
|
||||
x->props.header_len += sizeof(struct ipv6hdr);
|
||||
x->data = ahp;
|
||||
|
||||
|
@@ -237,7 +237,7 @@ static u32 esp6_get_max_size(struct xfrm_state *x, int mtu)
|
||||
struct esp_data *esp = x->data;
|
||||
u32 blksize = ALIGN(crypto_blkcipher_blocksize(esp->conf.tfm), 4);
|
||||
|
||||
if (x->props.mode) {
|
||||
if (x->props.mode == XFRM_MODE_TUNNEL) {
|
||||
mtu = ALIGN(mtu + 2, blksize);
|
||||
} else {
|
||||
/* The worst case. */
|
||||
@@ -358,7 +358,7 @@ static int esp6_init_state(struct xfrm_state *x)
|
||||
if (crypto_blkcipher_setkey(tfm, esp->conf.key, esp->conf.key_len))
|
||||
goto error;
|
||||
x->props.header_len = sizeof(struct ipv6_esp_hdr) + esp->conf.ivlen;
|
||||
if (x->props.mode)
|
||||
if (x->props.mode == XFRM_MODE_TUNNEL)
|
||||
x->props.header_len += sizeof(struct ipv6hdr);
|
||||
x->data = esp;
|
||||
return 0;
|
||||
|
@@ -212,7 +212,7 @@ static struct xfrm_state *ipcomp6_tunnel_create(struct xfrm_state *x)
|
||||
memcpy(t->id.daddr.a6, x->id.daddr.a6, sizeof(struct in6_addr));
|
||||
memcpy(&t->sel, &x->sel, sizeof(t->sel));
|
||||
t->props.family = AF_INET6;
|
||||
t->props.mode = 1;
|
||||
t->props.mode = XFRM_MODE_TUNNEL;
|
||||
memcpy(t->props.saddr.a6, x->props.saddr.a6, sizeof(struct in6_addr));
|
||||
|
||||
if (xfrm_init_state(t))
|
||||
@@ -417,7 +417,7 @@ static int ipcomp6_init_state(struct xfrm_state *x)
|
||||
goto out;
|
||||
|
||||
x->props.header_len = 0;
|
||||
if (x->props.mode)
|
||||
if (x->props.mode == XFRM_MODE_TUNNEL)
|
||||
x->props.header_len += sizeof(struct ipv6hdr);
|
||||
|
||||
mutex_lock(&ipcomp6_resource_mutex);
|
||||
@@ -429,7 +429,7 @@ static int ipcomp6_init_state(struct xfrm_state *x)
|
||||
goto error;
|
||||
mutex_unlock(&ipcomp6_resource_mutex);
|
||||
|
||||
if (x->props.mode) {
|
||||
if (x->props.mode == XFRM_MODE_TUNNEL) {
|
||||
err = ipcomp6_tunnel_attach(x);
|
||||
if (err)
|
||||
goto error_tunnel;
|
||||
|
@@ -72,7 +72,7 @@ int xfrm6_rcv_spi(struct sk_buff *skb, u32 spi)
|
||||
if (x->mode->input(x, skb))
|
||||
goto drop;
|
||||
|
||||
if (x->props.mode) { /* XXX */
|
||||
if (x->props.mode == XFRM_MODE_TUNNEL) { /* XXX */
|
||||
decaps = 1;
|
||||
break;
|
||||
}
|
||||
|
@@ -47,7 +47,7 @@ static int xfrm6_output_one(struct sk_buff *skb)
|
||||
goto error_nolock;
|
||||
}
|
||||
|
||||
if (x->props.mode) {
|
||||
if (x->props.mode == XFRM_MODE_TUNNEL) {
|
||||
err = xfrm6_tunnel_check_size(skb);
|
||||
if (err)
|
||||
goto error_nolock;
|
||||
@@ -80,7 +80,7 @@ static int xfrm6_output_one(struct sk_buff *skb)
|
||||
}
|
||||
dst = skb->dst;
|
||||
x = dst->xfrm;
|
||||
} while (x && !x->props.mode);
|
||||
} while (x && (x->props.mode != XFRM_MODE_TUNNEL));
|
||||
|
||||
IP6CB(skb)->flags |= IP6SKB_XFRM_TRANSFORMED;
|
||||
err = 0;
|
||||
|
@@ -114,7 +114,7 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
|
||||
|
||||
dst1->next = dst_prev;
|
||||
dst_prev = dst1;
|
||||
if (xfrm[i]->props.mode) {
|
||||
if (xfrm[i]->props.mode != XFRM_MODE_TRANSPORT) {
|
||||
remote = (struct in6_addr*)&xfrm[i]->id.daddr;
|
||||
local = (struct in6_addr*)&xfrm[i]->props.saddr;
|
||||
tunnel = 1;
|
||||
|
@@ -42,7 +42,7 @@ __xfrm6_init_tempsel(struct xfrm_state *x, struct flowi *fl,
|
||||
memcpy(&x->props.saddr, &tmpl->saddr, sizeof(x->props.saddr));
|
||||
if (ipv6_addr_any((struct in6_addr*)&x->props.saddr))
|
||||
memcpy(&x->props.saddr, saddr, sizeof(x->props.saddr));
|
||||
if (tmpl->mode && ipv6_addr_any((struct in6_addr*)&x->props.saddr)) {
|
||||
if (tmpl->mode == XFRM_MODE_TUNNEL && ipv6_addr_any((struct in6_addr*)&x->props.saddr)) {
|
||||
struct rt6_info *rt;
|
||||
struct flowi fl_tunnel = {
|
||||
.nl_u = {
|
||||
|
@@ -307,7 +307,7 @@ static int xfrm6_tunnel_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
|
||||
|
||||
static int xfrm6_tunnel_init_state(struct xfrm_state *x)
|
||||
{
|
||||
if (!x->props.mode)
|
||||
if (x->props.mode != XFRM_MODE_TUNNEL)
|
||||
return -EINVAL;
|
||||
|
||||
if (x->encap)
|
||||
|
Reference in New Issue
Block a user