From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mail.toke.dk (Postfix) with ESMTPS id 6432D982CF2 for ; Tue, 28 Jun 2022 21:49:32 +0200 (CEST) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=WoS096yJ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656445772; x=1687981772; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sU25U5z5Fc524fPGWGwlzdwktQUtdwxy/KN7ZKjuDgg=; b=WoS096yJ5/i8VY3l7/SvwLhqC+Neu7gAVis+No5SQzrC7xj4Teoww4SJ HD2Ssglm8ntMrCwFH5s5PrpR9WyMw1OIJEtWk+G5gbmqF06auZx7sKzN6 U8AE6U9/LJ6xIJR2RDyym4mdKOH8iHN91e3ag3aN9+Sy4WXGPiRu1WvFo uV90u8sZWElkhXHbmsQZMJ6iVxAODJ3XRijGJsW8ZHjHEpvIsy3Jyp2hW kA0M8t2CN9RXZdDdu6QNDHUqMpGytnhBWDYceCoO5+ISSYokqHfDF7n/Z l3ZFxJied0sojdKDCEVu7TJMktcvZS0ytCQy5qSZJClkX1ifv+dYEBJsp g==; X-IronPort-AV: E=McAfee;i="6400,9594,10392"; a="270595761" X-IronPort-AV: E=Sophos;i="5.92,229,1650956400"; d="scan'208";a="270595761" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2022 12:49:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,229,1650956400"; d="scan'208";a="590426284" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by orsmga002.jf.intel.com with ESMTP; 28 Jun 2022 12:49:03 -0700 Received: from newjersey.igk.intel.com (newjersey.igk.intel.com [10.102.20.203]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 25SJmr96022013; Tue, 28 Jun 2022 20:49:02 +0100 From: Alexander Lobakin To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Date: Tue, 28 Jun 2022 21:47:26 +0200 Message-Id: <20220628194812.1453059-7-alexandr.lobakin@intel.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220628194812.1453059-1-alexandr.lobakin@intel.com> References: <20220628194812.1453059-1-alexandr.lobakin@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: FG5M6IMP3TUMAZCJP4MHY27JY27DBTFI X-Message-ID-Hash: FG5M6IMP3TUMAZCJP4MHY27JY27DBTFI X-MailFrom: alexandr.lobakin@intel.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: Alexander Lobakin , Larysa Zaremba , Michal Swiatkowski , Jesper Dangaard Brouer , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , Toke Hoiland-Jorgensen , Lorenzo Bianconi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jesse Brandeburg , John Fastabend , Yajun Deng , Willem de Bruijn , bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, xdp-hints@xdp-project.net X-Mailman-Version: 3.3.5 Precedence: list Subject: [xdp-hints] [PATCH RFC bpf-next 06/52] bpf: pass a pointer to union bpf_attr to bpf_link_ops::update_prog() List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: In order to be able to use any arbitrary data from bpf_attr::link_update inside the bpf_link_ops::update_prog() implementations, pass a pointer to the whole attr as a callback argument. @new_prog and @old_prog arguments are still here as ::link_update contains only their FDs. Signed-off-by: Alexander Lobakin --- include/linux/bpf.h | 3 ++- kernel/bpf/bpf_iter.c | 1 + kernel/bpf/cgroup.c | 4 +++- kernel/bpf/net_namespace.c | 1 + kernel/bpf/syscall.c | 2 +- net/bpf/dev.c | 4 +++- 6 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index d05e1495a06e..c08690a49011 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -1155,7 +1155,8 @@ struct bpf_link_ops { void (*release)(struct bpf_link *link); void (*dealloc)(struct bpf_link *link); int (*detach)(struct bpf_link *link); - int (*update_prog)(struct bpf_link *link, struct bpf_prog *new_prog, + int (*update_prog)(struct bpf_link *link, const union bpf_attr *attr, + struct bpf_prog *new_prog, struct bpf_prog *old_prog); void (*show_fdinfo)(const struct bpf_link *link, struct seq_file *seq); int (*fill_link_info)(const struct bpf_link *link, diff --git a/kernel/bpf/bpf_iter.c b/kernel/bpf/bpf_iter.c index 7e8fd49406f6..1d3dcc853f70 100644 --- a/kernel/bpf/bpf_iter.c +++ b/kernel/bpf/bpf_iter.c @@ -400,6 +400,7 @@ static void bpf_iter_link_dealloc(struct bpf_link *link) } static int bpf_iter_link_replace(struct bpf_link *link, + const union bpf_attr *attr, struct bpf_prog *new_prog, struct bpf_prog *old_prog) { diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c index 7a394f7c205c..f4d8100dd22f 100644 --- a/kernel/bpf/cgroup.c +++ b/kernel/bpf/cgroup.c @@ -664,7 +664,9 @@ static int __cgroup_bpf_replace(struct cgroup *cgrp, return 0; } -static int cgroup_bpf_replace(struct bpf_link *link, struct bpf_prog *new_prog, +static int cgroup_bpf_replace(struct bpf_link *link, + const union bpf_attr *attr, + struct bpf_prog *new_prog, struct bpf_prog *old_prog) { struct bpf_cgroup_link *cg_link; diff --git a/kernel/bpf/net_namespace.c b/kernel/bpf/net_namespace.c index 868cc2c43899..5d80a4a9d0bd 100644 --- a/kernel/bpf/net_namespace.c +++ b/kernel/bpf/net_namespace.c @@ -162,6 +162,7 @@ static void bpf_netns_link_dealloc(struct bpf_link *link) } static int bpf_netns_link_update_prog(struct bpf_link *link, + const union bpf_attr *attr, struct bpf_prog *new_prog, struct bpf_prog *old_prog) { diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 7d5af5b99f0d..f7a674656067 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -4614,7 +4614,7 @@ static int link_update(union bpf_attr *attr) } if (link->ops->update_prog) - ret = link->ops->update_prog(link, new_prog, old_prog); + ret = link->ops->update_prog(link, attr, new_prog, old_prog); else ret = -EINVAL; diff --git a/net/bpf/dev.c b/net/bpf/dev.c index dfe0402947f8..68a7b2c49392 100644 --- a/net/bpf/dev.c +++ b/net/bpf/dev.c @@ -619,7 +619,9 @@ static int bpf_xdp_link_fill_link_info(const struct bpf_link *link, return 0; } -static int bpf_xdp_link_update(struct bpf_link *link, struct bpf_prog *new_prog, +static int bpf_xdp_link_update(struct bpf_link *link, + const union bpf_attr *attr, + struct bpf_prog *new_prog, struct bpf_prog *old_prog) { struct bpf_xdp_link *xdp_link = container_of(link, struct bpf_xdp_link, link); -- 2.36.1