mirror of
https://github.com/qemu/qemu.git
synced 2024-11-24 03:13:44 +08:00
net/filter-mirror.c: Introduce parameter for filter_send()
This patch change the filter_send() parameter from CharBackend to MirrorState, we can get more information like vnet_hdr(We use it to support packet with vnet_header). Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> Signed-off-by: Jason Wang <jasowang@redhat.com>
This commit is contained in:
parent
3cde5ea211
commit
dc3c5ac645
@ -43,7 +43,7 @@ typedef struct MirrorState {
|
||||
SocketReadState rs;
|
||||
} MirrorState;
|
||||
|
||||
static int filter_send(CharBackend *chr_out,
|
||||
static int filter_send(MirrorState *s,
|
||||
const struct iovec *iov,
|
||||
int iovcnt)
|
||||
{
|
||||
@ -58,14 +58,14 @@ static int filter_send(CharBackend *chr_out,
|
||||
}
|
||||
|
||||
len = htonl(size);
|
||||
ret = qemu_chr_fe_write_all(chr_out, (uint8_t *)&len, sizeof(len));
|
||||
ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)&len, sizeof(len));
|
||||
if (ret != sizeof(len)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
buf = g_malloc(size);
|
||||
iov_to_buf(iov, iovcnt, 0, buf, size);
|
||||
ret = qemu_chr_fe_write_all(chr_out, (uint8_t *)buf, size);
|
||||
ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)buf, size);
|
||||
g_free(buf);
|
||||
if (ret != size) {
|
||||
goto err;
|
||||
@ -141,7 +141,7 @@ static ssize_t filter_mirror_receive_iov(NetFilterState *nf,
|
||||
MirrorState *s = FILTER_MIRROR(nf);
|
||||
int ret;
|
||||
|
||||
ret = filter_send(&s->chr_out, iov, iovcnt);
|
||||
ret = filter_send(s, iov, iovcnt);
|
||||
if (ret) {
|
||||
error_report("filter mirror send failed(%s)", strerror(-ret));
|
||||
}
|
||||
@ -164,7 +164,7 @@ static ssize_t filter_redirector_receive_iov(NetFilterState *nf,
|
||||
int ret;
|
||||
|
||||
if (qemu_chr_fe_backend_connected(&s->chr_out)) {
|
||||
ret = filter_send(&s->chr_out, iov, iovcnt);
|
||||
ret = filter_send(s, iov, iovcnt);
|
||||
if (ret) {
|
||||
error_report("filter redirector send failed(%s)", strerror(-ret));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user