* [PATCH 7/23] [PATCH] [XFRM] STATE: Add a hook to find where to be inserted header in outbound.
@ 2006-07-29 9:30 Masahide NAKAMURA
2006-07-30 23:31 ` James Morris
2006-08-02 0:09 ` David Miller
0 siblings, 2 replies; 6+ messages in thread
From: Masahide NAKAMURA @ 2006-07-29 9:30 UTC (permalink / raw)
To: davem; +Cc: yoshfuji, anttit, vnuorval, netdev, usagi-core, Masahide NAKAMURA
On current kernel, ip6_find_1stfragopt() is used by IPv6 IPsec to find where to
be inserted header in outbound. (BTW, no usage may be needed for IPv4 case.)
Mobile IPv6 requires other logic for routing header and destination
options header respectively.
Based on MIPL2 kernel patch.
---
include/net/xfrm.h | 1 +
net/ipv6/xfrm6_output.c | 5 ++++-
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index aaef1c4..bcda8c0 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -270,6 +270,7 @@ struct xfrm_type
void (*destructor)(struct xfrm_state *);
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 **);
/* Estimate maximal size of result of transformation of a dgram */
u32 (*get_max_size)(struct xfrm_state *, int size);
};
diff --git a/net/ipv6/xfrm6_output.c b/net/ipv6/xfrm6_output.c
index 2736a54..8792b5c 100644
--- a/net/ipv6/xfrm6_output.c
+++ b/net/ipv6/xfrm6_output.c
@@ -48,7 +48,10 @@ static void xfrm6_encap(struct sk_buff *
u8 *prevhdr;
int hdr_len;
- hdr_len = ip6_find_1stfragopt(skb, &prevhdr);
+ if (x->type->place_find)
+ hdr_len = x->type->place_find(x, skb, &prevhdr);
+ else
+ hdr_len = ip6_find_1stfragopt(skb, &prevhdr);
skb->nh.raw = prevhdr - x->props.header_len;
skb->h.raw = skb->data + hdr_len;
memmove(skb->data, iph, hdr_len);
--
1.4.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 7/23] [PATCH] [XFRM] STATE: Add a hook to find where to be inserted header in outbound.
2006-07-29 9:30 [PATCH 7/23] [PATCH] [XFRM] STATE: Add a hook to find where to be inserted header in outbound Masahide NAKAMURA
@ 2006-07-30 23:31 ` James Morris
2006-08-02 0:09 ` David Miller
1 sibling, 0 replies; 6+ messages in thread
From: James Morris @ 2006-07-30 23:31 UTC (permalink / raw)
To: Masahide NAKAMURA; +Cc: davem, yoshfuji, anttit, vnuorval, netdev, usagi-core
On Sat, 29 Jul 2006, Masahide NAKAMURA wrote:
> - hdr_len = ip6_find_1stfragopt(skb, &prevhdr);
> + if (x->type->place_find)
> + hdr_len = x->type->place_find(x, skb, &prevhdr);
> + else
> + hdr_len = ip6_find_1stfragopt(skb, &prevhdr);
What about encapsulating this like:
static inline int hdr_offset(...)
{
if (x->type->place_find)
return x->type->place_find(x, skb, &prevhdr);
else
return ip6_find_1stfragopt(skb, &prevhdr);
}
Maybe also change the naming of ->place_find to ->hdr_offset
- James
--
James Morris
<jmorris@namei.org>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 7/23] [PATCH] [XFRM] STATE: Add a hook to find where to be inserted header in outbound.
2006-07-29 9:30 [PATCH 7/23] [PATCH] [XFRM] STATE: Add a hook to find where to be inserted header in outbound Masahide NAKAMURA
2006-07-30 23:31 ` James Morris
@ 2006-08-02 0:09 ` David Miller
2006-08-02 2:20 ` Masahide NAKAMURA
1 sibling, 1 reply; 6+ messages in thread
From: David Miller @ 2006-08-02 0:09 UTC (permalink / raw)
To: nakam; +Cc: yoshfuji, anttit, vnuorval, netdev, usagi-core
From: Masahide NAKAMURA <nakam@linux-ipv6.org>
Date: Sat, 29 Jul 2006 18:30:23 +0900
> @@ -270,6 +270,7 @@ struct xfrm_type
> void (*destructor)(struct xfrm_state *);
> 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 **);
> /* Estimate maximal size of result of transformation of a dgram */
> u32 (*get_max_size)(struct xfrm_state *, int size);
> };
I see a dangerous pattern of adding many, many, many methods
to the xfrm_type structure which are only used by ipv6.
But I cannot suggest another method.
There are frequent calls of the form:
if (x->type->op != NULL)
x->type->op(x, y, z);
else
foo(y, z);
it might be nicer to hide all of this behind carefully crafted
inline functions.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 7/23] [PATCH] [XFRM] STATE: Add a hook to find where to be inserted header in outbound.
2006-08-02 0:09 ` David Miller
@ 2006-08-02 2:20 ` Masahide NAKAMURA
2006-08-02 4:11 ` David Miller
0 siblings, 1 reply; 6+ messages in thread
From: Masahide NAKAMURA @ 2006-08-02 2:20 UTC (permalink / raw)
To: David Miller; +Cc: yoshfuji, anttit, vnuorval, netdev, usagi-core
David Miller wrote:
> From: Masahide NAKAMURA <nakam@linux-ipv6.org>
> Date: Sat, 29 Jul 2006 18:30:23 +0900
>
>> @@ -270,6 +270,7 @@ struct xfrm_type
>> void (*destructor)(struct xfrm_state *);
>> 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 **);
>> /* Estimate maximal size of result of transformation of a dgram */
>> u32 (*get_max_size)(struct xfrm_state *, int size);
>> };
>
> I see a dangerous pattern of adding many, many, many methods
> to the xfrm_type structure which are only used by ipv6.
> But I cannot suggest another method.
Sometimes this is a difficult point for me to design.
> There are frequent calls of the form:
>
> if (x->type->op != NULL)
> x->type->op(x, y, z);
> else
> foo(y, z);
>
> it might be nicer to hide all of this behind carefully crafted
> inline functions.
I'll fix it. James gave me this comment, too.
BTW he also gave me another point:
> Maybe also change the naming of ->place_find to ->hdr_offset
I'll use this idea, too.
Thank you.
--
Masahide NAKAMURA
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 7/23] [PATCH] [XFRM] STATE: Add a hook to find where to be inserted header in outbound.
2006-08-02 2:20 ` Masahide NAKAMURA
@ 2006-08-02 4:11 ` David Miller
2006-08-02 8:31 ` Masahide NAKAMURA
0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2006-08-02 4:11 UTC (permalink / raw)
To: nakam; +Cc: yoshfuji, anttit, vnuorval, netdev, usagi-core
From: Masahide NAKAMURA <nakam@linux-ipv6.org>
Date: Wed, 02 Aug 2006 11:20:30 +0900
> David Miller wrote:
> > I see a dangerous pattern of adding many, many, many methods
> > to the xfrm_type structure which are only used by ipv6.
> > But I cannot suggest another method.
>
> Sometimes this is a difficult point for me to design.
Do not worry so much about it right now, it is not a barrier
for code integration. We can try to refine this later on.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 7/23] [PATCH] [XFRM] STATE: Add a hook to find where to be inserted header in outbound.
2006-08-02 4:11 ` David Miller
@ 2006-08-02 8:31 ` Masahide NAKAMURA
0 siblings, 0 replies; 6+ messages in thread
From: Masahide NAKAMURA @ 2006-08-02 8:31 UTC (permalink / raw)
To: David Miller; +Cc: yoshfuji, anttit, vnuorval, netdev, usagi-core
David Miller wrote:
> From: Masahide NAKAMURA <nakam@linux-ipv6.org>
> Date: Wed, 02 Aug 2006 11:20:30 +0900
>
>> David Miller wrote:
>>> I see a dangerous pattern of adding many, many, many methods
>>> to the xfrm_type structure which are only used by ipv6.
>>> But I cannot suggest another method.
>> Sometimes this is a difficult point for me to design.
>
> Do not worry so much about it right now, it is not a barrier
> for code integration. We can try to refine this later on.
OK, I improve my code for current framework at first.
Thanks :-)
--
Masahide NAKAMURA
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-08-02 8:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-29 9:30 [PATCH 7/23] [PATCH] [XFRM] STATE: Add a hook to find where to be inserted header in outbound Masahide NAKAMURA
2006-07-30 23:31 ` James Morris
2006-08-02 0:09 ` David Miller
2006-08-02 2:20 ` Masahide NAKAMURA
2006-08-02 4:11 ` David Miller
2006-08-02 8:31 ` Masahide NAKAMURA
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).