bsn_flow_checksum: change checksum XOR operation to add/subtract
diff --git a/tests-1.3/bsn_flow_checksum.py b/tests-1.3/bsn_flow_checksum.py
index 26f40e9..2a21e68 100644
--- a/tests-1.3/bsn_flow_checksum.py
+++ b/tests-1.3/bsn_flow_checksum.py
@@ -29,6 +29,32 @@
     random.shuffle(l)
     return l
 
+def add_checksum(a, b):
+    return (a + b) % 2**64
+
+def subtract_checksum(a, b):
+    return (a - b) % 2**64
+
+def bucket_index(num_buckets, checksum):
+    """
+    Use the top bits of the checksum to select a bucket index
+    """
+    return checksum >> (64 - int(math.log(num_buckets, 2)))
+
+def add_bucket_checksum(buckets, checksum):
+    """
+    Add the checksum to the correct bucket
+    """
+    index = bucket_index(len(buckets), checksum)
+    buckets[index] = add_checksum(buckets[index], checksum)
+
+def subtract_bucket_checksum(buckets, checksum):
+    """
+    Subtract the checksum from the correct bucket
+    """
+    index = bucket_index(len(buckets), checksum)
+    buckets[index] = subtract_checksum(buckets[index], checksum)
+
 class FlowChecksumBase(base_tests.SimpleProtocol):
     """
     Base class that maintains the expected table and bucket checksums
@@ -52,17 +78,14 @@
         self.assertEquals(self.get_table_checksum(), self.table_checksum)
         self.assertEquals(self.get_checksum_buckets(), self.checksum_buckets)
 
-    def update_checksums(self, checksum):
-        self.table_checksum ^= checksum
-        checksum_shift = 64 - int(math.log(len(self.checksum_buckets), 2))
-        self.checksum_buckets[checksum >> checksum_shift] ^= checksum
-
     def insert_checksum(self, checksum):
-        self.update_checksums(checksum)
+        self.table_checksum = add_checksum(self.table_checksum, checksum)
+        add_bucket_checksum(self.checksum_buckets, checksum)
         self.all_checksums.append(checksum)
 
     def remove_checksum(self, checksum):
-        self.update_checksums(checksum)
+        self.table_checksum = subtract_checksum(self.table_checksum, checksum)
+        subtract_bucket_checksum(self.checksum_buckets, checksum)
         self.all_checksums.remove(checksum)
 
     def set_buckets_size(self, buckets_size):
@@ -72,10 +95,12 @@
         do_barrier(self.controller)
         verify_no_errors(self.controller)
 
+        old_checksums = self.all_checksums
+        self.all_checksums = []
         self.checksum_buckets = [0] * buckets_size
         self.table_checksum = 0
-        for checksum in self.all_checksums:
-            self.update_checksums(checksum)
+        for checksum in old_checksums:
+            self.insert_checksum(checksum)
 
 class FlowChecksum(FlowChecksumBase):
     """