Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1158608lqj; Mon, 3 Jun 2024 11:57:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVvB9JCstJoQn2lW8Hmu+QXjGpzDmCDzYyvbuSB0b5keUD1/VZie/C5ZnXqSFrP5vRwKmdy9B4I+r/syLLeAWW6Wvz7eE5ZcGReMFqYWA== X-Google-Smtp-Source: AGHT+IH7H1Sl/SWDn+3142qHGnz3eOQqYkLFoZeBtDTTzCRLhh/iKqUSaItfHJgyaY2clTsNv8UG X-Received: by 2002:a05:6a20:12c3:b0:1ad:7e4d:5b81 with SMTP id adf61e73a8af0-1b26f0ef892mr10738150637.5.1717441033718; Mon, 03 Jun 2024 11:57:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717441033; cv=pass; d=google.com; s=arc-20160816; b=P3jR3jAtmjw60E1uVX5d1XplgwelCHT2d0v0RqYp+zS0fv2XK/EyssgquiKxaGup9A TVwxlV1Z/rwHtgdwm19nIg4rlbt+ZQSt+lOg0HMoGC4GRAa3Bxoo3PRhUACZHLc9NwOf qtagfe+yX4Of/1XkxXcq8GwjpPlg0cR162LydfrWcHuXOa53kbbFi8wGWz7lMiW10+7+ 59XLRU77mO+lltmv6OveIychC72FTb/A8OS7H3HH7y3icynYkh8pnCZzs0BMprDY6JZh BZVpvAUUWeWh5PWSyw315QRpV4o63rEBsfXh+mTaY3joY5Iu2M6r8l+KCBLDRPKU387w 4Vfw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=FIDPi7gUErWP223w2FklBtvKymIuybnwzHfEv4BqDmM=; fh=WVVfreXWJVLS+3cUArQ7+LP5dwTkSDjx9JOOooK0PyM=; b=plsuTZlk1i0D5EnAVcwAL5eRnakGn9VksDxDAYkMVzoXTmAAE+qDZc1U0o7DGwGbxQ VKtyEmpNz7Qp9SRhIOwiZFXgerd5d2qSajE8DbQvfEfq3/RZ/6INRd1j58mzoe6gcs3Y KBBG3+hx8et+rKr4tJCu+Csazwy4PiYCHWxij1GdLE6r7v5Z8KM8DyA6HSi7250sJhte qknLT9K3g6dteYVp/JjcOTJyy8vRXOHucRO2J1MunKNTSxyb9g0KDvOalvltlnKy47LL 5UvYuP55tjE/OPyRoToHR0XIjXO3vjq9fx8MdfwjvopCHP+bP6gSHIjPK8/0TF/lBc0N o8dg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VHhHqSZj; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-199583-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199583-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c3540fb150si85777a12.165.2024.06.03.11.57.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 11:57:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199583-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VHhHqSZj; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-199583-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199583-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 27A48282E59 for ; Mon, 3 Jun 2024 18:57:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 74263139CEF; Mon, 3 Jun 2024 18:57:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VHhHqSZj" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 26BAC139CEE for ; Mon, 3 Jun 2024 18:57:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717441028; cv=none; b=h315TVe8hE8WMtYmUu62XeLzyse+/JdwapYOglWGoQSGEGbTAJwWgmyeW08zoBCifnBUIGBRbjqS+xCpJPWnxyAXZMKnExDuCEoth1ecQ3OAyxYClsBx6S6bM6aXi6LYgxrLLAY36/c+yLhHODg1gw45Bjtat6zty4FOGMQF4zU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717441028; c=relaxed/simple; bh=Ct9vywJmGK1CJloPL/bRZTZdgNRV/LmvFmSZ5WDVHwA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I1QVEA3xV6d4ItLKEVbinMA39FwKZd5Aa2emWls95Sj4YgiHXiWyEj7aRC7RNM8tLkaO9KBVa91J+d0R8VeKxecZHT2GJCNE9ubQTUQT2FlVEZQs/MCBHNPJ7Izp+qiu/mSBp2Poa8oNgAfHOVJ1PKQm9cCpg4TQ1BxZMTQpaBw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=VHhHqSZj; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717441026; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FIDPi7gUErWP223w2FklBtvKymIuybnwzHfEv4BqDmM=; b=VHhHqSZjUmA7mC9ymjWIrTwKPvSzJ8OIIeNchvoWVASNjKwnsV+nnlXImeYK+qgjltu5Bj 21wRvsJRYYHgrZmzj+e4NHvPhEJUqW1/U8FRMCogcutXZL0klMqANriAuGsEWCvaKqWm+p VTEg/kDz5VRGHfMow0jW31DmVDDTgTc= Received: from mx-prod-mc-03.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-530-_gplJciDNQavFqhIJSVcGw-1; Mon, 03 Jun 2024 14:56:59 -0400 X-MC-Unique: _gplJciDNQavFqhIJSVcGw-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 359E81913F40; Mon, 3 Jun 2024 18:56:58 +0000 (UTC) Received: from antares.redhat.com (unknown [10.39.193.112]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3A0AF190DB3B; Mon, 3 Jun 2024 18:56:52 +0000 (UTC) From: Adrian Moreno To: netdev@vger.kernel.org Cc: aconole@redhat.com, echaudro@redhat.com, horms@kernel.org, i.maximets@ovn.org, dev@openvswitch.org, Adrian Moreno , Yotam Gigi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 1/9] net: psample: add user cookie Date: Mon, 3 Jun 2024 20:56:35 +0200 Message-ID: <20240603185647.2310748-2-amorenoz@redhat.com> In-Reply-To: <20240603185647.2310748-1-amorenoz@redhat.com> References: <20240603185647.2310748-1-amorenoz@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Add a user cookie to the sample metadata so that sample emitters can provide more contextual information to samples. If present, send the user cookie in a new attribute: PSAMPLE_ATTR_USER_COOKIE. Signed-off-by: Adrian Moreno --- include/net/psample.h | 2 ++ include/uapi/linux/psample.h | 1 + net/psample/psample.c | 9 ++++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/net/psample.h b/include/net/psample.h index 0509d2d6be67..2ac71260a546 100644 --- a/include/net/psample.h +++ b/include/net/psample.h @@ -25,6 +25,8 @@ struct psample_metadata { out_tc_occ_valid:1, latency_valid:1, unused:5; + const u8 *user_cookie; + u32 user_cookie_len; }; struct psample_group *psample_group_get(struct net *net, u32 group_num); diff --git a/include/uapi/linux/psample.h b/include/uapi/linux/psample.h index e585db5bf2d2..e80637e1d97b 100644 --- a/include/uapi/linux/psample.h +++ b/include/uapi/linux/psample.h @@ -19,6 +19,7 @@ enum { PSAMPLE_ATTR_LATENCY, /* u64, nanoseconds */ PSAMPLE_ATTR_TIMESTAMP, /* u64, nanoseconds */ PSAMPLE_ATTR_PROTO, /* u16 */ + PSAMPLE_ATTR_USER_COOKIE, /* binary, user provided data */ __PSAMPLE_ATTR_MAX }; diff --git a/net/psample/psample.c b/net/psample/psample.c index a5d9b8446f77..b37488f426bc 100644 --- a/net/psample/psample.c +++ b/net/psample/psample.c @@ -386,7 +386,9 @@ void psample_sample_packet(struct psample_group *group, struct sk_buff *skb, nla_total_size(sizeof(u32)) + /* group_num */ nla_total_size(sizeof(u32)) + /* seq */ nla_total_size_64bit(sizeof(u64)) + /* timestamp */ - nla_total_size(sizeof(u16)); /* protocol */ + nla_total_size(sizeof(u16)) + /* protocol */ + (md->user_cookie_len ? + nla_total_size(md->user_cookie_len) : 0); /* user cookie */ #ifdef CONFIG_INET tun_info = skb_tunnel_info(skb); @@ -486,6 +488,11 @@ void psample_sample_packet(struct psample_group *group, struct sk_buff *skb, } #endif + if (md->user_cookie && md->user_cookie_len && + nla_put(nl_skb, PSAMPLE_ATTR_USER_COOKIE, md->user_cookie_len, + md->user_cookie)) + goto error; + genlmsg_end(nl_skb, data); genlmsg_multicast_netns(&psample_nl_family, group->net, nl_skb, 0, PSAMPLE_NL_MCGRP_SAMPLE, GFP_ATOMIC); -- 2.45.1