git: a4d766caf711 - main - bpf: add a crutch to support if_vmove
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 18 Dec 2025 16:47:07 UTC
The branch main has been updated by glebius:
URL: https://cgit.FreeBSD.org/src/commit/?id=a4d766caf7114392b80793c8306d5a712f31557c
commit a4d766caf7114392b80793c8306d5a712f31557c
Author: Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2025-12-18 16:46:20 +0000
Commit: Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2025-12-18 16:46:20 +0000
bpf: add a crutch to support if_vmove
Fixes: 0bf42a0a05b9c802a6d9ca4a6b8696b29a26e08b
---
sys/net/bpf.c | 16 ++++++++++++++++
sys/net/bpf.h | 1 +
sys/net/if.c | 1 +
3 files changed, 18 insertions(+)
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 54da49f3d656..9f0b57728e88 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -2722,6 +2722,22 @@ bpf_detach(struct bpf_if *bp)
BPF_UNLOCK();
}
+#ifdef VIMAGE
+/*
+ * Move bpf to a different VNET. This KPI is a crutch to support if_vmove
+ * and is not supposed to be used anywhere else.
+ */
+void
+bpf_vmove(struct bpf_if *bp)
+{
+
+ BPF_LOCK();
+ LIST_REMOVE(bp, bif_next);
+ LIST_INSERT_HEAD(&V_bpf_iflist, bp, bif_next);
+ BPF_UNLOCK();
+}
+#endif
+
bool
bpf_peers_present_if(struct ifnet *ifp)
{
diff --git a/sys/net/bpf.h b/sys/net/bpf.h
index f6bcb0e34ed4..6d2ecd985225 100644
--- a/sys/net/bpf.h
+++ b/sys/net/bpf.h
@@ -425,6 +425,7 @@ CK_LIST_HEAD(bpfd_list, bpf_d);
struct bpf_if * bpf_attach(const char *, u_int, u_int,
const struct bif_methods *, void *);
void bpf_detach(struct bpf_if *);
+void bpf_vmove(struct bpf_if *bp);
void bpf_bufheld(struct bpf_d *d);
int bpf_validate(const struct bpf_insn *, int);
void bpf_tap(struct bpf_if *, u_char *, u_int);
diff --git a/sys/net/if.c b/sys/net/if.c
index f5006781541c..d7c6b22821e2 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1285,6 +1285,7 @@ if_vmove(struct ifnet *ifp, struct vnet *new_vnet)
*/
CURVNET_SET_QUIET(new_vnet);
if_attach_internal(ifp, true);
+ bpf_vmove(ifp->if_bpf);
CURVNET_RESTORE();
}