[PATCH 2/2] bpf: support new commands BPF_LINK_{CREATE,UPDATE}

Dmitry V. Levin ldv at altlinux.org
Mon Apr 13 22:35:42 UTC 2020


On Mon, Apr 13, 2020 at 11:28:21AM +0200, Paul Chaignon wrote:
[...]
> +BEGIN_BPF_CMD_DECODER(BPF_LINK_UPDATE)
> +{
> +	PRINT_FIELD_FD("{link_update={", attr, link_fd, tcp);
> +	PRINT_FIELD_FD(", ", attr, new_prog_fd, tcp);
> +	PRINT_FIELD_FLAGS(", ", attr, flags, bpf_attach_flags,
> +			  "BPF_F_???");
> +	PRINT_FIELD_FD(", ", attr, old_prog_fd, tcp);
> +	tprints("}");
> +}
> +END_BPF_CMD_DECODER(RVAL_DECODED)

include/uapi/linux/bpf.h claims that old_prog_fd is specified only if
BPF_F_REPLACE flag is set in flags, and kernel/bpf/syscall.c indeed
looks at old_prog_fd only if BPF_F_REPLACE is set.

Do you think it makes sense to mirror the kernel and print old_prog_fd
only if BPF_F_REPLACE is set in flags?


-- 
ldv


More information about the Strace-devel mailing list