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:   Sat, 7 Mar 2020 07:59:48 +0100
From:   Jiri Pirko <jiri@...nulli.us>
To:     Jakub Kicinski <kuba@...nel.org>
Cc:     netdev@...r.kernel.org, davem@...emloft.net, saeedm@...lanox.com,
        leon@...nel.org, michael.chan@...adcom.com, vishal@...lsio.com,
        jeffrey.t.kirsher@...el.com, idosch@...lanox.com,
        aelior@...vell.com, peppe.cavallaro@...com,
        alexandre.torgue@...com, jhs@...atatu.com,
        xiyou.wangcong@...il.com, pablo@...filter.org,
        ecree@...arflare.com, mlxsw@...lanox.com
Subject: Re: [patch net-next v3 03/10] flow_offload: check for basic action
 hw stats type

Fri, Mar 06, 2020 at 08:28:51PM CET, kuba@...nel.org wrote:
>On Fri,  6 Mar 2020 14:28:49 +0100 Jiri Pirko wrote:
>> @@ -251,6 +252,66 @@ static inline bool flow_offload_has_one_action(const struct flow_action *action)
>>  	return action->num_entries == 1;
>>  }
>>  
>> +static inline bool
>> +flow_action_mixed_hw_stats_types_check(const struct flow_action *action,
>> +				       struct netlink_ext_ack *extack)
>> +{
>> +	const struct flow_action_entry *action_entry;
>> +	u8 uninitialized_var(last_hw_stats_type);
>
>Perhaps just initialize before the loop to action 0 and start loop 
>from 1?

Hmm, will check.


>
>> +	int i;
>> +
>> +	if (flow_offload_has_one_action(action))
>> +		return true;
>> +
>> +	for (i = 0; i < action->num_entries; i++) {
>> +		action_entry = &action->entries[0];
>
>s/0/i/ ?

Right, missed this.


>
>> +		if (i && action_entry->hw_stats_type != last_hw_stats_type) {
>> +			NL_SET_ERR_MSG_MOD(extack, "Mixing HW stats types for actions is not supported");
>> +			return false;
>> +		}
>> +		last_hw_stats_type = action_entry->hw_stats_type;
>> +	}
>> +	return true;
>> +}
>> +
>> +static inline const struct flow_action_entry *
>> +flow_action_first_entry_get(const struct flow_action *action)
>> +{
>> +	WARN_ON(!flow_action_has_entries(action));
>> +	return &action->entries[0];
>> +}
>> +
>> +static inline bool
>> +flow_action_hw_stats_types_check(const struct flow_action *action,
>> +				 struct netlink_ext_ack *extack,
>> +				 u8 allowed_hw_stats_type)
>> +{
>> +	const struct flow_action_entry *action_entry;
>> +
>> +	if (!flow_action_has_entries(action))
>> +		return true;
>> +	if (!flow_action_mixed_hw_stats_types_check(action, extack))
>> +		return false;
>> +	action_entry = flow_action_first_entry_get(action);
>> +	if (!allowed_hw_stats_type &&
>> +	    action_entry->hw_stats_type != FLOW_ACTION_HW_STATS_TYPE_ANY) {
>> +		NL_SET_ERR_MSG_MOD(extack, "Driver supports only default HW stats type \"any\"");
>> +		return false;
>> +	} else if (allowed_hw_stats_type &&
>> +		   action_entry->hw_stats_type != allowed_hw_stats_type) {
>
>Should this be an logical 'and' if we're doing it the bitfield way?

No. I driver passes allowed_hw_stats_type != 0, means that allowed_hw_stats_type
should be checked against action_entry->hw_stats_type.
With bitfield, this is a bit awkward, I didn't figure out to do it
better though.

>
>> +		NL_SET_ERR_MSG_MOD(extack, "Driver does not support selected HW stats type");
>> +		return false;
>> +	}
>> +	return true;
>> +}
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ