Page MenuHomeFreeBSD

D53867.id166927.diff
No OneTemporary

D53867.id166927.diff

diff --git a/sys/net/bpf.h b/sys/net/bpf.h
--- a/sys/net/bpf.h
+++ b/sys/net/bpf.h
@@ -410,11 +410,6 @@
struct bpf_if;
CK_LIST_HEAD(bpfd_list, bpf_d);
-struct bpf_if_ext {
- CK_LIST_ENTRY(bpf_if) bif_next; /* list of all interfaces */
- struct bpfd_list bif_dlist; /* descriptor list */
-};
-
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);
@@ -435,12 +430,12 @@
u_int bpf_filter(const struct bpf_insn *, u_char *, u_int, u_int);
static __inline bool
-bpf_peers_present(struct bpf_if *bpf)
+bpf_peers_present(const struct bpf_if *bpf)
{
- struct bpf_if_ext *ext;
+ const struct bpfd_list *dlist;
- ext = (struct bpf_if_ext *)bpf;
- return (!CK_LIST_EMPTY(&ext->bif_dlist));
+ dlist = (const struct bpfd_list *)bpf;
+ return (!CK_LIST_EMPTY(dlist));
}
#define BPF_TAP(_ifp, _pkt, _pktlen) \
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -98,14 +98,11 @@
MALLOC_DEFINE(M_BPF, "BPF", "BPF data");
-static const struct bpf_if_ext dead_bpf_if = {
- .bif_dlist = CK_LIST_HEAD_INITIALIZER()
-};
+static const struct bpfd_list dead_bpf_if = CK_LIST_HEAD_INITIALIZER();
struct bpf_if {
-#define bif_next bif_ext.bif_next
-#define bif_dlist bif_ext.bif_dlist
- struct bpf_if_ext bif_ext; /* public members */
+ struct bpfd_list bif_dlist; /* list of all interfaces */
+ CK_LIST_ENTRY(bpf_if) bif_next; /* descriptor list */
u_int bif_dlt; /* link layer type */
u_int bif_hdrlen; /* length of link header */
struct bpfd_list bif_wlist; /* writer-only list */
@@ -115,7 +112,9 @@
struct epoch_context epoch_ctx;
};
-CTASSERT(offsetof(struct bpf_if, bif_ext) == 0);
+/* See bpf_peers_present() in bpf.h. */
+_Static_assert(offsetof(struct bpf_if, bif_dlist) == 0,
+ "bpf_if shall start with bif_dlist");
struct bpf_program_buffer {
struct epoch_context epoch_ctx;

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 23, 12:57 AM (7 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25992627
Default Alt Text
D53867.id166927.diff (1 KB)

Event Timeline