[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170831071823.GB1973@nanopsycho>
Date: Thu, 31 Aug 2017 09:18:23 +0200
From: Jiri Pirko <jiri@...nulli.us>
To: David Ahern <dsahern@...il.com>
Cc: netdev@...r.kernel.org, davem@...emloft.net, arkadis@...lanox.com,
idosch@...lanox.com, mlxsw@...lanox.com
Subject: Re: [patch net-next 6/8] mlxsw: spectrum_dpipe: Add support for IPv6
host table dump
Wed, Aug 30, 2017 at 07:42:36PM CEST, dsahern@...il.com wrote:
>On 8/30/17 6:03 AM, Jiri Pirko wrote:
>> diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c
>> index 5924e97..75da2ef 100644
>> --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c
>> +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c
>> @@ -386,8 +386,19 @@ mlxsw_sp_dpipe_table_host_match_action_prepare(struct devlink_dpipe_match *match
>>
>> match = &matches[MLXSW_SP_DPIPE_TABLE_HOST_MATCH_DIP];
>> match->type = DEVLINK_DPIPE_MATCH_TYPE_FIELD_EXACT;
>> - match->header = &devlink_dpipe_header_ipv4;
>> - match->field_id = DEVLINK_DPIPE_FIELD_IPV4_DST_IP;
>> + switch (type) {
>> + case AF_INET:
>> + match->header = &devlink_dpipe_header_ipv4;
>> + match->field_id = DEVLINK_DPIPE_FIELD_IPV4_DST_IP;
>> + break;
>> + case AF_INET6:
>> + match->header = &devlink_dpipe_header_ipv6;
>> + match->field_id = DEVLINK_DPIPE_FIELD_IPV6_DST_IP;
>> + break;
>> + default:
>> + WARN_ON(1);
>
>Here as well.
>
>> + return;
>> + }
>>
>> action->type = DEVLINK_DPIPE_ACTION_TYPE_FIELD_MODIFY;
>> action->header = &devlink_dpipe_header_ethernet;
>> @@ -424,7 +435,18 @@ mlxsw_sp_dpipe_table_host_entry_prepare(struct devlink_dpipe_entry *entry,
>> match_value = &match_values[MLXSW_SP_DPIPE_TABLE_HOST_MATCH_DIP];
>>
>> match_value->match = match;
>> - match_value->value_size = sizeof(u32);
>> + switch (type) {
>> + case AF_INET:
>> + match_value->value_size = sizeof(u32);
>> + break;
>> + case AF_INET6:
>> + match_value->value_size = sizeof(struct in6_addr);
>> + break;
>> + default:
>> + WARN_ON(1);
>
>And here. WARN_ON is overkill
Again, only in case of bug in kernel.
>
>> + return -EINVAL;
>> + }
>> +
>> match_value->value = kmalloc(match_value->value_size, GFP_KERNEL);
>> if (!match_value->value)
>> return -ENOMEM;
>
Powered by blists - more mailing lists