From mboxrd@z Thu Jan 1 00:00:00 1970 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 809235A0054 for ; Wed, 12 Jun 2024 17:47:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718207275; 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=WjsPcigBaKk1TAW22snBKcbIZSn7+2GntJM1410LI/o=; b=RfbmSTcaXeh7+hFc91kgyo/8J7Nb+pMiUTG6XPHQQcJzc96OhTKwCnZz2bDdc8m2Wxlz6g sPJJEt/0lhaM7N7fV/nMx+GPRSPHUE6VRzNjsF3Psl/rv9ZDIn8BGUrqZe+nYdzJoGaI2o M2eCIlcglRpOC8gY4dOM9mrCwwZZILQ= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-6-rtyO1NLNOzKCWmGcQtZ7sQ-1; Wed, 12 Jun 2024 11:47:52 -0400 X-MC-Unique: rtyO1NLNOzKCWmGcQtZ7sQ-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A1E7D195608F; Wed, 12 Jun 2024 15:47:50 +0000 (UTC) Received: from lenovo-t14s.redhat.com (unknown [10.39.193.78]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 54C3D1956087; Wed, 12 Jun 2024 15:47:49 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH v6 8/8] tap: use in->buf_size rather than sizeof(pkt_buf) Date: Wed, 12 Jun 2024 17:47:34 +0200 Message-ID: <20240612154734.1044883-9-lvivier@redhat.com> In-Reply-To: <20240612154734.1044883-1-lvivier@redhat.com> References: <20240612154734.1044883-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: U5M3LKBF465KVRW3T3ECVAJTNXANHVT6 X-Message-ID-Hash: U5M3LKBF465KVRW3T3ECVAJTNXANHVT6 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: Laurent Vivier , David Gibson 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: buf_size is set to sizeof(pkt_buf) by default. And it seems more correct to provide the actual size of the buffer. Later a buf_size of 0 will allow vhost-user mode to detect guest memory buffers. Signed-off-by: Laurent Vivier Reviewed-by: David Gibson --- tap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tap.c b/tap.c index 4f7da7645599..856708979371 100644 --- a/tap.c +++ b/tap.c @@ -602,7 +602,7 @@ resume: if (!eh) continue; if (ntohs(eh->h_proto) == ETH_P_ARP) { - PACKET_POOL_P(pkt, 1, in->buf, sizeof(pkt_buf)); + PACKET_POOL_P(pkt, 1, in->buf, in->buf_size); packet_add(pkt, l2len, (char *)eh); arp(c, pkt); @@ -642,7 +642,7 @@ resume: continue; if (iph->protocol == IPPROTO_ICMP) { - PACKET_POOL_P(pkt, 1, in->buf, sizeof(pkt_buf)); + PACKET_POOL_P(pkt, 1, in->buf, in->buf_size); if (c->no_icmp) continue; @@ -661,7 +661,7 @@ resume: continue; if (iph->protocol == IPPROTO_UDP) { - PACKET_POOL_P(pkt, 1, in->buf, sizeof(pkt_buf)); + PACKET_POOL_P(pkt, 1, in->buf, in->buf_size); packet_add(pkt, l2len, (char *)eh); if (dhcp(c, pkt)) @@ -810,7 +810,7 @@ resume: } if (proto == IPPROTO_ICMPV6) { - PACKET_POOL_P(pkt, 1, in->buf, sizeof(pkt_buf)); + PACKET_POOL_P(pkt, 1, in->buf, in->buf_size); if (c->no_icmp) continue; @@ -834,7 +834,7 @@ resume: uh = (struct udphdr *)l4h; if (proto == IPPROTO_UDP) { - PACKET_POOL_P(pkt, 1, in->buf, sizeof(pkt_buf)); + PACKET_POOL_P(pkt, 1, in->buf, in->buf_size); packet_add(pkt, l4len, l4h); -- 2.45.2