netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Change xt_TOS v1 target to zero-out semantic
@ 2007-12-15 13:48 Jan Engelhardt
  2007-12-17 13:04 ` Patrick McHardy
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Engelhardt @ 2007-12-15 13:48 UTC (permalink / raw)
  To: kaber; +Cc: Netfilter Developer Mailing List


This patch changes the behavior of xt_TOS v1 so that the mask value
one supplies means "zero out these bits" rather than "keep these
bits". This is more easy on the user, as (I would assume) people
keep more bits than zeroing, so, an example:

	Action: Set bit 0x01.
	before: iptables -j TOS --set-tos 0x01/0xFE
	after:  iptables -j TOS --set-tos 0x01/0x01

This is not too "tragic" with xt_TOS, but where larger fields are
used (e.g. proposed xt_MARK v2), `--set-xmark 0x01/0xFFFFFFFE` vs.
`--set-xmark 0x01/0x01` is really a worthy difference.
Other modules, such as xt_TPROXY also use &~ rather than &, so
let's find a common ground.

(We can apply this patch because xt_TOS v1 is currently only in the
development tree, not mainline.)

Signed-off-by: Jan Engelhardt <jengelh@computergmbh.de>

---
 net/netfilter/xt_DSCP.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/net/netfilter/xt_DSCP.c
===================================================================
--- linux-2.6.orig/net/netfilter/xt_DSCP.c
+++ linux-2.6/net/netfilter/xt_DSCP.c
@@ -128,7 +128,7 @@ tos_tg(struct sk_buff *skb, const struct
 	u_int8_t orig, nv;
 
 	orig = ipv4_get_dsfield(iph);
-	nv   = (orig & info->tos_mask) ^ info->tos_value;
+	nv   = (orig & ~info->tos_mask) ^ info->tos_value;
 
 	if (orig != nv) {
 		if (!skb_make_writable(skb, sizeof(struct iphdr)))


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-12-17 13:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-15 13:48 [PATCH] Change xt_TOS v1 target to zero-out semantic Jan Engelhardt
2007-12-17 13:04 ` Patrick McHardy
2007-12-17 13:09   ` Jan Engelhardt
2007-12-17 13:13     ` Patrick McHardy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).