From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MTCPLe0d; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTP id 8076F5A061B for ; Wed, 27 Nov 2024 05:47:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732682878; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ltPG2Wd7VgdXlWjrPLnsb5JyeZKNmQI8RaSRMFH2CYg=; b=MTCPLe0dp1qejIGhbKtThJyYuNyQtvj8cLtZNmEP3KMtWki+jOnNiV6KxxhWkS3TbpWHxT 0tPVJkg/P+TzvRmEXJmfGvwBuSfHhSxVV2SJSfw933Y0WDFaJDBvF7flRPDbvnzKIHFNrt R+0ZELXdXJ/lGE8doDL2iwVvLEANqnM= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-207-g0gkodDyPmCQG8bEZA3Bgw-1; Tue, 26 Nov 2024 23:47:56 -0500 X-MC-Unique: g0gkodDyPmCQG8bEZA3Bgw-1 X-Mimecast-MFC-AGG-ID: g0gkodDyPmCQG8bEZA3Bgw Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-434a9dce888so3355085e9.0 for ; Tue, 26 Nov 2024 20:47:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732682874; x=1733287674; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ltPG2Wd7VgdXlWjrPLnsb5JyeZKNmQI8RaSRMFH2CYg=; b=wcirinIqQ28VQkjjHiVvJr62Gpeu7STBU+03sXX1U3lSquJDrPVPP4zmzYXr+GrN5R 9PUGaBQmPtvKyAh/Ge3VtHxEk//0YZ9joNgqQyXjpEei7YDuajR5AHABYK9mDsXNhe1V GLAYKOeeMQXoblv3RcV4ogecAjUEB1sMOBrXz2q5jdZgu3zJxtpQ1zxJBwbP7eMtgBMB UH/bRSu/bGibrgwx9znjupZiJ9/hBPyjJ+HR6zO6BTud/pn5eQ6Y04+w8jAp8uqUl/cl k1sxwohcwAeA3a7JqA1yR414FBF8giI+XESU4++TzcdoghzgnLzconABAI4j0KN7cccv 8DtQ== X-Gm-Message-State: AOJu0YzWSpsUaVIZDlIthWp80Hc1ZDDalKTIK2LcPN4l9FLW0PE+mq8c 1pzlazfgzXzdFVidUwLOZhEt1cF27h+mWPaV7Dgk7e570OJ5v2JobisrtgAgC2N5g3PqjNlRRXu P6oWK5seR+hODMYkCXr1KsvCbnSlw9FiOoYdN7iei12uAa/aKzBsOC8DwcvmlVtbF6yNgY30PZI nD9DIZPpBKH2H9f6UZBGSnV285xmc764LY X-Gm-Gg: ASbGncubx8Wl3Rysla1LAjxNUQPWn3Da6U9qKlquLMblJjwIubxWpQaPuUsMS04bQV7 nFJ2lxmjzyZcY0XtQXKHYaczPTz/c2sQkoDPIm2RqUoIzxki62b14+jtGf4ZC9N5zIW9Bx0DGQ6 dWSYWZ3Z4wHZMqLWhH1ie7VGmJbQr3MoNE3dvEisPqSlQS2pDzSoAA+wDO2mbpUVHF9axKnlrNz 8nVLIKpDYigudcDFCFEFzdIawqxC7UxjHXAeHwXyfkWVrndqmP7gt/1Fi1U7w== X-Received: by 2002:a05:600c:4f0e:b0:434:9cf0:d23d with SMTP id 5b1f17b1804b1-434a9deca10mr11632275e9.25.1732682874319; Tue, 26 Nov 2024 20:47:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHT2r2W9131UndEVof0RNVYG2RRw5OAJXz9bUg/JIlwzcWZBQoiNQ62KcK37DkhN8pisxeClQ== X-Received: by 2002:a05:600c:4f0e:b0:434:9cf0:d23d with SMTP id 5b1f17b1804b1-434a9deca10mr11632225e9.25.1732682873875; Tue, 26 Nov 2024 20:47:53 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-434aa7b6e72sm7965825e9.12.2024.11.26.20.47.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Nov 2024 20:47:52 -0800 (PST) Date: Wed, 27 Nov 2024 05:47:49 +0100 From: Stefano Brivio To: Laurent Vivier Subject: Re: [PATCH v14 7/9] vhost-user: add vhost-user Message-ID: <20241127054749.7f1cfb25@elisabeth> In-Reply-To: <20241122164337.3377854-8-lvivier@redhat.com> References: <20241122164337.3377854-1-lvivier@redhat.com> <20241122164337.3377854-8-lvivier@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: dP0pdxpp3gjhX3SA3AUd40Qp0qiJ8qVJ7hlZLVWuHAw_1732682876 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: KADQHY4HOACZ7RAPWRTKSQJIFM6VQJZH X-Message-ID-Hash: KADQHY4HOACZ7RAPWRTKSQJIFM6VQJZH X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Fri, 22 Nov 2024 17:43:34 +0100 Laurent Vivier wrote: > +/** > + * tcp_vu_send_flag() - Send segment with flags to vhost-user (no payload) > + * @c: Execution context > + * @conn: Connection pointer > + * @flags: TCP flags: if not set, send segment only if ACK is due > + * > + * Return: negative error code on connection reset, 0 otherwise > + */ > +int tcp_vu_send_flag(const struct ctx *c, struct tcp_tap_conn *conn, int flags) > +{ > + struct vu_dev *vdev = c->vdev; > + struct vu_virtq *vq = &vdev->vq[VHOST_USER_RX_QUEUE]; > + const struct flowside *tapside = TAPFLOW(conn); > + size_t l2len, l4len, optlen, hdrlen; > + struct vu_virtq_element flags_elem[2]; > + struct tcp_payload_t *payload; > + struct ipv6hdr *ip6h = NULL; > + struct iovec flags_iov[2]; > + struct iphdr *iph = NULL; > + struct ethhdr *eh; > + uint32_t seq; > + int elem_cnt; > + int nb_ack; > + int ret; > + > + hdrlen = tcp_vu_hdrlen(CONN_V6(conn)); > + > + vu_set_element(&flags_elem[0], NULL, &flags_iov[0]); > + > + elem_cnt = vu_collect(vdev, vq, &flags_elem[0], 1, > + hdrlen + sizeof(struct tcp_syn_opts), NULL); Oops, I made this crash, by starting a number of iperf3 client threads on the host: $ iperf3 -c localhost -p 6001 -Z -l 500 -w 256M -t 600 -P20 with matching server in the guest, then terminating QEMU while the test is running. Details (I saw it first, then I reproduced it under gdb): accepted connection from PID 3115463 NDP: received RS, sending RA DHCP: offer to discover from 52:54:00:12:34:56 DHCP: ack to request from 52:54:00:12:34:56 NDP: sending unsolicited RA, next in 212s Client connection closed Program received signal SIGSEGV, Segmentation fault. 0x00005555555884f5 in vring_avail_idx (vq=0x555559343f10 ) at virtio.c:138 138 vq->shadow_avail_idx = le16toh(vq->vring.avail->idx); (gdb) list 133 * 134 * Return: the available ring index of the given virtqueue 135 */ 136 static inline uint16_t vring_avail_idx(struct vu_virtq *vq) 137 { 138 vq->shadow_avail_idx = le16toh(vq->vring.avail->idx); 139 140 return vq->shadow_avail_idx; 141 } 142 (gdb) bt #0 0x00005555555884f5 in vring_avail_idx (vq=0x555559343f10 ) at virtio.c:138 #1 vu_queue_empty (vq=vq@entry=0x555559343f10 ) at virtio.c:290 #2 vu_queue_pop (dev=dev@entry=0x555559343a00 , vq=vq@entry=0x555559343f10 , elem=elem@entry=0x7ffffff6f510) at virtio.c:505 #3 0x0000555555588c8c in vu_collect (vdev=vdev@entry=0x555559343a00 , vq=vq@entry=0x555559343f10 , elem=elem@entry=0x7ffffff6f510, max_elem=max_elem@entry=1, size=size@entry=74, frame_size=frame_size@entry=0x0) at vu_common.c:86 #4 0x000055555557e00e in tcp_vu_send_flag (c=0x7ffffff6f7a0, conn=0x5555555bd2d0 , flags=4) at tcp_vu.c:116 #5 0x0000555555578125 in tcp_send_flag (flags=4, conn=0x5555555bd2d0 , c=0x7ffffff6f7a0) at tcp.c:1278 #6 tcp_rst_do (conn=, c=) at tcp.c:1293 #7 tcp_timer_handler (c=c@entry=0x7ffffff6f7a0, ref=..., ref@entry=...) at tcp.c:2266 #8 0x0000555555558f26 in main (argc=, argv=) at passt.c:342 (gdb) p *vq $1 = {vring = {num = 256, desc = 0x0, avail = 0x0, used = 0x0, log_guest_addr = 4338774592, flags = 0}, last_avail_idx = 35133, shadow_avail_idx = 35133, used_idx = 35133, signalled_used = 0, signalled_used_valid = false, notification = true, inuse = 0, call_fd = -1, kick_fd = -1, err_fd = -1, enable = 1, started = false, vra = {index = 0, flags = 0, desc_user_addr = 139660501995520, used_user_addr = 139660502000192, avail_user_addr = 139660501999616, log_guest_addr = 4338774592}} (gdb) p *vq->vring.avail Cannot access memory at address 0x0 ...so we're sending a RST segment to the guest, but the ring doesn't exist anymore. By the way, I still have the gdb session running, if you need something else out of it. Now, I guess we should eventually introduce a more comprehensive handling of the case where the guest suddenly terminates (not specific to vhost-user), but given that we have vu_cleanup() working as expected in this case, I wonder if we shouldn't simply avoid calling vring_avail_idx() (it has a single caller) by checking for !vring.avail in the caller, or something like that. We can also handle this as a follow-up patch, it's not something that would stand in the way of a bisect, but I wouldn't push the series without a fix immediately following it. -- Stefano