Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
tun/tap: Bad packets sent to kernel via tun/tap interface
[vpp.git]
/
src
/
vnet
/
unix
/
tapcli.c
diff --git
a/src/vnet/unix/tapcli.c
b/src/vnet/unix/tapcli.c
index
13154b3
..
ce38609
100644
(file)
--- a/
src/vnet/unix/tapcli.c
+++ b/
src/vnet/unix/tapcli.c
@@
-99,8
+99,11
@@
u8 * format_tapcli_rx_trace (u8 * s, va_list * va)
* @brief TAPCLI main state struct
*/
typedef struct {
* @brief TAPCLI main state struct
*/
typedef struct {
- /** Vector of iovecs for readv/writev calls. */
- struct iovec * iovecs;
+ /** Vector of iovecs for readv calls. */
+ struct iovec * rd_iovecs;
+
+ /** Vector of iovecs for writev calls. */
+ struct iovec * wr_iovecs;
/** Vector of VLIB rx buffers to use. We allocate them in blocks
of VLIB_FRAME_SIZE (256). */
/** Vector of VLIB rx buffers to use. We allocate them in blocks
of VLIB_FRAME_SIZE (256). */
@@
-199,11
+202,11
@@
tapcli_tx (vlib_main_t * vm,
ti = vec_elt_at_index (tm->tapcli_interfaces, p[0]);
/* Re-set iovecs if present. */
ti = vec_elt_at_index (tm->tapcli_interfaces, p[0]);
/* Re-set iovecs if present. */
- if (tm->iovecs)
- _vec_len (tm->iovecs) = 0;
+ if (tm->
wr_
iovecs)
+ _vec_len (tm->
wr_
iovecs) = 0;
/* VLIB buffer chain -> Unix iovec(s). */
/* VLIB buffer chain -> Unix iovec(s). */
- vec_add2 (tm->iovecs, iov, 1);
+ vec_add2 (tm->
wr_
iovecs, iov, 1);
iov->iov_base = b->data + b->current_data;
iov->iov_len = l = b->current_length;
iov->iov_base = b->data + b->current_data;
iov->iov_len = l = b->current_length;
@@
-212,7
+215,7
@@
tapcli_tx (vlib_main_t * vm,
do {
b = vlib_get_buffer (vm, b->next_buffer);
do {
b = vlib_get_buffer (vm, b->next_buffer);
- vec_add2 (tm->iovecs, iov, 1);
+ vec_add2 (tm->
wr_
iovecs, iov, 1);
iov->iov_base = b->data + b->current_data;
iov->iov_len = b->current_length;
iov->iov_base = b->data + b->current_data;
iov->iov_len = b->current_length;
@@
-220,7
+223,7
@@
tapcli_tx (vlib_main_t * vm,
} while (b->flags & VLIB_BUFFER_NEXT_PRESENT);
}
} while (b->flags & VLIB_BUFFER_NEXT_PRESENT);
}
- if (writev (ti->unix_fd, tm->
iovecs, vec_len (tm->
iovecs)) < l)
+ if (writev (ti->unix_fd, tm->
wr_iovecs, vec_len (tm->wr_
iovecs)) < l)
clib_unix_warning ("writev");
}
clib_unix_warning ("writev");
}
@@
-292,14
+295,14
@@
static uword tapcli_rx_iface(vlib_main_t * vm,
/* Allocate RX buffers from end of rx_buffers.
Turn them into iovecs to pass to readv. */
/* Allocate RX buffers from end of rx_buffers.
Turn them into iovecs to pass to readv. */
- vec_validate (tm->iovecs, tm->mtu_buffers - 1);
+ vec_validate (tm->
rd_
iovecs, tm->mtu_buffers - 1);
for (j = 0; j < tm->mtu_buffers; j++) {
b = vlib_get_buffer (vm, tm->rx_buffers[i_rx - j]);
for (j = 0; j < tm->mtu_buffers; j++) {
b = vlib_get_buffer (vm, tm->rx_buffers[i_rx - j]);
- tm->iovecs[j].iov_base = b->data;
- tm->iovecs[j].iov_len = buffer_size;
+ tm->
rd_
iovecs[j].iov_base = b->data;
+ tm->
rd_
iovecs[j].iov_len = buffer_size;
}
}
- n_bytes_left = readv (ti->unix_fd, tm->iovecs, tm->mtu_buffers);
+ n_bytes_left = readv (ti->unix_fd, tm->
rd_
iovecs, tm->mtu_buffers);
n_bytes_in_packet = n_bytes_left;
if (n_bytes_left <= 0) {
if (errno != EAGAIN) {
n_bytes_in_packet = n_bytes_left;
if (n_bytes_left <= 0) {
if (errno != EAGAIN) {