From nobody Sun Jun 21 06:27:52 2026 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F11638B7C1 for ; Mon, 6 Apr 2026 17:12:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775495574; cv=none; b=lhkFiYCKlzAB9xbRWP8fsDdTLkUSAHiNLQV4EbxeMPWz3eMiEycdjCBHpSucH+vUVVCRdrz9WX88OVu3Hek465SpOLHBa7AyYEEUEF1sGKp9LPSFPYaLh2iWmBMR83JK3Amygccq91+aLVg8/y/FfBG7nuPTqLyhjjR+pEaDUG0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775495574; c=relaxed/simple; bh=9vAAFXgRx1cmSWi6jUm2ZLeMtuWPDoC/eaQIz1joJFA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=sEEl5Gw90d0i3NKwUiq1NC2tnOHXwgtEvTgvxrE0w8Z08Hxbe3Peol9ctjpDqjsqMj4VWNXDkbnKeHX4BIW2gSvyCvzZ+1uvwG3VTgIIgfZfAvw3KF21AuqRTOfqCNvRGwIUnUUq40+dgy5sd844sgD2MuI91jm5HVFjH0l66rE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NJ9WEYTr; arc=none smtp.client-ip=209.85.215.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NJ9WEYTr" Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-c76b6abdb73so2942926a12.1 for ; Mon, 06 Apr 2026 10:12:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775495569; x=1776100369; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=OJLBPf/Bh0jBBKBg9VV473zQPK1on2i18HvqYVjSaQo=; b=NJ9WEYTrcnnGNNcrAXQYc6YG0YFvp3NObPzPtycNLHWdAGVr6FfonYmY9DqK9hXGTq 5q+TRo9BmuU+6EyEDYQjlg9sd8K/mpl1omLDl/oe03O/7dUYMfUMYb5eITVJ7/0d5wpp CfR6nUZ0+7MZ/71ZxH2iYCK5zu6hdI+Cr1QIYo5dJRCrb0f8WTZsnUUso0MwzG26daPc gvdIVWSsMZX8Q2rH3sTSLjcwV81yVguYjWqfdaRHeRJWr4hqmvxGFg8EXgCYok2tSPoM dQ71tbLM18TMn1X4/7648CI2qVGVmRhy+hkw/U4nYGtdzRlvvOmW5mlrbRVlqIuI0WoB jQ9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775495569; x=1776100369; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=OJLBPf/Bh0jBBKBg9VV473zQPK1on2i18HvqYVjSaQo=; b=cZnXJPUTRJi6KWD1fTF0R3eUjLe/Qc8zVhLHfPdLUgnvbc5ubdggK3+3j5J2BYZGxf Cm7QkXz1fsuyEmIpuI/EpxFs5RbSKjv+CxC3EdJsQC6EJRpTXNciR7TwHrk/shXRaGoU 29TIpoEMpBeeRjzW9WtTcXNRE3X0dkZyHKtOxWUbsbdI5MB+0CcOnGUGYDQkvmJkCp+p N4V4bNLH0G/6ZRnyhenWTwlZNXljGLH45hy3qawqJnar2zk0AdA2QN9sn2HJdaSslz14 ca9cTRajb8sGqV6y4bXFWd6mIy26x3b+0IepA6Ej38/sMr9lC1Wa3IDhX4vo/IXlLoiB 5l2A== X-Forwarded-Encrypted: i=1; AJvYcCXuzd6/GRBNXr2Exc3JMvPk6M/LKVMs3qybbjnGYmJbq/ciy7Hfzj11wkWTLo2Gapu53CDNHbKS/fypK/8=@vger.kernel.org X-Gm-Message-State: AOJu0Yw5SPsENRxJyUYI9U9KqFk87t9sjaj8VkR48+hT+S2MKPT4EewQ 1QLnF1UcU60TG3Uvzg03wHvH0xHemPjxOgAHfi24g2nYiu/lVEEcSAUm+hT7mKJu X-Gm-Gg: AeBDieuunfUUJ/MQetOVkotDjhwzhf0ZprZiXwnd0X6POND+GolSM/sbcdVxx5/apGu z4uYjOsInwg5fEqkiqJdHSY4rTkbiDoxPNrqwg2xmZum+DahZWX00Mrx2KWfwi5C+T2mksp2Az6 UCNSGBihBrwoL2PR4+mY/g8axaml2G0/I2sFoRDhzTEbuEPhUG0sewEXrt02PuyAN1Q22HtiOXS UnjixIWegcIfrFvGKyL9FxAgYqdPVuOKksC/suD9cj28WI5Vq+Zy9x4rrrprTBXpwIRwVvqedgg qAcKRbOnaI1oLT7PGSpF/b1mGzjYaZp/98dYJ5yf6eoFHaUjOe9+ttnSWSGlvrqZkNBs0jXWkh5 U9nejyHUkJmUInwlVZP9gJbHaWfiLbm3I0flSZUu2J9lKA173Ft3u30hbPCCEUsli+NRoULWyXD NRTGHpJHCe7BImwdvYy925kDlnA5xLu9O2Ngc= X-Received: by 2002:a05:6a20:3952:b0:39c:39d1:dbf4 with SMTP id adf61e73a8af0-39f2f0c86bemr12856117637.46.1775495568864; Mon, 06 Apr 2026 10:12:48 -0700 (PDT) Received: from C6-AF-E1-B8-1C-91 ([223.188.119.221]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c76c64a46ffsm13042113a12.13.2026.04.06.10.12.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2026 10:12:48 -0700 (PDT) From: Adith-Joshua To: bpf@vger.kernel.org Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, linux-kernel@vger.kernel.org, Adith-Joshua Subject: [PATCH] [RFC PATCH] bpf/xdp: propagate queue_index via xdp_frame for cpumap Date: Mon, 6 Apr 2026 22:42:26 +0530 Message-ID: <20260406171226.13325-1-adithalex29@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" cpu_map_bpf_prog_run_xdp() currently lacks queue_index information in xdp_rxq_info, as struct xdp_frame does not preserve it across the xdp_buff -> xdp_frame conversion. This results in loss of rx queue metadata when frames are redirected via cpumap and later processed by XDP programs. Propagate queue_index by storing it in struct xdp_frame during conversion and restoring it when reconstructing xdp_buff. All relevant xdp_frame constructors have been updated to ensure the field is co= nsistently initialized. This introduces a new field in struct xdp_frame, which may have implications for structure size and layout. Field reordering was considered to minimize padding, but is not included here to keep the change focused and avoid unrelated modifications. Feedback is appreciated on whether this approach is acceptable or if a different mechanism or struct layout would be preferred. Signed-off-by: Adith-Joshua --- include/net/xdp.h | 4 ++++ kernel/bpf/cpumap.c | 2 +- kernel/bpf/verifier.c | 12 ++++++++---- net/core/xdp.c | 1 + 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/include/net/xdp.h b/include/net/xdp.h index aa742f413c35..11aecf84a896 100644 --- a/include/net/xdp.h +++ b/include/net/xdp.h @@ -301,6 +301,7 @@ struct xdp_frame { */ enum xdp_mem_type mem_type:32; struct net_device *dev_rx; /* used by cpumap */ + u32 queue_index; u32 frame_sz; u32 flags; /* supported values defined in xdp_buff_flags */ }; @@ -347,6 +348,7 @@ static inline void xdp_scrub_frame(struct xdp_frame *fr= ame) { frame->data =3D NULL; frame->dev_rx =3D NULL; + frame->queue_index =3D 0; } =20 static inline void @@ -392,6 +394,7 @@ void xdp_convert_frame_to_buff(const struct xdp_frame *= frame, xdp->data =3D frame->data; xdp->data_end =3D frame->data + frame->len; xdp->data_meta =3D frame->data - frame->metasize; + xdp->rxq->queue_index =3D frame->queue_index; xdp->frame_sz =3D frame->frame_sz; xdp->flags =3D frame->flags; } @@ -419,6 +422,7 @@ int xdp_update_frame_from_buff(const struct xdp_buff *x= dp, xdp_frame->len =3D xdp->data_end - xdp->data; xdp_frame->headroom =3D headroom - sizeof(*xdp_frame); xdp_frame->metasize =3D metasize; + xdp_frame->queue_index =3D xdp->rxq->queue_index; xdp_frame->frame_sz =3D xdp->frame_sz; xdp_frame->flags =3D xdp->flags; =20 diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c index 32b43cb9061b..e475a732ceca 100644 --- a/kernel/bpf/cpumap.c +++ b/kernel/bpf/cpumap.c @@ -197,7 +197,7 @@ static int cpu_map_bpf_prog_run_xdp(struct bpf_cpu_map_= entry *rcpu, =20 rxq.dev =3D xdpf->dev_rx; rxq.mem.type =3D xdpf->mem_type; - /* TODO: report queue_index to xdp_rxq_info */ + rxq.queue_index =3D xdpf->queue_index; =20 xdp_convert_frame_to_buff(xdpf, &xdp); =20 diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index e3814152b52f..e2583dfd7bf2 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -18693,12 +18693,16 @@ static struct bpf_iarray *jt_from_subprog(struct = bpf_verifier_env *env, int i; =20 for (i =3D 0; i < env->insn_array_map_cnt; i++) { - /* - * TODO (when needed): collect only jump tables, not static keys - * or maps for indirect calls - */ map =3D env->insn_array_maps[i]; =20 + /* Only consider instruction array maps with multiple entries. + * These correspond to jump tables. Skip others (e.g. static keys, + * indirect call maps). + */ + if (map->map_type !=3D BPF_MAP_TYPE_INSN_ARRAY || + map->max_entries <=3D 1) + continue; + jt_cur =3D jt_from_map(map); if (IS_ERR(jt_cur)) { kvfree(jt); diff --git a/net/core/xdp.c b/net/core/xdp.c index 9890a30584ba..995f48e35310 100644 --- a/net/core/xdp.c +++ b/net/core/xdp.c @@ -604,6 +604,7 @@ struct xdp_frame *xdp_convert_zc_to_xdp_frame(struct xd= p_buff *xdp) xdpf->len =3D totsize - metasize; xdpf->headroom =3D 0; xdpf->metasize =3D metasize; + xdpf->queue_index =3D xdp->rxq->queue_index; xdpf->frame_sz =3D PAGE_SIZE; xdpf->mem_type =3D MEM_TYPE_PAGE_ORDER0; =20 --=20 2.53.0