Question with commit 299b0767(ipv6: Fix IPsec slowpath fragmentation problem)
Subsystems (4)
Hi, Steffen!
I found some problem while doing networking tests with IPSec that the first fragment doesn't use the max MTU to fill payload, but with 20 bytes smaller. When I reverted your commit 299b0767(ipv6: Fix IPsec slowpath fragmentation problem), things goes well.
Would you so kindly to point me out what the commit did, because I think the original implementation had taken IPSec header and tailer into account.
Thanks!
Steffen Klassert
maintainerQuoted 11 lines · Li Wei
Hi, Steffen!
I found some problem while doing networking tests with IPSec that the first fragment doesn't use the max MTU to fill payload, but with 20 bytes smaller. When I reverted your commit 299b0767(ipv6: Fix IPsec slowpath fragmentation problem), things goes well.
Would you so kindly to point me out what the commit did, because I think the original implementation had taken IPSec header and tailer into account.
Without this patch we used always the slow path in ip6_fragment() due to a miscalculation of the packet lenght in ip6_append_data().
This patch just makes use of the reduced IPsec mtu, and adapts the IPsec header handling to have enought headroom on the skb.
Quoted 13 lines · Steffen Klassert
Quoted 11 lines · Li Wei
Hi, Steffen!
I found some problem while doing networking tests with IPSec that the first fragment doesn't use the max MTU to fill payload, but with 20 bytes smaller. When I reverted your commit 299b0767(ipv6: Fix IPsec slowpath fragmentation problem), things goes well.
Would you so kindly to point me out what the commit did, because I think the original implementation had taken IPSec header and tailer into account.
Quoted 7 lines
Without this patch we used always the slow path in
ip6_fragment()due to a miscalculation of the packet lenght inip6_append_data().This patch just makes use of the reduced IPsec mtu, and adapts the IPsec header handling to have enought headroom on the skb.
Hi Steffen,
Thank you for your reply!
I see in your patch that you use the "mtu" of &rt->dst (which taken IPSec into account) instead of rt->dst.path, but the "exthdrlen" and "dst_exthdrlen" things process IPSec again. Does some duplication there?
After reverted the patch and put some "printk" things in the slow_path of ip6_fragment(), setup IPSec transport mode between two hosts, when sending some echo request which exceeds the MTU, I don't see any "printk" in slow_path outputed. Could you tell me how to reproduce the slow_path things?
Thanks,
Wei
Steffen Klassert
maintainerQuoted 5 lines · Li Wei
Hi Steffen,
Thank you for your reply!
Quoted 9 lines
I see in your patch that you use the "mtu" of
&rt->dst(which taken IPSec into account) instead ofrt->dst.path, but the "exthdrlen" and "dst_exthdrlen" things process IPSec again. Does some duplication there?After reverted the patch and put some "printk" things in the
slow_pathofip6_fragment(), setup IPSec transport mode between two hosts, when sending some echo request which exceeds the MTU, I don't see any "printk" inslow_pathoutputed. Could you tell me how to reproduce theslow_paththings?
Ok, I see what's going on. The slowpath fragmentation problem appeared in tunnel mode. This is because commit ad0081e43a
"ipv6: Fragment locally generated tunnel-mode IPSec6 packets as needed" changed tunnel mode to do fragmentation before the transformation while transport mode still does fragmentation after transformation. Now, tunnel mode needs IPsec headers and trailer for all fragments, while on transport mode it is sufficient to add the headers to the first fragment and the trailer to the last.
Not quite sure what to do here. We would have the information to check for tunnel/transport mode when we calculate the packet lenght in ip6_append_data(), but it would look quite ugly to search through the xfrm state bundle to figure out which mode this is using.
PATCH 1/1 ipv6: fix incorrect ipsec transport mode fragment
Since commit 299b0767(ipv6: Fix IPsec slowpath fragmentation problem) the fragment of ipsec transport mode packets is incorrect. because tunnel mode needs IPsec headers and trailer for all fragments, while on transport mode it is sufficient to add the headers to the first fragment and the trailer to the last.
so modify mtu and maxfraglen base on ipsec mode and if fragment is first or last.
with my test,it work well and does not trigger slow fragment path.
--- net/ipv6/ip6_output.c | 80 +++++++++++++++++++++++++++++++++++++----------- 1 files changed, 61 insertions(+), 19 deletions(-)
net/ipv6/ip6_output.c +61 -19
@@ -1191,19 +1191,23 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,struct ipv6_pinfo *np =inet6_sk (sk);struct inet_cork *cork;struct sk_buff *skb; -unsigned int maxfraglen, fragheaderlen; +unsigned int maxfraglen, maxfraglen_prev, fragheaderlen;int exthdrlen;int dst_exthdrlen;int hh_len; -int mtu; +int mtu, mtu_prev;int copy;int err;int offset =0 ;int csummode =CHECKSUM_NONE ;__u8 tx_flags =0 ; - +bool transport_mode = false; +struct xfrm_state *x = rt->dst.xfrm;if (flags&MSG_PROBE )return 0 ; +if (x && x->props.mode ==XFRM_MODE_TRANSPORT ) + transport_mode = true; + cork = &inet->cork.base;if (skb_queue_empty (&sk->sk_write_queue)) {/*
@@ -1248,13 +1252,17 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, inet->cork.fl.u.ip6 = *fl6; np->cork.hop_limit = hlimit; np->cork.tclass = tclass; - mtu = np->pmtudisc ==IPV6_PMTUDISC_PROBE ? - rt->dst.dev->mtu :dst_mtu (&rt->dst); +if (transport_mode) + mtu = np->pmtudisc ==IPV6_PMTUDISC_PROBE ? + rt->dst.dev->mtu :dst_mtu (rt->dst.path); +else + mtu = np->pmtudisc ==IPV6_PMTUDISC_PROBE ? + rt->dst.dev->mtu :dst_mtu (&rt->dst);if (np->frag_size < mtu) {if (np->frag_size) mtu = np->frag_size; } - cork->fragsize = mtu; + mtu_prev = cork->fragsize = mtu;if (dst_allfrag (rt->dst.path)) cork->flags |=IPCORK_ALLFRAG ; cork->length =0 ;
@@ -1271,14 +1279,15 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, transhdrlen =0 ; exthdrlen =0 ; dst_exthdrlen =0 ; - mtu = cork->fragsize; + mtu_prev = mtu = cork->fragsize; } hh_len =LL_RESERVED_SPACE (rt->dst.dev); fragheaderlen =sizeof (struct ipv6hdr ) + rt->rt6i_nfheader_len + (opt ? opt->opt_nflen :0 ); - maxfraglen = ((mtu - fragheaderlen) & ~7 ) + fragheaderlen -sizeof (struct frag_hdr ); + maxfraglen_prev = maxfraglen = ((mtu - fragheaderlen) & ~7 ) + + fragheaderlen -sizeof (struct frag_hdr );if (mtu <=sizeof (struct ipv6hdr ) +IPV6_MAXPLEN ) {if (cork->length + length >sizeof (struct ipv6hdr ) +IPV6_MAXPLEN - fragheaderlen) {
@@ -1329,15 +1338,27 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,return 0 ; } } - -if ((skb =skb_peek_tail (&sk->sk_write_queue)) ==NULL ) + skb =skb_peek_tail (&sk->sk_write_queue); +if (skb ==NULL ) { +if (transport_mode) { +/* +* transport mode the first ipsec fragment should contain +* ipsec header, so decrease dst_exthdrlen from mtu. +*/ + mtu -= dst_exthdrlen; + mtu_prev = mtu; + maxfraglen = ((mtu - fragheaderlen) & ~7 ) + + fragheaderlen -sizeof (struct frag_hdr ); + maxfraglen_prev = maxfraglen; + } goto alloc_new_skb; + }while (length >0 ) {/* Check if the remaining data fits into current packet. */ - copy = (cork->length <= mtu && !(cork->flags &IPCORK_ALLFRAG ) ? mtu : maxfraglen) - skb->len; + copy = (cork->length <= mtu_prev && !(cork->flags &IPCORK_ALLFRAG ) ? mtu_prev : maxfraglen_prev) - skb->len;if (copy < length) - copy = maxfraglen - skb->len; + copy = maxfraglen_prev - skb->len;if (copy <=0 ) {char *data;
@@ -1351,7 +1372,7 @@ alloc_new_skb:/* There's no room in the current skb */ if (skb_prev) - fraggap = skb_prev->len - maxfraglen; + fraggap = skb_prev->len - maxfraglen_prev;else fraggap =0 ;
@@ -1360,10 +1381,14 @@ alloc_new_skb:* we know we need more fragment(s). */ datalen = length + fraggap; -if (datalen > (cork->length <= mtu && !(cork->flags &IPCORK_ALLFRAG ) ? mtu : maxfraglen) - fragheaderlen) - datalen = maxfraglen - fragheaderlen; +if (datalen > (cork->length <= mtu && !(cork->flags &IPCORK_ALLFRAG ) ? mtu : maxfraglen) - fragheaderlen) { +/* +* decrease ipsec trailer here, +* if it's not the last fragment, add trailer latter +*/ + datalen = maxfraglen - fragheaderlen - rt->dst.trailer_len; + } - fraglen = datalen + fragheaderlen;if ((flags &MSG_MORE ) && !(rt->dst.dev->features&NETIF_F_SG )) alloclen = mtu;
@@ -1377,9 +1402,15 @@ alloc_new_skb:* Note: we overallocate on fragments with MSG_MODE * because we have no idea if we're the last one. */ -if (datalen == length + fraggap) - alloclen += rt->dst.trailer_len; - + alloclen += rt->dst.trailer_len; +if (datalen != length + fraggap) { +/* +* this fragment is not the last fragment, +* add trailer to datalen +*/ + datalen += rt->dst.trailer_len; + } + fraglen = datalen + fragheaderlen;/* * We just reserve space for fragment header. * Note: this may be overallocation if the message
@@ -1452,6 +1483,17 @@ alloc_new_skb: offset += copy; length -= datalen - fraggap; + + mtu_prev = mtu; + maxfraglen_prev = maxfraglen; +if (skb_prev ==NULL && transport_mode) { +/* +* transport mode the middle skb should not have +* ipsec header and trailer, so update the mtu. +*/ + mtu =dst_mtu (rt->dst.path); + maxfraglen = ((mtu - fragheaderlen) & ~7 ) + fragheaderlen -sizeof (struct frag_hdr ); + } transhdrlen =0 ; exthdrlen =0 ; dst_exthdrlen =0 ;
Signature · 1 line
1.7.7.6
Steffen Klassert
maintainerRe: [PATCH] ipv6: fix incorrect ipsec transport mode fragment
Quoted 5 lines · Gao feng
Since commit 299b0767(ipv6: Fix IPsec slowpath fragmentation problem) the fragment of ipsec transport mode packets is incorrect. because tunnel mode needs IPsec headers and trailer for all fragments, while on transport mode it is sufficient to add the headers to the first fragment and the trailer to the last.
I mentioned this in an other thread some time ago,
this is due to commit ad0081e43a
"ipv6: Fragment locally generated tunnel-mode IPSec6 packets as needed" changed tunnel mode to do fragmentation before the transformation while transport mode still does fragmentation after transformation. Now, tunnel mode needs IPsec headers and trailer for all fragments, while on transport mode it is sufficient to add the headers to the first fragment and the trailer to the last.
Quoted 3 lines
so modify mtu and maxfraglen base on ipsec mode and if fragment is first or last.
There might be other opinions, but I don't like to see this IPsec mode dependent stuff hacked into the generic ipv6 output path.
Basically we have two cases. One where we have to add rt->dst.header_len to the first fragment and rt->dst.trailer_len to the last fragment, and the other where we have to add both to all fragments. So perhaps we could isolate this code and create two functions, one for each case.
Quoted 26 lines
with my test,it work well and does not trigger slow fragment path.
Signed-off-by Gao feng <[email protected]>--- net/ipv6/ip6_output.c | 80 +++++++++++++++++++++++++++++++++++++----------- 1 files changed, 61 insertions(+), 19 deletions(-)net/ipv6/ip6_output.c +2
-2@@ -1191,19 +1191,23 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,struct ipv6_pinfo *np =inet6_sk (sk);struct inet_cork *cork;struct sk_buff *skb; -unsigned int maxfraglen, fragheaderlen; +unsigned int maxfraglen, maxfraglen_prev, fragheaderlen;int exthdrlen;int dst_exthdrlen;int hh_len; -int mtu; +int mtu, mtu_prev;int copy;int err;int offset =0 ;
net/ipv6/ip6_output.c int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, · line 1210
Quoted 10 lines
net/ipv6/ip6_output.c +5
-1int csummode =CHECKSUM_NONE ;__u8 tx_flags =0 ; - +bool transport_mode = false; +struct xfrm_state *x = rt->dst.xfrm;if (flags&MSG_PROBE )return 0 ; +if (x && x->props.mode ==XFRM_MODE_TRANSPORT ) + transport_mode = true; +
Btw. beet mode should behave like transport mode here, just tunnel mode was changed to do fragmentation before the transformation.
David Miller
maintainerRe: [PATCH] ipv6: fix incorrect ipsec transport mode fragment
From: Steffen Klassert <[email protected]>
Date: Mon, 14 May 2012 15:05:28 +0200
Quoted 2 lines
There might be other opinions, but I don't like to see this IPsec mode dependent stuff hacked into the generic ipv6 output path.
Completely agreed.
Re: [PATCH] ipv6: fix incorrect ipsec transport mode fragment
In reply to Steffen KlassertHi steffen:
Quoted 20 lines · Steffen Klassert
Quoted 5 lines · Gao feng
Since commit 299b0767(ipv6: Fix IPsec slowpath fragmentation problem) the fragment of ipsec transport mode packets is incorrect. because tunnel mode needs IPsec headers and trailer for all fragments, while on transport mode it is sufficient to add the headers to the first fragment and the trailer to the last.
I mentioned this in an other thread some time ago,
this is due to commitad0081e43a
"ipv6: Fragment locally generated tunnel-mode IPSec6 packets as needed" changed tunnel mode to do fragmentation before the transformation while transport mode still does fragmentation after transformation. Now, tunnel mode needs IPsec headers and trailer for all fragments, while on transport mode it is sufficient to add the headers to the first fragment and the trailer to the last.Quoted 3 lines
so modify mtu and maxfraglen base on ipsec mode and if fragment is first or last.
Quoted 8 lines
There might be other opinions, but I don't like to see this IPsec mode dependent stuff hacked into the generic ipv6 output path.
Basically we have two cases. One where we have to add
rt->dst.header_lento the first fragment andrt->dst.trailer_lento the last fragment, and the other where we have to add both to all fragments. So perhaps we could isolate this code and create two functions, one for each case.
how about add a function pointer append_data to the struct rt6_info? so we can just call rt->append_data in ip6_append_data without conside witch mode it is.
of course, we will set rt->append_data appropriatly in xfrm_lookup.
But the only problem is this will bloats up rt6_info,I don't konw if it's worth doing it in this way.
Quoted 32 lines
Quoted 32 lines
with my test,it work well and does not trigger slow fragment path.
Signed-off-by Gao feng <[email protected]>--- net/ipv6/ip6_output.c | 80 +++++++++++++++++++++++++++++++++++++----------- 1 files changed, 61 insertions(+), 19 deletions(-)net/ipv6/ip6_output.c +4
-3@@ -1191,19 +1191,23 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,struct ipv6_pinfo *np =inet6_sk (sk);struct inet_cork *cork;struct sk_buff *skb; -unsigned int maxfraglen, fragheaderlen; +unsigned int maxfraglen, maxfraglen_prev, fragheaderlen;int exthdrlen;int dst_exthdrlen;int hh_len; -int mtu; +int mtu, mtu_prev;int copy;int err;int offset =0 ;int csummode =CHECKSUM_NONE ;__u8 tx_flags =0 ; - +bool transport_mode = false; +struct xfrm_state *x = rt->dst.xfrm;
Quoted 9 lines
net/ipv6/ip6_output.c int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, · line 1210
Quoted 5 lines
net/ipv6/ip6_output.c +3
-0if (flags&MSG_PROBE )return 0 ; +if (x && x->props.mode ==XFRM_MODE_TRANSPORT ) + transport_mode = true; +Btw. beet mode should behave like transport mode here, just tunnel mode was changed to do fragmentation before the transformation.
thanks steffen,I miss it and CONFIG_XFRM...
Steffen Klassert
maintainerRe: [PATCH] ipv6: fix incorrect ipsec transport mode fragment
Quoted 5 lines · Gao feng
how about add a function pointer
append_datato the structrt6_info? so we can just callrt->append_datainip6_append_datawithout conside witch mode it is.
If you want to use a function pointer, it should go to stuct xfrm_mode. That's where the IPsec mode dependent functions reside.
A side note, I'll be off for three weeks starting from tomorrow. I'll have no E-mail access most of the time, so I'll probaply not respond for the next three weeks.
Re: [PATCH] ipv6: fix incorrect ipsec transport mode fragment
Quoted 10 lines · Steffen Klassert
Quoted 5 lines · Gao feng
how about add a function pointer
append_datato the structrt6_info? so we can just callrt->append_datainip6_append_datawithout conside witch mode it is.If you want to use a function pointer, it should go to stuct
xfrm_mode. That's where the IPsec mode dependent functions reside.
Yes,I will do it.
Quoted 3 lines
A side note, I'll be off for three weeks starting from tomorrow. I'll have no E-mail access most of the time, so I'll probaply not respond for the next three weeks.
thanks for your response.
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] ipv6: fix incorrect ipsec transport mode fragment
In reply to David MillerQuoted 7 lines · David Miller
From: Steffen Klassert <[email protected]>
Date: Mon, 14 May 2012 15:05:28 +0200Quoted 2 lines
There might be other opinions, but I don't like to see this IPsec mode dependent stuff hacked into the generic ipv6 output path.
Completely agreed.
Hi David
how do you think about adding function pointer to struct xfrm_mode? when prefering xfrm_mode,there must be some ipsec codes in the generic ipv6 output path,just like below.it looks ugly.
int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
int offset, int len, int odd, struct sk_buff *skb),
void *from, int length, int transhdrlen,
int hlimit, int tclass, struct ipv6_txoptions *opt, struct flowi6 *fl6, struct rt6_info *rt, unsigned int flags, int dontfrag)
{
#ifdef CONFIG_XFRM
struct xfrm_state *x = rt->dst.xfrm;
if (x && x->outer_mode && x->outer_mode->append_data) {
x->outer_mode->append_data(...);
} else
#endif
__ip6_append_data(...);
}I want to use one bit of rt6_info->rt6i_flags to identify the actions we should do in ip6_append_data. BUT it seems not what the rt6i_flags should do.this may make rt6i_flags in chaos.
What's your comment?
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
David Miller
maintainerRe: [PATCH] ipv6: fix incorrect ipsec transport mode fragment
From: Gao feng <[email protected]>
Date: Thu, 17 May 2012 15:42:00 +0800
Quoted 1 line
What's your comment?
I don't have any, you will need to work this out yourself.
Re: [PATCH] ipv6: fix incorrect ipsec transport mode fragment
In reply to Steffen KlassertHi Steffen
Quoted 20 lines · Steffen Klassert
Quoted 5 lines · Gao feng
Since commit 299b0767(ipv6: Fix IPsec slowpath fragmentation problem) the fragment of ipsec transport mode packets is incorrect. because tunnel mode needs IPsec headers and trailer for all fragments, while on transport mode it is sufficient to add the headers to the first fragment and the trailer to the last.
I mentioned this in an other thread some time ago,
this is due to commitad0081e43a
"ipv6: Fragment locally generated tunnel-mode IPSec6 packets as needed" changed tunnel mode to do fragmentation before the transformation while transport mode still does fragmentation after transformation. Now, tunnel mode needs IPsec headers and trailer for all fragments, while on transport mode it is sufficient to add the headers to the first fragment and the trailer to the last.Quoted 3 lines
so modify mtu and maxfraglen base on ipsec mode and if fragment is first or last.
Quoted 9 lines
There might be other opinions, but I don't like to see this IPsec mode dependent stuff hacked into the generic ipv6 output path.
Basically we have two cases. One where we have to add
rt->dst.header_lento the first fragment andrt->dst.trailer_lento the last fragment, and the other where we have to add both to all fragments. So perhaps we could isolate this code and create two functions, one for each case.
I thought this problem carefully,I think the important and troubled thing is how to deal with transport mode.
we have to use different mtu and maxfraglen for checking if the prev_skb has extra data or has free room. so mtu_prev and maxfraglen_prev have to be used.
And I also think it's not very well to create two function for the two cases, it will create a lot of redundant codes.
I will add a dst_entry flag DST_XFRM_TUNNEL to avoid ipsec mode dependent stuff hacked into the generic ipv6_output path, and send patch v2.
PATCH v2 1/1 ipv6: fix incorrect ipsec fragment
In reply to Gao fengSince commit ad0081e43a
"ipv6: Fragment locally generated tunnel-mode IPSec6 packets as needed" the fragment of packets is incorrect.
because tunnel mode needs IPsec headers and trailer for all fragments, while on transport mode it is sufficient to add the headers to the first fragment and the trailer to the last.
so modify mtu and maxfraglen base on ipsec mode and if fragment is first or last.
with my test,it work well(every fragment's size is the mtu) and does not trigger slow fragment path.
Changes from v1:
though optimization, mtu_prev and maxfraglen_prev can be delete. replace xfrm mode codes with dst_entry's new frag DST_XFRM_TUNNEL. add fuction ip6_append_data_mtu to make codes clearer.
--- include/net/dst.h | 1 + net/ipv6/ip6_output.c | 68 +++++++++++++++++++++++++++++++++++------------ net/xfrm/xfrm_policy.c | 3 ++ 3 files changed, 54 insertions(+), 18 deletions(-)
include/net/dst.h +1 -0
@@ -60,6 +60,7 @@ struct dst_entry {#define DST_NOCOUNT 0x0020#define DST_NOPEER 0x0040#define DST_FAKE_RTABLE 0x0080 +#define DST_XFRM_TUNNEL 0x0100short error;short obsolete;
net/ipv6/ip6_output.c +50 -18
109 lines not on this page · raw message
net/xfrm/xfrm_policy.c +3 -0
@@ -1921,6 +1921,9 @@ no_transform: } ok:xfrm_pols_put (pols, drop_pols); +if (dst && dst->xfrm && + dst->xfrm->props.mode ==XFRM_MODE_TUNNEL ) + dst->flags |=DST_XFRM_TUNNEL ;return dst; nopol:
Signature · 1 line
1.7.7.6
Re: [PATCH] ipv6: fix incorrect ipsec transport mode fragment
In reply to Gao fengQuoted 33 lines · Gao feng
Hi Steffen
Quoted 20 lines · Steffen Klassert
Quoted 5 lines · Gao feng
Since commit 299b0767(ipv6: Fix IPsec slowpath fragmentation problem) the fragment of ipsec transport mode packets is incorrect. because tunnel mode needs IPsec headers and trailer for all fragments, while on transport mode it is sufficient to add the headers to the first fragment and the trailer to the last.
I mentioned this in an other thread some time ago,
this is due to commitad0081e43a
"ipv6: Fragment locally generated tunnel-mode IPSec6 packets as needed" changed tunnel mode to do fragmentation before the transformation while transport mode still does fragmentation after transformation. Now, tunnel mode needs IPsec headers and trailer for all fragments, while on transport mode it is sufficient to add the headers to the first fragment and the trailer to the last.Quoted 3 lines
so modify mtu and maxfraglen base on ipsec mode and if fragment is first or last.
Quoted 9 lines
There might be other opinions, but I don't like to see this IPsec mode dependent stuff hacked into the generic ipv6 output path.
Basically we have two cases. One where we have to add
rt->dst.header_lento the first fragment andrt->dst.trailer_lento the last fragment, and the other where we have to add both to all fragments. So perhaps we could isolate this code and create two functions, one for each case.
Quoted 6 lines
I thought this problem carefully,I think the important and troubled thing is how to deal with transport mode.
we have to use different mtu and maxfraglen for checking if the
prev_skbhas extra data or has free room. somtu_prevandmaxfraglen_prevhave to be used.
I found we can delete the mtu_prev and maxfraglen prev ;)
Re: [PATCH v2] ipv6: fix incorrect ipsec fragment
In reply to Gao fengFrom: Gao feng <[email protected]>
Date: Sat, 26 May 2012 19:30:53 +0800
Quoted 13 lines
Since commit
ad0081e43a
"ipv6: Fragment locally generated tunnel-mode IPSec6 packets as needed" the fragment of packets is incorrect.
because tunnel mode needs IPsec headers and trailer for all fragments, while on transport mode it is sufficient to add the headers to the first fragment and the trailer to the last.so modify mtu and maxfraglen base on ipsec mode and if fragment is first or last.
with my test,it work well(every fragment's size is the mtu) and does not trigger slow fragment path.
Quoted 6 lines
Changes from v1:
though optimization,mtu_prevandmaxfraglen_prevcan be delete. replace xfrm mode codes with dst_entry's new fragDST_XFRM_TUNNEL. add fuctionip6_append_data_mtuto make codes clearer.Signed-off-by Gao feng <[email protected]>
Applied, and queued up for -stable, thanks.