* [PATCHv2 net] {pktgen, xfrm} Update IPv4 header total len and checksum after tranformation
@ 2013-12-01 8:28 Fan Du
2013-12-02 1:35 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Fan Du @ 2013-12-01 8:28 UTC (permalink / raw)
To: steffen.klassert; +Cc: davem, netdev
commit a553e4a6317b2cfc7659542c10fe43184ffe53da ("[PKTGEN]: IPSEC support")
tried to support IPsec ESP transport transformation for pktgen, but acctually
this doesn't work at all for two reasons(The orignal transformed packet has
bad IPv4 checksum value, as well as wrong auth value, reported by wireshark)
- After transpormation, IPv4 header total length needs update,
because encrypted payload's length is NOT same as that of plain text.
- After transformation, IPv4 checksum needs re-caculate because of payload
has been changed.
With this patch, armmed pktgen with below cofiguration, Wireshark is able to
decrypted ESP packet generated by pktgen without any IPv4 checksum error or
auth value error.
pgset "flag IPSEC"
pgset "flows 1"
Signed-off-by: Fan Du <fan.du@windriver.com>
---
v2:
- compute IPv4 checksum only after transformation taken place.
- This weekend I also noticed auth value is not correct as well, further
investigation indicates IPv4 header length is not updated after
transformation.,so v2 fix this.
---
net/core/pktgen.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 261357a..0bb8e5c 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2527,6 +2527,8 @@ static int process_ipsec(struct pktgen_dev *pkt_dev,
if (x) {
int ret;
__u8 *eth;
+ struct iphdr *iph;
+
nhead = x->props.header_len - skb_headroom(skb);
if (nhead > 0) {
ret = pskb_expand_head(skb, nhead, 0, GFP_ATOMIC);
@@ -2548,6 +2550,11 @@ static int process_ipsec(struct pktgen_dev *pkt_dev,
eth = (__u8 *) skb_push(skb, ETH_HLEN);
memcpy(eth, pkt_dev->hh, 12);
*(u16 *) ð[12] = protocol;
+
+ /* Update IPv4 header len as well as checksum value */
+ iph = ip_hdr(skb);
+ iph->tot_len = htons(skb->len - ETH_HLEN);
+ ip_send_check(iph);
}
}
return 1;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCHv2 net] {pktgen, xfrm} Update IPv4 header total len and checksum after tranformation
2013-12-01 8:28 [PATCHv2 net] {pktgen, xfrm} Update IPv4 header total len and checksum after tranformation Fan Du
@ 2013-12-02 1:35 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2013-12-02 1:35 UTC (permalink / raw)
To: fan.du; +Cc: steffen.klassert, netdev
From: Fan Du <fan.du@windriver.com>
Date: Sun, 1 Dec 2013 16:28:48 +0800
> commit a553e4a6317b2cfc7659542c10fe43184ffe53da ("[PKTGEN]: IPSEC support")
> tried to support IPsec ESP transport transformation for pktgen, but acctually
> this doesn't work at all for two reasons(The orignal transformed packet has
> bad IPv4 checksum value, as well as wrong auth value, reported by wireshark)
>
> - After transpormation, IPv4 header total length needs update,
> because encrypted payload's length is NOT same as that of plain text.
>
> - After transformation, IPv4 checksum needs re-caculate because of payload
> has been changed.
>
> With this patch, armmed pktgen with below cofiguration, Wireshark is able to
> decrypted ESP packet generated by pktgen without any IPv4 checksum error or
> auth value error.
>
> pgset "flag IPSEC"
> pgset "flows 1"
>
> Signed-off-by: Fan Du <fan.du@windriver.com>
Applied and queued up for -stable, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-12-02 1:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-01 8:28 [PATCHv2 net] {pktgen, xfrm} Update IPv4 header total len and checksum after tranformation Fan Du
2013-12-02 1:35 ` David Miller
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).