Skip to contentSkip to conversation

macvtap: remove useless codes in macvtap_aio_read() and macvtap_recvmsg()

PATCH Applied Zhi Yong Wu 4 participants 11 messages Dec 6, 2013 – Dec 11, 2013

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

PATCH 1/2 macvtap: remove useless codes in macvtap_aio_read() and macvtap_recvmsg()

From: Zhi Yong Wu <[email protected]>

By checking related codes, it is impossible that ret > len or total_len, so we should remove some useless coeds in both above functions.

---
 drivers/net/macvtap.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
drivers/net/macvtap.c +0 -5
index 4c6f84c..7f4ccdd 100644
@@ -871,7 +871,6 @@ static ssize_t macvtap_aio_read(struct kiocb *iocb, const struct iovec *iv,
 	}
 
 	ret = macvtap_do_read(q, iv, len, file->f_flags & O_NONBLOCK);
-	ret = min_t(ssize_t, ret, len); /* XXX copied from tun.c. Why? */
 out:
 	return ret;
 }
@@ -1104,10 +1103,6 @@ static int macvtap_recvmsg(struct kiocb *iocb, struct socket *sock,
 		return -EINVAL;
 	ret = macvtap_do_read(q, m->msg_iov, total_len,
 			  flags & MSG_DONTWAIT);
-	if (ret > total_len) {
-		m->msg_flags |= MSG_TRUNC;
-		ret = flags & MSG_TRUNC ? ret : total_len;
-	}
 	return ret;
 }
 
Signature · 1 line
1.7.6.5
#1 lore raw

PATCH 2/2 tun: remove useless codes in tun_chr_aio_read() and tun_recvmsg()

From: Zhi Yong Wu <[email protected]>

By checking related codes, it is impossible that ret > len or total_len, so we should remove some useless codes in both above functions.

---
 drivers/net/tun.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
drivers/net/tun.c +0 -5
index f9c935a..d61719c 100644
@@ -1354,7 +1354,6 @@ static ssize_t tun_chr_aio_read(struct kiocb *iocb, const struct iovec *iv,
 
 	ret = tun_do_read(tun, tfile, iv, len,
 			  file->f_flags & O_NONBLOCK);
-	ret = min_t(ssize_t, ret, len);
 out:
 	tun_put(tun);
 	return ret;
@@ -1453,10 +1452,6 @@ static int tun_recvmsg(struct kiocb *iocb, struct socket *sock,
 	}
 	ret = tun_do_read(tun, tfile, m->msg_iov, total_len,
 			  flags & MSG_DONTWAIT);
-	if (ret > total_len) {
-		m->msg_flags |= MSG_TRUNC;
-		ret = flags & MSG_TRUNC ? ret : total_len;
-	}
 out:
 	tun_put(tun);
 	return ret;
Signature · 1 line
1.7.6.5
#8 lore raw
In reply to Zhi Yong Wu
Quoted 4 lines · Zhi Yong Wu

From: Zhi Yong Wu <[email protected]>

By checking related codes, it is impossible that ret > len or total_len, so we should remove some useless coeds in both above functions.

Looks like commit 6680ec68eff47d36f67b4351bc9836fd6cba9532

Author: Jason Wang <[email protected]>
Date:   Thu Jul 25 13:00:33 2013 +0800

tuntap: hardware vlan tx support

Introduced a change in tun_put_user() where we can never return a length longer then len or total_len. This has an effect that is now impossible to signal truncated status. It seems like a potential loss of functionality and it might make sense to restore it.

-vlad

Quoted 30 lines
---
 drivers/net/macvtap.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
drivers/net/macvtap.c +0 -5
index 4c6f84c..7f4ccdd 100644
@@ -871,7 +871,6 @@ static ssize_t macvtap_aio_read(struct kiocb *iocb, const struct iovec *iv,
 	}
 
 	ret = macvtap_do_read(q, iv, len, file->f_flags & O_NONBLOCK);
-	ret = min_t(ssize_t, ret, len); /* XXX copied from tun.c. Why? */
 out:
 	return ret;
 }
@@ -1104,10 +1103,6 @@ static int macvtap_recvmsg(struct kiocb *iocb, struct socket *sock,
 		return -EINVAL;
 	ret = macvtap_do_read(q, m->msg_iov, total_len,
 			  flags & MSG_DONTWAIT);
-	if (ret > total_len) {
-		m->msg_flags |= MSG_TRUNC;
-		ret = flags & MSG_TRUNC ? ret : total_len;
-	}
 	return ret;
 }
 
#9 lore raw
Quoted 11 lines · Vlad Yasevich
Quoted 4 lines · Zhi Yong Wu
Quoted 4 lines

From: Zhi Yong Wu <[email protected]>

By checking related codes, it is impossible that ret > len or total_len, so we should remove some useless coeds in both above functions.

Looks like commit 6680ec68eff47d36f67b4351bc9836fd6cba9532

Author: Jason Wang <[email protected]>
Date:   Thu Jul 25 13:00:33 2013 +0800

tuntap: hardware vlan tx support

Quoted 7 lines

Introduced a change in tun_put_user() where we can never return a length longer then len or total_len. This has an effect that is now impossible to signal truncated status. It seems like a potential loss of functionality and it might make sense to restore it.

-vlad

True, will send a patch. For macvtap, we'd better also correct current behaviour to be same with tun.

Thanks

#3 lore raw

Re: [PATCH 2/2] tun: remove useless codes in tun_chr_aio_read() and tun_recvmsg()

Quoted 11 lines · David Miller

From: Zhi Yong Wu <[email protected]>
Date: Sat, 7 Dec 2013 04:55:00 +0800

Quoted 6 lines

From: Zhi Yong Wu <[email protected]>

By checking related codes, it is impossible that ret > len or total_len, so we should remove some useless codes in both above functions.

Applied.

Wait a sec. We want to be able to return a value bigger then len to trigger a MSG_TRUNC. Jason has patches for to fix this. If you apply this, we'll have to re-introduce this code back in.

Same goes for patch 1/2.

-vlad

Quoted 5 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

maintainer
#4 lore raw

Re: [PATCH 2/2] tun: remove useless codes in tun_chr_aio_read() and tun_recvmsg()

From: Vlad Yasevich <[email protected]>
Date: Tue, 10 Dec 2013 12:18:09 -0500

Quoted 11 lines · David Miller
Quoted 10 lines

From: Zhi Yong Wu <[email protected]>
Date: Sat, 7 Dec 2013 04:55:00 +0800

Quoted 6 lines

From: Zhi Yong Wu <[email protected]>

By checking related codes, it is impossible that ret > len or total_len, so we should remove some useless codes in both above functions.

Quoted 7 lines
Quoted 1 line

Applied.

Wait a sec. We want to be able to return a value bigger then len to trigger a MSG_TRUNC. Jason has patches for to fix this. If you apply this, we'll have to re-introduce this code back in.

Same goes for patch 1/2.

That's fine, right now the code makes no sense as the condition can never be triggered so there is no harm removing the illogical code meanwhile.

#5 lore raw

Re: [PATCH 2/2] tun: remove useless codes in tun_chr_aio_read() and tun_recvmsg()

Only one reminder, since David has committed the two patches, you maybe need to take their impact on your patches into account.

Quoted 25 lines · David Miller

From: Vlad Yasevich <[email protected]>
Date: Tue, 10 Dec 2013 12:18:09 -0500

Quoted 11 lines · David Miller
Quoted 10 lines

From: Zhi Yong Wu <[email protected]>
Date: Sat, 7 Dec 2013 04:55:00 +0800

Quoted 6 lines

From: Zhi Yong Wu <[email protected]>

By checking related codes, it is impossible that ret > len or total_len, so we should remove some useless codes in both above functions.

Quoted 7 lines
Quoted 1 line

Applied.

Wait a sec. We want to be able to return a value bigger then len to trigger a MSG_TRUNC. Jason has patches for to fix this. If you apply this, we'll have to re-introduce this code back in.

Same goes for patch 1/2.

That's fine, right now the code makes no sense as the condition can never be triggered so there is no harm removing the illogical code meanwhile.

Signature · 3 lines
Regards,

Zhi Yong Wu
maintainer
#6 lore raw

Re: [PATCH 2/2] tun: remove useless codes in tun_chr_aio_read() and tun_recvmsg()

From: Zhi Yong Wu <[email protected]>
Date: Wed, 11 Dec 2013 11:14:04 +0800

Quoted 2 lines

Only one reminder, since David has committed the two patches, you maybe need to take their impact on your patches into account.

I reverted these changes from net-next.

#7 lore raw

Re: [PATCH 2/2] tun: remove useless codes in tun_chr_aio_read() and tun_recvmsg()

Quoted 7 lines · David Miller

From: Zhi Yong Wu <[email protected]>
Date: Wed, 11 Dec 2013 11:14:04 +0800

Quoted 2 lines

Only one reminder, since David has committed the two patches, you maybe need to take their impact on your patches into account.

I reverted these changes from net-next.

So rapid:), thanks for your reminder.

Signature · 3 lines
Regards,

Zhi Yong Wu