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.129.124]) by mail.toke.dk (Postfix) with ESMTPS id BC90A9E5154 for ; Fri, 27 Jan 2023 14:58:35 +0100 (CET) Authentication-Results: mail.toke.dk; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=PPnp2t6x DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674827914; 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: in-reply-to:in-reply-to:references:references; bh=SdjTBVez/3ftvZX6/OLdL9ZR1SQ75cgVUwtb7qk4ZfM=; b=PPnp2t6x4OdXKaVDCfrbCoZ7M26hidgx0FJtni69Sqkl53JIJre+S/C/lThSGmcksA9Xls 6IMXj6ZQzhMh14i/sS6nfwA4wWz+tXjQWNcrNPRuiybfNn4ECueoeRA+tmIbKqswJsgFgp EhA5egXBbSQwUSw0RFmUnbY1SNOWb4k= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-93-NtHjI5VEPumxnTvxK31srQ-1; Fri, 27 Jan 2023 08:58:33 -0500 X-MC-Unique: NtHjI5VEPumxnTvxK31srQ-1 Received: by mail-ej1-f70.google.com with SMTP id kt9-20020a1709079d0900b00877f4df5aceso3473531ejc.21 for ; Fri, 27 Jan 2023 05:58:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SdjTBVez/3ftvZX6/OLdL9ZR1SQ75cgVUwtb7qk4ZfM=; b=rwp5kFknS3xon3m4tPe16/OwDOHqNLfDE0anjTNzfCGiGzxi+6DjNzvlQJgJH5Rdt5 PoASAGcKe76PjshaK/cfWiiiwa9aBgbP4FnrwvOlrDjnfqkYC4pxv/b6woIl4LWnNBXD 7Rgsm1lo79T+YQnv2oR4jOts6KxKFLACp9fhJwm3Y+S5LWlYJhrs4eaBe3Sop09l1Rw6 1XUcf0Jb1AG4xV/ToBZ3d7xVW+2GLh4aTfWqXs5fqhiuYvYs98fwbDgHOxwIndQfuVDr HmvNFa2/Zi0L6oaFg6tG83EDPDDT96BKq3r9Pq/o6UWM3Vxd6lIB5VgzdldL6a7mnPSR 5ihA== X-Gm-Message-State: AO0yUKXIdQ+Mre/g1znyenN14NGn/N++508t0XziRfAEEOaFhETULUzI Hl145w0ZyWLZmBvYYkxMOKsARUYLK6E4oH0QewGe/ZifODomIIqu2gI6Yw5aWxeXPYnHRCKeF5v ZHxZEsmS2W306VFB734f0 X-Received: by 2002:a17:906:6c87:b0:87b:59d9:5a03 with SMTP id s7-20020a1709066c8700b0087b59d95a03mr2515396ejr.36.1674827911106; Fri, 27 Jan 2023 05:58:31 -0800 (PST) X-Google-Smtp-Source: AK7set+3UBn4OcKy5pYLNxZ0qgtJJk59jcWp2z39qXFHB5Q8CawryZtKG7DrALckbaIQUtmNvCCSKg== X-Received: by 2002:a17:906:6c87:b0:87b:59d9:5a03 with SMTP id s7-20020a1709066c8700b0087b59d95a03mr2515303ejr.36.1674827909461; Fri, 27 Jan 2023 05:58:29 -0800 (PST) Received: from alrua-x1.borgediget.toke.dk ([2a0c:4d80:42:443::2]) by smtp.gmail.com with ESMTPSA id w10-20020a170906d20a00b008448d273670sm2255205ejz.49.2023.01.27.05.58.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 05:58:28 -0800 (PST) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 2266C943260; Fri, 27 Jan 2023 14:58:28 +0100 (CET) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: Jesper Dangaard Brouer , bpf@vger.kernel.org, Stanislav Fomichev In-Reply-To: <167482734243.892262.18210955230092032606.stgit@firesoul> References: <167482734243.892262.18210955230092032606.stgit@firesoul> X-Clacks-Overhead: GNU Terry Pratchett Date: Fri, 27 Jan 2023 14:58:28 +0100 Message-ID: <87cz70krjv.fsf@toke.dk> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Message-ID-Hash: DYVZWAQPA4TEGIN4ZTX4ATGAOF7447HK X-Message-ID-Hash: DYVZWAQPA4TEGIN4ZTX4ATGAOF7447HK X-MailFrom: toke@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: Jesper Dangaard Brouer , netdev@vger.kernel.org, martin.lau@kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, dsahern@gmail.com, willemb@google.com, void@manifault.com, kuba@kernel.org, xdp-hints@xdp-project.net X-Mailman-Version: 3.3.8 Precedence: list Subject: [xdp-hints] Re: [PATCH bpf-next RFC V1] selftests/bpf: xdp_hw_metadata clear metadata when -EOPNOTSUPP List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Jesper Dangaard Brouer writes: > The AF_XDP userspace part of xdp_hw_metadata see non-zero as a signal of > the availability of rx_timestamp and rx_hash in data_meta area. The > kernel-side BPF-prog code doesn't initialize these members when kernel > returns an error e.g. -EOPNOTSUPP. This memory area is not guaranteed to > be zeroed, and can contain garbage/previous values, which will be read > and interpreted by AF_XDP userspace side. > > Tested this on different drivers. The experiences are that for most > packets they will have zeroed this data_meta area, but occasionally it > will contain garbage data. > > Example of failure tested on ixgbe: > poll: 1 (0) > xsk_ring_cons__peek: 1 > 0x18ec788: rx_desc[0]->addr=100000000008000 addr=8100 comp_addr=8000 > rx_hash: 3697961069 > rx_timestamp: 9024981991734834796 (sec:9024981991.7348) > 0x18ec788: complete idx=8 addr=8000 > > Converting to date: > date -d @9024981991 > 2255-12-28T20:26:31 CET > > I choose a simple fix in this patch. When kfunc fails or isn't supported > assign zero to the corresponding struct meta value. > > It's up to the individual BPF-programmer to do something smarter e.g. > that fits their use-case, like getting a software timestamp and marking > a flag that gives the type of timestamp. > > Another possibility is for the behavior of kfunc's > bpf_xdp_metadata_rx_timestamp and bpf_xdp_metadata_rx_hash to require > clearing return value pointer. I definitely think we should leave it up to the BPF programmer to react to failures; that's what the return code is there for, after all :) -Toke