Net patches
Subsystems (3)
[PULL V2 01/20] virtio-net: calculating proper msix vectors on init
In reply to Jason WangCurrently, the default msix vectors for virtio-net-pci is 3 which is obvious not suitable for multiqueue guest, so we depends on the user or management tools to pass a correct vectors parameter. In fact, we can simplifying this by calculating the number of vectors on realize.
Consider we have N queues, the number of vectors needed is 2*N + 2 (#queue pairs + plus one config interrupt and control vq). We didn't check whether or not host support control vq because it was added unconditionally by qemu to avoid breaking legacy guests such as Minix.
--- hw/core/machine.c | 1 + hw/virtio/virtio-net-pci.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-)
hw/core/machine.c +1 -0
@@ -39,6 +39,7 @@GlobalProperty hw_compat_5_2[] = { {"ICH9-LPC" ,"smm-compat" ,"on" }, {"PIIX4_PM" ,"smm-compat" ,"on" }, + {"virtio-net-pci" ,"vectors" ,"3" }, };const size_t hw_compat_5_2_len =G_N_ELEMENTS (hw_compat_5_2);
hw/virtio/virtio-net-pci.c +9 -1
@@ -41,7 +41,8 @@ struct VirtIONetPCI {static Property virtio_net_properties[] = {DEFINE_PROP_BIT ("ioeventfd" , VirtIOPCIProxy, flags,VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT , true), -DEFINE_PROP_UINT32 ("vectors" , VirtIOPCIProxy, nvectors,3 ), +DEFINE_PROP_UINT32 ("vectors" , VirtIOPCIProxy, nvectors, +DEV_NVECTORS_UNSPECIFIED ),DEFINE_PROP_END_OF_LIST (), };
@@ -50,6 +51,13 @@ static void virtio_net_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)DeviceState *qdev =DEVICE (vpci_dev);VirtIONetPCI *dev =VIRTIO_NET_PCI (vpci_dev);DeviceState *vdev =DEVICE (&dev->vdev); +VirtIONet *net =VIRTIO_NET (vdev); + +if (vpci_dev->nvectors ==DEV_NVECTORS_UNSPECIFIED ) { + vpci_dev->nvectors =2 *MAX (net->nic_conf.peers.queues,1 ) + +1 /* Config interrupt */ + +1 /* Control vq */ ; + }virtio_net_set_netclient_name (&dev->vdev, qdev->id,object_get_typename (OBJECT (qdev)));
Signature · 1 line
2.7.4
The following changes since commit 6157b0e19721aadb4c7fdcfe57b2924af6144b14:
Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-6.0-pull-request' into staging (2021-03-14 17:47:49 +0000)
are available in the git repository at:
https://github.com/jasowang/qemu.git tags/net-pull-request
for you to fetch changes up to f2e8319d456724c3d8514d943dc4607e2f08e88a:
net: Do not fill legacy info_str for backends (2021-03-15 16:41:22 +0800)
----------------------------------------------------------------
Changes since V1:
- drop the workaound of "-nic" id and fix the merge
- add the series of query-netdev
----------------------------------------------------------------
Alexander Bulekov (4):
rtl8139: switch to use qemu_receive_packet() for loopback
pcnet: switch to use qemu_receive_packet() for loopback
cadence_gem: switch to use qemu_receive_packet() for loopback
lan9118: switch to use qemu_receive_packet() for loopback
Alexey Kirillov (5):
qapi: net: Add query-netdev command
tests: Add tests for query-netdev command
net: Move NetClientState.info_str to dynamic allocations
hmp: Use QAPI NetdevInfo in hmp_info_network
net: Do not fill legacy info_str for backends
Bin Meng (1):
net: Fix build error when DEBUG_NET is on
Cornelia Huck (1):
pvrdma: wean code off pvrdma_ring.h kernel header
Jason Wang (8):
virtio-net: calculating proper msix vectors on init
e1000: fail early for evil descriptor
net: introduce qemu_receive_packet()
e1000: switch to use qemu_receive_packet() for loopback
dp8393x: switch to use qemu_receive_packet() for loopback packet
msf2-mac: switch to use qemu_receive_packet() for loopback
sungem: switch to use qemu_receive_packet() for loopback
tx_pkt: switch to use qemu_receive_packet_iov() for loopback
Paolo Bonzini (1):
net: validate that ids are well formed
hw/core/machine.c | 1 + hw/net/cadence_gem.c | 4 +- hw/net/dp8393x.c | 2 +- hw/net/e1000.c | 6 +- hw/net/lan9118.c | 2 +- hw/net/msf2-emac.c | 2 +- hw/net/net_tx_pkt.c | 2 +- hw/net/pcnet.c | 2 +- hw/net/rtl8139.c | 2 +- hw/net/sungem.c | 2 +- hw/net/xen_nic.c | 5 +- hw/rdma/vmw/pvrdma.h | 5 +- hw/rdma/vmw/pvrdma_cmd.c | 6 +- hw/rdma/vmw/pvrdma_dev_ring.c | 41 +++-- hw/rdma/vmw/pvrdma_dev_ring.h | 9 +- hw/rdma/vmw/pvrdma_main.c | 4 +- hw/virtio/virtio-net-pci.c | 10 +- include/net/net.h | 10 +- include/net/queue.h | 8 + include/qapi/hmp-output-visitor.h | 30 ++++ .../drivers/infiniband/hw/vmw_pvrdma/pvrdma_ring.h | 114 ------------ net/l2tpv3.c | 8 +- net/net.c | 117 +++++++++++-- net/netmap.c | 7 + net/queue.c | 22 +++ net/slirp.c | 124 ++++++++++++- net/socket.c | 92 +++++++--- net/tap-win32.c | 10 +- net/tap.c | 107 ++++++++++-- net/vde.c | 25 ++- net/vhost-user.c | 20 ++- net/vhost-vdpa.c | 15 +- qapi/hmp-output-visitor.c | 193 +++++++++++++++++++++ qapi/meson.build | 1 + qapi/net.json | 80 +++++++++ scripts/update-linux-headers.sh | 3 +- tests/qtest/meson.build | 3 + tests/qtest/test-query-netdev.c | 120 +++++++++++++ 38 files changed, 990 insertions(+), 224 deletions(-) create mode 100644 include/qapi/hmp-output-visitor.h delete mode 100644 include/standard-headers/drivers/infiniband/hw/vmw_pvrdma/pvrdma_ring.h create mode 100644 qapi/hmp-output-visitor.c create mode 100644 tests/qtest/test-query-netdev.c
[PULL V2 02/20] net: Fix build error when DEBUG_NET is on
From: Bin Meng <[email protected]>
"qemu-common.h" should be included to provide the forward declaration of qemu_hexdump() when DEBUG_NET is on.
--- net/net.c | 1 + 1 file changed, 1 insertion(+)
net/net.c +1 -0
@@ -23,6 +23,7 @@*/ #include "qemu/osdep.h" +#include "qemu-common.h" #include "net/net.h" #include "clients.h"
Signature · 1 line
2.7.4
[PULL V2 10/20] tx_pkt: switch to use qemu_receive_packet_iov() for loopback
In reply to Jason WangThis patch switches to use qemu_receive_receive_iov() which can detect reentrancy and return early.
This is intended to address CVE-2021-3416.
--- hw/net/net_tx_pkt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/net_tx_pkt.c +1 -1
@@ -553,7 +553,7 @@ static inline void net_tx_pkt_sendv(struct NetTxPkt *pkt, NetClientState *nc, const struct iovec *iov, int iov_cnt) { if (pkt->is_loopback) { - nc->info->receive_iov(nc, iov, iov_cnt); +qemu_receive_packet_iov (nc ,iov ,iov_cnt ); } else {qemu_sendv_packet (nc, iov, iov_cnt); }
Signature · 1 line
2.7.4
[PULL V2 05/20] net: introduce qemu_receive_packet()
In reply to Jason WangSome NIC supports loopback mode and this is done by calling nc->info->receive() directly which in fact suppresses the effort of reentrancy check that is done in qemu_net_queue_send().
Unfortunately we can't use qemu_net_queue_send() here since for loopback there's no sender as peer, so this patch introduce a qemu_receive_packet() which is used for implementing loopback mode for a NIC with this check.
NIC that supports loopback mode will be converted to this helper.
This is intended to address CVE-2021-3416.
--- include/net/net.h | 5 +++++ include/net/queue.h | 8 ++++++++ net/net.c | 38 +++++++++++++++++++++++++++++++------- net/queue.c | 22 ++++++++++++++++++++++ 4 files changed, 66 insertions(+), 7 deletions(-)
include/net/net.h +5 -0
@@ -144,12 +144,17 @@ void *qemu_get_nic_opaque(NetClientState *nc);void qemu_del_net_client (NetClientState *nc);typedef void (*qemu_nic_foreach )(NICState *nic,void *opaque);void qemu_foreach_nic (qemu_nic_foreach func,void *opaque); +int qemu_can_receive_packet (NetClientState *nc);int qemu_can_send_packet (NetClientState *nc);ssize_t qemu_sendv_packet (NetClientState *nc,const struct iovec *iov,int iovcnt);ssize_t qemu_sendv_packet_async (NetClientState *nc,const struct iovec *iov,int iovcnt,NetPacketSent *sent_cb);ssize_t qemu_send_packet (NetClientState *nc,const uint8_t *buf,int size); +ssize_t qemu_receive_packet (NetClientState *nc,const uint8_t *buf,int size); +ssize_t qemu_receive_packet_iov (NetClientState *nc, +const struct iovec *iov, +int iovcnt);ssize_t qemu_send_packet_raw (NetClientState *nc,const uint8_t *buf,int size);ssize_t qemu_send_packet_async (NetClientState *nc,const uint8_t *buf,int size,NetPacketSent *sent_cb);
include/net/queue.h +8 -0
@@ -55,6 +55,14 @@ void qemu_net_queue_append_iov(NetQueue *queue,void qemu_del_net_queue (NetQueue *queue); +ssize_t qemu_net_queue_receive (NetQueue *queue, +const uint8_t *data, +size_t size); + +ssize_t qemu_net_queue_receive_iov (NetQueue *queue, +const struct iovec *iov, +int iovcnt); + ssize_t qemu_net_queue_send(NetQueue *queue, NetClientState *sender, unsigned flags,
net/net.c +31 -7
@@ -529,6 +529,17 @@ int qemu_set_vnet_be(NetClientState *nc, bool is_be)#endif } +int qemu_can_receive_packet (NetClientState *nc) +{ +if (nc->receive_disabled) { +return 0 ; + }else if (nc->info->can_receive && + !nc->info->can_receive (nc)) { +return 0 ; + } +return 1 ; +} +int qemu_can_send_packet (NetClientState *sender) {int vm_running =runstate_is_running ();
@@ -541,13 +552,7 @@ int qemu_can_send_packet(NetClientState *sender)return 1 ; } -if (sender->peer->receive_disabled) { -return 0 ; - }else if (sender->peer->info->can_receive && - !sender->peer->info->can_receive (sender->peer)) { -return 0 ; - } -return 1 ; +return qemu_can_receive_packet (sender->peer); } static ssize_t filter_receive_iov(NetClientState *nc,
@@ -680,6 +685,25 @@ ssize_t qemu_send_packet(NetClientState *nc, const uint8_t *buf, int size)return qemu_send_packet_async (nc, buf, size,NULL ); } +ssize_t qemu_receive_packet (NetClientState *nc,const uint8_t *buf,int size) +{ +if (!qemu_can_receive_packet (nc)) { +return 0 ; + } + +return qemu_net_queue_receive (nc->incoming_queue, buf, size); +} + +ssize_t qemu_receive_packet_iov (NetClientState *nc,const struct iovec *iov, +int iovcnt) +{ +if (!qemu_can_receive_packet (nc)) { +return 0 ; + } + +return qemu_net_queue_receive_iov (nc->incoming_queue, iov, iovcnt); +} +ssize_t qemu_send_packet_raw (NetClientState *nc,const uint8_t *buf,int size) { return qemu_send_packet_async_with_flags(nc, QEMU_NET_PACKET_FLAG_RAW,
net/queue.c +22 -0
@@ -182,6 +182,28 @@ static ssize_t qemu_net_queue_deliver_iov(NetQueue *queue,return ret; } +ssize_t qemu_net_queue_receive (NetQueue *queue, +const uint8_t *data, +size_t size) +{ +if (queue->delivering) { +return 0 ; + } + +return qemu_net_queue_deliver (queue,NULL ,0 , data, size); +} + +ssize_t qemu_net_queue_receive_iov (NetQueue *queue, +const struct iovec *iov, +int iovcnt) +{ +if (queue->delivering) { +return 0 ; + } + +return qemu_net_queue_deliver_iov (queue,NULL ,0 , iov, iovcnt); +} + ssize_t qemu_net_queue_send(NetQueue *queue, NetClientState *sender, unsigned flags,
Signature · 1 line
2.7.4
[PULL V2 03/20] net: validate that ids are well formed
In reply to Jason WangFrom: Paolo Bonzini <[email protected]>
When a network or network device is created from the command line or HMP, QemuOpts ensures that the id passes the id_wellformed check. However, QMP skips this:
$ qemu-system-x86_64 -qmp stdio -S -nic user,id=123/456 qemu-system-x86_64: -nic user,id=123/456: Parameter id expects an identifier Identifiers consist of letters, digits, -, ., _, starting with a letter.
$ qemu-system-x86_64 -qmp stdio -S
{"execute":"qmp_capabilities"}
{"return": {}}
{"execute":"netdev_add", "arguments": {"type": "user", "id": "123/456"}}
{"return": {}}After:
$ qemu-system-x86_64 -qmp stdio -S
{"execute":"qmp_capabilities"}
{"return": {}}
{"execute":"netdev_add", "arguments": {"type": "user", "id": "123/456"}}
{"error": {"class": "GenericError", "desc": "Parameter "id" expects an identifier"}}Validity checks should be performed always at the bottom of the call chain, because QMP skips all the steps above. At the same time we know that every call chain should go through either QMP or (for legacy) through QemuOpts. Because the id for -net and -nic is automatically generated and not well-formed by design, just add the check to QMP.
--- net/net.c | 5 +++++ 1 file changed, 5 insertions(+)
net/net.c +5 -0
@@ -1134,6 +1134,11 @@ void netdev_add(QemuOpts *opts, Error **errp)void qmp_netdev_add (Netdev *netdev,Error **errp) { +if (!id_wellformed (netdev->id)) { +error_setg (errp,QERR_INVALID_PARAMETER_VALUE ,"id" ,"an identifier" ); +return ; + } +net_client_init1 (netdev, true, errp); }
Signature · 1 line
2.7.4
[PULL V2 04/20] e1000: fail early for evil descriptor
In reply to Jason WangDuring procss_tx_desc(), driver can try to chain data descriptor with legacy descriptor, when will lead underflow for the following calculation in process_tx_desc() for bytes:
if (tp->size + bytes > msh)
bytes = msh - tp->size;This will lead a infinite loop. So check and fail early if tp->size if greater or equal to msh.
--- hw/net/e1000.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/net/e1000.c +4 -0
@@ -670,6 +670,9 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp) msh = tp->tso_props.hdr_len + tp->tso_props.mss; do { bytes = split_size; + if (tp->size >= msh) { + goto eop; + } if (tp->size + bytes > msh) bytes = msh - tp->size;
@@ -695,6 +698,7 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp) tp->size += split_size; } +eop:if (!(txd_lower &E1000_TXD_CMD_EOP ))return ;if (!(tp->cptse && tp->size < tp->tso_props.hdr_len)) {
Signature · 1 line
2.7.4
[PULL V2 12/20] pcnet: switch to use qemu_receive_packet() for loopback
In reply to Jason WangFrom: Alexander Bulekov <[email protected]>
This patch switches to use qemu_receive_packet() which can detect reentrancy and return early.
This is intended to address CVE-2021-3416.
--- hw/net/pcnet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/pcnet.c +1 -1
@@ -1250,7 +1250,7 @@ txagain:if (BCR_SWSTYLE (s) ==1 ) add_crc = !GET_FIELD (tmd.status,TMDS ,NOFCS ); s->looptest = add_crc ?PCNET_LOOPTEST_CRC :PCNET_LOOPTEST_NOCRC ; -pcnet_receive (qemu_get_queue (s->nic), s->buffer, s->xmit_pos); +qemu_receive_packet (qemu_get_queue (s->nic), s->buffer, s->xmit_pos); s->looptest =0 ; }else {if (s->nic) {
Signature · 1 line
2.7.4
[PULL V2 08/20] msf2-mac: switch to use qemu_receive_packet() for loopback
In reply to Jason WangThis patch switches to use qemu_receive_packet() which can detect reentrancy and return early.
This is intended to address CVE-2021-3416.
--- hw/net/msf2-emac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/msf2-emac.c +1 -1
@@ -158,7 +158,7 @@ static void msf2_dma_tx(MSF2EmacState *s)* R_CFG1 bit 0 is set. */ if (s->regs[R_CFG1 ] &R_CFG1_LB_EN_MASK ) { - nc->info->receive (nc, buf, size); +qemu_receive_packet (nc, buf, size); }else {qemu_send_packet (nc, buf, size); }
Signature · 1 line
2.7.4
[PULL V2 06/20] e1000: switch to use qemu_receive_packet() for loopback
In reply to Jason WangThis patch switches to use qemu_receive_packet() which can detect reentrancy and return early.
This is intended to address CVE-2021-3416.
--- hw/net/e1000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/e1000.c +1 -1
@@ -546,7 +546,7 @@ e1000_send_packet(E1000State *s, const uint8_t *buf, int size)NetClientState *nc =qemu_get_queue (s->nic);if (s->phy_reg[PHY_CTRL ] &MII_CR_LOOPBACK ) { - nc->info->receive (nc, buf, size); +qemu_receive_packet (nc, buf, size); }else {qemu_send_packet (nc, buf, size); }
Signature · 1 line
2.7.4
[PULL V2 18/20] net: Move NetClientState.info_str to dynamic allocations
In reply to Jason WangFrom: Alexey Kirillov <[email protected]>
The info_str field of the NetClientState structure is static and has a size of 256 bytes. This amount is often unclaimed, and the field itself is used exclusively for HMP "info network".
The patch translates info_str to dynamic memory allocation.
This action is also allows us to painlessly discard usage of this field for backend devices.
--- hw/net/xen_nic.c | 5 ++--- include/net/net.h | 2 +- net/l2tpv3.c | 3 +-- net/net.c | 14 ++++++++------ net/slirp.c | 5 ++--- net/socket.c | 43 ++++++++++++++++++++++++------------------- net/tap-win32.c | 3 +-- net/tap.c | 13 +++++-------- net/vde.c | 3 +-- net/vhost-user.c | 3 +-- net/vhost-vdpa.c | 2 +- 11 files changed, 47 insertions(+), 49 deletions(-)
hw/net/xen_nic.c +2 -3
@@ -296,9 +296,8 @@ static int net_init(struct XenLegacyDevice *xendev) netdev->nic =qemu_new_nic (&net_xen_info, &netdev->conf,"xen" ,NULL , netdev); -snprintf (qemu_get_queue (netdev->nic)->info_str, -sizeof (qemu_get_queue (netdev->nic)->info_str), -"nic: xenbus vif macaddr=%s" , netdev->mac); +qemu_get_queue (netdev->nic)->info_str =g_strdup_printf ( +"nic: xenbus vif macaddr=%s" , netdev->mac);/* fill info */ xenstore_write_be_int (&netdev->xendev,"feature-rx-copy" ,1 );
include/net/net.h +1 -1
@@ -94,7 +94,7 @@ struct NetClientState {NetQueue *incoming_queue;char *model;char *name; -char info_str[256 ]; +char *info_str;NetdevInfo *stored_config; unsigned receive_disabled : 1;NetClientDestructor *destructor;
net/l2tpv3.c +1 -2
@@ -730,8 +730,7 @@ int net_init_l2tpv3(const Netdev *netdev,QAPI_CLONE_MEMBERS (NetdevL2TPv3Options, &nc->stored_config->u.l2tpv3, l2tpv3); -snprintf (s->nc.info_str,sizeof (s->nc.info_str), -"l2tpv3: connected" ); + s->nc.info_str =g_strdup_printf ("l2tpv3: connected" );return 0 ; outerr:qemu_del_net_client (nc);
net/net.c +8 -6
@@ -129,11 +129,12 @@ char *qemu_mac_strdup_printf(const uint8_t *macaddr)void qemu_format_nic_info_str (NetClientState *nc,uint8_t macaddr[6 ]) { -snprintf (nc->info_str,sizeof (nc->info_str), -"model=%s,macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , - nc->model, - macaddr[0 ], macaddr[1 ], macaddr[2 ], - macaddr[3 ], macaddr[4 ], macaddr[5 ]); +g_free (nc->info_str); + nc->info_str =g_strdup_printf ( +"model=%s,macaddr=%02x:%02x:%02x:%02x:%02x:%02x" , + nc->model, + macaddr[0 ], macaddr[1 ], macaddr[2 ], + macaddr[3 ], macaddr[4 ], macaddr[5 ]); }static int mac_table[256 ] = {0 };
@@ -352,6 +353,7 @@ static void qemu_free_net_client(NetClientState *nc) }g_free (nc->name);g_free (nc->model); +g_free (nc->info_str);qapi_free_NetdevInfo (nc->stored_config);if (nc->destructor) { nc->destructor (nc);
@@ -1226,7 +1228,7 @@ void print_net_client(Monitor *mon, NetClientState *nc)monitor_printf (mon,"%s: index=%d,type=%s,%s\n" , nc->name, nc->queue_index,NetClientDriver_str (nc->info->type), - nc->info_str); + nc->info_str ? nc->info_str :"" );if (!QTAILQ_EMPTY (&nc->filters)) {monitor_printf (mon,"filters:\n" ); }
net/slirp.c +2 -3
@@ -664,9 +664,8 @@ static int net_slirp_init(NetClientState *peer, const char *model, stored->tftp_server_name =g_strdup (tftp_server_name); } -snprintf (nc->info_str,sizeof (nc->info_str), -"net=%s,restrict=%s" ,inet_ntoa (net), - restricted ?"on" :"off" ); + nc->info_str =g_strdup_printf ("net=%s,restrict=%s" ,inet_ntoa (net), + restricted ?"on" :"off" ); s =DO_UPCAST (SlirpState, nc, nc);
net/socket.c +24 -19
90 lines not on this page · raw message
net/tap-win32.c +1 -2
@@ -787,8 +787,7 @@ static int tap_win32_init(NetClientState *peer, const char *model, stored->has_ifname = true; stored->ifname =g_strdup (ifname); -snprintf (s->nc.info_str,sizeof (s->nc.info_str), -"tap: ifname=%s" , ifname); + s->nc.info_str =g_strdup_printf ("tap: ifname=%s" , ifname); s->handle = handle;
net/tap.c +5 -8
@@ -625,8 +625,7 @@ int net_init_bridge(const Netdev *netdev, const char *name, stored->helper =g_strdup (helper); } -snprintf (s->nc.info_str,sizeof (s->nc.info_str),"helper=%s,br=%s" , helper, - br); + s->nc.info_str =g_strdup_printf ("helper=%s,br=%s" , helper, br);return 0 ; }
@@ -714,7 +713,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,g_free (tmp_s); } -snprintf (s->nc.info_str,sizeof (s->nc.info_str),"fd=%d" , fd); + s->nc.info_str =g_strdup_printf ("fd=%d" , fd); }else if (tap->has_helper) {if (!stored->has_helper) { stored->has_helper = true;
@@ -727,8 +726,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,g_strdup (DEFAULT_BRIDGE_INTERFACE ); } -snprintf (s->nc.info_str,sizeof (s->nc.info_str),"helper=%s" , - tap->helper); + s->nc.info_str =g_strdup_printf ("helper=%s" , tap->helper); }else {if (ifname && !stored->has_ifname) { stored->has_ifname = true;
@@ -745,9 +743,8 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, stored->downscript =g_strdup (downscript); } -snprintf (s->nc.info_str,sizeof (s->nc.info_str), -"ifname=%s,script=%s,downscript=%s" , ifname, script, - downscript); + s->nc.info_str =g_strdup_printf ("ifname=%s,script=%s,downscript=%s" , + ifname, script, downscript);if (strcmp (downscript,"no" ) !=0 ) {snprintf (s->down_script,sizeof (s->down_script),"%s" , downscript);
net/vde.c +1 -2
@@ -100,8 +100,7 @@ static int net_vde_init(NetClientState *peer, const char *model, nc =qemu_new_net_client (&net_vde_info, peer, model, name); -snprintf (nc->info_str,sizeof (nc->info_str),"sock=%s,fd=%d" , - sock,vde_datafd (vde)); + nc->info_str =g_strdup_printf ("sock=%s,fd=%d" , sock,vde_datafd (vde)); s =DO_UPCAST (VDEState, nc, nc);
net/vhost-user.c +1 -2
@@ -327,8 +327,7 @@ static int net_vhost_user_init(NetClientState *peer, const char *device, user = g_new0(struct VhostUserState, 1);for (i =0 ; i < queues; i++) { nc =qemu_new_net_client (&net_vhost_user_info, peer, device, name); -snprintf (nc->info_str,sizeof (nc->info_str),"vhost-user%d to %s" , - i, chr->label); + nc->info_str =g_strdup_printf ("vhost-user%d to %s" , i, chr->label); nc->queue_index = i;if (!nc0) { nc0 = nc;
net/vhost-vdpa.c +1 -1
@@ -200,7 +200,7 @@ static int net_vhost_vdpa_init(NetClientState *peer, const char *device, stored->has_queues = true; stored->queues =1 ;/* TODO: change when support multiqueue */ -snprintf (nc->info_str,sizeof (nc->info_str),TYPE_VHOST_VDPA ); + nc->info_str =g_strdup_printf (TYPE_VHOST_VDPA ); nc->queue_index =0 ; s =DO_UPCAST (VhostVDPAState, nc, nc); vdpa_device_fd =qemu_open_old (vhostdev,O_RDWR );
Signature · 1 line
2.7.4
[PULL V2 07/20] dp8393x: switch to use qemu_receive_packet() for loopback packet
In reply to Jason WangThis patch switches to use qemu_receive_packet() which can detect reentrancy and return early.
This is intended to address CVE-2021-3416.
--- hw/net/dp8393x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/dp8393x.c +1 -1
@@ -506,7 +506,7 @@ static void dp8393x_do_transmit_packets(dp8393xState *s) s->regs[SONIC_TCR ] |=SONIC_TCR_CRSL ;if (nc->info->can_receive (nc)) { s->loopback_packet =1 ; - nc->info->receive (nc, s->tx_buffer, tx_len); +qemu_receive_packet (nc, s->tx_buffer, tx_len); } }else {/* Transmit packet */
Signature · 1 line
2.7.4
[PULL V2 09/20] sungem: switch to use qemu_receive_packet() for loopback
In reply to Jason WangThis patch switches to use qemu_receive_packet() which can detect reentrancy and return early.
This is intended to address CVE-2021-3416.
--- hw/net/sungem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/sungem.c +1 -1
@@ -306,7 +306,7 @@ static void sungem_send_packet(SunGEMState *s, const uint8_t *buf,NetClientState *nc =qemu_get_queue (s->nic);if (s->macregs[MAC_XIFCFG >>2 ] &MAC_XIFCFG_LBCK ) { - nc->info->receive (nc, buf, size); +qemu_receive_packet (nc, buf, size); }else {qemu_send_packet (nc, buf, size); }
Signature · 1 line
2.7.4
[PULL V2 11/20] rtl8139: switch to use qemu_receive_packet() for loopback
In reply to Jason WangFrom: Alexander Bulekov <[email protected]>
This patch switches to use qemu_receive_packet() which can detect reentrancy and return early.
This is intended to address CVE-2021-3416.
--- hw/net/rtl8139.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/rtl8139.c +1 -1
@@ -1795,7 +1795,7 @@ static void rtl8139_transfer_frame(RTL8139State *s, uint8_t *buf, int size, }DPRINTF ("+++ transmit loopback mode\n" ); -rtl8139_do_receive (qemu_get_queue (s->nic), buf, size, do_interrupt); +qemu_receive_packet (qemu_get_queue (s->nic), buf, size);if (iov) {g_free (buf2);
Signature · 1 line
2.7.4
[PULL V2 16/20] qapi: net: Add query-netdev command
In reply to Jason WangFrom: Alexey Kirillov <[email protected]>
The query-netdev command is used to get the configuration of the current network device backends (netdevs).
This is the QMP analog of the HMP command "info network" but only for netdevs (i.e. excluding NIC and hubports).
The query-netdev command returns an array of objects of the NetdevInfo type, which are an extension of Netdev type. It means that response can be used for netdev-add after small modification. This can be useful for recreate the same netdev configuration.
Information about the network device is filled in when it is created or modified and is available through the NetClientState->stored_config.
--- include/net/net.h | 3 ++ net/l2tpv3.c | 7 ++++ net/net.c | 30 +++++++++++++- net/netmap.c | 7 ++++ net/slirp.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ net/socket.c | 71 +++++++++++++++++++++++++++++++ net/tap-win32.c | 9 ++++ net/tap.c | 103 ++++++++++++++++++++++++++++++++++++++++++--- net/vde.c | 22 ++++++++++ net/vhost-user.c | 18 ++++++-- net/vhost-vdpa.c | 14 +++++++ qapi/net.json | 80 +++++++++++++++++++++++++++++++++++ 12 files changed, 477 insertions(+), 9 deletions(-)
include/net/net.h +3 -0
@@ -5,6 +5,8 @@#include "qapi/qapi-types-net.h" #include "net/queue.h" #include "hw/qdev-properties-system.h" +#include "qapi/clone-visitor.h" +#include "qapi/qapi-visit-net.h" #define MAC_FMT "%02X:%02X:%02X:%02X:%02X:%02X"#define MAC_ARG (x) ((uint8_t *)(x))[0], ((uint8_t *)(x))[1], \
@@ -93,6 +95,7 @@ struct NetClientState {char *model;char *name;char info_str[256 ]; +NetdevInfo *stored_config; unsigned receive_disabled : 1;NetClientDestructor *destructor;unsigned int queue_index;
net/l2tpv3.c +7 -0
@@ -723,6 +723,13 @@ int net_init_l2tpv3(const Netdev *netdev,l2tpv3_read_poll (s, true); +/* Store startup parameters */ + nc->stored_config =g_new0 (NetdevInfo,1 ); + nc->stored_config->type =NET_BACKEND_L2TPV3 ; + +QAPI_CLONE_MEMBERS (NetdevL2TPv3Options, + &nc->stored_config->u.l2tpv3, l2tpv3); +snprintf (s->nc.info_str,sizeof (s->nc.info_str),"l2tpv3: connected" );return 0 ;
net/net.c +29 -1
@@ -36,7 +36,6 @@#include "monitor/monitor.h" #include "qemu/help_option.h" #include "qapi/qapi-commands-net.h" -#include "qapi/qapi-visit-net.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" #include "qemu/error-report.h"
@@ -353,6 +352,7 @@ static void qemu_free_net_client(NetClientState *nc) }g_free (nc->name);g_free (nc->model); +qapi_free_NetdevInfo (nc->stored_config);if (nc->destructor) { nc->destructor (nc); }
@@ -1289,6 +1289,34 @@ RxFilterInfoList *qmp_query_rx_filter(bool has_name, const char *name,return filter_list; } +NetdevInfoList *qmp_query_netdev (Error **errp) +{ +NetdevInfoList *list =NULL ; +NetClientState *nc; + + QTAILQ_FOREACH(nc, &net_clients, next) { +/* +* Only look at netdevs (backend network devices), not for each queue +* or NIC / hubport +*/ +if (nc->stored_config) { +NetdevInfo *element =QAPI_CLONE (NetdevInfo, nc->stored_config); + +g_free (element->id);/* Need to dealloc empty id after clone */ + element->id =g_strdup (nc->name); + + element->has_peer_id = nc->peer !=NULL ; +if (element->has_peer_id) { + element->peer_id =g_strdup (nc->peer->name); + } + +QAPI_LIST_PREPEND (list, element); + } + } + +return list; +} +void hmp_info_network (Monitor *mon,const QDict *qdict) {NetClientState *nc, *peer;
net/netmap.c +7 -0
@@ -427,6 +427,13 @@ int net_init_netmap(const Netdev *netdev,pstrcpy (s->ifname,sizeof (s->ifname), netmap_opts->ifname);netmap_read_poll (s, true);/* Initially only poll for reads. */ +/* Store startup parameters */ + nc->stored_config =g_new0 (NetdevInfo,1 ); + nc->stored_config->type =NET_BACKEND_NETMAP ; + +QAPI_CLONE_MEMBERS (NetdevNetmapOptions, + &nc->stored_config->u.netmap, netmap_opts); +return 0 ; }
net/slirp.c +122 -0
149 lines not on this page · raw message
net/socket.c +71 -0
157 lines not on this page · raw message
net/tap-win32.c +9 -0
@@ -768,6 +768,7 @@ static int tap_win32_init(NetClientState *peer, const char *model,NetClientState *nc;TAPState *s;tap_win32_overlapped_t *handle; +NetdevTapOptions *stored;if (tap_win32_open (&handle, ifname) <0 ) {printf ("tap: Could not open '%s'\n" , ifname);
@@ -778,6 +779,14 @@ static int tap_win32_init(NetClientState *peer, const char *model, s =DO_UPCAST (TAPState, nc, nc); +/* Store startup parameters */ + nc->stored_config =g_new0 (NetdevInfo,1 ); + nc->stored_config->type =NET_BACKEND_TAP ; + stored = &nc->stored_config->u.tap; + + stored->has_ifname = true; + stored->ifname =g_strdup (ifname); +snprintf (s->nc.info_str,sizeof (s->nc.info_str),"tap: ifname=%s" , ifname);
net/tap.c +98 -5
182 lines not on this page · raw message
net/vde.c +22 -0
@@ -84,6 +84,7 @@ static int net_vde_init(NetClientState *peer, const char *model,VDECONN *vde;char *init_group = (char *)group;char *init_sock = (char *)sock; +NetdevVdeOptions *stored;struct vde_open_args args = { .port = port,
@@ -108,6 +109,27 @@ static int net_vde_init(NetClientState *peer, const char *model,qemu_set_fd_handler (vde_datafd (s->vde), vde_to_qemu,NULL , s); +/* Store startup parameters */ + nc->stored_config =g_new0 (NetdevInfo,1 ); + nc->stored_config->type =NET_BACKEND_VDE ; + stored = &nc->stored_config->u.vde; + +if (sock) { + stored->has_sock = true; + stored->sock =g_strdup (sock); + } + + stored->has_port = true; + stored->port = port; + +if (group) { + stored->has_group = true; + stored->group =g_strdup (group); + } + + stored->has_mode = true; + stored->mode = mode; +return 0 ; }
net/vhost-user.c +15 -3
@@ -311,14 +311,15 @@ static void net_vhost_user_event(void *opaque, QEMUChrEvent event) }static int net_vhost_user_init (NetClientState *peer,const char *device, -const char *name,Chardev *chr, -int queues) +const char *name,const char *chardev, +Chardev *chr,int queues) {Error *err =NULL ;NetClientState *nc, *nc0 =NULL ;NetVhostUserState *s =NULL ;VhostUserState *user;int i; +NetdevVhostUserOptions *stored;assert (name);assert (queues >0 );
@@ -355,6 +356,16 @@ static int net_vhost_user_init(NetClientState *peer, const char *device,assert (s->vhost_net); +/* Store startup parameters */ + nc0->stored_config =g_new0 (NetdevInfo,1 ); + nc0->stored_config->type =NET_BACKEND_VHOST_USER ; + stored = &nc0->stored_config->u.vhost_user; + + stored->chardev =g_strdup (chardev); + + stored->has_queues = true; + stored->queues = queues; +return 0 ; err:
@@ -446,5 +457,6 @@ int net_init_vhost_user(const Netdev *netdev, const char *name,return -1 ; } -return net_vhost_user_init (peer,"vhost_user" , name, chr, queues); +return net_vhost_user_init (peer,"vhost_user" , name, + vhost_user_opts->chardev, chr, queues); }
net/vhost-vdpa.c +14 -0
@@ -184,8 +184,22 @@ static int net_vhost_vdpa_init(NetClientState *peer, const char *device,VhostVDPAState *s;int vdpa_device_fd =-1 ;int ret =0 ; +NetdevVhostVDPAOptions *stored; +assert (name); nc =qemu_new_net_client (&net_vhost_vdpa_info, peer, device, name); + +/* Store startup parameters */ + nc->stored_config =g_new0 (NetdevInfo,1 ); + nc->stored_config->type =NET_BACKEND_VHOST_VDPA ; + stored = &nc->stored_config->u.vhost_vdpa; + + stored->has_vhostdev = true; + stored->vhostdev =g_strdup (vhostdev); + + stored->has_queues = true; + stored->queues =1 ;/* TODO: change when support multiqueue */ +snprintf (nc->info_str,sizeof (nc->info_str),TYPE_VHOST_VDPA ); nc->queue_index =0 ; s =DO_UPCAST (VhostVDPAState, nc, nc);
qapi/net.json +80 -0
83 lines not on this page · raw message
Signature · 1 line
2.7.4
[PULL V2 13/20] cadence_gem: switch to use qemu_receive_packet() for loopback
In reply to Jason WangFrom: Alexander Bulekov <[email protected]>
This patch switches to use qemu_receive_packet() which can detect reentrancy and return early.
This is intended to address CVE-2021-3416.
--- hw/net/cadence_gem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/net/cadence_gem.c +2 -2
@@ -1275,8 +1275,8 @@ static void gem_transmit(CadenceGEMState *s)/* Send the packet somewhere */ if (s->phy_loop || (s->regs[GEM_NWCTRL ] &GEM_NWCTRL_LOCALLOOP )) { -gem_receive (qemu_get_queue (s->nic), s->tx_packet, - total_bytes); +qemu_receive_packet (qemu_get_queue (s->nic), s->tx_packet, + total_bytes); }else {qemu_send_packet (qemu_get_queue (s->nic), s->tx_packet, total_bytes);
Signature · 1 line
2.7.4
[PULL V2 19/20] hmp: Use QAPI NetdevInfo in hmp_info_network
In reply to Jason WangFrom: Alexey Kirillov <[email protected]>
Replace usage of legacy field info_str of NetClientState for backend network devices with QAPI NetdevInfo stored_config that already used in QMP query-netdev.
This change increases the detail of the "info network" output and takes a more general approach to composing the output.
NIC and hubports still use legacy info_str field.
--- include/qapi/hmp-output-visitor.h | 30 ++++++ net/net.c | 31 +++++- qapi/hmp-output-visitor.c | 193 ++++++++++++++++++++++++++++++++++++++ qapi/meson.build | 1 + 4 files changed, 254 insertions(+), 1 deletion(-) create mode 100644 include/qapi/hmp-output-visitor.h create mode 100644 qapi/hmp-output-visitor.c
include/qapi/hmp-output-visitor.h new file +30 -0
@@ -0,0 +1,30 @@ +/* +* HMP string output Visitor +* +* Copyright Yandex N.V., 2021 +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +*/ + +#ifndef HMP_OUTPUT_VISITOR_H +#define HMP_OUTPUT_VISITOR_H + +#include "qapi/visitor.h" + +typedef struct HMPOutputVisitor HMPOutputVisitor ; + +/** +* Create a HMP string output visitor for @obj +* +* Flattens dicts/structures, only shows arrays borders. +* +* Errors are not expected to happen. +* +* The caller is responsible for freeing the visitor with +* visit_free(). +*/ +Visitor *hmp_output_visitor_new (char **result); + +#endif
net/net.c +30 -1
@@ -55,6 +55,7 @@#include "sysemu/sysemu.h" #include "net/filter.h" #include "qapi/string-output-visitor.h" +#include "qapi/hmp-output-visitor.h" /* Net bridge is currently not supported for W32. */ #if !defined(_WIN32)
@@ -1221,14 +1222,42 @@ static void netfilter_print_info(Monitor *mon, NetFilterState *nf)monitor_printf (mon,"\n" ); } +static char *generate_info_str (NetClientState *nc) +{ +NetdevInfo *ni = nc->stored_config; +char *ret_out =NULL ; +Visitor *v; + +/* Use legacy field info_str for NIC and hubports */ +if ((nc->info->type ==NET_CLIENT_DRIVER_NIC ) || + (nc->info->type ==NET_CLIENT_DRIVER_HUBPORT )) { +return g_strdup (nc->info_str ? nc->info_str :"" ); + } + +if (!ni) { +return g_malloc0 (1 ); + } + + v =hmp_output_visitor_new (&ret_out); +if (visit_type_NetdevInfo (v,"" , &ni,NULL )) { +visit_complete (v, &ret_out); + } +visit_free (v); + +return ret_out; +} +void print_net_client (Monitor *mon,NetClientState *nc) {NetFilterState *nf; +char *info_str =generate_info_str (nc);monitor_printf (mon,"%s: index=%d,type=%s,%s\n" , nc->name, nc->queue_index,NetClientDriver_str (nc->info->type), - nc->info_str ? nc->info_str :"" ); + info_str); +g_free (info_str); +if (!QTAILQ_EMPTY (&nc->filters)) {monitor_printf (mon,"filters:\n" ); }
qapi/hmp-output-visitor.c new file +193 -0
193 lines not on this page · raw message
qapi/meson.build +1 -0
@@ -8,6 +8,7 @@ util_ss.add(files( 'qobject-output-visitor.c', 'string-input-visitor.c', 'string-output-visitor.c', + 'hmp-output-visitor.c', )) if have_system or have_tools util_ss.add(files(
Signature · 1 line
2.7.4
[PULL V2 14/20] lan9118: switch to use qemu_receive_packet() for loopback
In reply to Jason WangFrom: Alexander Bulekov <[email protected]>
This patch switches to use qemu_receive_packet() which can detect reentrancy and return early.
This is intended to address CVE-2021-3416.
--- hw/net/lan9118.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/lan9118.c +1 -1
@@ -680,7 +680,7 @@ static void do_tx_packet(lan9118_state *s)/* FIXME: Honor TX disable, and allow queueing of packets. */ if (s->phy_control &0x4000 ) {/* This assumes the receive routine doesn't touch the VLANClient. */ -lan9118_receive (qemu_get_queue (s->nic), s->txp->data, s->txp->len); +qemu_receive_packet (qemu_get_queue (s->nic), s->txp->data, s->txp->len); }else {qemu_send_packet (qemu_get_queue (s->nic), s->txp->data, s->txp->len); }
Signature · 1 line
2.7.4
[PULL V2 20/20] net: Do not fill legacy info_str for backends
In reply to Jason WangFrom: Alexey Kirillov <[email protected]>
As we use QAPI NetClientState->stored_config to store and get information about backend network devices, we can drop fill of legacy field info_str for them.
We still use info_str field for NIC and hubports, so we can not completely remove it.
--- net/l2tpv3.c | 2 -- net/slirp.c | 3 --- net/socket.c | 28 ---------------------------- net/tap-win32.c | 2 -- net/tap.c | 9 --------- net/vde.c | 2 -- net/vhost-user.c | 1 - net/vhost-vdpa.c | 1 - 8 files changed, 48 deletions(-)
net/l2tpv3.c +0 -2
@@ -729,8 +729,6 @@ int net_init_l2tpv3(const Netdev *netdev,QAPI_CLONE_MEMBERS (NetdevL2TPv3Options, &nc->stored_config->u.l2tpv3, l2tpv3); - - s->nc.info_str =g_strdup_printf ("l2tpv3: connected" );return 0 ; outerr:qemu_del_net_client (nc);
net/slirp.c +0 -3
@@ -664,9 +664,6 @@ static int net_slirp_init(NetClientState *peer, const char *model, stored->tftp_server_name =g_strdup (tftp_server_name); } - nc->info_str =g_strdup_printf ("net=%s,restrict=%s" ,inet_ntoa (net), - restricted ?"on" :"off" ); - s =DO_UPCAST (SlirpState, nc, nc); s->slirp = slirp_init(restricted, ipv4, net, mask, host,
net/socket.c +0 -28
@@ -180,8 +180,6 @@ static void net_socket_send(void *opaque) s->fd =-1 ;net_socket_rs_init (&s->rs, net_socket_rs_finalize, false); s->nc.link_down = true; -g_free (s->nc.info_str); - s->nc.info_str =g_new0 (char,1 );return ; }
@@ -401,16 +399,10 @@ static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer, stored->mcast =g_strdup (mcast); s->dgram_dst = saddr; - nc->info_str =g_strdup_printf ("socket: fd=%d (cloned mcast=%s:%d)" , - fd,inet_ntoa (saddr.sin_addr), -ntohs (saddr.sin_port)); }else {if (sa_type ==SOCKET_ADDRESS_TYPE_UNIX ) { s->dgram_dst.sin_family =AF_UNIX ; } - - nc->info_str =g_strdup_printf ("socket: fd=%d %s" , - fd,SocketAddressType_str (sa_type)); }return s;
@@ -445,8 +437,6 @@ static NetSocketState *net_socket_fd_init_stream(NetClientState *peer, nc =qemu_new_net_client (&net_socket_info, peer, model, name); - nc->info_str =g_strdup_printf ("socket: fd=%d" , fd); - s =DO_UPCAST (NetSocketState, nc, nc); s->fd = fd;
@@ -528,11 +518,6 @@ static void net_socket_accept(void *opaque) stored->has_fd = true; stored->fd =g_strdup_printf ("%d" , fd); - -g_free (s->nc.info_str); - s->nc.info_str =g_strdup_printf ("socket: connection from %s:%d" , -inet_ntoa (saddr.sin_addr), -ntohs (saddr.sin_port)); } static int net_socket_listen_init(NetClientState *peer,
@@ -647,10 +632,6 @@ static int net_socket_connect_init(NetClientState *peer, stored->has_connect = true; stored->connect =g_strdup (host_str); -g_free (s->nc.info_str); - s->nc.info_str =g_strdup_printf ("socket: connect to %s:%d" , -inet_ntoa (saddr.sin_addr), -ntohs (saddr.sin_port));return 0 ; }
@@ -707,12 +688,7 @@ static int net_socket_mcast_init(NetClientState *peer, stored->localaddr =g_strdup (localaddr_str); } -g_free (s->nc.info_str); - s->nc.info_str =g_strdup_printf ("socket: mcast=%s:%d" , -inet_ntoa (saddr.sin_addr), -ntohs (saddr.sin_port));return 0 ; - } static int net_socket_udp_init(NetClientState *peer,
@@ -773,10 +749,6 @@ static int net_socket_udp_init(NetClientState *peer, stored->has_udp = true; stored->udp =g_strdup (rhost); -g_free (s->nc.info_str); - s->nc.info_str =g_strdup_printf ("socket: udp=%s:%d" , -inet_ntoa (raddr.sin_addr), -ntohs (raddr.sin_port));return 0 ; }
net/tap-win32.c +0 -2
@@ -787,8 +787,6 @@ static int tap_win32_init(NetClientState *peer, const char *model, stored->has_ifname = true; stored->ifname =g_strdup (ifname); - s->nc.info_str =g_strdup_printf ("tap: ifname=%s" , ifname); - s->handle = handle;qemu_add_wait_object (s->handle->tap_semaphore, tap_win32_send, s);
net/tap.c +0 -9
@@ -625,8 +625,6 @@ int net_init_bridge(const Netdev *netdev, const char *name, stored->helper =g_strdup (helper); } - s->nc.info_str =g_strdup_printf ("helper=%s,br=%s" , helper, br); -return 0 ; }
@@ -712,8 +710,6 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, stored->fds =g_strdup_printf ("%s:%d" , stored->fds, fd);g_free (tmp_s); } - - s->nc.info_str =g_strdup_printf ("fd=%d" , fd); }else if (tap->has_helper) {if (!stored->has_helper) { stored->has_helper = true;
@@ -725,8 +721,6 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, stored->br = tap->has_br ?g_strdup (tap->br) :g_strdup (DEFAULT_BRIDGE_INTERFACE ); } - - s->nc.info_str =g_strdup_printf ("helper=%s" , tap->helper); }else {if (ifname && !stored->has_ifname) { stored->has_ifname = true;
@@ -743,9 +737,6 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, stored->downscript =g_strdup (downscript); } - s->nc.info_str =g_strdup_printf ("ifname=%s,script=%s,downscript=%s" , - ifname, script, downscript); -if (strcmp (downscript,"no" ) !=0 ) {snprintf (s->down_script,sizeof (s->down_script),"%s" , downscript); snprintf(s->down_script_arg, sizeof(s->down_script_arg),
net/vde.c +0 -2
@@ -100,8 +100,6 @@ static int net_vde_init(NetClientState *peer, const char *model, nc =qemu_new_net_client (&net_vde_info, peer, model, name); - nc->info_str =g_strdup_printf ("sock=%s,fd=%d" , sock,vde_datafd (vde)); - s =DO_UPCAST (VDEState, nc, nc); s->vde = vde;
net/vhost-user.c +0 -1
@@ -327,7 +327,6 @@ static int net_vhost_user_init(NetClientState *peer, const char *device, user = g_new0(struct VhostUserState, 1);for (i =0 ; i < queues; i++) { nc =qemu_new_net_client (&net_vhost_user_info, peer, device, name); - nc->info_str =g_strdup_printf ("vhost-user%d to %s" , i, chr->label); nc->queue_index = i;if (!nc0) { nc0 = nc;
net/vhost-vdpa.c +0 -1
@@ -200,7 +200,6 @@ static int net_vhost_vdpa_init(NetClientState *peer, const char *device, stored->has_queues = true; stored->queues =1 ;/* TODO: change when support multiqueue */ - nc->info_str =g_strdup_printf (TYPE_VHOST_VDPA ); nc->queue_index =0 ; s =DO_UPCAST (VhostVDPAState, nc, nc); vdpa_device_fd =qemu_open_old (vhostdev,O_RDWR );
Signature · 1 line
2.7.4
[PULL V2 15/20] pvrdma: wean code off pvrdma_ring.h kernel header
In reply to Jason WangFrom: Cornelia Huck <[email protected]>
The pvrdma code relies on the pvrdma_ring.h kernel header for some basic ring buffer handling. The content of that header isn't very exciting, but contains some (q)atomic_*() invocations that (a) cause manual massaging when doing a headers update, and (b) are an indication that we probably should not be importing that header at all.
Let's reimplement the ring buffer handling directly in the pvrdma code instead. This arguably also improves readability of the code.
Importing the header can now be dropped.
--- hw/rdma/vmw/pvrdma.h | 5 +- hw/rdma/vmw/pvrdma_cmd.c | 6 +- hw/rdma/vmw/pvrdma_dev_ring.c | 41 ++++---- hw/rdma/vmw/pvrdma_dev_ring.h | 9 +- hw/rdma/vmw/pvrdma_main.c | 4 +- .../drivers/infiniband/hw/vmw_pvrdma/pvrdma_ring.h | 114 --------------------- scripts/update-linux-headers.sh | 3 +- 7 files changed, 38 insertions(+), 144 deletions(-) delete mode 100644 include/standard-headers/drivers/infiniband/hw/vmw_pvrdma/pvrdma_ring.h
hw/rdma/vmw/pvrdma.h +2 -3
@@ -26,7 +26,6 @@#include "../rdma_backend_defs.h" #include "../rdma_rm_defs.h" -#include "standard-headers/drivers/infiniband/hw/vmw_pvrdma/pvrdma_ring.h" #include "standard-headers/drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h" #include "pvrdma_dev_ring.h" #include "qom/object.h"
@@ -64,10 +63,10 @@ typedef struct DSRInfo {union pvrdma_cmd_req *req;union pvrdma_cmd_resp *rsp; -struct pvrdma_ring *async_ring_state; +PvrdmaRingState *async_ring_state;PvrdmaRing async; -struct pvrdma_ring *cq_ring_state; +PvrdmaRingState *cq_ring_state;PvrdmaRing cq; } DSRInfo;
hw/rdma/vmw/pvrdma_cmd.c +3 -3
@@ -262,7 +262,7 @@ static int create_cq_ring(PCIDevice *pci_dev , PvrdmaRing **ring, r =g_malloc (sizeof (*r)); *ring = r; - r->ring_state = (struct pvrdma_ring *) + r->ring_state = (PvrdmaRingState *)rdma_pci_dma_map (pci_dev, tbl[0 ],TARGET_PAGE_SIZE );if (!r->ring_state) {
@@ -398,7 +398,7 @@ static int create_qp_rings(PCIDevice *pci_dev, uint64_t pdir_dma, *rings = sr;/* Create send ring */ - sr->ring_state = (struct pvrdma_ring *) + sr->ring_state = (PvrdmaRingState *)rdma_pci_dma_map (pci_dev, tbl[0 ],TARGET_PAGE_SIZE );if (!sr->ring_state) {rdma_error_report ("Failed to map to QP ring state" );
@@ -639,7 +639,7 @@ static int create_srq_ring(PCIDevice *pci_dev, PvrdmaRing **ring, r =g_malloc (sizeof (*r)); *ring = r; - r->ring_state = (struct pvrdma_ring *) + r->ring_state = (PvrdmaRingState *)rdma_pci_dma_map (pci_dev, tbl[0 ],TARGET_PAGE_SIZE );if (!r->ring_state) {rdma_error_report ("Failed to map tp SRQ ring state" );
hw/rdma/vmw/pvrdma_dev_ring.c +23 -18
82 lines not on this page · raw message
hw/rdma/vmw/pvrdma_dev_ring.h +7 -2
@@ -19,18 +19,23 @@#define MAX_RING_NAME_SZ 32 +typedef struct PvrdmaRingState { +int prod_tail;/* producer tail */ +int cons_head;/* consumer head */ +}PvrdmaRingState ; +typedef struct PvrdmaRing {char name[MAX_RING_NAME_SZ ];PCIDevice *dev;uint32_t max_elems;size_t elem_sz; -struct pvrdma_ring *ring_state;/* used only for unmap */ +PvrdmaRingState *ring_state;/* used only for unmap */ int npages;void **pages; }PvrdmaRing ;int pvrdma_ring_init (PvrdmaRing *ring,const char *name,PCIDevice *dev, -struct pvrdma_ring *ring_state,uint32_t max_elems, +PvrdmaRingState *ring_state,uint32_t max_elems,size_t elem_sz,dma_addr_t *tbl,uint32_t npages);void *pvrdma_ring_next_elem_read (PvrdmaRing *ring);void pvrdma_ring_read_inc (PvrdmaRing *ring);
hw/rdma/vmw/pvrdma_main.c +2 -2
@@ -85,7 +85,7 @@ static void free_dev_ring(PCIDevice *pci_dev, PvrdmaRing *ring,rdma_pci_dma_unmap (pci_dev, ring_state,TARGET_PAGE_SIZE ); } -static int init_dev_ring (PvrdmaRing *ring,struct pvrdma_ring **ring_state, +static int init_dev_ring (PvrdmaRing *ring,PvrdmaRingState **ring_state,const char *name,PCIDevice *pci_dev,dma_addr_t dir_addr,uint32_t num_pages) {
@@ -114,7 +114,7 @@ static int init_dev_ring(PvrdmaRing *ring, struct pvrdma_ring **ring_state,/* RX ring is the second */ (*ring_state)++; rc = pvrdma_ring_init(ring, name, pci_dev, - (struct pvrdma_ring *)*ring_state, + (PvrdmaRingState *)*ring_state, (num_pages - 1) * TARGET_PAGE_SIZE / sizeof(struct pvrdma_cqne), sizeof(struct pvrdma_cqne),
include/standard-headers/drivers/infiniband/hw/vmw_pvrdma/pvrdma_ring.h deleted +0 -114
114 lines not on this page · raw message
scripts/update-linux-headers.sh +1 -2
@@ -215,8 +215,7 @@ sed -e '1h;2,$H;$!d;g' -e 's/[^};]*pvrdma[^(| ]*([^)]*);//g' \ "$linux/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.h" > \ "$tmp_pvrdma_verbs"; -for i in "$linux/drivers/infiniband/hw/vmw_pvrdma/pvrdma_ring.h" \ - "$linux/drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h" \ +for i in "$linux/drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h" \ "$tmp_pvrdma_verbs"; do \ cp_portable "$i" \ "$output/include/standard-headers/drivers/infiniband/hw/vmw_pvrdma/"
Signature · 1 line
2.7.4
[PULL V2 17/20] tests: Add tests for query-netdev command
In reply to Jason WangFrom: Alexey Kirillov <[email protected]>
A simply qtest that checks for correct number of netdevs in the response of the query-netdev.
--- tests/qtest/meson.build | 3 + tests/qtest/test-query-netdev.c | 120 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 tests/qtest/test-query-netdev.c
tests/qtest/meson.build +3 -0
@@ -30,6 +30,9 @@ qtests_generic = [ if config_host.has_key('CONFIG_MODULES') qtests_generic += [ 'modules-test' ] endif +if slirp.found() + qtests_generic += [ 'test-query-netdev' ] +endif qtests_pci = \ (config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : []) + \
tests/qtest/test-query-netdev.c new file +120 -0
120 lines not on this page · raw message
Signature · 1 line
2.7.4
Peter Maydell
AppliedQuoted 11 lines · Jason Wang
The following changes since commit
6157b0e19721aadb4c7fdcfe57b2924af6144b14:Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-6.0-pull-request' into staging (2021-03-14 17:47:49 +0000)
are available in the git repository at:
https://github.com/jasowang/qemu.git tags/net-pull-request
for you to fetch changes up to
f2e8319d456724c3d8514d943dc4607e2f08e88a:
Quoted 7 lines
net: Do not fill legacy
info_strfor backends (2021-03-15 16:41:22 +0800)----------------------------------------------------------------
Changes since V1:
- drop the workaound of "-nic" id and fix the merge
- add the series of query-netdev
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/6.0
for any user-visible changes.
-- PMM
Re: [PULL V2 16/20] qapi: net: Add query-netdev command
In reply to Jason WangQuoted 13 lines · Jason Wang
From: Alexey Kirillov <[email protected]>
The query-netdev command is used to get the configuration of the current network device backends (netdevs).
This is the QMP analog of the HMP command "info network" but only for netdevs (i.e. excluding NIC and hubports).The query-netdev command returns an array of objects of the NetdevInfo type, which are an extension of Netdev type. It means that response can be used for netdev-add after small modification. This can be useful for recreate the same netdev configuration.
Quoted 6 lines
Information about the network device is filled in when it is created or modified and is available through the
NetClientState->stored_config.Signed-off-by Alexey Kirillov <[email protected]>Signed-off-by Jason Wang <[email protected]>
Hi; Coverity is doubtful (CID 1450841) about this code:
net/tap.c static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, · line 694
Quoted 10 lines
net/tap.c +8
-0@@ -668,12 +686,65 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, +if (!stored->has_fds) { + stored->has_fds = true; + stored->fds =g_strdup_printf ("%d" , fd); + }else { +char *tmp_s = stored->fds; + stored->fds =g_strdup_printf ("%s:%d" , stored->fds, fd); +g_free (tmp_s); + }
Here we have a bit of code which maintains stored->fds as a colon-separated string of integers, by tacking the new fd onto the end of the old string if it's already present.
net/tap.c static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, · line 823
Quoted 12 lines
net/tap.c +8
-0@@ -731,6 +813,15 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, } options.opaque = (void *)(uintptr_t )vhostfd; +if (!stored->has_vhostfds) { + stored->has_vhostfds = true; + stored->vhostfds =g_strdup_printf ("%d" , vhostfd); + }else { +char *tmp_s = stored->vhostfds; + stored->vhostfds =g_strdup_printf ("%s:%d" , stored->fds, vhostfd); +g_free (tmp_s); + }
Here we have a bit of code that's kind of similar, except that the first argument to g_strdup_printf() is 'stored->fds', not 'stored->vhostfds'.
Coverity suspects cut-n-paste error -- is it right ?
thanks
-- PMM
Re: [PULL V2 16/20] qapi: net: Add query-netdev command
In reply to Jason WangQuoted 13 lines · Jason Wang
From: Alexey Kirillov <[email protected]>
The query-netdev command is used to get the configuration of the current network device backends (netdevs).
This is the QMP analog of the HMP command "info network" but only for netdevs (i.e. excluding NIC and hubports).The query-netdev command returns an array of objects of the NetdevInfo type, which are an extension of Netdev type. It means that response can be used for netdev-add after small modification. This can be useful for recreate the same netdev configuration.
Quoted 7 lines
Information about the network device is filled in when it is created or modified and is available through the
NetClientState->stored_config.Signed-off-by Alexey Kirillov <[email protected]>Signed-off-by Jason Wang <[email protected]>---
Hi; Coverity complains about a memory leak in this code (CID 1450842):
net/slirp.c static int net_slirp_init(NetClientState *peer, const char *model, · line 700
Quoted 9 lines
net/slirp.c +4
-0@@ -581,15 +693,25 @@ static int net_slirp_init(NetClientState *peer, const char *model, s->poll_notifier.notify = net_slirp_poll_notify;main_loop_poll_add_notifier (&s->poll_notifier); + stored_hostfwd = &stored->hostfwd; + stored_guestfwd = &stored->guestfwd; +for (config = slirp_configs; config; config = config->next) { +String *element =g_new0 (String,1 );
Here we allocate memory...
net/slirp.c static int net_slirp_init(NetClientState *peer, const char *model, · line 705
Quoted 5 lines
net/slirp.c +2
-0+ + element->str =g_strdup (config->str);if (config->flags &SLIRP_CFG_HOSTFWD ) {if (slirp_hostfwd (s, config->str, errp) <0 ) { goto error;
...but if we take this error-exit path we have neither freed nor kept a pointer to that memory.
net/slirp.c static int net_slirp_init(NetClientState *peer, const char *model, · line 711
Quoted 6 lines
net/slirp.c +2
-0} + stored->has_hostfwd = true; +QAPI_LIST_APPEND (stored_hostfwd, element); }else {if (slirp_guestfwd (s, config->str, errp) <0 ) { goto error;
Similarly here.
net/slirp.c static int net_slirp_init(NetClientState *peer, const char *model, · line 717
Quoted 6 lines
net/slirp.c +2
-0} + stored->has_guestfwd = true; +QAPI_LIST_APPEND (stored_guestfwd, element); } }#ifndef _WIN32
More generally, what state is the net backend init function supposed to leave 'stored' in if it fails? Is it the backend's responsibility to free everything that it might have allocated and left a pointer to? eg if we did
stored->hostname = g_strdup(vhostname);
do we need to go back and free(stored->hostname) ? Or is the caller guaranteeing to clean up 'stored' somehow ? Or is the backend supposed to not touch 'stored' until it's sure it's going to succeed ? (presumably not, as the current code does not do this...)
This commit has no comments describing or documenting the API requirements the new functionality imposes on a net backend:
could we have a followup patch which adds some documentation, please, so that authors of future backends know what they have to implement ?
thanks
-- PMM
Re: [PULL V2 16/20] qapi: net: Add query-netdev command
Quoted 34 lines · Peter Maydell
Quoted 12 lines · Jason Wang
From: Alexey Kirillov <[email protected]>
The query-netdev command is used to get the configuration of the current network device backends (netdevs).
This is the QMP analog of the HMP command "info network" but only for netdevs (i.e. excluding NIC and hubports).The query-netdev command returns an array of objects of the NetdevInfo type, which are an extension of Netdev type. It means that response can be used for netdev-add after small modification. This can be useful for recreate the same netdev configuration.
Quoted 7 lines
Information about the network device is filled in when it is created or modified and is available through the
NetClientState->stored_config.Signed-off-by Alexey Kirillov <[email protected]>Signed-off-by Jason Wang <[email protected]>---
Hi; Coverity complains about a memory leak in this code (CID 1450842):
net/slirp.c static int net_slirp_init(NetClientState *peer, const char *model, · line 700
Quoted 9 lines
net/slirp.c +4
-0@@ -581,15 +693,25 @@ static int net_slirp_init(NetClientState *peer, const char *model, s->poll_notifier.notify = net_slirp_poll_notify;main_loop_poll_add_notifier (&s->poll_notifier); + stored_hostfwd = &stored->hostfwd; + stored_guestfwd = &stored->guestfwd; +for (config = slirp_configs; config; config = config->next) { +String *element =g_new0 (String,1 );Here we allocate memory...
Quoted 7 lines
net/slirp.c static int net_slirp_init(NetClientState *peer, const char *model, · line 705
Quoted 5 lines
net/slirp.c +2
-0+ + element->str =g_strdup (config->str);if (config->flags &SLIRP_CFG_HOSTFWD ) {if (slirp_hostfwd (s, config->str, errp) <0 ) { goto error;...but if we take this error-exit path we have neither freed nor kept a pointer to that memory.
Yes.
Quoted 19 lines
net/slirp.c static int net_slirp_init(NetClientState *peer, const char *model, · line 711
Quoted 7 lines
net/slirp.c +2
-0} + stored->has_hostfwd = true; +QAPI_LIST_APPEND (stored_hostfwd, element); }else {if (slirp_guestfwd (s, config->str, errp) <0 ) { goto error;Similarly here.
net/slirp.c static int net_slirp_init(NetClientState *peer, const char *model, · line 717
Quoted 6 lines
net/slirp.c +2
-0} + stored->has_guestfwd = true; +QAPI_LIST_APPEND (stored_guestfwd, element); } }#ifndef _WIN32More generally, what state is the net backend init function supposed to leave 'stored' in if it fails? Is it the backend's responsibility to free everything that it might have allocated and left a pointer to? eg if we did
Quoted 5 lines
stored->hostname = g_strdup(vhostname);do we need to go back and
free(stored->hostname)? Or is the caller guaranteeing to clean up 'stored' somehow ? Or is the backend supposed to not touch 'stored' until it's sure it's going to succeed ? (presumably not, as the current code does not do this...)
Clean and free in the function that do the allocation seems better (self-conatined).
Quoted 6 lines
This commit has no comments describing or documenting the API requirements the new functionality imposes on a net backend:
could we have a followup patch which adds some documentation, please, so that authors of future backends know what they have to implement ?
Alexey, plase send patches to fix the above issues and document the API.
Thanks
Quoted 4 lines
thanks
-- PMM
Re: [PULL V2 16/20] qapi: net: Add query-netdev command
In reply to Peter MaydellQuoted 50 lines · Peter Maydell
Quoted 12 lines · Jason Wang
From: Alexey Kirillov <[email protected]>
The query-netdev command is used to get the configuration of the current network device backends (netdevs).
This is the QMP analog of the HMP command "info network" but only for netdevs (i.e. excluding NIC and hubports).The query-netdev command returns an array of objects of the NetdevInfo type, which are an extension of Netdev type. It means that response can be used for netdev-add after small modification. This can be useful for recreate the same netdev configuration.
Quoted 6 lines
Information about the network device is filled in when it is created or modified and is available through the
NetClientState->stored_config.Signed-off-by Alexey Kirillov <[email protected]>Signed-off-by Jason Wang <[email protected]>Hi; Coverity is doubtful (CID 1450841) about this code:
net/tap.c static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, · line 693
Quoted 9 lines
net/tap.c +8
-0@@ -668,12 +686,65 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, +if (!stored->has_fds) { + stored->has_fds = true; + stored->fds =g_strdup_printf ("%d" , fd); + }else { +char *tmp_s = stored->fds; + stored->fds =g_strdup_printf ("%s:%d" , stored->fds, fd); +g_free (tmp_s); + }Here we have a bit of code which maintains
stored->fdsas a colon-separated string of integers, by tacking the new fd onto the end of the old string if it's already present.net/tap.c static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, · line 823
Quoted 12 lines
net/tap.c +8
-0@@ -731,6 +813,15 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, } options.opaque = (void *)(uintptr_t )vhostfd; +if (!stored->has_vhostfds) { + stored->has_vhostfds = true; + stored->vhostfds =g_strdup_printf ("%d" , vhostfd); + }else { +char *tmp_s = stored->vhostfds; + stored->vhostfds =g_strdup_printf ("%s:%d" , stored->fds, vhostfd); +g_free (tmp_s); + }Here we have a bit of code that's kind of similar, except that the first argument to
g_strdup_printf()is 'stored->fds', not 'stored->vhostfds'.
Quoted 1 line
Coverity suspects cut-n-paste error -- is it right ?
Yes, stored->vhostfds should be used here.
Alexey, please send patch to fix this.
Thanks
Quoted 4 lines
thanks
-- PMM
Re: [PULL V2 16/20] qapi: net: Add query-netdev command
In reply to Jason WangQuoted 86 lines · Jason Wang
Quoted 35 lines · Peter Maydell
Quoted 12 lines · Jason Wang
From: Alexey Kirillov <[email protected]>
The query-netdev command is used to get the configuration of the current network device backends (netdevs).
This is the QMP analog of the HMP command "info network" but only for netdevs (i.e. excluding NIC and hubports).The query-netdev command returns an array of objects of the NetdevInfo type, which are an extension of Netdev type. It means that response can be used for netdev-add after small modification. This can be useful for recreate the same netdev configuration.
Quoted 7 lines
Information about the network device is filled in when it is created or modified and is available through the
NetClientState->stored_config.Signed-off-by Alexey Kirillov <[email protected]>Signed-off-by Jason Wang <[email protected]>---
Hi; Coverity complains about a memory leak in this code (CID 1450842):
net/slirp.c static int net_slirp_init(NetClientState · line 701
Quoted 10 lines
net/slirp.c +4
-0@@ -581,15 +693,25 @@ static int net_slirp_init(NetClientState *peer, const char *model, s->poll_notifier.notify = net_slirp_poll_notify; main_loop_poll_add_notifier(&s->poll_notifier); + stored_hostfwd = &stored->hostfwd; + stored_guestfwd = &stored->guestfwd; + for (config = slirp_configs; config; config = config->next) { + String *element = g_new0(String, 1);Here we allocate memory...
Quoted 7 lines
net/slirp.c static int net_slirp_init(NetClientState *peer, const char *model, · line 705
Quoted 5 lines
net/slirp.c +2
-0+ + element->str = g_strdup(config->str); if (config->flags & SLIRP_CFG_HOSTFWD) { if (slirp_hostfwd(s, config->str, errp) < 0) { goto error;...but if we take this error-exit path we have neither freed nor kept a pointer to that memory.
Yes.
Quoted 15 lines
net/slirp.c static int net_slirp_init(NetClientState *peer, const char *model, · line 711
Quoted 7 lines
net/slirp.c +2
-0} + stored->has_hostfwd = true; + QAPI_LIST_APPEND(stored_hostfwd, element); } else { if (slirp_guestfwd(s, config->str, errp) < 0) { goto error;Similarly here.
Quoted 6 lines
net/slirp.c +2
-0} + stored->has_guestfwd = true; + QAPI_LIST_APPEND(stored_guestfwd, element); } }#ifndef
_WIN32Quoted 9 lines
More generally, what state is the net backend init function supposed to leave 'stored' in if it fails? Is it the backend's responsibility to free everything that it might have allocated and left a pointer to? eg if we did
stored->hostname=g_strdup(vhostname);
do we need to go back andfree(stored->hostname)? Or is the caller guaranteeing to clean up 'stored' somehow ? Or is the backend supposed to not touch 'stored' until it's sure it's going to succeed ? (presumably not, as the current code does not do this...)Clean and free in the function that do the allocation seems better (self-conatined).
Quoted 6 lines
This commit has no comments describing or documenting the API requirements the new functionality imposes on a net backend:
could we have a followup patch which adds some documentation, please, so that authors of future backends know what they have to implement ?
Quoted 3 lines
Alexey, plase send patches to fix the above issues and document the API.
Thanks
Alexey, any update on this. If it takes time I tend to revert this and let's re-try for 6.1?
Thanks
Quoted 8 lines
Quoted 6 lines
thanks
-- PMM