Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1670313lqp; Mon, 15 Apr 2024 13:19:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWPkudmMC9deLyxDJnb7AW68aJEs57NSJ+0GAkXVQnS90Q5DUikcE6lcB63A8zHuB1UTHPZM2LrA+TNltWc+Irso6OwAPkBrWXOXemuOQ== X-Google-Smtp-Source: AGHT+IFPihu0lQ3St91MCqEjlY5g+2aOpaeB2IjCmeD77UaSw0Uk4ZaIqx4mXoDgwyYrRms1/P+F X-Received: by 2002:a05:6a20:6f96:b0:1a9:ff21:8862 with SMTP id gv22-20020a056a206f9600b001a9ff218862mr3617453pzb.60.1713212392539; Mon, 15 Apr 2024 13:19:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713212392; cv=pass; d=google.com; s=arc-20160816; b=iJDRgGXj131s/OClPfD9YjhozoqPJkjd+KKupPWz6eS3FAWgz4GnZV3apcNJA1aA0L sezHpub0BCXS7WllOWRSg37aoWCQMrZ/0W/su5rPJrbwSQPl2s36hB1mM8O9Ig7MBxwk YVoavvMGfbHscKxsmiVrLkMmOnx7FjQhxoMKF/vojZ3oa2fvxvWL+NqBsAVJ3hX3KVUU tznUgikmEwBOiNnk1OzPb5BHdGEcqNuOhioN9erDp7ukYtEZq5Nmz+Sc/ZW2GBulkNH5 HnnGp02bAycEftrV42iejtP5hfVeGIPglA6ZuSdNgNTjba3Rtj2PCjVM/2Dqh23EFWpd 3hPg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature:message-id; bh=0SJ/k5TZL9DMkDb6OS5NjYq8QZGa3dXX1/Ar8kH56co=; fh=ZO0C86uXLmZvgHG6EU/nNug+lXWAfp6e82qN9QEcauY=; b=s0XogYOQW3miyxiBqmwYBz3lPDWYpR/CXVRQPXdRHqPnz4O80cgiHE346a2XuavzDj L+ptyo1E6EWMUZf8/i3zhUTCEggQ+ay+IUK9+zkub19teVjfgQqSTa6tG5K3s6AXtl4q +qFNk13BkAFh+hZRKA4jhixjy3qI9d7dXXo+7B2VXP+oid+5bSCJ13z/5QTHJIRQtiIz wuxlEZ+P462PRc2olOAlFqmu82OFwJRdEDOjq0tniuwpomWxv/HmQSlkKKECKIeLLVhz HQ1ulRh4koe5roTI9wTjEUuUtgiAKo98VwG4L2sY3kcPxYEf4AB8/vP946XLnaOjuqPq q4mQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=pOd14QbR; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-145857-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145857-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id lk11-20020a17090308cb00b001e63ff9edf9si3086099plb.586.2024.04.15.13.19.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 13:19:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-145857-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=pOd14QbR; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-145857-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145857-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 21DE4B2148E for ; Mon, 15 Apr 2024 20:01:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A59E6156237; Mon, 15 Apr 2024 20:00:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="pOd14QbR" Received: from out-178.mta0.migadu.com (out-178.mta0.migadu.com [91.218.175.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9FD3156225 for ; Mon, 15 Apr 2024 20:00:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713211252; cv=none; b=Pws6Nu1K6quWBdVEixUsn8gVWXEwTuA/0KhTSx1ot4fHj+Wac14i+g8X4kRzSmpUy5t3y1yLTFerS29AEN+EUdRqqTwIsaVnWEOnYSVfblRTmhAH1+afaPRrR/GKFAfohVTvF61CUtLnhIybgZ/qmBW8WcRdac1e48SROyBpXr0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713211252; c=relaxed/simple; bh=Wng/zjvzq6AH7/m1b0joVL/p8BnUv1nNNKBDl6nF7sY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=JCUGTDIzZhdM+SFO3yCKCzUQq314gZEljEE7lInsYCuTUY/TGZ6caiq0yvJlOHi/RTn0GUuWj3wZ/SDtnXlnHdt62xYknCRy8DOWIGDoinK436oWMv0fBVaZae2sCIrTMpdLGYNgZ/7fsdTWbdXJIMqGH32udIRVhxvihnoq0iY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=pOd14QbR; arc=none smtp.client-ip=91.218.175.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Message-ID: <617e2577-8de2-4fde-bbfe-2d6280c48c29@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1713211248; 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=0SJ/k5TZL9DMkDb6OS5NjYq8QZGa3dXX1/Ar8kH56co=; b=pOd14QbRT99LhYEk7rHt2FDGGGkJZco+GAC6Y9PWAlKTh3I//gxLAAKKq0TjqfuN5xy+Hb obfsgalSovughcoaw1ZPnVR0iRjO7IM1kAmqIptIIyuLtfpx14bKNG3T5jPEmwigXS5yfK JUGW32P7QwW5J7wem8Tco4LTO2a9zDs= Date: Mon, 15 Apr 2024 13:00:42 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [RFC PATCH bpf-next v3 2/2] net: Add additional bit to support userspace timestamp type To: Abhishek Chauhan , Willem de Bruijn Cc: kernel@quicinc.com, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Halaney , Martin KaFai Lau , Daniel Borkmann , bpf References: <20240412210125.1780574-1-quic_abchauha@quicinc.com> <20240412210125.1780574-3-quic_abchauha@quicinc.com> <661ad7d4c65da_3be9a7294e@willemb.c.googlers.com.notmuch> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Martin KaFai Lau In-Reply-To: <661ad7d4c65da_3be9a7294e@willemb.c.googlers.com.notmuch> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 4/13/24 12:07 PM, Willem de Bruijn wrote: >> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h >> index a83a2120b57f..b6346c21c3d4 100644 >> --- a/include/linux/skbuff.h >> +++ b/include/linux/skbuff.h >> @@ -827,7 +827,8 @@ enum skb_tstamp_type { >> * @tstamp_type: When set, skb->tstamp has the >> * delivery_time in mono clock base (i.e. EDT). Otherwise, the >> * skb->tstamp has the (rcv) timestamp at ingress and >> - * delivery_time at egress. >> + * delivery_time at egress or skb->tstamp defined by skb->sk->sk_clockid >> + * coming from userspace >> * @napi_id: id of the NAPI struct this skb came from >> * @sender_cpu: (aka @napi_id) source CPU in XPS >> * @alloc_cpu: CPU which did the skb allocation. >> @@ -955,7 +956,7 @@ struct sk_buff { >> /* private: */ >> __u8 __mono_tc_offset[0]; >> /* public: */ >> - __u8 tstamp_type:1; /* See SKB_MONO_DELIVERY_TIME_MASK */ >> + __u8 tstamp_type:2; /* See SKB_MONO_DELIVERY_TIME_MASK */ >> #ifdef CONFIG_NET_XGRESS >> __u8 tc_at_ingress:1; /* See TC_AT_INGRESS_MASK */ >> __u8 tc_skip_classify:1; > > A quick pahole for a fairly standard .config that I had laying around > shows a hole after this list of bits, so no huge concerns there from > adding a bit: > > __u8 slow_gro:1; /* 3: 4 1 */ > __u8 csum_not_inet:1; /* 3: 5 1 */ > > /* XXX 2 bits hole, try to pack */ > > __u16 tc_index; /* 4 2 */ > >> @@ -1090,10 +1091,10 @@ struct sk_buff { >> */ >> #ifdef __BIG_ENDIAN_BITFIELD >> #define SKB_MONO_DELIVERY_TIME_MASK (1 << 7) >> -#define TC_AT_INGRESS_MASK (1 << 6) >> +#define TC_AT_INGRESS_MASK (1 << 5) > > Have to be careful when adding a new 2 bit tstamp_type with both bits > set, that this does not incorrectly get interpreted as MONO. > > I haven't looked closely at the BPF API, but hopefully it can be > extensible to return the specific type. If it is hardcoded to return > either MONO or not, then only 0x1 should match, not 0x3. Good point. I believe it is the best to have bpf to consider both bits in tstamp_type:2 in filter.c to avoid the 0x3 surprise in the future. The BPF API can be extended to support SKB_CLOCK_TAI. Regardless, in bpf_convert_tstamp_write(), it still needs to clear both bits in tstamp_type when it is at ingress. Right now it only clears the mono bit. Then it may as well consider both tstamp_type:2 bits in bpf_convert_tstamp_read() and bpf_convert_tstamp_type_read(). e.g. bpf_convert_tstamp_type_read(), it should be a pretty straight forward change because the SKB_CLOCK_* enum value should be a 1:1 mapping to the BPF_SKB_TSTAMP_*. > >> #else >> #define SKB_MONO_DELIVERY_TIME_MASK (1 << 0) >> -#define TC_AT_INGRESS_MASK (1 << 1) >> +#define TC_AT_INGRESS_MASK (1 << 2) >> #endif >> #define SKB_BF_MONO_TC_OFFSET offsetof(struct sk_buff, __mono_tc_offset) >>