Skip to contentSkip to conversation

net: rps: support 802.1Q

PATCH Changli Gao 3 participants 7 messages Aug 19, 2011 – Aug 20, 2011

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

For the 802.1Q packets, if the NIC doesn't support hw-accel-vlan-rx, RPS won't inspect the internal 4 tuples to generate skb->rxhash, so this kind of traffic can't get any benefit from RPS.

This patch adds the support for 802.1Q to RPS.

---
 net/core/dev.c |    8 ++++++++
 1 file changed, 8 insertions(+)
net/core/dev.c +8 -0
index ead0366..be7ee50 100644
@@ -2529,6 +2529,7 @@ void __skb_get_rxhash(struct sk_buff *skb)
 	int nhoff, hash = 0, poff;
 	const struct ipv6hdr *ip6;
 	const struct iphdr *ip;
+	const struct vlan_hdr *vlan;
 	u8 ip_proto;
 	u32 addr1, addr2;
 	u16 proto;
@@ -2565,6 +2566,13 @@ again:
 		addr2 = (__force u32) ip6->daddr.s6_addr32[3];
 		nhoff += 40;
 		break;
+	case __constant_htons(ETH_P_8021Q):
+		if (!pskb_may_pull(skb, sizeof(*vlan) + nhoff))
+			goto done;
+		vlan = (const struct vlan_hdr *) (skb->data + nhoff);
+		proto = vlan->h_vlan_encapsulated_proto;
+		nhoff += sizeof(*vlan);
+		goto again;
 	default:
 		goto done;
 	}
maintainer
#1 lore raw

From: Changli Gao <[email protected]>
Date: Fri, 19 Aug 2011 13:05:53 +0800

Quoted 7 lines

For the 802.1Q packets, if the NIC doesn't support hw-accel-vlan-rx, RPS won't inspect the internal 4 tuples to generate skb->rxhash, so this kind of traffic can't get any benefit from RPS.

This patch adds the support for 802.1Q to RPS.

Looks fine, applied to net-next, thanks!

#2 lore raw
Quoted 7 lines · David Miller

From: Changli Gao <[email protected]>
Date: Fri, 19 Aug 2011 13:05:53 +0800

Quoted 4 lines

For the 802.1Q packets, if the NIC doesn't support hw-accel-vlan-rx, RPS won't inspect the internal 4 tuples to generate skb->rxhash, so this kind of traffic can't get any benefit from RPS.

Quoted 6 lines
Quoted 3 lines

This patch adds the support for 802.1Q to RPS.

Looks fine, applied to net-next, thanks!

Thanks for applying it. I have another patch which adds the support for PPPOE session messages. Do you think it worth doing?

Signature · 2 lines
Regards,
Changli Gao([email protected])
maintainer
#3 lore raw

From: Changli Gao <[email protected]>
Date: Fri, 19 Aug 2011 13:22:03 +0800

Quoted 10 lines · David Miller
Quoted 9 lines

From: Changli Gao <[email protected]>
Date: Fri, 19 Aug 2011 13:05:53 +0800

Quoted 6 lines

For the 802.1Q packets, if the NIC doesn't support hw-accel-vlan-rx, RPS won't inspect the internal 4 tuples to generate skb->rxhash, so this kind of traffic can't get any benefit from RPS.

This patch adds the support for 802.1Q to RPS.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Looks fine, applied to net-next, thanks!

Thanks for applying it. I have another patch which adds the support for PPPOE session messages. Do you think it worth doing?

Sure.

#4 lore raw
In reply to Changli Gao
Quoted 5 lines · Changli Gao

For the 802.1Q packets, if the NIC doesn't support hw-accel-vlan-rx, RPS won't inspect the internal 4 tuples to generate skb->rxhash, so this kind of traffic can't get any benefit from RPS.

This patch adds the support for 802.1Q to RPS.

[...]

Quoted 4 lines
net/core/dev.c +0 -0
@@ -2565,6 +2566,13 @@ again:
 		addr2 = (__force u32) ip6->daddr.s6_addr32[3];
 		nhoff += 40;
 		break;

net/core/dev.c again: · line 2578

Quoted 10 lines
net/core/dev.c +7 -0
+	case __constant_htons(ETH_P_8021Q):
+		if (!pskb_may_pull(skb, sizeof(*vlan) + nhoff))
+			goto done;
+		vlan = (const struct vlan_hdr *) (skb->data + nhoff);
+		proto = vlan->h_vlan_encapsulated_proto;
+		nhoff += sizeof(*vlan);
+		goto again;
 	default:
 		goto done;
 	}

Should this really be reading an unlimited number of tags? What if an attacker starts sending packets full of VLAN tags? Since this runs before netfilter, there would be no way to prevent those packets burning our CPU time. And if there are legitimately multiple VLAN tags, they presumably won't all have the 802.1q Ethertype.

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#5 lore raw
Quoted 2 lines · Ben Hutchings

Should this really be reading an unlimited number of tags?

Not unlimited, but it won't stop until reaching the end of the packet.

Quoted 6 lines

 What if an
attacker starts sending packets full of VLAN tags?  Since this runs before netfilter, there would be no way to prevent those packets burning our CPU time.  And if there are legitimately multiple VLAN tags, they presumably won't all have the 802.1q Ethertype.

Do we need to limit the number of rounds to stop this kind of "bad" packets from burning our CPU time? Then, __netif_receive_skb() has to be update too, so the inspection of tunnel in __skb_get_rxhash() does. Is there a such limitation in xfrm?

Thanks.

Signature · 2 lines
Regards,
Changli Gao([email protected])
#6 lore raw
Quoted 6 lines · Changli Gao
Quoted 2 lines · Ben Hutchings

Should this really be reading an unlimited number of tags?

Not unlimited, but it won't stop until reaching the end of the packet.

Right, I understand that the parsing is properly range-checked against the length of the packet.

Quoted 9 lines
Quoted 6 lines

What if an
attacker starts sending packets full of VLAN tags? Since this runs before netfilter, there would be no way to prevent those packets burning our CPU time. And if there are legitimately multiple VLAN tags, they presumably won't all have the 802.1q Ethertype.

Do we need to limit the number of rounds to stop this kind of "bad" packets from burning our CPU time?

Well, maybe. Then again, the most effective way for an attacker to waste a target's CPU time (aside from application-level vulnerabilities) will often be just to send minimum size packets.

Quoted 2 lines

Then, __netif_receive_skb() has to
be update too, so the inspection of tunnel in __skb_get_rxhash() does.

Yes, if we agree this is something worth defending against then we would need to be consistent in limiting any such parsing loop in pre-netfilter processing.

Quoted 1 line

Is there a such limitation in xfrm?

It appears to be limited to 6 levels of encapsulation.

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.