--- build-i386-xen-686/drivers/xen/netback/netback.c.orig	2006-11-30 21:10:20.000000000 +0100
+++ build-i386-xen-686/drivers/xen/netback/netback.c	2006-11-30 21:14:42.000000000 +0100
@@ -804,7 +804,7 @@
 
 static void tx_add_credit(netif_t *netif)
 {
-	unsigned long max_burst;
+	unsigned long max_burst, max_credit;
 
 	/*
 	 * Allow a burst big enough to transmit a jumbo packet of up to 128kB.
@@ -814,9 +814,12 @@
 	max_burst = min(max_burst, 131072UL);
 	max_burst = max(max_burst, netif->credit_bytes);
 
-	netif->remaining_credit = min(netif->remaining_credit +
-				      netif->credit_bytes,
-				      max_burst);
+	/* Take care that adding a new chunk of credit doesn't wrap to zero. */
+	max_credit = netif->remaining_credit + netif->credit_bytes;
+	if (max_credit < netif->remaining_credit)
+		max_credit = ULONG_MAX; /* wrapped: clamp to ULONG_MAX */
+
+	netif->remaining_credit = min(max_credit, max_burst);
 }
 
 static void tx_credit_callback(unsigned long data)
