The math is done in network byte order so the 32 bits won't
match between big and little endian, so the assert fails.
Reduce to 16 bits and then compare to the converted constant.
Signed-off-by: Flavio Leitner <fbl@redhat.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
static void
test_pseudo(void)
{
+ ovs_be16 csum;
/* Try an IP header similar to one that the tunnel code
* might generate. */
struct ip_header ip = {
.ip_dst = { .hi = htons(0x1400), .lo = htons(0x0001) }
};
- assert(packet_csum_pseudoheader(&ip) == 0x8628);
+ csum = csum_finish(packet_csum_pseudoheader(&ip));
+ assert(csum == htons(0xd779));
/* And also test something totally different to check for
* corner cases. */
memset(&ip, 0xff, sizeof ip);
- assert(packet_csum_pseudoheader(&ip) == 0x5c2fb);
+ csum = csum_finish(packet_csum_pseudoheader(&ip));
+ assert(csum == htons(0xff3c));
mark('#');
}