2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

netdev_class: Pass a struct ofpbuf * to rx_recv()

Update the netdev_class so that struct ofpbuf * is passed to rx_recv()
to provide both the data and size of the data to read a packet into.

On success, update struct ofpbuf size inside netdev_class rx_recv
implementation and return 0. This moves logic from the caller.
On error a positive error code is returned, whereas previously
a negative error code was returned. This is a more common convention.

This patch should not have any behavioural changes.

This patch is in preparation for the netdev-linux variant of rx_recv()
making use of headroom in the struct ofpbuf * parameter to push a VLAN tag
obtained from auxdata.

Signed-off-by: Simon Horman <horms@verge.net.au>
Co-authored-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
Simon Horman
2014-01-15 17:17:00 +09:00
committed by Ben Pfaff
parent 6a62a162ef
commit bfd3367b9e
5 changed files with 45 additions and 37 deletions

View File

@@ -848,25 +848,29 @@ netdev_linux_rx_dealloc(struct netdev_rx *rx_)
}
static int
netdev_linux_rx_recv(struct netdev_rx *rx_, void *data, size_t size)
netdev_linux_rx_recv(struct netdev_rx *rx_, struct ofpbuf *buffer)
{
struct netdev_rx_linux *rx = netdev_rx_linux_cast(rx_);
ssize_t retval;
size_t size = ofpbuf_tailroom(buffer);
do {
retval = (rx->is_tap
? read(rx->fd, data, size)
: recv(rx->fd, data, size, MSG_TRUNC));
? read(rx->fd, buffer->data, size)
: recv(rx->fd, buffer->data, size, MSG_TRUNC));
} while (retval < 0 && errno == EINTR);
if (retval >= 0) {
return retval > size ? -EMSGSIZE : retval;
} else {
if (retval < 0) {
if (errno != EAGAIN) {
VLOG_WARN_RL(&rl, "error receiving Ethernet packet on %s: %s",
ovs_strerror(errno), netdev_rx_get_name(rx_));
}
return -errno;
return errno;
} else if (retval > size) {
return EMSGSIZE;
} else {
buffer->size += retval;
return 0;
}
}