aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/xfrm.h4
-rw-r--r--net/ipv6/mip6.c11
-rw-r--r--net/ipv6/xfrm6_policy.c20
3 files changed, 12 insertions, 23 deletions
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 1dd20cf17982..3434fdc7de37 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -282,6 +282,8 @@ struct xfrm_type
282 __u8 flags; 282 __u8 flags;
283#define XFRM_TYPE_NON_FRAGMENT 1 283#define XFRM_TYPE_NON_FRAGMENT 1
284#define XFRM_TYPE_REPLAY_PROT 2 284#define XFRM_TYPE_REPLAY_PROT 2
285#define XFRM_TYPE_LOCAL_COADDR 4
286#define XFRM_TYPE_REMOTE_COADDR 8
285 287
286 int (*init_state)(struct xfrm_state *x); 288 int (*init_state)(struct xfrm_state *x);
287 void (*destructor)(struct xfrm_state *); 289 void (*destructor)(struct xfrm_state *);
@@ -289,8 +291,6 @@ struct xfrm_type
289 int (*output)(struct xfrm_state *, struct sk_buff *pskb); 291 int (*output)(struct xfrm_state *, struct sk_buff *pskb);
290 int (*reject)(struct xfrm_state *, struct sk_buff *, struct flowi *); 292 int (*reject)(struct xfrm_state *, struct sk_buff *, struct flowi *);
291 int (*hdr_offset)(struct xfrm_state *, struct sk_buff *, u8 **); 293 int (*hdr_offset)(struct xfrm_state *, struct sk_buff *, u8 **);
292 xfrm_address_t *(*local_addr)(struct xfrm_state *, xfrm_address_t *);
293 xfrm_address_t *(*remote_addr)(struct xfrm_state *, xfrm_address_t *);
294 /* Estimate maximal size of result of transformation of a dgram */ 294 /* Estimate maximal size of result of transformation of a dgram */
295 u32 (*get_mtu)(struct xfrm_state *, int size); 295 u32 (*get_mtu)(struct xfrm_state *, int size);
296}; 296};
diff --git a/net/ipv6/mip6.c b/net/ipv6/mip6.c
index 7fd841d41019..edfd9cdd721c 100644
--- a/net/ipv6/mip6.c
+++ b/net/ipv6/mip6.c
@@ -34,11 +34,6 @@
34#include <net/xfrm.h> 34#include <net/xfrm.h>
35#include <net/mip6.h> 35#include <net/mip6.h>
36 36
37static xfrm_address_t *mip6_xfrm_addr(struct xfrm_state *x, xfrm_address_t *addr)
38{
39 return x->coaddr;
40}
41
42static inline unsigned int calc_padlen(unsigned int len, unsigned int n) 37static inline unsigned int calc_padlen(unsigned int len, unsigned int n)
43{ 38{
44 return (n - len + 16) & 0x7; 39 return (n - len + 16) & 0x7;
@@ -337,14 +332,13 @@ static struct xfrm_type mip6_destopt_type =
337 .description = "MIP6DESTOPT", 332 .description = "MIP6DESTOPT",
338 .owner = THIS_MODULE, 333 .owner = THIS_MODULE,
339 .proto = IPPROTO_DSTOPTS, 334 .proto = IPPROTO_DSTOPTS,
340 .flags = XFRM_TYPE_NON_FRAGMENT, 335 .flags = XFRM_TYPE_NON_FRAGMENT | XFRM_TYPE_LOCAL_COADDR,
341 .init_state = mip6_destopt_init_state, 336 .init_state = mip6_destopt_init_state,
342 .destructor = mip6_destopt_destroy, 337 .destructor = mip6_destopt_destroy,
343 .input = mip6_destopt_input, 338 .input = mip6_destopt_input,
344 .output = mip6_destopt_output, 339 .output = mip6_destopt_output,
345 .reject = mip6_destopt_reject, 340 .reject = mip6_destopt_reject,
346 .hdr_offset = mip6_destopt_offset, 341 .hdr_offset = mip6_destopt_offset,
347 .local_addr = mip6_xfrm_addr,
348}; 342};
349 343
350static int mip6_rthdr_input(struct xfrm_state *x, struct sk_buff *skb) 344static int mip6_rthdr_input(struct xfrm_state *x, struct sk_buff *skb)
@@ -467,13 +461,12 @@ static struct xfrm_type mip6_rthdr_type =
467 .description = "MIP6RT", 461 .description = "MIP6RT",
468 .owner = THIS_MODULE, 462 .owner = THIS_MODULE,
469 .proto = IPPROTO_ROUTING, 463 .proto = IPPROTO_ROUTING,
470 .flags = XFRM_TYPE_NON_FRAGMENT, 464 .flags = XFRM_TYPE_NON_FRAGMENT | XFRM_TYPE_REMOTE_COADDR,
471 .init_state = mip6_rthdr_init_state, 465 .init_state = mip6_rthdr_init_state,
472 .destructor = mip6_rthdr_destroy, 466 .destructor = mip6_rthdr_destroy,
473 .input = mip6_rthdr_input, 467 .input = mip6_rthdr_input,
474 .output = mip6_rthdr_output, 468 .output = mip6_rthdr_output,
475 .hdr_offset = mip6_rthdr_offset, 469 .hdr_offset = mip6_rthdr_offset,
476 .remote_addr = mip6_xfrm_addr,
477}; 470};
478 471
479static int __init mip6_init(void) 472static int __init mip6_init(void)
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
index 77dc3651437e..3b38e493d151 100644
--- a/net/ipv6/xfrm6_policy.c
+++ b/net/ipv6/xfrm6_policy.c
@@ -87,20 +87,16 @@ __xfrm6_find_bundle(struct flowi *fl, struct xfrm_policy *policy)
87 return dst; 87 return dst;
88} 88}
89 89
90static inline struct in6_addr* 90static inline xfrm_address_t *__xfrm6_bundle_addr_remote(struct xfrm_state *x)
91__xfrm6_bundle_addr_remote(struct xfrm_state *x, struct in6_addr *addr)
92{ 91{
93 return (x->type->remote_addr) ? 92 return (x->type->flags & XFRM_TYPE_REMOTE_COADDR) ? x->coaddr :
94 (struct in6_addr*)x->type->remote_addr(x, (xfrm_address_t *)addr) : 93 &x->id.daddr;
95 (struct in6_addr*)&x->id.daddr;
96} 94}
97 95
98static inline struct in6_addr* 96static inline xfrm_address_t *__xfrm6_bundle_addr_local(struct xfrm_state *x)
99__xfrm6_bundle_addr_local(struct xfrm_state *x, struct in6_addr *addr)
100{ 97{
101 return (x->type->local_addr) ? 98 return (x->type->flags & XFRM_TYPE_LOCAL_COADDR) ? x->coaddr :
102 (struct in6_addr*)x->type->local_addr(x, (xfrm_address_t *)addr) : 99 &x->props.saddr;
103 (struct in6_addr*)&x->props.saddr;
104} 100}
105 101
106/* Allocate chain of dst_entry's, attach known xfrm's, calculate 102/* Allocate chain of dst_entry's, attach known xfrm's, calculate
@@ -171,9 +167,9 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
171 fl_tunnel.fl4_src = xfrm[i]->props.saddr.a4; 167 fl_tunnel.fl4_src = xfrm[i]->props.saddr.a4;
172 break; 168 break;
173 case AF_INET6: 169 case AF_INET6:
174 ipv6_addr_copy(&fl_tunnel.fl6_dst, __xfrm6_bundle_addr_remote(xfrm[i], &fl->fl6_dst)); 170 ipv6_addr_copy(&fl_tunnel.fl6_dst, (struct in6_addr *)__xfrm6_bundle_addr_remote(xfrm[i]));
175 171
176 ipv6_addr_copy(&fl_tunnel.fl6_src, __xfrm6_bundle_addr_local(xfrm[i], &fl->fl6_src)); 172 ipv6_addr_copy(&fl_tunnel.fl6_src, (struct in6_addr *)__xfrm6_bundle_addr_local(xfrm[i]));
177 break; 173 break;
178 default: 174 default:
179 BUG_ON(1); 175 BUG_ON(1);