Skip to content

Commit bbd3762

Browse files
committed
net: Revert macvtap/tun truncation signalling changes.
Jason Wang and Michael S. Tsirkin are still discussing how to properly fix this. Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 730054d commit bbd3762

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

drivers/net/macvtap.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -767,14 +767,10 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
767767
const struct sk_buff *skb,
768768
const struct iovec *iv, int len)
769769
{
770-
int ret, off;
770+
int ret;
771771
int vnet_hdr_len = 0;
772772
int vlan_offset = 0;
773773
int copied;
774-
struct {
775-
__be16 h_vlan_proto;
776-
__be16 h_vlan_TCI;
777-
} veth;
778774

779775
if (q->flags & IFF_VNET_HDR) {
780776
struct virtio_net_hdr vnet_hdr;
@@ -789,36 +785,39 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
789785
if (memcpy_toiovecend(iv, (void *)&vnet_hdr, 0, sizeof(vnet_hdr)))
790786
return -EFAULT;
791787
}
792-
off = copied = vnet_hdr_len;
788+
copied = vnet_hdr_len;
793789

794790
if (!vlan_tx_tag_present(skb))
795791
len = min_t(int, skb->len, len);
796792
else {
797793
int copy;
798-
794+
struct {
795+
__be16 h_vlan_proto;
796+
__be16 h_vlan_TCI;
797+
} veth;
799798
veth.h_vlan_proto = skb->vlan_proto;
800799
veth.h_vlan_TCI = htons(vlan_tx_tag_get(skb));
801800

802801
vlan_offset = offsetof(struct vlan_ethhdr, h_vlan_proto);
803802
len = min_t(int, skb->len + VLAN_HLEN, len);
804803

805804
copy = min_t(int, vlan_offset, len);
806-
ret = skb_copy_datagram_const_iovec(skb, 0, iv, off, copy);
805+
ret = skb_copy_datagram_const_iovec(skb, 0, iv, copied, copy);
807806
len -= copy;
808-
off += copy;
807+
copied += copy;
809808
if (ret || !len)
810809
goto done;
811810

812811
copy = min_t(int, sizeof(veth), len);
813-
ret = memcpy_toiovecend(iv, (void *)&veth, off, copy);
812+
ret = memcpy_toiovecend(iv, (void *)&veth, copied, copy);
814813
len -= copy;
815-
off += copy;
814+
copied += copy;
816815
if (ret || !len)
817816
goto done;
818817
}
819818

820-
ret = skb_copy_datagram_const_iovec(skb, vlan_offset, iv, off, len);
821-
copied += skb->len + (vlan_offset ? sizeof(veth) : 0);
819+
ret = skb_copy_datagram_const_iovec(skb, vlan_offset, iv, copied, len);
820+
copied += len;
822821

823822
done:
824823
return ret ? ret : copied;
@@ -876,7 +875,7 @@ static ssize_t macvtap_aio_read(struct kiocb *iocb, const struct iovec *iv,
876875
}
877876

878877
ret = macvtap_do_read(q, iocb, iv, len, file->f_flags & O_NONBLOCK);
879-
ret = min_t(ssize_t, ret, len);
878+
ret = min_t(ssize_t, ret, len); /* XXX copied from tun.c. Why? */
880879
if (ret > 0)
881880
iocb->ki_pos = ret;
882881
out:

drivers/net/tun.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,11 +1183,7 @@ static ssize_t tun_put_user(struct tun_struct *tun,
11831183
const struct iovec *iv, int len)
11841184
{
11851185
struct tun_pi pi = { 0, skb->protocol };
1186-
struct {
1187-
__be16 h_vlan_proto;
1188-
__be16 h_vlan_TCI;
1189-
} veth;
1190-
ssize_t total = 0, off = 0;
1186+
ssize_t total = 0;
11911187
int vlan_offset = 0;
11921188

11931189
if (!(tun->flags & TUN_NO_PI)) {
@@ -1252,11 +1248,14 @@ static ssize_t tun_put_user(struct tun_struct *tun,
12521248
total += tun->vnet_hdr_sz;
12531249
}
12541250

1255-
off = total;
12561251
if (!vlan_tx_tag_present(skb)) {
12571252
len = min_t(int, skb->len, len);
12581253
} else {
12591254
int copy, ret;
1255+
struct {
1256+
__be16 h_vlan_proto;
1257+
__be16 h_vlan_TCI;
1258+
} veth;
12601259

12611260
veth.h_vlan_proto = skb->vlan_proto;
12621261
veth.h_vlan_TCI = htons(vlan_tx_tag_get(skb));
@@ -1265,22 +1264,22 @@ static ssize_t tun_put_user(struct tun_struct *tun,
12651264
len = min_t(int, skb->len + VLAN_HLEN, len);
12661265

12671266
copy = min_t(int, vlan_offset, len);
1268-
ret = skb_copy_datagram_const_iovec(skb, 0, iv, off, copy);
1267+
ret = skb_copy_datagram_const_iovec(skb, 0, iv, total, copy);
12691268
len -= copy;
1270-
off += copy;
1269+
total += copy;
12711270
if (ret || !len)
12721271
goto done;
12731272

12741273
copy = min_t(int, sizeof(veth), len);
1275-
ret = memcpy_toiovecend(iv, (void *)&veth, off, copy);
1274+
ret = memcpy_toiovecend(iv, (void *)&veth, total, copy);
12761275
len -= copy;
1277-
off += copy;
1276+
total += copy;
12781277
if (ret || !len)
12791278
goto done;
12801279
}
12811280

1282-
skb_copy_datagram_const_iovec(skb, vlan_offset, iv, off, len);
1283-
total += skb->len + (vlan_offset ? sizeof(veth) : 0);
1281+
skb_copy_datagram_const_iovec(skb, vlan_offset, iv, total, len);
1282+
total += len;
12841283

12851284
done:
12861285
tun->dev->stats.tx_packets++;

0 commit comments

Comments
 (0)