Skip to contentSkip to conversation

ipt_TOS fix.

PATCH New Rusty Russell 1 participant 1 message Jan 29, 2001

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipt_TOS fix.

Linus, please apply v2.4.0.

ipt_TOS checksum calculations were completely broken, causing bad csum packets. Whoever implemented it didn't understand the code it was copied from.

This fixes the problem (tested in userspace against all TOS changes).

Rusty.
--
Premature optmztion is rt of all evl. --DK

net/ipv4/netfilter/ipt_TOS.c +3 -3
diff -urN -I \$.*\$ -X /tmp/kerndiff.ZtZl97 --minimal linux-2.4.0-official/net/ipv4/netfilter/ipt_TOS.c working-2.4.0/net/ipv4/netfilter/ipt_TOS.c
@@ -19,11 +19,11 @@
 	const struct ipt_tos_target_info *tosinfo = targinfo;
 
 	if ((iph->tos & IPTOS_TOS_MASK) != tosinfo->tos) {
-		u_int8_t diffs[2];
+		u_int16_t diffs[2];
 
-		diffs[0] = iph->tos;
+		diffs[0] = htons(iph->tos) ^ 0xFFFF;
 		iph->tos = (iph->tos & IPTOS_PREC_MASK) | tosinfo->tos;
-		diffs[1] = iph->tos;
+		diffs[1] = htons(iph->tos);
 		iph->check = csum_fold(csum_partial((char *)diffs,
 		                                    sizeof(diffs),
 		                                    iph->check^0xFFFF));

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/