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

Commit b4fac96d authored by Jakub Kicinski's avatar Jakub Kicinski Committed by Daniel Borkmann
Browse files

tools: bpftool: remove new lines from errors



It's a little bit unusual for kernel style, but we add the new line
character to error strings inside the p_err() function.  We do this
because new lines at the end of error strings will break JSON output.

Fix a few p_err("..\n") which snuck in recently.

Fixes: 5ccda64d ("bpftool: implement cgroup bpf operations")
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarQuentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent 6ebe6dbd
Loading
Loading
Loading
Loading
+9 −9
Original line number Original line Diff line number Diff line
@@ -124,16 +124,16 @@ static int do_show(int argc, char **argv)
	int ret = -1;
	int ret = -1;


	if (argc < 1) {
	if (argc < 1) {
		p_err("too few parameters for cgroup show\n");
		p_err("too few parameters for cgroup show");
		goto exit;
		goto exit;
	} else if (argc > 1) {
	} else if (argc > 1) {
		p_err("too many parameters for cgroup show\n");
		p_err("too many parameters for cgroup show");
		goto exit;
		goto exit;
	}
	}


	cgroup_fd = open(argv[0], O_RDONLY);
	cgroup_fd = open(argv[0], O_RDONLY);
	if (cgroup_fd < 0) {
	if (cgroup_fd < 0) {
		p_err("can't open cgroup %s\n", argv[1]);
		p_err("can't open cgroup %s", argv[1]);
		goto exit;
		goto exit;
	}
	}


@@ -171,19 +171,19 @@ static int do_attach(int argc, char **argv)
	int i;
	int i;


	if (argc < 4) {
	if (argc < 4) {
		p_err("too few parameters for cgroup attach\n");
		p_err("too few parameters for cgroup attach");
		goto exit;
		goto exit;
	}
	}


	cgroup_fd = open(argv[0], O_RDONLY);
	cgroup_fd = open(argv[0], O_RDONLY);
	if (cgroup_fd < 0) {
	if (cgroup_fd < 0) {
		p_err("can't open cgroup %s\n", argv[1]);
		p_err("can't open cgroup %s", argv[1]);
		goto exit;
		goto exit;
	}
	}


	attach_type = parse_attach_type(argv[1]);
	attach_type = parse_attach_type(argv[1]);
	if (attach_type == __MAX_BPF_ATTACH_TYPE) {
	if (attach_type == __MAX_BPF_ATTACH_TYPE) {
		p_err("invalid attach type\n");
		p_err("invalid attach type");
		goto exit_cgroup;
		goto exit_cgroup;
	}
	}


@@ -199,7 +199,7 @@ static int do_attach(int argc, char **argv)
		} else if (is_prefix(argv[i], "override")) {
		} else if (is_prefix(argv[i], "override")) {
			attach_flags |= BPF_F_ALLOW_OVERRIDE;
			attach_flags |= BPF_F_ALLOW_OVERRIDE;
		} else {
		} else {
			p_err("unknown option: %s\n", argv[i]);
			p_err("unknown option: %s", argv[i]);
			goto exit_cgroup;
			goto exit_cgroup;
		}
		}
	}
	}
@@ -229,13 +229,13 @@ static int do_detach(int argc, char **argv)
	int ret = -1;
	int ret = -1;


	if (argc < 4) {
	if (argc < 4) {
		p_err("too few parameters for cgroup detach\n");
		p_err("too few parameters for cgroup detach");
		goto exit;
		goto exit;
	}
	}


	cgroup_fd = open(argv[0], O_RDONLY);
	cgroup_fd = open(argv[0], O_RDONLY);
	if (cgroup_fd < 0) {
	if (cgroup_fd < 0) {
		p_err("can't open cgroup %s\n", argv[1]);
		p_err("can't open cgroup %s", argv[1]);
		goto exit;
		goto exit;
	}
	}


+2 −2
Original line number Original line Diff line number Diff line
@@ -813,12 +813,12 @@ static int do_load(int argc, char **argv)
		usage();
		usage();


	if (bpf_prog_load(argv[0], BPF_PROG_TYPE_UNSPEC, &obj, &prog_fd)) {
	if (bpf_prog_load(argv[0], BPF_PROG_TYPE_UNSPEC, &obj, &prog_fd)) {
		p_err("failed to load program\n");
		p_err("failed to load program");
		return -1;
		return -1;
	}
	}


	if (do_pin_fd(prog_fd, argv[1])) {
	if (do_pin_fd(prog_fd, argv[1])) {
		p_err("failed to pin program\n");
		p_err("failed to pin program");
		return -1;
		return -1;
	}
	}