Skip to contentSkip to conversation

macvtap: Do not double-count received packets

PATCH Applied Vlad Yasevich 4 participants 4 messages Nov 26, 2013 – Nov 29, 2013

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

PATCH 1/1 macvtap: Do not double-count received packets

Currently macvlan will count received packets after calling each
vlans receive handler. Macvtap attempts to count the packet
yet again when the user reads the packet from the tap socket. This code doesn't do this consistently either. Remove the counting from macvap and let only macvlan count received packets.

---
 drivers/net/macvtap.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/net/macvtap.c +0 -10
index dc76670..50f8dce 100644
@@ -767,7 +767,6 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
 				const struct sk_buff *skb,
 				const struct iovec *iv, int len)
 {
-	struct macvlan_dev *vlan;
 	int ret;
 	int vnet_hdr_len = 0;
 	int vlan_offset = 0;
@@ -821,15 +820,6 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
 	copied += len;
 
 done:
-	rcu_read_lock();
-	vlan = rcu_dereference(q->vlan);
-	if (vlan) {
-		preempt_disable();
-		macvlan_count_rx(vlan, copied - vnet_hdr_len, ret == 0, 0);
-		preempt_enable();
-	}
-	rcu_read_unlock();
-
 	return ret ? ret : copied;
 }
 
Signature · 1 line
1.8.4.2
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Vlad Yasevich

Currently macvlan will count received packets after calling each
vlans receive handler. Macvtap attempts to count the packet
yet again when the user reads the packet from the tap socket. This code doesn't do this consistently either. Remove the counting from macvap and let only macvlan count received packets.

Quoted 34 lines
---
 drivers/net/macvtap.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/net/macvtap.c +0 -10
index dc76670..50f8dce 100644
@@ -767,7 +767,6 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
 				const struct sk_buff *skb,
 				const struct iovec *iv, int len)
 {
-	struct macvlan_dev *vlan;
 	int ret;
 	int vnet_hdr_len = 0;
 	int vlan_offset = 0;
@@ -821,15 +820,6 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
 	copied += len;
 
 done:
-	rcu_read_lock();
-	vlan = rcu_dereference(q->vlan);
-	if (vlan) {
-		preempt_disable();
-		macvlan_count_rx(vlan, copied - vnet_hdr_len, ret == 0, 0);
-		preempt_enable();
-	}
-	rcu_read_unlock();
-
 	return ret ? ret : copied;
 }
 
Signature · 1 line
1.8.4.2
Acked-by on v1 1/1
#2 lore raw
In reply to Vlad Yasevich
Quoted 30 lines · Vlad Yasevich

Currently macvlan will count received packets after calling each
vlans receive handler. Macvtap attempts to count the packet
yet again when the user reads the packet from the tap socket. This code doesn't do this consistently either. Remove the counting from macvap and let only macvlan count received packets.

---
 drivers/net/macvtap.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/net/macvtap.c +0 -3
index dc76670..50f8dce 100644
@@ -767,7 +767,6 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
 				const struct sk_buff *skb,
 				const struct iovec *iv, int len)
 {
-	struct macvlan_dev *vlan;
 	int ret;
 	int vnet_hdr_len = 0;
 	int vlan_offset = 0;
@@ -821,15 +820,6 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
 	copied += len;
 
 done:
-	rcu_read_lock();
-	vlan = rcu_dereference(q->vlan);

drivers/net/macvtap.c static ssize_t macvtap_put_user(struct macvtap_queue *q, · line 825

Quoted 10 lines
drivers/net/macvtap.c +0 -7
-	if (vlan) {
-		preempt_disable();
-		macvlan_count_rx(vlan, copied - vnet_hdr_len, ret == 0, 0);
-		preempt_enable();
-	}
-	rcu_read_unlock();
-
 	return ret ? ret : copied;
 }
 
maintainer Applied
#3 lore raw
In reply to Vlad Yasevich

From: Vlad Yasevich <[email protected]>
Date: Tue, 26 Nov 2013 12:37:12 -0500

Quoted 5 lines

Currently macvlan will count received packets after calling each
vlans receive handler. Macvtap attempts to count the packet
yet again when the user reads the packet from the tap socket. This code doesn't do this consistently either. Remove the counting from macvap and let only macvlan count received

                ^^^^^^

--> macvtap

Quoted 3 lines

packets.

Applied, with the above typo fixed, thanks.