Skip to contentSkip to conversation

e1000: Fix TCP checksum overflow with TSO

PATCH Applied Alex Williamson 2 participants 2 messages Nov 5, 2010 – Nov 8, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 e1000: Fix TCP checksum overflow with TSO

When adding the length to the pseudo header, we're not properly accounting for overflow.

From: Mark Wu <[email protected]>

---

 hw/e1000.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
hw/e1000.c +4 -1
index 532efdc..677165f 100644
@@ -384,9 +384,12 @@ xmit_seg(E1000State *s)
         } else	// UDP
             cpu_to_be16wu((uint16_t *)(tp->data+css+4), len);
         if (tp->sum_needed & E1000_TXD_POPTS_TXSM) {
+            unsigned int phsum;
             // add pseudo-header length before checksum calculation
             sp = (uint16_t *)(tp->data + tp->tucso);
-            cpu_to_be16wu(sp, be16_to_cpup(sp) + len);
+            phsum = be16_to_cpup(sp) + len;
+            phsum = (phsum >> 16) + (phsum & 0xffff);
+            cpu_to_be16wu(sp, phsum);
         }
         tp->tso_frames++;
     }
#1 lore raw
Quoted 5 lines · Alex Williamson

When adding the length to the pseudo header, we're not properly accounting for overflow.

From: Mark Wu <[email protected]>

Thanks, applied.

Quoted 23 lines

---

 hw/e1000.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
hw/e1000.c +4 -1
index 532efdc..677165f 100644
@@ -384,9 +384,12 @@ xmit_seg(E1000State *s)
         } else	// UDP
             cpu_to_be16wu((uint16_t *)(tp->data+css+4), len);
         if (tp->sum_needed & E1000_TXD_POPTS_TXSM) {
+            unsigned int phsum;
             // add pseudo-header length before checksum calculation
             sp = (uint16_t *)(tp->data + tp->tucso);
-            cpu_to_be16wu(sp, be16_to_cpup(sp) + len);
+            phsum = be16_to_cpup(sp) + len;
+            phsum = (phsum >> 16) + (phsum & 0xffff);
+            cpu_to_be16wu(sp, phsum);
         }
         tp->tso_frames++;
     }