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=TluZgU0X; 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 9D5CE5A004E for ; Wed, 27 Nov 2024 10:09:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1732698598; 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:autocrypt:autocrypt; bh=EHmovDQlz4XiOanfvf9lgnJZnayf6dhgwprzTDhUgfI=; b=TluZgU0XLmyOZHhOE24LGyMRugzIUB1dRRD3VW1dToHzzHLAB88p8N4bql9gZkWBGK40Km fKuxr7hsxvodUIbEcmuOEW4VPbQJWH3l9fXf89hTHcr4iXAVQxptK7IS0qIHV23ajFwwtj wKZjmXPhGyew8gX2LxX4aqgb55wBroA= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-609-w5m-YP9lO72dnVbhHcGG-Q-1; Wed, 27 Nov 2024 04:09:56 -0500 X-MC-Unique: w5m-YP9lO72dnVbhHcGG-Q-1 X-Mimecast-MFC-AGG-ID: w5m-YP9lO72dnVbhHcGG-Q Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-382428c2564so3955281f8f.2 for ; Wed, 27 Nov 2024 01:09:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732698595; x=1733303395; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=EHmovDQlz4XiOanfvf9lgnJZnayf6dhgwprzTDhUgfI=; b=RDTXHURv2W9A14qLxQZUd9hAji8TbeZZFsYdGAt/Qwbvmv3czZklktVEaMGPzDZuVh VjsJxVLh1vP+zokKSuI02OjFn/++N/wRBvf26hdfOGVfWdeaz7u0XFgVI1aAo8idM9YZ eTMt8w9xADbE0i6e4XqAoTtGSNOauiiPU0u+KzY1m5mYrql7k57cAmQi95KwdyEmX2Xq jcyAHHTVS+O+FRZk6mhU2Ld060KvP4EEzmTAePtMR6FXl/Jay2I45YbS0OaelMOCbYF0 i8YDvUdQTAQFlTgXj1WrDDsI3lQ7R39zm2iIWNMAZ4XFavxRCCJ8nfv1AVTjTH1/Ghu4 i9+g== X-Gm-Message-State: AOJu0Yxut2PQm56t98CBO38ISCiOaVwtk9p1k48me/JSd7fuYSnfvRoq T8IuaAFjmwUz/rtuIPBWPHXxUhbtzTVvEUT/tU9AZ132ApfDFD/Ohv8iaRRuH9u5PalQRCMN+4f Wwznmww/sTASrq1HzVMsydlyUWQszFoi0Lixxc7dmRXaeiVvSMQ== X-Gm-Gg: ASbGncvW1TbdPSJm869bfAck0Dz/7GBBt03rO9aJEm1FUJj0UkEOd5HqkYmraNFmTjg IDn4Dg7wQJz60q1foqPOkH7DCItIJaEk1seU58KAVnGBVoVOoHBane2DWUWd22ZCAhQVriNng6p uF3jUnGmBbVKk/epGM7XXJiyMgh2EIAZgpnKQ73eDaMLJU5tQUtlm2gX4L12cGuTKscH3+0W7r5 GdGutKeZ+TYgIrjcb48i5iLglM/ETWfPeGxn/kVpnyny8r/9WfJ7O6zanrczsVLwP9+mrFyjP33 uma/ViSWHeqc X-Received: by 2002:a05:6000:2b09:b0:382:2976:c27c with SMTP id ffacd0b85a97d-385c6ec0911mr1118073f8f.30.1732698594829; Wed, 27 Nov 2024 01:09:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHIo1oIJlzxoT/NHGQRcqPKPM0o4XANiTiW9+RD9xKXKQqMMYlGJA6brUEwWX3005LHFQ0lZg== X-Received: by 2002:a05:6000:2b09:b0:382:2976:c27c with SMTP id ffacd0b85a97d-385c6ec0911mr1118050f8f.30.1732698594406; Wed, 27 Nov 2024 01:09:54 -0800 (PST) Received: from ?IPV6:2a01:e0a:e10:ef90:343a:68f:2e91:95c? ([2a01:e0a:e10:ef90:343a:68f:2e91:95c]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3825fb30590sm15801046f8f.57.2024.11.27.01.09.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Nov 2024 01:09:53 -0800 (PST) Message-ID: Date: Wed, 27 Nov 2024 10:09:53 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v14 7/9] vhost-user: add vhost-user To: Stefano Brivio References: <20241122164337.3377854-1-lvivier@redhat.com> <20241122164337.3377854-8-lvivier@redhat.com> <20241127054749.7f1cfb25@elisabeth> From: Laurent Vivier Autocrypt: addr=lvivier@redhat.com; keydata= xsFNBFYFJhkBEAC2me7w2+RizYOKZM+vZCx69GTewOwqzHrrHSG07MUAxJ6AY29/+HYf6EY2 WoeuLWDmXE7A3oJoIsRecD6BXHTb0OYS20lS608anr3B0xn5g0BX7es9Mw+hV/pL+63EOCVm SUVTEQwbGQN62guOKnJJJfphbbv82glIC/Ei4Ky8BwZkUuXd7d5NFJKC9/GDrbWdj75cDNQx UZ9XXbXEKY9MHX83Uy7JFoiFDMOVHn55HnncflUncO0zDzY7CxFeQFwYRbsCXOUL9yBtqLer Ky8/yjBskIlNrp0uQSt9LMoMsdSjYLYhvk1StsNPg74+s4u0Q6z45+l8RAsgLw5OLtTa+ePM JyS7OIGNYxAX6eZk1+91a6tnqfyPcMbduxyBaYXn94HUG162BeuyBkbNoIDkB7pCByed1A7q q9/FbuTDwgV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SoBpTkgV7rLUEhh9Ms82VWW/h2TxL8enfx40PrfbDtWwqRID3WY8jLrjKfTd R3LW8BnUDNkG+c4FzvvGUs8AvuqxxyHbXAfDx9o/jXfPHVRmJVhSmd+hC3mcQ+4iX5bBPBPM oDqSoLt5w9GoQQ6gDVP2ZjTWqwSRMLzNr37rJjZ1pt0DCMMTbiYIUcrhX8eveCJtY7NGWNyx FCRkhxRuGcpwPmRVDwOl39MB3iTsRighiMnijkbLXiKoJ5CDVvX5yicNqYJPKh5MFXN1bvsB kmYiStMRbrD0HoY1kx5/VozBtc70OU0EB8Wrv9hZD+Ofp0T3KOr1RUHvCZoLURfFhSQ= In-Reply-To: <20241127054749.7f1cfb25@elisabeth> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: bj0H2oEZ31cFfn5cu4YTB59cIhTWhi1d6pdpwozkXqg_1732698595 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: LNIUE7RKVEPVGTOLT7ZFIMQHIKQEPICB X-Message-ID-Hash: LNIUE7RKVEPVGTOLT7ZFIMQHIKQEPICB X-MailFrom: lvivier@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 27/11/2024 05:47, Stefano Brivio wrote: > 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. > Yes, I think it's the lines I removed during the reviews: if (!vq->vring.avail) return true; Could you try to checkout virtio.c from v11? Thanks, Laurent