Skip to contentSkip to conversation

STATE: Add a hook to obtain local/remote outbound address.

PATCH In review Masahide NAKAMURA 2 participants 2 messages Jul 29, 2006 – Jul 30, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 8/23 STATE: Add a hook to obtain local/remote outbound address.

Outbound transformation replaces both source and destination address with state's end-point addresses at the same time when IPsec tunnel mode. It is also required to change them for Mobile IPv6 route optimization, but we should care about the following differences:
- changing result is not end-point but care-of address
- either source or destination is replaced for each state
This hook is a common platform to change outbound address.
Based on MIPL2 kernel patch.

---
 include/net/xfrm.h      |    2 ++
 net/ipv6/xfrm6_policy.c |    8 ++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)
include/net/xfrm.h +2 -0
index bcda8c0..e14ae3c 100644
@@ -271,6 +271,8 @@ struct xfrm_type
 	int			(*input)(struct xfrm_state *, struct sk_buff *skb);
 	int			(*output)(struct xfrm_state *, struct sk_buff *pskb);
 	int			(*place_find)(struct xfrm_state *, struct sk_buff *, u8 **);
+	xfrm_address_t		*(*local_addr)(struct xfrm_state *, xfrm_address_t *);
+	xfrm_address_t		*(*remote_addr)(struct xfrm_state *, xfrm_address_t *);
 	/* Estimate maximal size of result of transformation of a dgram */
 	u32			(*get_max_size)(struct xfrm_state *, int size);
 };
net/ipv6/xfrm6_policy.c +6 -2
index 1d8489b..28bc272 100644
@@ -118,8 +118,12 @@ __xfrm6_bundle_create(struct xfrm_policy
 		dst1->next = dst_prev;
 		dst_prev = dst1;
 		if (xfrm[i]->props.mode != XFRM_MODE_TRANSPORT) {
-			remote = (struct in6_addr*)&xfrm[i]->id.daddr;
-			local  = (struct in6_addr*)&xfrm[i]->props.saddr;
+			remote = (xfrm[i]->type->remote_addr) ?
+				(struct in6_addr*)xfrm[i]->type->remote_addr(xfrm[i], (xfrm_address_t *)remote):
+				(struct in6_addr*)&xfrm[i]->id.daddr;
+			local  = (xfrm[i]->type->local_addr) ?
+				(struct in6_addr*)xfrm[i]->type->local_addr(xfrm[i], (xfrm_address_t *)local):
+				(struct in6_addr*)&xfrm[i]->props.saddr;
 			tunnel = 1;
 		}
 		header_len += xfrm[i]->props.header_len;
Signature · 1 line
1.4.1
#1 lore raw

net/ipv6/xfrm6_policy.c __xfrm6_bundle_create(struct xfrm_policy · line 126

Quoted 6 lines · Masahide NAKAMURA
net/ipv6/xfrm6_policy.c +6 -0
+			remote = (xfrm[i]->type->remote_addr) ?
+				(struct in6_addr*)xfrm[i]->type->remote_addr(xfrm[i], (xfrm_address_t *)remote):
+				(struct in6_addr*)&xfrm[i]->id.daddr;
+			local  = (xfrm[i]->type->local_addr) ?
+				(struct in6_addr*)xfrm[i]->type->local_addr(xfrm[i], (xfrm_address_t *)local):
+				(struct in6_addr*)&xfrm[i]->props.saddr;

Again, it'd make the code so much cleaner to provide static inline wrappers for all of these types of:

	foo = op ? op->() : bar;

and

if (op)

		bar = op->();
Signature · 2 lines
James Morris
<[email protected]>