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=OZot9tQ2; 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 023EF5A004C for ; Tue, 01 Oct 2024 09:29:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727767779; 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=nuut5XV4VgTGuP76egjcsbYXWk3vZOfB5/0LhMI/Nl4=; b=OZot9tQ2eRNkFVE9oRkGu0dt8vYT1Bwyw28jaTU0IYjjm5cCAGOfnBwvYuzweZGoCfQIqS G7gK8cXn9SMWaxE2HoDKKfolmzSCYjYT28AuLbGV9eri4l0n/KbGL7v16vUHXGF43978vH CXFxxaW/foQqI1V3jEpfcQVhVsFSgp8= 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-645-mxKa5lSjM-uszFtiIPo6hw-1; Tue, 01 Oct 2024 03:29:38 -0400 X-MC-Unique: mxKa5lSjM-uszFtiIPo6hw-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-42ca8037d9aso34311385e9.3 for ; Tue, 01 Oct 2024 00:29:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727767776; x=1728372576; 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=nuut5XV4VgTGuP76egjcsbYXWk3vZOfB5/0LhMI/Nl4=; b=cAkcsHy+gZnEbBjGT3EsriWeLMaK3dmZjn95wjTbNXaXKoHB1q0o1c+w2f0H673SPo XI7HwCfY+9dDQQFR62Rk7gc9Zsq7sL1lhiBdKsFg1sOul9H7o9W+6P4VUkmsmX0f5/2H 5qhWl2MnEv/mccs/87lopPTKBeWrSaECf+qdoKT5UXf2GrY2+WVejx+MLkfCzsReLyuw D1Wzkhlw/2pPl/Kot0HwuRBVekgvSoJCpZ2vrmhrvOcmIgs0fKA4acuVCXbDJDSVT/si i6QEPhGWNzFNbMhuR8uFcIPon5GW6z9aHJyKQIXX5fALaXrsc3z/KChmmrBXnCQbPW/o jwKQ== X-Gm-Message-State: AOJu0YwIyYf2wHvW9V8NVboomaaBhiUNIKgbPpGDlDs0ggodf4A3+WK3 1mAeyFPeg2tfnAMD5QSnNK2XPCxOjEa/YwhOn8T0tOpWtdztamMdfRVEEYdn1aPFnY3G79xhr0Q kh6OQsbBhyBmQ7vmN0w2vA6FP2yC91ZF2+69LaZAYXZcOyBlC6xFPt5Dg0aihOHHfXyAKTyzH1I SQ7+WTednJlT2p8u0dF5SS4IscuYSwz8Nm X-Received: by 2002:a05:600c:4f84:b0:42c:af06:71b with SMTP id 5b1f17b1804b1-42f6bec79b9mr31843835e9.28.1727767776273; Tue, 01 Oct 2024 00:29:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG4+0IGqy0gexoWNVS2klC0PRSqCs5Ite/a2VwX0kQCBD2oJoDmNjKPCNHaqsDFjZo3SQFX6g== X-Received: by 2002:a05:600c:4f84:b0:42c:af06:71b with SMTP id 5b1f17b1804b1-42f6bec79b9mr31843625e9.28.1727767775713; Tue, 01 Oct 2024 00:29:35 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37cd574268bsm11093960f8f.97.2024.10.01.00.29.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 00:29:35 -0700 (PDT) Date: Tue, 1 Oct 2024 09:29:28 +0200 From: Stefano Brivio To: Laurent Vivier Subject: Re: [PATCH v5 4/5] tcp: Update TCP checksum using an iovec array Message-ID: <20241001092928.33755f2b@elisabeth> In-Reply-To: <20240927135349.675850-5-lvivier@redhat.com> References: <20240927135349.675850-1-lvivier@redhat.com> <20240927135349.675850-5-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-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: SS7CP7EYPH6WCANRXZQP3POEPEZFF4AD X-Message-ID-Hash: SS7CP7EYPH6WCANRXZQP3POEPEZFF4AD 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, 27 Sep 2024 15:53:48 +0200 Laurent Vivier wrote: > [...] > > +void tcp_update_check_tcp4(const struct iphdr *iph, > + const struct iovec *iov, int iov_cnt, > + size_t l4offset) > { > uint16_t l4len = ntohs(iph->tot_len) - sizeof(struct iphdr); > struct in_addr saddr = { .s_addr = iph->saddr }; > struct in_addr daddr = { .s_addr = iph->daddr }; > - uint32_t sum = proto_ipv4_header_psum(l4len, IPPROTO_TCP, saddr, daddr); > + size_t check_ofs; > + __sum16 *check; > + int check_idx; > + uint32_t sum; > + uintptr_t ptr; > + > + sum = proto_ipv4_header_psum(l4len, IPPROTO_TCP, saddr, daddr); > + > + check_idx = iov_skip_bytes(iov, iov_cnt, > + l4offset + offsetof(struct tcphdr, check), > + &check_ofs); > + > + if (check_idx >= iov_cnt) { > + err("TCP4 buffer is too small, iov size %zd, check offset %zd", > + iov_size(iov, iov_cnt), > + l4offset + offsetof(struct tcphdr, check)); > + return; > + } > > - bp->th.check = 0; > - bp->th.check = csum(bp, l4len, sum); > + if (check_ofs + sizeof(*check) > iov[check_idx].iov_len) { > + err("TCP4 checksum field memory is not contiguous " > + "check_ofs %zd check_idx %d iov_len %zd", > + check_ofs, check_idx, iov[check_idx].iov_len); > + return; > + } > + > + ptr = (uintptr_t)((char *)iov[check_idx].iov_base + check_ofs); > + if (ptr & (__alignof__(*check) - 1)) { > + err("TCP4 checksum field is not correctly aligned in memory"); > + return; > + } > + > + check = (__sum16 *)ptr; clang-tidy (14.0.6) says: /home/sbrivio/passt/tcp.c:803:10: error: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr,-warnings-as-errors] check = (__sum16 *)ptr; ^ /home/sbrivio/passt/tcp.c:854:10: error: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr,-warnings-as-errors] check = (__sum16 *)ptr; ^ ...I'm still trying to figure out what that actually means. If it's trivial I can fix that up on merge. -- Stefano