lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 7 Mar 2022 09:09:19 +0200
From:   Roi Dayan <roid@...dia.com>
To:     Baowen Zheng <baowen.zheng@...igine.com>,
        David Ahern <dsahern@...il.com>
Cc:     netdev@...r.kernel.org, oss-drivers@...igine.com, jhs@...atatu.com,
        Victor Nogueira <victor@...atatu.com>,
        Simon Horman <simon.horman@...igine.com>
Subject: Re: [PATCH iproute2-next v1] tc: separate action print for filter and
 action dump



On 2022-03-04 4:01 AM, Baowen Zheng wrote:
> We need to separate action print for filter and action dump since
> in action dump, we need to print hardware status and flags. But in
> filter dump, we do not need to print action hardware status and
> hardware related flags.
> 
> In filter dump, actions hardware status should be same with filter.
> so we will not print action hardware status in this case.
> 
> Action print for action dump:
>    action order 0:  police 0xff000100 rate 0bit burst 0b mtu 64Kb pkts_rate 50000 pkts_burst 10000 action drop/pipe overhead 0b linklayer unspec
>    ref 4 bind 3  installed 666 sec used 0 sec firstused 106 sec
>    Action statistics:
>    Sent 7634140154 bytes 5109889 pkt (dropped 0, overlimits 0 requeues 0)
>    Sent software 84 bytes 3 pkt
>    Sent hardware 7634140070 bytes 5109886 pkt
>    backlog 0b 0p requeues 0
>    in_hw in_hw_count 1
>    used_hw_stats delayed
> 
> Action print for filter dump:
>    action order 1:  police 0xff000100 rate 0bit burst 0b mtu 64Kb pkts_rate 50000 pkts_burst 10000 action drop/pipe overhead 0b linklayer unspec
>    ref 4 bind 3  installed 680 sec used 0 sec firstused 119 sec
>    Action statistics:
>    Sent 8627975846 bytes 5775107 pkt (dropped 0, overlimits 0 requeues 0)
>    Sent software 84 bytes 3 pkt
>    Sent hardware 8627975762 bytes 5775104 pkt
>    backlog 0b 0p requeues 0
>    used_hw_stats delayed
> 
> Signed-off-by: Baowen Zheng <baowen.zheng@...igine.com>
> Signed-off-by: Simon Horman <simon.horman@...igine.com>
> ---
>   tc/m_action.c | 53 ++++++++++++++++++++++++++++++++++++-----------------
>   1 file changed, 36 insertions(+), 17 deletions(-)
> 
> diff --git a/tc/m_action.c b/tc/m_action.c
> index 1dd5425..b3fd019 100644
> --- a/tc/m_action.c
> +++ b/tc/m_action.c
> @@ -364,7 +364,7 @@ bad_val:
>   	return -1;
>   }
>   
> -static int tc_print_one_action(FILE *f, struct rtattr *arg)
> +static int tc_print_one_action(FILE *f, struct rtattr *arg, bool bind)
>   {
>   
>   	struct rtattr *tb[TCA_ACT_MAX + 1];
> @@ -415,26 +415,37 @@ static int tc_print_one_action(FILE *f, struct rtattr *arg)
>   	}
>   	if (tb[TCA_ACT_FLAGS] || tb[TCA_ACT_IN_HW_COUNT]) {
>   		bool skip_hw = false;
> +		bool newline = false;
> +
>   		if (tb[TCA_ACT_FLAGS]) {
>   			struct nla_bitfield32 *flags = RTA_DATA(tb[TCA_ACT_FLAGS]);
>   
> -			if (flags->selector & TCA_ACT_FLAGS_NO_PERCPU_STATS)
> +			if (flags->selector & TCA_ACT_FLAGS_NO_PERCPU_STATS) {
> +				newline = true;
>   				print_bool(PRINT_ANY, "no_percpu", "\tno_percpu",
>   					   flags->value &
>   					   TCA_ACT_FLAGS_NO_PERCPU_STATS);
> -			if (flags->selector & TCA_ACT_FLAGS_SKIP_HW) {
> -				print_bool(PRINT_ANY, "skip_hw", "\tskip_hw",
> -					   flags->value &
> -					   TCA_ACT_FLAGS_SKIP_HW);
> -				skip_hw = !!(flags->value & TCA_ACT_FLAGS_SKIP_HW);
>   			}
> -			if (flags->selector & TCA_ACT_FLAGS_SKIP_SW)
> -				print_bool(PRINT_ANY, "skip_sw", "\tskip_sw",
> -					   flags->value &
> -					   TCA_ACT_FLAGS_SKIP_SW);
> +			if (!bind) {
> +				if (flags->selector & TCA_ACT_FLAGS_SKIP_HW) {
> +					newline = true;
> +					print_bool(PRINT_ANY, "skip_hw", "\tskip_hw",
> +						   flags->value &
> +						   TCA_ACT_FLAGS_SKIP_HW);
> +					skip_hw = !!(flags->value & TCA_ACT_FLAGS_SKIP_HW);
> +				}
> +				if (flags->selector & TCA_ACT_FLAGS_SKIP_SW) {
> +					newline = true;
> +					print_bool(PRINT_ANY, "skip_sw", "\tskip_sw",
> +						   flags->value &
> +						   TCA_ACT_FLAGS_SKIP_SW);
> +				}
> +			}
>   		}
> -		if (tb[TCA_ACT_IN_HW_COUNT] && !skip_hw) {
> +		if (tb[TCA_ACT_IN_HW_COUNT] && !bind && !skip_hw) {
>   			__u32 count = rta_getattr_u32(tb[TCA_ACT_IN_HW_COUNT]);
> +
> +			newline = true;
>   			if (count) {
>   				print_bool(PRINT_ANY, "in_hw", "\tin_hw",
>   					   true);
> @@ -446,7 +457,8 @@ static int tc_print_one_action(FILE *f, struct rtattr *arg)
>   			}
>   		}
>   
> -		print_nl();
> +		if (newline)
> +			print_nl();
>   	}
>   	if (tb[TCA_ACT_HW_STATS])
>   		print_hw_stats(tb[TCA_ACT_HW_STATS], false);
> @@ -483,8 +495,9 @@ tc_print_action_flush(FILE *f, const struct rtattr *arg)
>   	return 0;
>   }
>   
> -int
> -tc_print_action(FILE *f, const struct rtattr *arg, unsigned short tot_acts)
> +static int
> +tc_dump_action(FILE *f, const struct rtattr *arg, unsigned short tot_acts,
> +	       bool bind)
>   {
>   
>   	int i;
> @@ -509,7 +522,7 @@ tc_print_action(FILE *f, const struct rtattr *arg, unsigned short tot_acts)
>   			print_nl();
>   			print_uint(PRINT_ANY, "order",
>   				   "\taction order %u: ", i);
> -			if (tc_print_one_action(f, tb[i]) < 0)
> +			if (tc_print_one_action(f, tb[i], bind) < 0)
>   				fprintf(stderr, "Error printing action\n");
>   			close_json_object();
>   		}
> @@ -520,6 +533,12 @@ tc_print_action(FILE *f, const struct rtattr *arg, unsigned short tot_acts)
>   	return 0;
>   }
>   
> +int
> +tc_print_action(FILE *f, const struct rtattr *arg, unsigned short tot_acts)
> +{
> +	return tc_dump_action(f, arg, tot_acts, true);
> +}
> +
>   int print_action(struct nlmsghdr *n, void *arg)
>   {
>   	FILE *fp = (FILE *)arg;
> @@ -570,7 +589,7 @@ int print_action(struct nlmsghdr *n, void *arg)
>   	}
>   
>   	open_json_object(NULL);
> -	tc_print_action(fp, tb[TCA_ACT_TAB], tot_acts ? *tot_acts:0);
> +	tc_dump_action(fp, tb[TCA_ACT_TAB], tot_acts ? *tot_acts:0, false);
>   	close_json_object();
>   
>   	return 0;

thanks

Reviewed-by: Roi Dayan <roid@...dia.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ