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=Tju9WaLx; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id A33FD5A004E for ; Thu, 19 Dec 2024 10:00:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734598818; 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=W2tc77rnrD6Ja0s0jKyLmEEqvUJYAw79MlAyK/16svU=; b=Tju9WaLx+Gjcdx+83W4WCWO+F8/tonNNMA6KbSD3/8eaWdMZ5cN/l5lNY6Iz9Oaon9pBYo R4G95PUHfr4e7c0rIy43URjRiEuL5PZr/ZD8eMXfr+xSlAE3H0vhgRgyUjgvIHA/Q5JB1C j5ODmCEAsWL+ysxWEuHFV+N9ILuitNM= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-668-a-zvE_S4OI2F9BwaM7Bb_Q-1; Thu, 19 Dec 2024 04:00:16 -0500 X-MC-Unique: a-zvE_S4OI2F9BwaM7Bb_Q-1 X-Mimecast-MFC-AGG-ID: a-zvE_S4OI2F9BwaM7Bb_Q Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-43621907030so4349395e9.1 for ; Thu, 19 Dec 2024 01:00:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734598814; x=1735203614; 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=W2tc77rnrD6Ja0s0jKyLmEEqvUJYAw79MlAyK/16svU=; b=dudoZt5iK9VclRK9G14XZjZMzTQif0munjHH4X1IoMXbr0pyp4gOo88Vy1eI8xoBCP 8I04PHDYzcgxTYo7xUNbGqdjYbmgmaXEgYFh2c8HyHMES/GTuW9kW8ohr3wkJaureBtE tOuYuugEUdITRFTE7bpKDHQCDhsP0Em7rF/IhSBnCqtJ+SbQ312IQkyl5d0AXC5AR+dk hDtq88iubmlWww0TQhhbtiB0qx9Bg1n69+2sxK+NOEH3eDiws3FZ6nR6tq7iS2jj8gVa deZ/WWvZ+r133JEm+ri0w8BUchbmh8btOVFcmVvem9damGjeUM5cIoO1aE/v2yrT3QbA hhPA== X-Gm-Message-State: AOJu0YwCOFUojjhadQh/laO/isBxdecLCbspwppjLO1AJjsJofFBU9RS w7v08mPg6/9V7O8tfuNLstRYcvC+VHyKj3uCRrxoNIOEFbTizcxihZSWHPGX3OTMna/fvzmxL6d yNiRzUNpl7O39S8OTNE0pRQQfIcPZ7eEXwEpTN6sIbp1To3OtKiHkOVrv8w== X-Gm-Gg: ASbGnctxmC0c/29DZM1Ek4G4f/8/EPcRG7JeOHeY2FCE2yKf12n+wc/10Eoi1cz1Bdz GD6siYkyVANjwnydC6IMOJMx1duPC930C6N9vpjS6ipK/g7pHbX7qI9ielquy/c7Hv4VFVeckix saPYo680T8JYLI+swOswbI8TiYt8bq4kXRohHIKRcQmvPodV2IZKruUZLqCJzuD1CFnr6c922GO tXc6FgzBIoEtCIFjqvIb1CPIerrXGp2/D3oIQm+9NDl/SKWhEkllozL64n/c4ObeBsn9cgss0h0 5qjoM49NvQ== X-Received: by 2002:a05:600c:4f47:b0:436:1baa:de1c with SMTP id 5b1f17b1804b1-4365c78125cmr19352595e9.13.1734598814277; Thu, 19 Dec 2024 01:00:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IH89eIsVKhH9E39ZICZNbzJw8KXP0xHAYkLqcgHkBh3NUqYnH4MpM9ZVjACUU7K6fWEtcTLVw== X-Received: by 2002:a05:600c:4f47:b0:436:1baa:de1c with SMTP id 5b1f17b1804b1-4365c78125cmr19352395e9.13.1734598813923; Thu, 19 Dec 2024 01:00:13 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656af6c35sm46111095e9.7.2024.12.19.01.00.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 01:00:13 -0800 (PST) Date: Thu, 19 Dec 2024 10:00:11 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 2/3] packet: Don't have struct pool specify its buffer Message-ID: <20241219100011.5faed9fd@elisabeth> In-Reply-To: <20241213120156.4123972-3-david@gibson.dropbear.id.au> References: <20241213120156.4123972-1-david@gibson.dropbear.id.au> <20241213120156.4123972-3-david@gibson.dropbear.id.au> 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: yc4q8HQkgn7ENZ688985KLpoMfnBh-FQjW413fQV04M_1734598816 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: VARF4EUGDL374MSQGKMDHCXG7VOQ32DJ X-Message-ID-Hash: VARF4EUGDL374MSQGKMDHCXG7VOQ32DJ 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, 13 Dec 2024 23:01:55 +1100 David Gibson wrote: > struct pool, which represents a batch of packets includes values giving > the buffer in which all the packets lie - or for vhost_user a link to the > vu_dev_region array in which the packets sit. Originally that made sense > because we stored each packet as an offset and length within that buffer. > > However dd143e389 ("packet: replace struct desc by struct iovec") replaced > the offset and length with a struct iovec which can directly reference a > packet anywhere in memory. This means we no longer need the buffer > reference to interpret packets from the pool. So there's really no need > to check where the packet sits. We can remove the buf reference and all > checks associated with it. As a bonus this removes the special case for > vhost-user. > > Similarly the old representation used a 16-bit length, so there were some > checks that packets didn't exceed that. That's also no longer necessary > with the struct iovec which uses a size_t length. > > I think under an unlikely set of circumstances it might have been possible > to hit that 16-bit limit for a legitimate packet: other parts of the code > place a limit of 65535 bytes on the L2 frame, however that doesn't include > the length tag used by the qemu socket protocol. That tag *is* included in > the packet as stored in the pool, however, meaning we could get a 65539 > byte packet at this level. As I mentioned in the call on Monday: sure, we need to fix this, but at the same time I'm not quite convinced that it's a good idea to drop all these sanity checks. Even if they're not based on offsets anymore, I think it's still valuable to ensure that the packets are not exactly _anywhere_ in memory, but only where we expect them to be. If it's doable, I would rather keep these checks, and change the ones on the length to allow a maximum value of 65539 bytes. I mean, there's a big difference between 65539 and, say, 4294967296. By the way, I haven't checked what happens with MTUs slightly bigger than 65520 bytes: virtio-net (at least with QEMU) doesn't budge if I set more than 65520, but I didn't actually send big packets. I'll try to have a look (also with muvm) unless you already checked. -- Stefano