aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfan.du <fan.du@windriver.com>2013-12-01 03:28:48 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-08 10:29:26 -0500
commitdd5e5276c4e7922e784c156be630972341d51370 (patch)
tree97dea37846c740aa02f745ac2fae5c6762af23e2
parente761bada6f1eb056e720afd5704a21a79fb8df35 (diff)
{pktgen, xfrm} Update IPv4 header total len and checksum after tranformation
[ Upstream commit 3868204d6b89ea373a273e760609cb08020beb1a ] 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> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--net/core/pktgen.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 11f2704c3810..ebbea5371967 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2515,6 +2515,8 @@ static int process_ipsec(struct pktgen_dev *pkt_dev,
2515 if (x) { 2515 if (x) {
2516 int ret; 2516 int ret;
2517 __u8 *eth; 2517 __u8 *eth;
2518 struct iphdr *iph;
2519
2518 nhead = x->props.header_len - skb_headroom(skb); 2520 nhead = x->props.header_len - skb_headroom(skb);
2519 if (nhead > 0) { 2521 if (nhead > 0) {
2520 ret = pskb_expand_head(skb, nhead, 0, GFP_ATOMIC); 2522 ret = pskb_expand_head(skb, nhead, 0, GFP_ATOMIC);
@@ -2536,6 +2538,11 @@ static int process_ipsec(struct pktgen_dev *pkt_dev,
2536 eth = (__u8 *) skb_push(skb, ETH_HLEN); 2538 eth = (__u8 *) skb_push(skb, ETH_HLEN);
2537 memcpy(eth, pkt_dev->hh, 12); 2539 memcpy(eth, pkt_dev->hh, 12);
2538 *(u16 *) &eth[12] = protocol; 2540 *(u16 *) &eth[12] = protocol;
2541
2542 /* Update IPv4 header len as well as checksum value */
2543 iph = ip_hdr(skb);
2544 iph->tot_len = htons(skb->len - ETH_HLEN);
2545 ip_send_check(iph);
2539 } 2546 }
2540 } 2547 }
2541 return 1; 2548 return 1;