Skip to contentSkip to conversation

qlcnic: vlan rx accleration support

PATCH In review Amit Kumar Salecha 3 participants 25 messages Sep 17, 2010 – Sep 21, 2010

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

v2 cover qlcnic: vlan rx accleration support

Hi
Series v2 of 5 patches to support vlan rx accleration. This takes care of Eric Dumazet comment of using dev_kfree_skb(skb).

I haven't combined accleration and GRO patch. Though its look strange with first patch. But I want to have separate patches for two different entity.

-Amit

#1 lore raw

PATCH v2 1/5 qlcnic: support vlan rx accleration

Implemented vlan rx accleration in driver. This helps in increasing significant performance and reduces cpu utilization with GRO and LRO.

Eric Dumazet:
"Its a bit strange you use dev_kfree_skb_any(skb) here." "We run in NAPI mode, so you can use dev_kfree_skb()."
Amit:

	Done. Using dev_kfree_skb();
---
 drivers/net/qlcnic/qlcnic.h      |    1 +
 drivers/net/qlcnic/qlcnic_init.c |   59 ++++++++++++++++++++++----------------
 drivers/net/qlcnic/qlcnic_main.c |   10 ++++++-
 3 files changed, 44 insertions(+), 26 deletions(-)
drivers/net/qlcnic/qlcnic.h +1 -0
index cc8385a..c8caec9 100644
@@ -1013,6 +1013,7 @@ struct qlcnic_adapter {
 
 	u64 dev_rst_time;
 
+	struct vlan_group *vlgrp;
 	struct qlcnic_npar_info *npars;
 	struct qlcnic_eswitch *eswitch;
 	struct qlcnic_nic_template *nic_ops;
drivers/net/qlcnic/qlcnic_init.c +34 -25

107 lines not on this page · raw message

drivers/net/qlcnic/qlcnic_main.c +9 -1
index 5fd2abd..9eb0ced 100644
@@ -371,6 +371,13 @@ static int qlcnic_set_mac(struct net_device *netdev, void *p)
 	return 0;
 }
 
+static void qlcnic_vlan_rx_register(struct net_device *netdev,
+		struct vlan_group *grp)
+{
+	struct qlcnic_adapter *adapter = netdev_priv(netdev);
+	adapter->vlgrp = grp;
+}
+
 static const struct net_device_ops qlcnic_netdev_ops = {
 	.ndo_open	   = qlcnic_open,
 	.ndo_stop	   = qlcnic_close,
@@ -381,6 +388,7 @@ static const struct net_device_ops qlcnic_netdev_ops = {
 	.ndo_set_mac_address    = qlcnic_set_mac,
 	.ndo_change_mtu	   = qlcnic_change_mtu,
 	.ndo_tx_timeout	   = qlcnic_tx_timeout,
+	.ndo_vlan_rx_register = qlcnic_vlan_rx_register,
 #ifdef CONFIG_NET_POLL_CONTROLLER
 	.ndo_poll_controller = qlcnic_poll_controller,
 #endif
@@ -1446,7 +1454,7 @@ qlcnic_setup_netdev(struct qlcnic_adapter *adapter,
 	SET_ETHTOOL_OPS(netdev, &qlcnic_ethtool_ops);
 
 	netdev->features |= (NETIF_F_SG | NETIF_F_IP_CSUM |
-		NETIF_F_IPV6_CSUM | NETIF_F_GRO);
+		NETIF_F_IPV6_CSUM | NETIF_F_GRO | NETIF_F_HW_VLAN_RX);
 	netdev->vlan_features |= (NETIF_F_SG | NETIF_F_IP_CSUM |
 		NETIF_F_IPV6_CSUM);
 
Signature · 1 line
1.6.0.2
Acked-by on v2 1/5
#2 lore raw

Re: [PATCHv2 NEXT 1/5] qlcnic: support vlan rx accleration

Quoted 11 lines · Amit Kumar Salecha

Implemented vlan rx accleration in driver. This helps in increasing significant performance and reduces cpu utilization with GRO and LRO.

Eric Dumazet:
"Its a bit strange you use dev_kfree_skb_any(skb) here." "We run in NAPI mode, so you can use dev_kfree_skb()."
Amit:

	Done. Using dev_kfree_skb();
#3 lore raw

PATCH 1/1 qlcnic: dont assume NET_IP_ALIGN is 2

In reply to Amit Kumar Salecha

Amit, I noticed following bug in qlnic driver.

Also, skb->truesize should not be changed by drivers, unless dealing with fragments.

When you have :

	skb->truesize = skb->len + sizeof(struct sk_buff);

you are lying to stack that can queue many "small" UDP packets, accouting for small packets in socket rcvbuf, while the truesize was really 1532 + sizeof(struct sk_buff)

Could you take a look ?

Thanks

[PATCH] qlcnic: dont assume NET_IP_ALIGN is 2

qlcnic driver allocates rx skbs and gives to hardware too bytes of extra storage, allowing for corruption of kernel data.

NET_IP_ALIGN being 0 on some platforms (including x86), drivers should not assume it's 2.

rds_ring->skb_size = rds_ring->dma_size + NET_IP_ALIGN;
...
skb = dev_alloc_skb(rds_ring->skb_size);
skb_reserve(skb, 2);
pci_map_single(pdev, skb->data, rds_ring->dma_size, PCI_DMA_FROMDEVICE);

(and rds_ring->skb_size == rds_ring->dma_size) -> bug

Because of extra alignment (1500 + 32) -> four extra bytes are available before the struct skb_shared_info, so corruption is not noticed.

Note: this driver could use netdev_alloc_skb_ip_align()

---

drivers/net/qlcnic/qlcnic_init.c +1 -1
index 75ba744..60ab753 100644
@@ -1316,7 +1316,7 @@ qlcnic_alloc_rx_skb(struct qlcnic_adapter *adapter,
 		return -ENOMEM;
 	}
 
-	skb_reserve(skb, 2);
+	skb_reserve(skb, NET_IP_ALIGN);
 
 	dma = pci_map_single(pdev, skb->data,
 			rds_ring->dma_size, PCI_DMA_FROMDEVICE);
#4 lore raw

RE: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2

Quoted 15 lines

-----Original Message-----
From: Eric Dumazet [mailto:[email protected]]
Sent: Friday, September 17, 2010 3:27 PM
To: Amit Salecha
Cc: [email protected]; Ameen Rahman; Anirban Chakraborty; David Miller
Subject: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2

Amit, I noticed following bug in qlnic driver.

Also, skb->truesize should not be changed by drivers, unless dealing with fragments.

Quoted 8 lines

When you have :

	skb->truesize = skb->len + sizeof(struct sk_buff);

you are lying to stack that can queue many "small" UDP packets, accouting for small packets in socket rcvbuf, while the truesize was really 1532 + sizeof(struct sk_buff)

Could you take a look ?

I will take a look and get back to you.

- Thanks.

Quoted 48 lines

Thanks

[PATCH] qlcnic: dont assume NET_IP_ALIGN is 2

qlcnic driver allocates rx skbs and gives to hardware too bytes of extra
storage, allowing for corruption of kernel data.

NET_IP_ALIGN being 0 on some platforms (including x86), drivers should not assume it's 2.

rds_ring->skb_size = rds_ring->dma_size + NET_IP_ALIGN;
...
skb = dev_alloc_skb(rds_ring->skb_size); skb_reserve(skb, 2);
pci_map_single(pdev, skb->data, rds_ring->dma_size, PCI_DMA_FROMDEVICE);

(and rds_ring->skb_size == rds_ring->dma_size) -> bug

Because of extra alignment (1500 + 32) -> four extra bytes are available
before the struct skb_shared_info, so corruption is not noticed.

Note: this driver could use netdev_alloc_skb_ip_align()

---

drivers/net/qlcnic/qlcnic_init.c +1 -1
index 75ba744..60ab753 100644
@@ -1316,7 +1316,7 @@ qlcnic_alloc_rx_skb(struct qlcnic_adapter
 *adapter,
 		return -ENOMEM;
 	}
 
-	skb_reserve(skb, 2);
+	skb_reserve(skb, NET_IP_ALIGN);
 
 	dma = pci_map_single(pdev, skb->data,

rds_ring->dma_size, PCI_DMA_FROMDEVICE);

maintainer Applied
#5 lore raw

Re: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2

In reply to Eric Dumazet

From: Eric Dumazet <[email protected]>
Date: Fri, 17 Sep 2010 11:57:28 +0200

Quoted 17 lines

[PATCH] qlcnic: dont assume NET_IP_ALIGN is 2

qlcnic driver allocates rx skbs and gives to hardware too bytes of extra storage, allowing for corruption of kernel data.

NET_IP_ALIGN being 0 on some platforms (including x86), drivers should not assume it's 2.

rds_ring->skb_size = rds_ring->dma_size + NET_IP_ALIGN;
...
skb = dev_alloc_skb(rds_ring->skb_size);
skb_reserve(skb, 2);
pci_map_single(pdev, skb->data, rds_ring->dma_size, PCI_DMA_FROMDEVICE);

(and rds_ring->skb_size == rds_ring->dma_size) -> bug

Quoted 6 lines

Because of extra alignment (1500 + 32) -> four extra bytes are available before the struct skb_shared_info, so corruption is not noticed.

Note: this driver could use netdev_alloc_skb_ip_align()

Applied to net-2.6, thanks Eric.

#6 lore raw

RE: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2

In reply to Eric Dumazet
Quoted 15 lines

-----Original Message-----
From: Eric Dumazet [mailto:[email protected]]
Sent: Friday, September 17, 2010 3:27 PM
To: Amit Salecha
Cc: [email protected]; Ameen Rahman; Anirban Chakraborty; David Miller
Subject: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2

Amit, I noticed following bug in qlnic driver.

Also, skb->truesize should not be changed by drivers, unless dealing with fragments.

Quoted 10 lines

When you have :

	skb->truesize = skb->len + sizeof(struct sk_buff);

you are lying to stack that can queue many "small" UDP packets, accouting for small packets in socket rcvbuf, while the truesize was really 1532 + sizeof(struct sk_buff)

Could you take a look ?

This can be cleaned up.
Though I have one doubt. We are allocating larger packets than the actual data used. Doesn't it will break accounting ?

-Amit

#7 lore raw

RE: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2

Quoted 3 lines · Amit Salecha

This can be cleaned up.
Though I have one doubt. We are allocating larger packets than the actual data used. Doesn't it will break accounting ?

truesize accounts for the real size of buffers, not the used part in them.

IMHO, a driver not dealing with fragments should not touch skb->truesize

# grep truesize drivers/net/tg3.c
<nothing>

If a driver deals with fragments, it probably should use "+=" operator only, not hardcoding sizeof(struct sk_buff) thing that only core network has to deal with.

$ find drivers/net/bnx2x|xargs grep truesize
drivers/net/bnx2x/bnx2x_cmn.c:		skb->truesize += frag_len;

Almost all drivers are fine, they are some of them that should be changed.

#8 lore raw

PATCH 1/1 qlnic: dont set skb->truesize

Quoted 18 lines · Eric Dumazet
Quoted 3 lines · Amit Salecha

This can be cleaned up.
Though I have one doubt. We are allocating larger packets than the actual data used. Doesn't it will break accounting ?

truesize accounts for the real size of buffers, not the used part in them.

IMHO, a driver not dealing with fragments should not touch skb->truesize

# grep truesize drivers/net/tg3.c
<nothing>

If a driver deals with fragments, it probably should use "+=" operator only, not hardcoding sizeof(struct sk_buff) thing that only core network has to deal with.

Quoted 7 lines
$ find drivers/net/bnx2x|xargs grep truesize
drivers/net/bnx2x/bnx2x_cmn.c:		skb->truesize += frag_len;

Almost all drivers are fine, they are some of them that should be changed.

I suspect following patch should be fine :

[PATCH net-next-2.6] qlnic: dont set skb->truesize

skb->truesize is set in core network.

Dont change it unless dealing with fragments.

---
 drivers/net/qlcnic/qlcnic_init.c |    6 ------
 1 file changed, 6 deletions(-)
drivers/net/qlcnic/qlcnic_init.c +0 -6
index e26fa95..16dd9eb 100644
@@ -1418,8 +1418,6 @@ qlcnic_process_rcv(struct qlcnic_adapter *adapter,
 	if (pkt_offset)
 		skb_pull(skb, pkt_offset);
 
-	skb->truesize = skb->len + sizeof(struct sk_buff);
-
 	if (unlikely(qlcnic_check_rx_tagging(adapter, skb, &vid))) {
 		adapter->stats.rxdropped++;
 		dev_kfree_skb(skb);
@@ -1491,8 +1489,6 @@ qlcnic_process_lro(struct qlcnic_adapter *adapter,
 
 	skb_put(skb, lro_length + data_offset);
 
-	skb->truesize = skb->len + sizeof(struct sk_buff) + skb_headroom(skb);
-
 	skb_pull(skb, l2_hdr_offset);
 
 	if (unlikely(qlcnic_check_rx_tagging(adapter, skb, &vid))) {
@@ -1732,8 +1728,6 @@ qlcnic_process_rcv_diag(struct qlcnic_adapter *adapter,
 	if (pkt_offset)
 		skb_pull(skb, pkt_offset);
 
-	skb->truesize = skb->len + sizeof(struct sk_buff);
-
 	if (!qlcnic_check_loopback_buff(skb->data))
 		adapter->diag_cnt++;
 
maintainer
#9 lore raw

Re: [PATCH net-next-2.6] qlnic: dont set skb->truesize

From: Eric Dumazet <[email protected]>
Date: Mon, 20 Sep 2010 14:28:59 +0200

Quoted 7 lines

[PATCH net-next-2.6] qlnic: dont set skb->truesize

skb->truesize is set in core network.

Dont change it unless dealing with fragments.

Looks good to me too, applied thanks!

maintainer
#10 lore raw

Re: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2

In reply to Amit Salecha

From: Amit Salecha <[email protected]>
Date: Mon, 20 Sep 2010 06:16:31 -0500

Quoted 2 lines

Though I have one doubt. We are allocating larger packets than the actual data used. Doesn't it will break accounting ?

No, it will "fix" accounting.

You must charge to the SKB all of the non-shared memory that was allocated to the SKB.

This means even if the packet only uses 128 bytes of the SKB data area, you must still account for the full blob of linear memory that was allocated for the SKB data area in skb->truesize.

Otherwise remote attackers could consume enormous amounts of memory by tricking our socket accounting via carefully sized packets.

#11 lore raw

RE: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2

Quoted 22 lines

-----Original Message-----
From: David Miller [mailto:[email protected]]
Sent: Monday, September 20, 2010 9:29 PM
To: Amit Salecha
Cc: [email protected]; [email protected]; Ameen Rahman; Anirban Chakraborty
Subject: Re: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2

From: Amit Salecha <[email protected]>
Date: Mon, 20 Sep 2010 06:16:31 -0500

Quoted 1 line

Though I have one doubt. We are allocating larger packets than the

actual data used.

Quoted 1 line

Doesn't it will break accounting ?

No, it will "fix" accounting.

You must charge to the SKB all of the non-shared memory that was allocated to the SKB.

Quoted 6 lines

This means even if the packet only uses 128 bytes of the SKB data area, you must still account for the full blob of linear memory that was allocated for the SKB data area in skb->truesize.

Otherwise remote attackers could consume enormous amounts of memory by tricking our socket accounting via carefully sized packets.

Wont this affect throughput ?
As problem discuss in this thread http://www.mail-archive.com/[email protected]/msg06848.html, it can affect tcp window scaling.

-Amit

#12 lore raw

RE: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2

Quoted 25 lines · Amit Salecha
Quoted 25 lines

-----Original Message-----
From: David Miller [mailto:[email protected]]
Sent: Monday, September 20, 2010 9:29 PM
To: Amit Salecha
Cc: [email protected]; [email protected]; Ameen Rahman; Anirban Chakraborty
Subject: Re: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2

From: Amit Salecha <[email protected]>
Date: Mon, 20 Sep 2010 06:16:31 -0500

Quoted 1 line

Though I have one doubt. We are allocating larger packets than the

actual data used.

Quoted 1 line

Doesn't it will break accounting ?

No, it will "fix" accounting.

You must charge to the SKB all of the non-shared memory that was allocated to the SKB.

This means even if the packet only uses 128 bytes of the SKB data area, you must still account for the full blob of linear memory that was allocated for the SKB data area in skb->truesize.

Quoted 6 lines
Quoted 2 lines

Otherwise remote attackers could consume enormous amounts of memory by tricking our socket accounting via carefully sized packets.

Wont this affect throughput ?
As problem discuss in this thread http://www.mail-archive.com/[email protected]/msg06848.html, it can affect tcp window scaling.

Amit, if you believe this is a problem, you should address it for all NICS, not only qlcnic.

Qlcnic was lying to stack, because it consumed 2Kbytes blocs and pretended they were consuming skb->len bytes. (assuming MTU=1500, problem is worse if MTU is bigger)

So in order to improve "throughput", you were allowing for memory exhaust and freeze of the _machine_ ?

#13 lore raw

RE: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2

Quoted 51 lines

-----Original Message-----
From: [email protected] [mailto:netdev- [email protected]] On Behalf Of Eric Dumazet
Sent: Tuesday, September 21, 2010 2:05 PM
To: Amit Salecha
Cc: David Miller; [email protected]; Ameen Rahman; Anirban Chakraborty
Subject: RE: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2

Quoted 9 lines · Amit Salecha
Quoted 9 lines

-----Original Message-----
From: David Miller [mailto:[email protected]]
Sent: Monday, September 20, 2010 9:29 PM
To: Amit Salecha
Cc: [email protected]; [email protected]; Ameen Rahman; Anirban Chakraborty
Subject: Re: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2

Quoted 4 lines
Quoted 4 lines

From: Amit Salecha <[email protected]>
Date: Mon, 20 Sep 2010 06:16:31 -0500

Quoted 1 line

Though I have one doubt. We are allocating larger packets than

the

Quoted 5 lines
Quoted 5 lines

actual data used.

Quoted 1 line

Doesn't it will break accounting ?

No, it will "fix" accounting.

Quoted 8 lines
Quoted 8 lines

You must charge to the SKB all of the non-shared memory that was allocated to the SKB.

This means even if the packet only uses 128 bytes of the SKB data area, you must still account for the full blob of linear memory that was allocated for the SKB data area in skb->truesize.

Otherwise remote attackers could consume enormous amounts of memory

by

Quoted 4 lines
Quoted 1 line

tricking our socket accounting via carefully sized packets.

Wont this affect throughput ?
As problem discuss in this thread http://www.mail-

archive.com/[email protected]/msg06848.html, it can affect tcp window scaling.

Quoted 1 line

Amit, if you believe this is a problem, you should address it for all NICS, not only qlcnic.

Quoted 7 lines

Qlcnic was lying to stack, because it consumed 2Kbytes blocs and pretended they were consuming skb->len bytes. (assuming MTU=1500, problem is worse if MTU is bigger)

So in order to improve "throughput", you were allowing for memory exhaust and freeze of the _machine_ ?

This won't lead to such problem. truesize is used for accounting only.

Quoted 6 lines

--
To unsubscribe from this list: send the line "unsubscribe netdev" 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] qlcnic: dont assume NET_IP_ALIGN is 2

Quoted 11 lines · Amit Salecha
Quoted 10 lines

Amit, if you believe this is a problem, you should address it for all NICS, not only qlcnic.

Qlcnic was lying to stack, because it consumed 2Kbytes blocs and pretended they were consuming skb->len bytes. (assuming MTU=1500, problem is worse if MTU is bigger)

So in order to improve "throughput", you were allowing for memory exhaust and freeze of the _machine_ ?

This won't lead to such problem. truesize is used for accounting only.

You must have big machines in your lab and never hit OOM ?

You really should take a look on various files in net/core, net/ipv4 trees. And files like "/proc/sys/net/tcp_mem", "/proc/sys/net/udp_mem"

In fact, truesize is _underestimated_ : (we dont account for struct skb_shared_info) and kmalloc() rounding

We probably should use this patch (without having to check all possible net drivers !)

Problem is this would slow down alloc_skb(), so this patch is not for inclusion.

cheap alternative would be to use

size + sizeof(struct sk_buff) + SKB_DATA_ALIGN(sizeof(struct skb_shared_info))

If you think about it, when 128bit arches come, truesize will grow anyway. If some tuning is needed in our stack, we'll do it.

(socket api SO_RCVBUF/ SO_SNDBUF is the problem, because
applications are not aware of packetization or kernel internals)

SOCK_MIN_RCVBUF is way too small, since sizeof(struct sk_buff) is already close to 256. I guess we cannot even receive a single frame.

 include/net/sock.h |    2 +-
 net/core/skbuff.c  |    2 +-
 net/core/sock.c    |    8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)
include/net/sock.h +1 -1
index 8ae97c4..348fc9e 100644
@@ -1558,7 +1558,7 @@ static inline void sk_wake_async(struct sock *sk, int how, int band)
 }
 
 #define SOCK_MIN_SNDBUF 2048
-#define SOCK_MIN_RCVBUF 256
+#define SOCK_MIN_RCVBUF 1024
 
 static inline void sk_stream_moderate_sndbuf(struct sock *sk)
 {
net/core/skbuff.c +1 -1
index 752c197..5ab2e8e 100644
@@ -196,7 +196,7 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
 	 * the tail pointer in struct sk_buff!
 	 */
 	memset(skb, 0, offsetof(struct sk_buff, tail));
-	skb->truesize = size + sizeof(struct sk_buff);
+	skb->truesize = ksize(data) + sizeof(struct sk_buff);
 	atomic_set(&skb->users, 1);
 	skb->head = data;
 	skb->data = data;
net/core/sock.c +4 -4
index f3a06c4..803e041 100644
@@ -535,10 +535,10 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
 			val = sysctl_wmem_max;
 set_sndbuf:
 		sk->sk_userlocks |= SOCK_SNDBUF_LOCK;
-		if ((val * 2) < SOCK_MIN_SNDBUF)
+		if ((val * 4) < SOCK_MIN_SNDBUF)
 			sk->sk_sndbuf = SOCK_MIN_SNDBUF;
 		else
-			sk->sk_sndbuf = val * 2;
+			sk->sk_sndbuf = val * 4;
 
 		/*
 		 *	Wake up sending tasks if we
@@ -579,10 +579,10 @@ set_rcvbuf:
 		 * returning the value we actually used in getsockopt
 		 * is the most desirable behavior.
 		 */
-		if ((val * 2) < SOCK_MIN_RCVBUF)
+		if ((val * 4) < SOCK_MIN_RCVBUF)
 			sk->sk_rcvbuf = SOCK_MIN_RCVBUF;
 		else
-			sk->sk_rcvbuf = val * 2;
+			sk->sk_rcvbuf = val * 4;
 		break;
 
 	case SO_RCVBUFFORCE:
maintainer
#15 lore raw

Re: [PATCH] qlcnic: dont assume NET_IP_ALIGN is 2

In reply to Amit Salecha

From: Amit Salecha <[email protected]>
Date: Tue, 21 Sep 2010 03:41:42 -0500

Quoted 4 lines
Quoted 3 lines

So in order to improve "throughput", you were allowing for memory exhaust and freeze of the _machine_ ?

This won't lead to such problem. truesize is used for accounting only.

Yes, it will.

Do you understand that we enforce both socket-level and system-wide networking buffer usage in the stack? And this limiting is based upon skb->truesize and therefore only works if skb->truesize is accurate?

It's meant to keep people from attacking a server and consuming large percentages of system memory with networking buffer memory such that other tasks cannot complete successfully.

And by mis-reporting the truesize you are subverting that entirely.

This qlcnic truesize bug is a huge security hole, can't you see this now?

#16 lore raw

PATCH 1/1 netxen: dont set skb->truesize

Quoted 15 lines · David Miller

From: Amit Salecha <[email protected]>
Date: Tue, 21 Sep 2010 03:41:42 -0500

Quoted 4 lines
Quoted 3 lines

So in order to improve "throughput", you were allowing for memory exhaust and freeze of the _machine_ ?

This won't lead to such problem. truesize is used for accounting only.

Yes, it will.

Do you understand that we enforce both socket-level and system-wide networking buffer usage in the stack? And this limiting is based upon skb->truesize and therefore only works if skb->truesize is accurate?

Quoted 9 lines

It's meant to keep people from attacking a server and consuming large percentages of system memory with networking buffer memory such that other tasks cannot complete successfully.

And by mis-reporting the truesize you are subverting that entirely.

This qlcnic truesize bug is a huge security hole, can't you see this now?

BTW, drivers/net/netxen/netxen_nic_init.c has same problem.

[PATCH] netxen: dont set skb->truesize

skb->truesize is set in core network.

Dont change it unless dealing with fragments.

---
 drivers/net/netxen/netxen_nic_init.c |    3 ---
 1 file changed, 3 deletions(-)
drivers/net/netxen/netxen_nic_init.c +0 -3
index cabae7b..b075a35 100644
@@ -1540,7 +1540,6 @@ netxen_process_rcv(struct netxen_adapter *adapter,
 	if (pkt_offset)
 		skb_pull(skb, pkt_offset);
 
-	skb->truesize = skb->len + sizeof(struct sk_buff);
 	skb->protocol = eth_type_trans(skb, netdev);
 
 	napi_gro_receive(&sds_ring->napi, skb);
@@ -1602,8 +1601,6 @@ netxen_process_lro(struct netxen_adapter *adapter,
 
 	skb_put(skb, lro_length + data_offset);
 
-	skb->truesize = skb->len + sizeof(struct sk_buff) + skb_headroom(skb);
-
 	skb_pull(skb, l2_hdr_offset);
 	skb->protocol = eth_type_trans(skb, netdev);
 
maintainer Applied
#17 lore raw

Re: [PATCH] netxen: dont set skb->truesize

From: Eric Dumazet <[email protected]>
Date: Tue, 21 Sep 2010 21:55:10 +0200

Quoted 3 lines

BTW, drivers/net/netxen/netxen_nic_init.c has same problem.

[PATCH] netxen: dont set skb->truesize

Applied to net-2.6, and I backported the qlcnic patch in net-next-2.6 into net-2.6 too.

Thanks.

#18 lore raw

PATCH v2 2/5 qlcnic: vlan gro support

In reply to Amit Kumar Salecha

GRO support + vlan rx accleration, boost around 9% performance and reduces 25% of cpu utilization on vlan interface.

---
 drivers/net/qlcnic/qlcnic_init.c |    2 +-
 drivers/net/qlcnic/qlcnic_main.c |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/qlcnic/qlcnic_init.c +1 -1
index 10cebb1..9f994b9 100644
@@ -1455,7 +1455,7 @@ qlcnic_process_rcv(struct qlcnic_adapter *adapter,
 	skb->protocol = eth_type_trans(skb, netdev);
 
 	if ((vid != 0xffff) && adapter->vlgrp)
-		vlan_hwaccel_receive_skb(skb, adapter->vlgrp, vid);
+		vlan_gro_receive(&sds_ring->napi, adapter->vlgrp, vid, skb);
 	else
 		napi_gro_receive(&sds_ring->napi, skb);
 
drivers/net/qlcnic/qlcnic_main.c +2 -2
index 9eb0ced..f7eb30b 100644
@@ -796,7 +796,7 @@ qlcnic_set_netdev_features(struct qlcnic_adapter *adapter,
 	features = (NETIF_F_SG | NETIF_F_IP_CSUM |
 			NETIF_F_IPV6_CSUM | NETIF_F_GRO);
 	vlan_features = (NETIF_F_SG | NETIF_F_IP_CSUM |
-			NETIF_F_IPV6_CSUM);
+			NETIF_F_IPV6_CSUM | NETIF_F_GRO);
 
 	if (adapter->capabilities & QLCNIC_FW_CAPABILITY_TSO) {
 		features |= (NETIF_F_TSO | NETIF_F_TSO6);
@@ -1456,7 +1456,7 @@ qlcnic_setup_netdev(struct qlcnic_adapter *adapter,
 	netdev->features |= (NETIF_F_SG | NETIF_F_IP_CSUM |
 		NETIF_F_IPV6_CSUM | NETIF_F_GRO | NETIF_F_HW_VLAN_RX);
 	netdev->vlan_features |= (NETIF_F_SG | NETIF_F_IP_CSUM |
-		NETIF_F_IPV6_CSUM);
+		NETIF_F_IPV6_CSUM | NETIF_F_GRO);
 
 	if (adapter->capabilities & QLCNIC_FW_CAPABILITY_TSO) {
 		netdev->features |= (NETIF_F_TSO | NETIF_F_TSO6);
Signature · 1 line
1.6.0.2
maintainer
#19 lore raw

Re: [PATCHv2 NEXT 2/5] qlcnic: vlan gro support

From: Amit Kumar Salecha <[email protected]>
Date: Thu, 16 Sep 2010 22:14:40 -0700

Quoted 10 lines
drivers/net/qlcnic/qlcnic_main.c +1 -1
@@ -796,7 +796,7 @@ qlcnic_set_netdev_features(struct qlcnic_adapter *adapter,
 	features = (NETIF_F_SG | NETIF_F_IP_CSUM |
 			NETIF_F_IPV6_CSUM | NETIF_F_GRO);
 	vlan_features = (NETIF_F_SG | NETIF_F_IP_CSUM |
-			NETIF_F_IPV6_CSUM);
+			NETIF_F_IPV6_CSUM | NETIF_F_GRO);
 
 	if (adapter->capabilities & QLCNIC_FW_CAPABILITY_TSO) {
 		features |= (NETIF_F_TSO | NETIF_F_TSO6);

drivers/net/qlcnic/qlcnic_main.c qlcnic_setup_netdev(struct qlcnic_adapter *adapter, · line 1461

Quoted 7 lines
drivers/net/qlcnic/qlcnic_main.c +1 -1
@@ -1456,7 +1456,7 @@ qlcnic_setup_netdev(struct qlcnic_adapter *adapter,
 	netdev->features |= (NETIF_F_SG | NETIF_F_IP_CSUM |
 		NETIF_F_IPV6_CSUM | NETIF_F_GRO | NETIF_F_HW_VLAN_RX);
 	netdev->vlan_features |= (NETIF_F_SG | NETIF_F_IP_CSUM |
-		NETIF_F_IPV6_CSUM);
+		NETIF_F_IPV6_CSUM | NETIF_F_GRO);
 
 	if (adapter->capabilities & QLCNIC_FW_CAPABILITY_TSO) {

Drivers no longer should set NETIF_F_GRO in their vlan_features flags, the generic networking core does this for you now in register_netdevice() in net-next-2.6

Please respin this patch with these settings removed.

Thanks.

maintainer
#20 lore raw

Re: [PATCHv2 NEXT 2/5] qlcnic: vlan gro support

From: David Miller <[email protected]>
Date: Fri, 17 Sep 2010 11:24:55 -0700 (PDT)

Quoted 19 lines

From: Amit Kumar Salecha <[email protected]>
Date: Thu, 16 Sep 2010 22:14:40 -0700

Quoted 16 lines
drivers/net/qlcnic/qlcnic_main.c +2 -2
@@ -796,7 +796,7 @@ qlcnic_set_netdev_features(struct qlcnic_adapter *adapter,
 	features = (NETIF_F_SG | NETIF_F_IP_CSUM |
 			NETIF_F_IPV6_CSUM | NETIF_F_GRO);
 	vlan_features = (NETIF_F_SG | NETIF_F_IP_CSUM |
-			NETIF_F_IPV6_CSUM);
+			NETIF_F_IPV6_CSUM | NETIF_F_GRO);
 
 	if (adapter->capabilities & QLCNIC_FW_CAPABILITY_TSO) {
 		features |= (NETIF_F_TSO | NETIF_F_TSO6);
@@ -1456,7 +1456,7 @@ qlcnic_setup_netdev(struct qlcnic_adapter *adapter,
 	netdev->features |= (NETIF_F_SG | NETIF_F_IP_CSUM |
 		NETIF_F_IPV6_CSUM | NETIF_F_GRO | NETIF_F_HW_VLAN_RX);
 	netdev->vlan_features |= (NETIF_F_SG | NETIF_F_IP_CSUM |
-		NETIF_F_IPV6_CSUM);
+		NETIF_F_IPV6_CSUM | NETIF_F_GRO);
 
Quoted 7 lines

Review qlcnic_setup_netdev(struct qlcnic_adapter *adapter, · line 1461

Quoted 1 line
(quoted diff) +0 -0
 	if (adapter->capabilities & QLCNIC_FW_CAPABILITY_TSO) {

Drivers no longer should set NETIF_F_GRO in their vlan_features flags, the generic networking core does this for you now in register_netdevice() in net-next-2.6

Please respin this patch with these settings removed.

Actually, nevermind, I'll take care of doing this for you, just be aware of this new convention.

Thank you.

#21 lore raw

PATCH v2 3/5 qlcnic: vlan lro support

In reply to Amit Kumar Salecha

LRO + GRO + vlan rx accleration support, performance increases around 20% and cpu utilization reduces around 70% on vlan interface.

---
 drivers/net/qlcnic/qlcnic_main.c |   39 +++++++++++++++++++++++++++++--------
 1 files changed, 30 insertions(+), 9 deletions(-)
drivers/net/qlcnic/qlcnic_main.c +30 -9
index f7eb30b..ea729a5 100644
@@ -107,7 +107,7 @@ static irqreturn_t qlcnic_msi_intr(int irq, void *data);
 static irqreturn_t qlcnic_msix_intr(int irq, void *data);
 
 static struct net_device_stats *qlcnic_get_stats(struct net_device *netdev);
-static void qlcnic_config_indev_addr(struct net_device *dev, unsigned long);
+static void qlcnic_restore_indev_addr(struct net_device *dev, unsigned long);
 static int qlcnic_start_firmware(struct qlcnic_adapter *);
 
 static void qlcnic_alloc_lb_filters_mem(struct qlcnic_adapter *adapter);
@@ -1759,7 +1759,7 @@ qlcnic_resume(struct pci_dev *pdev)
 		if (err)
 			goto done;
 
-		qlcnic_config_indev_addr(netdev, NETDEV_UP);
+		qlcnic_restore_indev_addr(netdev, NETDEV_UP);
 	}
 done:
 	netif_device_attach(netdev);
@@ -2958,7 +2958,7 @@ attach:
 		if (qlcnic_up(adapter, netdev))
 			goto done;
 
-		qlcnic_config_indev_addr(netdev, NETDEV_UP);
+		qlcnic_restore_indev_addr(netdev, NETDEV_UP);
 	}
 
 done:
@@ -3120,7 +3120,7 @@ static int qlcnic_attach_func(struct pci_dev *pdev)
 		if (err)
 			goto done;
 
-		qlcnic_config_indev_addr(netdev, NETDEV_UP);
+		qlcnic_restore_indev_addr(netdev, NETDEV_UP);
 	}
  done:
 	netif_device_attach(netdev);
@@ -4035,10 +4035,10 @@ qlcnic_remove_diag_entries(struct qlcnic_adapter *adapter)
 #define is_qlcnic_netdev(dev) (dev->netdev_ops == &qlcnic_netdev_ops)
 
 static void
-qlcnic_config_indev_addr(struct net_device *dev, unsigned long event)
+qlcnic_config_indev_addr(struct qlcnic_adapter *adapter,
+			struct net_device *dev, unsigned long event)
 {
 	struct in_device *indev;
-	struct qlcnic_adapter *adapter = netdev_priv(dev);
 
 	indev = in_dev_get(dev);
 	if (!indev)
@@ -4062,6 +4062,27 @@ qlcnic_config_indev_addr(struct net_device *dev, unsigned long event)
 	in_dev_put(indev);
 }
 
+static void
+qlcnic_restore_indev_addr(struct net_device *netdev, unsigned long event)
+{
+	struct qlcnic_adapter *adapter = netdev_priv(netdev);
+	struct net_device *dev;
+	u16 vid;
+
+	qlcnic_config_indev_addr(adapter, netdev, event);
+
+	if (!adapter->vlgrp)
+		return;
+
+	for (vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
+		dev = vlan_group_get_device(adapter->vlgrp, vid);
+		if (!dev)
+			continue;
+
+		qlcnic_config_indev_addr(adapter, dev, event);
+	}
+}
+
 static int qlcnic_netdev_event(struct notifier_block *this,
 				 unsigned long event, void *ptr)
 {
@@ -4088,7 +4109,7 @@ recheck:
 	if (!test_bit(__QLCNIC_DEV_UP, &adapter->state))
 		goto done;
 
-	qlcnic_config_indev_addr(dev, event);
+	qlcnic_config_indev_addr(adapter, dev, event);
 done:
 	return NOTIFY_DONE;
 }
@@ -4105,7 +4126,7 @@ qlcnic_inetaddr_event(struct notifier_block *this,
 	dev = ifa->ifa_dev ? ifa->ifa_dev->dev : NULL;
 
 recheck:
-	if (dev == NULL || !netif_running(dev))
+	if (dev == NULL)
 		goto done;
 
 	if (dev->priv_flags & IFF_802_1Q_VLAN) {
@@ -4148,7 +4169,7 @@ static struct notifier_block qlcnic_inetaddr_cb = {
 };
 #else
 static void
-qlcnic_config_indev_addr(struct net_device *dev, unsigned long event)
+qlcnic_restore_indev_addr(struct net_device *dev, unsigned long event)
 { }
 #endif
 static struct pci_error_handlers qlcnic_err_handler = {
Signature · 1 line
1.6.0.2
#22 lore raw

PATCH v2 4/5 qlcnic: remove fw version check

In reply to Amit Kumar Salecha

Don't compare flash and file fw version. Allow to load old fw from file than flashed fw.
If file fw is present, don't skip fw re-intialization.

---
 drivers/net/qlcnic/qlcnic_init.c |   30 ++----------------------------
 1 files changed, 2 insertions(+), 28 deletions(-)
drivers/net/qlcnic/qlcnic_init.c +2 -28
index 9f994b9..e26fa95 100644
@@ -1015,8 +1015,6 @@ qlcnic_check_fw_hearbeat(struct qlcnic_adapter *adapter)
 int
 qlcnic_need_fw_reset(struct qlcnic_adapter *adapter)
 {
-	u32 val, version, major, minor, build;
-
 	if (qlcnic_check_fw_hearbeat(adapter)) {
 		qlcnic_rom_lock_recovery(adapter);
 		return 1;
@@ -1025,20 +1023,8 @@ qlcnic_need_fw_reset(struct qlcnic_adapter *adapter)
 	if (adapter->need_fw_reset)
 		return 1;
 
-	/* check if we have got newer or different file firmware */
-	if (adapter->fw) {
-
-		val = qlcnic_get_fw_version(adapter);
-
-		version = QLCNIC_DECODE_VERSION(val);
-
-		major = QLCRD32(adapter, QLCNIC_FW_VERSION_MAJOR);
-		minor = QLCRD32(adapter, QLCNIC_FW_VERSION_MINOR);
-		build = QLCRD32(adapter, QLCNIC_FW_VERSION_SUB);
-
-		if (version > QLCNIC_VERSION_CODE(major, minor, build))
-			return 1;
-	}
+	if (adapter->fw)
+		return 1;
 
 	return 0;
 }
@@ -1174,18 +1160,6 @@ qlcnic_validate_firmware(struct qlcnic_adapter *adapter)
 		return -EINVAL;
 	}
 
-	/* check if flashed firmware is newer */
-	if (qlcnic_rom_fast_read(adapter,
-			QLCNIC_FW_VERSION_OFFSET, (int *)&val))
-		return -EIO;
-
-	val = QLCNIC_DECODE_VERSION(val);
-	if (val > ver) {
-		dev_info(&pdev->dev, "%s: firmware is older than flash\n",
-				fw_name[fw_type]);
-		return -EINVAL;
-	}
-
 	QLCWR32(adapter, QLCNIC_CAM_RAM(0x1fc), QLCNIC_BDINFO_MAGIC);
 	return 0;
 }
Signature · 1 line
1.6.0.2
#23 lore raw

PATCH v2 5/5 qlcnic: update version 5.0.10

In reply to Amit Kumar Salecha
---
 drivers/net/qlcnic/qlcnic.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/qlcnic/qlcnic.h +2 -2
index c8caec9..714ddf4 100644
@@ -51,8 +51,8 @@
 
 #define _QLCNIC_LINUX_MAJOR 5
 #define _QLCNIC_LINUX_MINOR 0
-#define _QLCNIC_LINUX_SUBVERSION 9
-#define QLCNIC_LINUX_VERSIONID  "5.0.9"
+#define _QLCNIC_LINUX_SUBVERSION 10
+#define QLCNIC_LINUX_VERSIONID  "5.0.10"
 #define QLCNIC_DRV_IDC_VER  0x01
 #define QLCNIC_DRIVER_VERSION  ((_QLCNIC_LINUX_MAJOR << 16) |\
 		 (_QLCNIC_LINUX_MINOR << 8) | (_QLCNIC_LINUX_SUBVERSION))
Signature · 1 line
1.6.0.2
maintainer
#24 lore raw
In reply to Amit Kumar Salecha

From: Amit Kumar Salecha <[email protected]>
Date: Thu, 16 Sep 2010 22:14:38 -0700

Quoted 7 lines

Hi
Series v2 of 5 patches to support vlan rx accleration. This takes care of Eric Dumazet comment of using dev_kfree_skb(skb).

I haven't combined accleration and GRO patch. Though its look strange with first patch. But I want to have separate patches for two different entity.

All applied, thanks.