Linux Documentation
 help / color / mirror / Atom feed
From: "Björn Töpel" <bjorn@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemb@google.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	Nikolay Aleksandrov <razor@blackwall.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Magnus Karlsson <magnus.karlsson@intel.com>,
	Maciej Fijalkowski <maciej.fijalkowski@intel.com>,
	Donald Hunter <donald.hunter@gmail.com>,
	Alexander Duyck <alexanderduyck@fb.com>,
	Saeed Mahameed <saeedm@nvidia.com>,
	Tariq Toukan <tariqt@nvidia.com>, Mark Bloch <mbloch@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>, Shuah Khan <shuah@kernel.org>,
	Jonathan Corbet <corbet@lwn.net>,
	netdev@vger.kernel.org, bpf@vger.kernel.org
Cc: "Björn Töpel" <bjorn@kernel.org>,
	"Simon Horman" <horms@kernel.org>,
	"Stanislav Fomichev" <sdf@fomichev.me>,
	"Martin KaFai Lau" <martin.lau@linux.dev>,
	"Song Liu" <song@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>,
	"Jiri Olsa" <jolsa@kernel.org>,
	"Emil Tsalapatis" <emil@etsalapatis.com>,
	"Ihor Solodrai" <ihor.solodrai@linux.dev>,
	"David Wei" <dw@davidwei.uk>, "Tao Cui" <cuitao@kylinos.cn>,
	linux-kernel@vger.kernel.org, kernel-team@meta.com,
	"Mike Marciniszyn (Meta)" <mike.marciniszyn@gmail.com>,
	linux-rdma@vger.kernel.org, linux-kselftest@vger.kernel.org,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	"Randy Dunlap" <rdunlap@infradead.org>,
	linux-doc@vger.kernel.org
Subject: [PATCH net-next v2 04/15] xdp: Run programs on XDP-only buffers
Date: Fri,  4 Dec 2026 17:27:09 +0100	[thread overview]
Message-ID: <20261204162723.755897-5-bjorn@kernel.org> (raw)
In-Reply-To: <20261204162723.755897-1-bjorn@kernel.org>

The AF_XDP provider needs native XDP to steer packets and for the RX
metadata kfuncs. XDP reads its UMEM chunks through the kernel mapping,
but userspace may write them at any time. Currently, multi-buffer
shared info, XDP_TX and redirect frames, and XDP_PASS skbs live in the
buffer.

Run programs on such XDP-only buffers, but keep kernel structures out
of them.

The core tells an XDP-only head by its address, with one range check
under a static key, so other buffers pay nothing while no provider is
bound. Such a buffer keeps its shared info in the provider.
Registering such a page pool without its RX queue fails with
-EOPNOTSUPP.

The core turns XDP_TX and XDP_PASS of these buffers into XDP_DROP, so
drivers need no checks. Frame and skb construction refuse these
buffers, so devmap and cpumap drop them.

The kernel takes bounds only from its own fields, and a helper that
reads bytes twice must check a copy.

Signed-off-by: Björn Töpel <bjorn@kernel.org>
---

Notes (v2changes):
    Changes in v2:
    - Rename from "xdp: Run programs on buffers that must not hold kernel
      structures".
    - Keep the shared info of XDP-only buffers in the provider, with the
      queue only pointing to it. In v1 the queue owned it, which breaks
      for drivers that copy their queue info.
    - Take the frame and skb refusals of v1 patch 2. The rest of that
      patch went to net as a series of its own, which covers classic zero
      copy too (Maciej). The frame and skb paths of classic zero copy stay
      as they are.
    - XDP_PASS and XDP_TX stay drops in this posting. A follow-up adds
      them as copies (Maciej).
    - Call the buffers XDP-only rather than sink buffers, also in the
      names of their flag, test and static key.

 include/net/netmem.h          |  9 ++++-
 include/net/page_pool/types.h |  7 ++--
 include/net/xdp.h             | 70 ++++++++++++++++++++++++++++++++++-
 net/core/xdp.c                | 55 +++++++++++++++++++++++++++
 4 files changed, 135 insertions(+), 6 deletions(-)

diff --git a/include/net/netmem.h b/include/net/netmem.h
index 5d3ec8554fb0..9a3994fb12ab 100644
--- a/include/net/netmem.h
+++ b/include/net/netmem.h
@@ -68,6 +68,7 @@ DECLARE_STATIC_KEY_FALSE(page_pool_mem_providers);
 enum net_iov_type {
 	NET_IOV_DMABUF,
 	NET_IOV_IOURING,
+	NET_IOV_XSK,
 };
 
 /* A memory descriptor representing abstract networking I/O vectors.
@@ -81,7 +82,9 @@ enum net_iov_type {
  * CPU-readable or unreadable. New code must not assume net_iov implies
  * unreadable memory (check readability via netmem_address() or
  * skb_frags_readable() instead) and should, as much as possible, generalize
- * existing limitations to match the design principles.
+ * existing limitations to match the design principles. AF_XDP memory provider
+ * net_iovs (%NET_IOV_XSK) are unreadable for the core and the stack as well:
+ * only XDP reads them, through their XDP view (&net_iov_area.xdp_vaddr).
  *
  * @pp_magic:	pp field, similar to the one in struct page/struct
  *		netmem_desc.
@@ -115,6 +118,10 @@ struct net_iov_area {
 	void *xdp_vaddr;
 	size_t xdp_vsize;
 	unsigned int xdp_shift;
+	/* Shared info of the XDP buffers of an MP_XDP_ONLY provider, in its
+	 * kernel memory, see %XDP_FLAGS_SINFO_EXT
+	 */
+	struct skb_shared_info *xdp_sinfo;
 };
 
 static inline struct net_iov_area *net_iov_owner(const struct net_iov *niov)
diff --git a/include/net/page_pool/types.h b/include/net/page_pool/types.h
index c9b9b738e8ba..4172e9aee28f 100644
--- a/include/net/page_pool/types.h
+++ b/include/net/page_pool/types.h
@@ -33,9 +33,10 @@
 
 /*
  * Allow an XDP-only memory provider of the queue (%MP_XDP_ONLY) to back the
- * pool. The driver registers the pool as the memory model of the RX queue,
- * sets up XDP buffers with xdp_prepare_buff() at xdp_netmem_address() of
- * their head, and puts heads back by netmem, not by address.
+ * pool. The driver registers the pool as the memory model of the RX queue
+ * with xdp_rxq_info_reg_mem_model(), sets up XDP buffers with
+ * xdp_prepare_buff() at xdp_netmem_address() of their head, and puts heads
+ * back by netmem, not by address.
  *
  * Such a provider takes no lock, so the driver also lets one context at a
  * time use the buffers of the queue: its NAPI, or an operation that runs
diff --git a/include/net/xdp.h b/include/net/xdp.h
index da4bb98fceeb..077d4b4b2614 100644
--- a/include/net/xdp.h
+++ b/include/net/xdp.h
@@ -65,8 +65,13 @@ struct xdp_rxq_info {
 	u32 reg_state;
 	struct xdp_mem_info mem;
 	u32 frag_size;
+	/* Area of the MP_XDP_ONLY provider of the page pool, see
+	 * xdp_mark_xdp_only()
+	 */
+	struct net_iov_area *xdp_only_area;
 	/* Shared info of buffers with %XDP_FLAGS_SINFO_EXT, in the XSk buffer
-	 * pool, set by xsk_pool_set_rxq_info().
+	 * pool, set by xsk_pool_set_rxq_info(), or where an XDP-only memory
+	 * provider keeps it, set by xdp_rxq_info_reg_mem_model()
 	 */
 	struct skb_shared_info *ext_sinfo;
 } ____cacheline_aligned; /* perf critical, avoid false-sharing */
@@ -93,6 +98,15 @@ enum xdp_buff_flags {
 	 * must copy what it needs.
 	 */
 	XDP_FLAGS_SINFO_EXT		= BIT(3),
+	/* XDP-only memory, see %MP_XDP_ONLY: the buffer may only go to the
+	 * AF_XDP socket of its queue. Userspace may write it at any time,
+	 * also while the kernel reads it. So the kernel takes bounds only
+	 * from its own fields, and only the XDP program and its helpers read
+	 * the bytes. A helper that checks bytes and reads them again later
+	 * must check a copy. Nothing builds a frame or an skb in the
+	 * buffer.
+	 */
+	XDP_FLAGS_MP_XDP_ONLY		= BIT(4),
 };
 
 struct xdp_buff {
@@ -148,6 +162,14 @@ static __always_inline void xdp_buff_set_frag_unreadable(struct xdp_buff *xdp)
 	xdp->flags |= XDP_FLAGS_FRAGS_UNREADABLE;
 }
 
+static __always_inline bool xdp_buff_is_xdp_only(const struct xdp_buff *xdp)
+{
+	return !!(xdp->flags & XDP_FLAGS_MP_XDP_ONLY);
+}
+
+/* Enabled while an AF_XDP socket receives with explicit return */
+DECLARE_STATIC_KEY_FALSE(xdp_only_mp_key);
+
 static __always_inline u32 xdp_buff_get_skb_flags(const struct xdp_buff *xdp)
 {
 	return xdp->flags;
@@ -176,6 +198,26 @@ xdp_init_buff(struct xdp_buff *xdp, u32 frame_sz, struct xdp_rxq_info *rxq)
 #endif
 }
 
+/* Drivers take the address of a head buffer with xdp_netmem_address(),
+ * which for an AF_XDP memory provider lies in its XDP view, the UMEM, see
+ * &net_iov_area.xdp_vaddr. Mark such buffers before the driver adds
+ * fragments: their shared info lives in the queue, and they may only go to
+ * the AF_XDP socket of the queue.
+ */
+static __always_inline void xdp_mark_xdp_only(struct xdp_buff *xdp)
+{
+	struct net_iov_area *area = xdp->rxq->xdp_only_area;
+	unsigned long off;
+
+	off = (u8 *)xdp->data_hard_start - (u8 *)area->xdp_vaddr;
+	/* A byte-wide update would leave the next load of the flags two
+	 * stores to merge, which x86 cannot forward
+	 */
+	if (off < area->xdp_vsize)
+		WRITE_ONCE(xdp->flags, xdp->flags | XDP_FLAGS_MP_XDP_ONLY |
+				       XDP_FLAGS_SINFO_EXT);
+}
+
 /* XDP view of net_iovs: a memory provider may give XDP an address for its
  * net_iovs, see &net_iov_area.xdp_vaddr. XDP code may read and write a
  * net_iov only through these helpers, and only if its provider offers a
@@ -216,6 +258,9 @@ static __always_inline void *xdp_frag_address(const skb_frag_t *frag)
 	return addr ? addr + skb_frag_off(frag) : NULL;
 }
 
+/* Marks XDP-only buffers in @xdp->flags too: call it after
+ * xdp_init_buff(), which clears the flags
+ */
 static __always_inline void
 xdp_prepare_buff(struct xdp_buff *xdp, unsigned char *hard_start,
 		 int headroom, int data_len, const bool meta_valid)
@@ -226,6 +271,10 @@ xdp_prepare_buff(struct xdp_buff *xdp, unsigned char *hard_start,
 	xdp->data = data;
 	xdp->data_end = data + data_len;
 	xdp->data_meta = meta_valid ? data : data + 1;
+
+	if (static_branch_unlikely(&xdp_only_mp_key) && xdp->rxq &&
+	    unlikely(xdp->rxq->xdp_only_area))
+		xdp_mark_xdp_only(xdp);
 }
 
 /* Reserve memory area at end-of data area.
@@ -351,8 +400,12 @@ static inline bool xdp_buff_add_frag(struct xdp_buff *xdp, netmem_ref netmem,
 
 	if (unlikely(netmem_is_pfmemalloc(netmem)))
 		xdp_buff_set_frag_pfmemalloc(xdp);
-	if (unlikely(netmem_is_net_iov(netmem)))
+	if (unlikely(netmem_is_net_iov(netmem))) {
 		xdp_buff_set_frag_unreadable(xdp);
+		/* XDP-only memory may only go to the socket of its queue */
+		if (netmem_to_net_iov(netmem)->type == NET_IOV_XSK)
+			xdp->flags |= XDP_FLAGS_MP_XDP_ONLY;
+	}
 
 	return true;
 }
@@ -481,6 +534,13 @@ int xdp_update_frame_from_buff(const struct xdp_buff *xdp,
 		return -ENOSPC;
 	}
 
+	/* XDP-only buffers go to their AF_XDP socket, or nowhere. They
+	 * exist only while the key is on.
+	 */
+	if (static_branch_unlikely(&xdp_only_mp_key) &&
+	    xdp_buff_is_xdp_only(xdp))
+		return -EFAULT;
+
 	xdp_frame->data = xdp->data;
 	xdp_frame->len  = xdp->data_end - xdp->data;
 	xdp_frame->headroom = headroom - sizeof(*xdp_frame);
@@ -761,6 +821,12 @@ static __always_inline u32 bpf_prog_run_xdp(const struct bpf_prog *prog,
 	 */
 	u32 act = __bpf_prog_run(prog, xdp, BPF_DISPATCHER_FUNC(xdp));
 
+	/* XDP-only buffers go to the AF_XDP socket of their queue only */
+	if (static_branch_unlikely(&xdp_only_mp_key) &&
+	    xdp_buff_is_xdp_only(xdp) &&
+	    (act == XDP_PASS || act == XDP_TX))
+		act = XDP_DROP;
+
 	if (static_branch_unlikely(&bpf_master_redirect_enabled_key)) {
 		if (act == XDP_TX && netif_is_bond_slave(xdp->rxq->dev))
 			act = xdp_master_redirect(xdp);
diff --git a/net/core/xdp.c b/net/core/xdp.c
index 33a6740b411f..56b32ef795a0 100644
--- a/net/core/xdp.c
+++ b/net/core/xdp.c
@@ -15,6 +15,7 @@
 #include <linux/rhashtable.h>
 #include <linux/bug.h>
 #include <net/page_pool/helpers.h>
+#include <net/page_pool/memory_provider.h>
 
 #include <net/hotdata.h>
 #include <net/netdev_lock.h>
@@ -142,6 +143,14 @@ void xdp_rxq_info_unreg_mem_model(struct xdp_rxq_info *xdp_rxq)
 	}
 
 	xdp_unreg_mem_model(&xdp_rxq->mem);
+	/* Both belong to the provider, which may go away now. The pool of a
+	 * classic zero-copy queue owns its shared info, so leave that
+	 * pointer to xp_set_rxq_info().
+	 */
+	if (xdp_rxq->xdp_only_area) {
+		xdp_rxq->xdp_only_area = NULL;
+		xdp_rxq->ext_sinfo = NULL;
+	}
 }
 EXPORT_SYMBOL_GPL(xdp_rxq_info_unreg_mem_model);
 
@@ -332,11 +341,23 @@ static struct xdp_mem_allocator *__xdp_reg_mem_model(struct xdp_mem_info *mem,
 	return ERR_PTR(errno);
 }
 
+/* The page pool has an MP_XDP_ONLY provider */
+static bool xdp_mem_is_xdp_only(enum xdp_mem_type type, void *allocator)
+{
+	struct page_pool *pp = allocator;
+
+	return type == MEM_TYPE_PAGE_POOL && pp && pp->mp_ops &&
+	       pp->mp_ops->flags & MP_XDP_ONLY;
+}
+
 int xdp_reg_mem_model(struct xdp_mem_info *mem,
 		      enum xdp_mem_type type, void *allocator)
 {
 	struct xdp_mem_allocator *xdp_alloc;
 
+	if (xdp_mem_is_xdp_only(type, allocator))
+		return -EOPNOTSUPP;
+
 	xdp_alloc = __xdp_reg_mem_model(mem, type, allocator);
 	if (IS_ERR(xdp_alloc))
 		return PTR_ERR(xdp_alloc);
@@ -344,16 +365,30 @@ int xdp_reg_mem_model(struct xdp_mem_info *mem,
 }
 EXPORT_SYMBOL_GPL(xdp_reg_mem_model);
 
+DEFINE_STATIC_KEY_FALSE(xdp_only_mp_key);
+EXPORT_SYMBOL_GPL(xdp_only_mp_key);
+
 int xdp_rxq_info_reg_mem_model(struct xdp_rxq_info *xdp_rxq,
 			       enum xdp_mem_type type, void *allocator)
 {
 	struct xdp_mem_allocator *xdp_alloc;
+	struct net_iov_area *area = NULL;
 
 	if (xdp_rxq->reg_state != REG_STATE_REGISTERED) {
 		WARN(1, "Missing register, driver bug");
 		return -EFAULT;
 	}
 
+	/* MP_XDP_ONLY providers put their net_iov_area first in mp_priv. As
+	 * userspace may write XDP-only buffers, the provider keeps their shared
+	 * info.
+	 */
+	if (xdp_mem_is_xdp_only(type, allocator)) {
+		area = ((struct page_pool *)allocator)->mp_priv;
+		if (WARN_ON_ONCE(!area->xdp_sinfo))
+			return -EINVAL;
+	}
+
 	xdp_alloc = __xdp_reg_mem_model(&xdp_rxq->mem, type, allocator);
 	if (IS_ERR(xdp_alloc))
 		return PTR_ERR(xdp_alloc);
@@ -361,6 +396,22 @@ int xdp_rxq_info_reg_mem_model(struct xdp_rxq_info *xdp_rxq,
 	if (type == MEM_TYPE_XSK_BUFF_POOL && allocator)
 		xsk_pool_set_rxq_info(allocator, xdp_rxq);
 
+	/* The queue only points to both, which live as long as the page
+	 * pool. Copies of the queue info need no care.
+	 */
+	xdp_rxq->xdp_only_area = area;
+	if (area) {
+		xdp_rxq->ext_sinfo = area->xdp_sinfo;
+		/* The driver publishes the queue to its buffers after this,
+		 * as mlx5 does when it starts the new channel, and a reader
+		 * of a buffer takes the queue with READ_ONCE(xdp->rxq), as
+		 * xdp_get_shared_info_from_buff() does: order the shared
+		 * info of the queue before the queue reaches a buffer, the
+		 * way xp_set_rxq_info() does for classic zero copy.
+		 */
+		smp_wmb();
+	}
+
 	if (trace_mem_connect_enabled() && xdp_alloc)
 		trace_mem_connect(xdp_alloc, xdp_rxq);
 	return 0;
@@ -638,6 +689,10 @@ struct sk_buff *xdp_build_skb_from_buff(const struct xdp_buff *xdp)
 	u32 nr_frags = 0;
 	int metalen;
 
+	/* XDP-only buffers go to their AF_XDP socket, or nowhere */
+	if (unlikely(xdp_buff_is_xdp_only(xdp)))
+		return NULL;
+
 	if (unlikely(xdp_buff_has_frags(xdp))) {
 		sinfo = xdp_get_shared_info_from_buff(xdp);
 		nr_frags = sinfo->nr_frags;
-- 
2.56.1


  parent reply	other threads:[~2026-12-04 16:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 16:27 [PATCH net-next v2 00/15] xsk: Return UMEM chunks explicitly Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 01/15] xdp: Let memory providers expose net_iovs to XDP Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 02/15] net: Add memory providers that only feed XDP Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 03/15] page_pool: Let memory providers take back net_iovs Björn Töpel
2026-12-04 16:27 ` Björn Töpel [this message]
2026-12-04 16:27 ` [PATCH net-next v2 05/15] xsk: Back a queue's page pools with UMEM chunks Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 06/15] xsk: Deliver packets and return chunks explicitly Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 07/15] xsk: Receive with explicit chunk return Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 08/15] xsk: Drop references of a run of buffers at once Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 09/15] eth: fbnic: Receive into XDP-only memory providers Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 10/15] net/mlx5e: Handle restarts with XDP-only providers Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 11/15] net/mlx5e: Receive into XDP-only memory providers Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 12/15] net/mlx5e: Release XDP-only pages earlier Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 13/15] net/mlx5e: Test for XDP-only pages per RQ Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 14/15] selftests: net: xsk: Test explicit chunk return Björn Töpel
2026-12-04 16:27 ` [PATCH net-next v2 15/15] Documentation: xsk: Describe " Björn Töpel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261204162723.755897-5-bjorn@kernel.org \
    --to=bjorn@kernel.org \
    --cc=alexanderduyck@fb.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=corbet@lwn.net \
    --cc=cuitao@kylinos.cn \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=dw@davidwei.uk \
    --cc=eddyz87@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=emil@etsalapatis.com \
    --cc=hawk@kernel.org \
    --cc=horms@kernel.org \
    --cc=ihor.solodrai@linux.dev \
    --cc=ilias.apalodimas@linaro.org \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=maciej.fijalkowski@intel.com \
    --cc=magnus.karlsson@intel.com \
    --cc=martin.lau@linux.dev \
    --cc=mbloch@nvidia.com \
    --cc=memxor@gmail.com \
    --cc=mike.marciniszyn@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=razor@blackwall.org \
    --cc=rdunlap@infradead.org \
    --cc=saeedm@nvidia.com \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=song@kernel.org \
    --cc=tariqt@nvidia.com \
    --cc=willemb@google.com \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox