Wed, Aug 30, 2017 at 07:42:36PM CEST, dsah...@gmail.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; >