Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7a69c0f2 authored by John Fastabend's avatar John Fastabend Committed by Daniel Borkmann
Browse files

bpf: skmsg, replace comments with BUILD bug



Enforce comment on structure layout dependency with a BUILD_BUG_ON
to ensure the condition is maintained.

Suggested-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent bc1b4f01
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -36,9 +36,7 @@ struct sk_msg_sg {
	struct scatterlist		data[MAX_MSG_FRAGS + 1];
};

/* UAPI in filter.c depends on struct sk_msg_sg being first element. If
 * this is moved filter.c also must be updated.
 */
/* UAPI in filter.c depends on struct sk_msg_sg being first element. */
struct sk_msg {
	struct sk_msg_sg		sg;
	void				*data;
+3 −0
Original line number Diff line number Diff line
@@ -7425,6 +7425,9 @@ static u32 sk_msg_convert_ctx_access(enum bpf_access_type type,
	int off;
#endif

	/* convert ctx uses the fact sg element is first in struct */
	BUILD_BUG_ON(offsetof(struct sk_msg, sg) != 0);

	switch (si->off) {
	case offsetof(struct sk_msg_md, data):
		*insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(struct sk_msg, data),