Skip to contentSkip to conversation

netfilter/IPv6: fix DSCP mangle code

PATCH In review Fernando Luis Vazquez Cao 5 participants 20 messages Apr 22, 2011 – May 6, 2011

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

PATCH 1/1 netfilter/IPv6: fix DSCP mangle code

The mask indicates the bits one wants to zero out, so it needs to be inverted before applying to the original TOS field.

---

net/netfilter/xt_DSCP.c +1 -1
diff -urNp linux-2.6.37-orig/net/netfilter/xt_DSCP.c linux-2.6.37/net/netfilter/xt_DSCP.c
@@ -99,7 +99,7 @@ tos_tg6(struct sk_buff *skb, const struc
 	u_int8_t orig, nv;
 
 	orig = ipv6_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)))
maintainer
#1 lore raw

From: Fernando Luis Vazquez Cao <[email protected]>
Date: Fri, 22 Apr 2011 16:02:39 +0900

Quoted 5 lines

The mask indicates the bits one wants to zero out, so it needs to be inverted before applying to the original TOS field.

---

Netfilter patches should be sent to the netfilter developer list, CC:'d

Quoted 14 lines

diff -urNp linux-2.6.37-orig/net/netfilter/xt_DSCP.c linux-2.6.37/net/netfilter/xt_DSCP.c

net/netfilter/xt_DSCP.c +1 -1
@@ -99,7 +99,7 @@ tos_tg6(struct sk_buff *skb, const struc
 	u_int8_t orig, nv;
 
 	orig = ipv6_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)))
#2 lore raw
Quoted 11 lines · David Miller

From: Fernando Luis Vazquez Cao <[email protected]>
Date: Fri, 22 Apr 2011 16:02:39 +0900

Quoted 5 lines

The mask indicates the bits one wants to zero out, so it needs to be inverted before applying to the original TOS field.

---

Netfilter patches should be sent to the netfilter developer list, CC:'d

Thank you for the heads-up, David.

By the way, I have just sent one more patch that fixes what I think is another netfilter bug. If everyone is ok with these two patches it would be great if we could get them merged for the next -rc release (we hit these bugs in our production systems).

Regards,
Fernando

#3 lore raw

PATCH 1/1 netfilter/IPv6: initialize TOS field in REJECT target module

In reply to Fernando Luis Vazquez Cao

The IPv6 header is not zeroed out in alloc_skb so we must initialize it properly unless we want to see IPv6 packets with random TOS fields floating around. The current implementation resets the flow label but this could be changed if deemed necessary.

We stumbled upon this issue when trying to apply a mangle rule to the RST packet generated by the REJECT target module.

---

net/ipv6/netfilter/ip6t_REJECT.c +3 -1
diff -urNp linux-2.6.38.4-orig/net/ipv6/netfilter/ip6t_REJECT.c linux-2.6.38.4/net/ipv6/netfilter/ip6t_REJECT.c
@@ -45,6 +45,8 @@ static void send_reset(struct net *net,
 	int tcphoff, needs_ack;
 	const struct ipv6hdr *oip6h = ipv6_hdr(oldskb);
 	struct ipv6hdr *ip6h;
+#define DEFAULT_TOS_VALUE	0x0U
+	const __u8 tclass = DEFAULT_TOS_VALUE;
 	struct dst_entry *dst = NULL;
 	u8 proto;
 	struct flowi fl;
@@ -123,7 +125,7 @@ static void send_reset(struct net *net,
 	skb_put(nskb, sizeof(struct ipv6hdr));
 	skb_reset_network_header(nskb);
 	ip6h = ipv6_hdr(nskb);
-	ip6h->version = 6;
+	*(__be32 *)ip6h =  htonl(0x60000000 | (tclass << 20));
 	ip6h->hop_limit = ip6_dst_hoplimit(dst);
 	ip6h->nexthdr = IPPROTO_TCP;
 	ipv6_addr_copy(&ip6h->saddr, &oip6h->daddr);
#4 lore raw

Re: [PATCH] netfilter/IPv6: initialize TOS field in REJECT target module

Le vendredi 22 avril 2011 à 16:19 +0900, Fernando Luis Vazquez Cao a écrit :

Quoted 24 lines

The IPv6 header is not zeroed out in alloc_skb so we must initialize it properly unless we want to see IPv6 packets with random TOS fields floating around. The current implementation resets the flow label but this could be changed if deemed necessary.

We stumbled upon this issue when trying to apply a mangle rule to the RST packet generated by the REJECT target module.

---

diff -urNp linux-2.6.38.4-orig/net/ipv6/netfilter/ip6t_REJECT.c linux-2.6.38.4/net/ipv6/netfilter/ip6t_REJECT.c

net/ipv6/netfilter/ip6t_REJECT.c +2 -0
@@ -45,6 +45,8 @@ static void send_reset(struct net *net,
 	int tcphoff, needs_ack;
 	const struct ipv6hdr *oip6h = ipv6_hdr(oldskb);
 	struct ipv6hdr *ip6h;
+#define DEFAULT_TOS_VALUE	0x0U
+	const __u8 tclass = DEFAULT_TOS_VALUE;
 	struct dst_entry *dst = NULL;
 	u8 proto;
 	struct flowi fl;

net/ipv6/netfilter/ip6t_REJECT.c static void send_reset(struct net *net, · line 128

Quoted 5 lines
net/ipv6/netfilter/ip6t_REJECT.c +1 -1
@@ -123,7 +125,7 @@ static void send_reset(struct net *net,
 	skb_put(nskb, sizeof(struct ipv6hdr));
 	skb_reset_network_header(nskb);
 	ip6h = ipv6_hdr(nskb);
-	ip6h->version = 6;
+	*(__be32 *)ip6h =  htonl(0x60000000 | (tclass << 20));

It seems fine but I am wondering where is payload_len set ?

#5 lore raw

Re: [PATCH] netfilter/IPv6: initialize TOS field in REJECT target module

Quoted 25 lines · Eric Dumazet

Le vendredi 22 avril 2011 à 16:19 +0900, Fernando Luis Vazquez Cao a écrit :

Quoted 23 lines

The IPv6 header is not zeroed out in alloc_skb so we must initialize it properly unless we want to see IPv6 packets with random TOS fields floating around. The current implementation resets the flow label but this could be changed if deemed necessary.

We stumbled upon this issue when trying to apply a mangle rule to the RST packet generated by the REJECT target module.

---

diff -urNp linux-2.6.38.4-orig/net/ipv6/netfilter/ip6t_REJECT.c linux-2.6.38.4/net/ipv6/netfilter/ip6t_REJECT.c

net/ipv6/netfilter/ip6t_REJECT.c +2 -0
@@ -45,6 +45,8 @@ static void send_reset(struct net *net,
 	int tcphoff, needs_ack;
 	const struct ipv6hdr *oip6h = ipv6_hdr(oldskb);
 	struct ipv6hdr *ip6h;
+#define DEFAULT_TOS_VALUE	0x0U
+	const __u8 tclass = DEFAULT_TOS_VALUE;
 	struct dst_entry *dst = NULL;
 	u8 proto;
 	struct flowi fl;
Quoted 8 lines

net/ipv6/netfilter/ip6t_REJECT.c static void send_reset(struct net *net, · line 128

Quoted 6 lines
net/ipv6/netfilter/ip6t_REJECT.c +1 -1
@@ -123,7 +125,7 @@ static void send_reset(struct net *net,
 	skb_put(nskb, sizeof(struct ipv6hdr));
 	skb_reset_network_header(nskb);
 	ip6h = ipv6_hdr(nskb);
-	ip6h->version = 6;
+	*(__be32 *)ip6h =  htonl(0x60000000 | (tclass << 20));

It seems fine but I am wondering where is payload_len set ?

Hi Eric,

Thank you for the review, I really appreciate it.

payload_len is set in __ip6_local_out() which is called from ip6_local_out.

Could I get your acked-by for the two patches I sent?

Thanks,
Fernando

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Acked-by
#6 lore raw

Re: [PATCH] netfilter/IPv6: initialize TOS field in REJECT target module

Le vendredi 22 avril 2011 à 16:47 +0900, Fernando Luis Vazquez Cao a écrit :

Quoted 7 lines

Hi Eric,

Thank you for the review, I really appreciate it.

payload_len is set in __ip6_local_out() which is called from ip6_local_out.

Thats right, thanks !

Quoted 2 lines

Could I get your acked-by for the two patches I sent?

Sure

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw

Re: [PATCH] netfilter/IPv6: initialize TOS field in REJECT target module

Quoted 8 lines · Eric Dumazet

Le vendredi 22 avril 2011 à 16:47 +0900, Fernando Luis Vazquez Cao a écrit :

Quoted 2 lines

Could I get your acked-by for the two patches I sent?

Sure

Thank you!

Should we send these two patches to -stable too?

#8 lore raw

Re: [PATCH] netfilter/IPv6: initialize TOS field in REJECT target module

Le vendredi 22 avril 2011 à 17:11 +0900, Fernando Luis Vazquez Cao a écrit :

Quoted 4 lines

Thank you!

Should we send these two patches to -stable too?

David takes care of stable submissions for netdev stuff, thanks.

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#9 lore raw

Re: [PATCH] netfilter/IPv6: initialize TOS field in REJECT target module

Quoted 8 lines · Eric Dumazet

Le vendredi 22 avril 2011 à 17:11 +0900, Fernando Luis Vazquez Cao a écrit :

Quoted 3 lines

Thank you!

Should we send these two patches to -stable too?

David takes care of stable submissions for netdev stuff, thanks.

If the patch follows the netfilter path, we'll take care of sending stable submissions.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#10 lore raw

Re: [PATCH] netfilter/IPv6: initialize TOS field in REJECT target module

Quoted 4 lines · Pablo Neira Ayuso
Quoted 3 lines · Eric Dumazet

Le vendredi 22 avril 2011 à 17:11 +0900, Fernando Luis Vazquez Cao a écrit :

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Thank you!

Should we send these two patches to -stable too?

David takes care of stable submissions for netdev stuff, thanks.

If the patch follows the netfilter path, we'll take care of sending stable submissions.

David, will you take care of these two patches or should they go through the netfilter tree?

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#11 lore raw

Re: [PATCH] netfilter/IPv6: initialize TOS field in REJECT target module

From: Fernando Luis Vazquez Cao <[email protected]>
Date: Tue, 26 Apr 2011 10:26:20 +0900

Quoted 9 lines · Pablo Neira Ayuso
Quoted 8 lines · Eric Dumazet
Quoted 7 lines

Le vendredi 22 avril 2011 à 17:11 +0900, Fernando Luis Vazquez Cao a écrit :

Quoted 3 lines

Thank you!

Should we send these two patches to -stable too?

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

David takes care of stable submissions for netdev stuff, thanks.

If the patch follows the netfilter path, we'll take care of sending stable submissions.

David, will you take care of these two patches or should they go through the netfilter tree?

Netfilter, as usual.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#12 lore raw

Re: [PATCH] netfilter/IPv6: initialize TOS field in REJECT target module

Quoted 14 lines · David Miller

From: Fernando Luis Vazquez Cao <[email protected]>
Date: Tue, 26 Apr 2011 10:26:20 +0900

Quoted 11 lines · Pablo Neira Ayuso
Quoted 10 lines · Eric Dumazet
Quoted 8 lines

Le vendredi 22 avril 2011 à 17:11 +0900, Fernando Luis Vazquez Cao a écrit :

Quoted 3 lines

Thank you!

Should we send these two patches to -stable too?

David takes care of stable submissions for netdev stuff, thanks.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

If the patch follows the netfilter path, we'll take care of sending stable submissions.

David, will you take care of these two patches or should they go through the netfilter tree?

Netfilter, as usual.

Thank you for the clarification. I really appreciate it.

Pablo, could you pull in the two patches below? They have already been acked by Eric. It would be great it we could get them merged for the next -rc and stable releases.

[PATCH] netfilter/IPv6: fix DSCP mangle code
[PATCH] netfilter/IPv6: initialize TOS field in REJECT target module

- Fernando

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#13 lore raw

Re: [PATCH] netfilter/IPv6: initialize TOS field in REJECT target module

Quoted 23 lines · Fernando Luis Vazquez Cao
Quoted 14 lines · David Miller

From: Fernando Luis Vazquez Cao <[email protected]>
Date: Tue, 26 Apr 2011 10:26:20 +0900

Quoted 11 lines · Pablo Neira Ayuso
Quoted 10 lines · Eric Dumazet
Quoted 8 lines

Le vendredi 22 avril 2011 à 17:11 +0900, Fernando Luis Vazquez Cao a écrit :

Quoted 3 lines

Thank you!

Should we send these two patches to -stable too?

David takes care of stable submissions for netdev stuff, thanks.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

If the patch follows the netfilter path, we'll take care of sending stable submissions.

David, will you take care of these two patches or should they go through the netfilter tree?

Netfilter, as usual.

Quoted 8 lines

Thank you for the clarification. I really appreciate it.

Pablo, could you pull in the two patches below? They have already been acked by Eric. It would be great it we could get them merged for the next -rc and stable releases.

[PATCH] netfilter/IPv6: fix DSCP mangle code
[PATCH] netfilter/IPv6: initialize TOS field in REJECT target module

Patrick is the primary link to take patches, I'm including him in this CC. If he experiences any problem, I'll make sure that these hit -rc, so never mind.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#14 lore raw

Re: [PATCH] netfilter/IPv6: initialize TOS field in REJECT target module

Quoted 30 lines · Pablo Neira Ayuso
Quoted 29 lines · Fernando Luis Vazquez Cao
Quoted 14 lines · David Miller

From: Fernando Luis Vazquez Cao <[email protected]>
Date: Tue, 26 Apr 2011 10:26:20 +0900

Quoted 11 lines · Pablo Neira Ayuso
Quoted 10 lines · Eric Dumazet
Quoted 8 lines

Le vendredi 22 avril 2011 à 17:11 +0900, Fernando Luis Vazquez Cao a écrit :

Quoted 3 lines

Thank you!

Should we send these two patches to -stable too?

David takes care of stable submissions for netdev stuff, thanks.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

If the patch follows the netfilter path, we'll take care of sending stable submissions.

David, will you take care of these two patches or should they go through the netfilter tree?

Netfilter, as usual.

Thank you for the clarification. I really appreciate it.

Pablo, could you pull in the two patches below? They have already been acked by Eric. It would be great it we could get them merged for the next -rc and stable releases.

Quoted 6 lines
Quoted 2 lines

[PATCH] netfilter/IPv6: fix DSCP mangle code
[PATCH] netfilter/IPv6: initialize TOS field in REJECT target module

Patrick is the primary link to take patches, I'm including him in this CC. If he experiences any problem, I'll make sure that these hit -rc, so never mind.

^^^^^^^^^^

Sorry, I meant to say, "don't worry" :-)

#15 lore raw

Re: [PATCH] netfilter/IPv6: initialize TOS field in REJECT target module

Quoted 9 lines · Pablo Neira Ayuso
Quoted 8 lines · Pablo Neira Ayuso
Quoted 6 lines · Fernando Luis Vazquez Cao

Pablo, could you pull in the two patches below? They have already been acked by Eric. It would be great it we could get them merged for the next -rc and stable releases.

[PATCH] netfilter/IPv6: fix DSCP mangle code
[PATCH] netfilter/IPv6: initialize TOS field in REJECT target module

Quoted 6 lines
Quoted 3 lines

Patrick is the primary link to take patches, I'm including him in this CC. If he experiences any problem, I'll make sure that these hit -rc, so never mind.

^^^^^^^^^^

Sorry, I meant to say, "don't worry" :-)

Thank you, Pablo. I really appreciate it.

- Fernando

#16 lore raw

Re: [PATCH] netfilter/IPv6: initialize TOS field in REJECT target module

In reply to Pablo Neira Ayuso
Quoted 11 lines · Pablo Neira Ayuso
Quoted 6 lines · Fernando Luis Vazquez Cao

Pablo, could you pull in the two patches below? They have already been acked by Eric. It would be great it we could get them merged for the next -rc and stable releases.

[PATCH] netfilter/IPv6: fix DSCP mangle code
[PATCH] netfilter/IPv6: initialize TOS field in REJECT target module

Patrick is the primary link to take patches, I'm including him in this CC. If he experiences any problem, I'll make sure that these hit -rc, so never mind.

It seems that the two patches above did not make it into 2.6.39-rc6. Any chance we can get them merged before 2.6.39 is released?

Thanks,
Fernando

#17 lore raw

Re: [PATCH] netfilter/IPv6: initialize TOS field in REJECT target module

Quoted 9 lines · Fernando Luis Vázquez Cao
Quoted 8 lines · Pablo Neira Ayuso
Quoted 6 lines · Fernando Luis Vazquez Cao

Pablo, could you pull in the two patches below? They have already been acked by Eric. It would be great it we could get them merged for the next -rc and stable releases.

[PATCH] netfilter/IPv6: fix DSCP mangle code
[PATCH] netfilter/IPv6: initialize TOS field in REJECT target module

Quoted 6 lines
Quoted 3 lines

Patrick is the primary link to take patches, I'm including him in this CC. If he experiences any problem, I'll make sure that these hit -rc, so never mind.

It seems that the two patches above did not make it into 2.6.39-rc6. Any chance we can get them merged before 2.6.39 is released?

I'll pick them and push them to davem by monday. Thanks!

#18 lore raw

Re: [PATCH] netfilter/IPv6: initialize TOS field in REJECT target module

Quoted 10 lines · Pablo Neira Ayuso
Quoted 9 lines · Fernando Luis Vázquez Cao
Quoted 8 lines · Pablo Neira Ayuso
Quoted 6 lines · Fernando Luis Vazquez Cao

Pablo, could you pull in the two patches below? They have already been acked by Eric. It would be great it we could get them merged for the next -rc and stable releases.

[PATCH] netfilter/IPv6: fix DSCP mangle code
[PATCH] netfilter/IPv6: initialize TOS field in REJECT target module

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Patrick is the primary link to take patches, I'm including him in this CC. If he experiences any problem, I'll make sure that these hit -rc, so never mind.

It seems that the two patches above did not make it into 2.6.39-rc6. Any chance we can get them merged before 2.6.39 is released?

I'll pick them and push them to davem by monday. Thanks!

Also revert a2361c8735e07322023aedc36e4938b35af31eb0 please.

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#19 lore raw

Re: [PATCH] netfilter/IPv6: initialize TOS field in REJECT target module

In reply to Pablo Neira Ayuso

From: Pablo Neira Ayuso <[email protected]>
Date: Tue, 26 Apr 2011 03:13:16 +0200

Quoted 12 lines · Eric Dumazet
Quoted 8 lines

Le vendredi 22 avril 2011 à 17:11 +0900, Fernando Luis Vazquez Cao a écrit :

Quoted 3 lines

Thank you!

Should we send these two patches to -stable too?

David takes care of stable submissions for netdev stuff, thanks.

If the patch follows the netfilter path, we'll take care of sending stable submissions.

Right.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html