Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp97520lqh; Fri, 3 May 2024 14:47:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV4oJ23iMaU9DWfP82W9RYfxS4wQru6eZwGFRmeXOdCdzoE6PAhIYKJ20SsonyVvDCU4rZvgr1y2iOXgtWpZOcwKfU9DgkI8lXHhx1sgg== X-Google-Smtp-Source: AGHT+IGitEiFhzVQxDQApEIlUqyf3rFQ+MkhkGRXbN/3cr/bKq7LBlWFxLoNm9oezOrE9YMr0UKe X-Received: by 2002:a05:620a:8cb:b0:790:ec93:3e0 with SMTP id z11-20020a05620a08cb00b00790ec9303e0mr6952999qkz.36.1714772856443; Fri, 03 May 2024 14:47:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714772856; cv=pass; d=google.com; s=arc-20160816; b=iZe8x/XikfX43MyDoaCARiqunsTeIUWmXOs1MoNNqKIfWb4a0pv6oM1dBXDdUI3zUJ ZiR/aSGx2M4epE3ZjFcTTrpaDCOIjwRjZTQd3MWX74t+MkI7YiluRTo3iVhQ39Vtj6PP 0Df1GLEytWzGgBD3lW6p50IMperUxLx9pUeINhsFm4725PZT0f720KCHUlBRDYqyZrf/ sOa6v+EzgieLFQu3kY1tjE1G4msNk3oLYoOB7JmLjxft7ljKKGOvlE+86qhhxbfURKSJ 5T9MMmCuOg8lEVInyYUcHuM+eZ9fk5DuxM9GyJ+TsLaRAZbBG9GPUWKX/sAwi/2F06uM PBSg== 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=p/Q/2B8nlKGo4p9HVJI/N3QC9LbWf3C4w9luKfxzv9s=; fh=U1EGp8rZR10AyDDGCdgQLFpg4E4JSlDnkyLElmFsT3o=; b=V6Pq8dC0vsX+AqYkM01sK0vhxWuPP49HQmIiveSIiyVo5TF+PB4H8Ompj11DrlMP6l rHJ/VmdlCIRE3mOPlw5vQW3sOFsIq38g9F+lV5g8t8pGR04FbUE/ZM3EzIrDGVacQ1oH fNfdTdiekHy1+dWVr89a3op9Z7AOetEWGLOaxq0b/2v9OfvTKmZJ//uQQl0A3lPb8gHJ f+QvUwfUMYrKK3MDLsr510Qhl4125o8KYKz6iDVKGhNK92J6SQyfLFhGDwCNpOj/wUMb aDYDYt728FxcafnNeRGc6vkUukCwzabyN7JZfn6e3Ot/lsv+9y9da2VbA1OjSyA6fMnL 0kXw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=l5AZ0+Rn; 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-168314-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168314-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id w13-20020a05620a444d00b007909479124bsi4473498qkp.4.2024.05.03.14.47.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 14:47:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168314-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=l5AZ0+Rn; 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-168314-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168314-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 8F13C1C22DC7 for ; Fri, 3 May 2024 21:47:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 07ECC65BB7; Fri, 3 May 2024 21:41:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="l5AZ0+Rn" Received: from out-179.mta1.migadu.com (out-179.mta1.migadu.com [95.215.58.179]) (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 984931EB21; Fri, 3 May 2024 21:41:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714772477; cv=none; b=rRWtayDfFayAUjTkwoKAFpUkFAta4xwKTwTfkqSC7gz0G3Jb7HCVeiYaAOWOLKhir7wKOoUbRFfS2fP4mjXgJyBn5O4X2/6SAjcMl+Obsg1rftbs6DVv5VyKnknap/iOw0WCe7TmkdmAJpTervMPRsXKGJJrtg9ZKjiNHuGkrRE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714772477; c=relaxed/simple; bh=5Ie0VfWEVEhTaPq2tuo8Tm98X78hh2rfQuYKbrLkDTA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=KPGVcO0/DmPS6vR8gsNvKKaRvPqiqhoWop7mREefYeTMryI0gqMnv/dEisaP7XxLRjgtgZ0wL6M4L+VqzUjrg3bp0pETxF4iURQ2z9E/PvqviASx7xMC4eKUZORz+DjnCgBw6DYhpqPi4XQ8eBI/aPSvB7ZtaqFrJhRK4E/8FTc= 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=l5AZ0+Rn; arc=none smtp.client-ip=95.215.58.179 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: <8376c566-14a4-4b11-89ba-bb544ee5f8e2@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1714772472; 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=p/Q/2B8nlKGo4p9HVJI/N3QC9LbWf3C4w9luKfxzv9s=; b=l5AZ0+RnzYYlybEQotGfzh4XVbQDt7zU3J4piKdbNzJrVsWee6Ytrv97Z62cDJVbVu/Aaw 1zj+kQNI1WZ2HpFhqTBmQ0lC2+Z8lYHghuEjV/ljuTa89ZTz0zmpjIjaEQlUW6Y8XLy3WV 8j1d/wmf+7oZgbgvR7Qp6PPck6jCt3w= Date: Fri, 3 May 2024 14:41:00 -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 v5 2/2] net: Add additional bit to support clockid_t timestamp type To: "Abhishek Chauhan (ABC)" Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Halaney , Willem de Bruijn , Martin KaFai Lau , Daniel Borkmann , bpf , kernel@quicinc.com References: <20240424222028.1080134-1-quic_abchauha@quicinc.com> <20240424222028.1080134-3-quic_abchauha@quicinc.com> <2b2c3eb1-df87-40fe-b871-b52812c8ecd0@linux.dev> <0f88ec53-6c92-434d-81c8-538b31a2385e@quicinc.com> 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: <0f88ec53-6c92-434d-81c8-538b31a2385e@quicinc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT On 5/3/24 2:33 PM, Abhishek Chauhan (ABC) wrote: > >> BPF_CALL_3(bpf_skb_set_tstamp, struct sk_buff *, skb, >>            u64, tstamp, u32, tstamp_type) >> { >>     /* ... */ >>     case BPF_SKB_CLOCK_TAI: >>         if (!tstamp) >>             return -EINVAL; >>         skb->tstamp = tstamp; >>         skb->tstamp_type = SKB_CLOCK_TAI; >>         break; >>         case BPF_SKB_CLOCK_REALTIME: >>         skb->tstamp = tstamp; >>         skb->tstamp_type = SKB_CLOCK_REALTIME; >>         break; >> >>     /* ... */ >> } >> >>>               return -EINVAL; >> >>> @@ -9388,17 +9394,17 @@ static struct bpf_insn *bpf_convert_tstamp_type_read(const struct bpf_insn *si, >>>   { >>>       __u8 value_reg = si->dst_reg; >>>       __u8 skb_reg = si->src_reg; >>> -    /* AX is needed because src_reg and dst_reg could be the same */ >>> -    __u8 tmp_reg = BPF_REG_AX; >>> - >>> -    *insn++ = BPF_LDX_MEM(BPF_B, tmp_reg, skb_reg, >>> -                  SKB_BF_MONO_TC_OFFSET); >>> -    *insn++ = BPF_JMP32_IMM(BPF_JSET, tmp_reg, >>> -                SKB_MONO_DELIVERY_TIME_MASK, 2); >>> -    *insn++ = BPF_MOV32_IMM(value_reg, BPF_SKB_TSTAMP_UNSPEC); >>> -    *insn++ = BPF_JMP_A(1); >>> -    *insn++ = BPF_MOV32_IMM(value_reg, BPF_SKB_TSTAMP_DELIVERY_MONO); >>> - >>> +    BUILD_BUG_ON(__SKB_CLOCK_MAX != BPF_SKB_TSTAMP_DELIVERY_TAI); >> >> Add these also: >> >>     BUILD_BUG_ON(SKB_CLOCK_REALTIME != BPF_SKB_CLOCK_REALTIME); >>     BUILD_BUG_ON(SKB_CLOCK_MONOTONIC != BPF_SKB_CLOCK_MONOTONIC); >>     BUILD_BUG_ON(SKB_CLOCK_TAI != BPF_SKB_CLOCK_TAI); >> > > Martin, The above suggestion of adding BUILD_BUG_ON always gives me a warning stating the following. > > Some systems considers warning as error if compiler flags are enabled. I believe this requires your suggestion before i raise RFC v6 patchset to either keep the > BUILD_BUG_ON or remove it completely. cast it? > > /local/mnt/workspace/kernel_master/linux-next/net/core/filter.c:9395:34: warning: comparison between ‘enum skb_tstamp_type’ and ‘enum ’ [-Wenum-compare] > 9395 | BUILD_BUG_ON(SKB_CLOCK_REALTIME != BPF_SKB_CLOCK_REALTIME); > | ^~ > /local/mnt/workspace/kernel_master/linux-next/include/linux/compiler_types.h:451:9: note: in definition of macro ‘__compiletime_assert’ > 451 | if (!(condition)) \ > | ^~~~~~~~~ > /local/mnt/workspace/kernel_master/linux-next/include/linux/compiler_types.h:471:2: note: in expansion of macro ‘_compiletime_assert’ > 471 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) > | ^~~~~~~~~~~~~~~~~~~ > /local/mnt/workspace/kernel_master/linux-next/include/linux/build_bug.h:39:37: note: in expansion of macro ‘compiletime_assert’ > 39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) > | ^~~~~~~~~~~~~~~~~~ > /local/mnt/workspace/kernel_master/linux-next/include/linux/build_bug.h:50:2: note: in expansion of macro ‘BUILD_BUG_ON_MSG’ > 50 | BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition) > | ^~~~~~~~~~~~~~~~ > /local/mnt/workspace/kernel_master/linux-next/net/core/filter.c:9395:2: note: in expansion of macro ‘BUILD_BUG_ON’ > 9395 | BUILD_BUG_ON(SKB_CLOCK_REALTIME != BPF_SKB_CLOCK_REALTIME); > | ^~~~~~~~~~~~ > /local/mnt/workspace/kernel_master/linux-next/net/core/filter.c:9396:35: warning: comparison between ‘enum skb_tstamp_type’ and ‘enum ’ [-Wenum-compare] > 9396 | BUILD_BUG_ON(SKB_CLOCK_MONOTONIC != BPF_SKB_CLOCK_MONOTONIC); > | ^~ > /local/mnt/workspace/kernel_master/linux-next/include/linux/compiler_types.h:451:9: note: in definition of macro ‘__compiletime_assert’ > 451 | if (!(condition)) \ > | ^~~~~~~~~ > > | ^~ > > >