Skip to content

Commit 89ffd14

Browse files
Manish Chopradavem330
authored andcommitted
qede: Validate unsupported configurations
Validate and prevent some of the configurations for unsupported [by firmware] inputs [for example - mac ext, vlans, masks/prefix, tos/tclass] via ethtool -N/-U. Signed-off-by: Manish Chopra <manish.chopra@cavium.com> Signed-off-by: Shahed Shaikh <shahed.shaikh@cavium.com> Signed-off-by: Ariel Elior <ariel.elior@cavium.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8788531 commit 89ffd14

1 file changed

Lines changed: 73 additions & 0 deletions

File tree

‎drivers/net/ethernet/qlogic/qede/qede_filter.c‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,10 +1560,63 @@ static void qede_flow_build_ipv6_hdr(struct qede_arfs_tuple *t,
15601560
ports[1] = t->dst_port;
15611561
}
15621562

1563+
/* Validate fields which are set and not accepted by the driver */
1564+
static int qede_flow_spec_validate_unused(struct qede_dev *edev,
1565+
struct ethtool_rx_flow_spec *fs)
1566+
{
1567+
if (fs->flow_type & FLOW_MAC_EXT) {
1568+
DP_INFO(edev, "Don't support MAC extensions\n");
1569+
return -EOPNOTSUPP;
1570+
}
1571+
1572+
if ((fs->flow_type & FLOW_EXT) &&
1573+
(fs->h_ext.vlan_etype || fs->h_ext.vlan_tci)) {
1574+
DP_INFO(edev, "Don't support vlan-based classification\n");
1575+
return -EOPNOTSUPP;
1576+
}
1577+
1578+
if ((fs->flow_type & FLOW_EXT) &&
1579+
(fs->h_ext.data[0] || fs->h_ext.data[1])) {
1580+
DP_INFO(edev, "Don't support user defined data\n");
1581+
return -EOPNOTSUPP;
1582+
}
1583+
1584+
return 0;
1585+
}
1586+
15631587
static int qede_flow_spec_to_tuple_ipv4_common(struct qede_dev *edev,
15641588
struct qede_arfs_tuple *t,
15651589
struct ethtool_rx_flow_spec *fs)
15661590
{
1591+
if ((fs->h_u.tcp_ip4_spec.ip4src &
1592+
fs->m_u.tcp_ip4_spec.ip4src) != fs->h_u.tcp_ip4_spec.ip4src) {
1593+
DP_INFO(edev, "Don't support IP-masks\n");
1594+
return -EOPNOTSUPP;
1595+
}
1596+
1597+
if ((fs->h_u.tcp_ip4_spec.ip4dst &
1598+
fs->m_u.tcp_ip4_spec.ip4dst) != fs->h_u.tcp_ip4_spec.ip4dst) {
1599+
DP_INFO(edev, "Don't support IP-masks\n");
1600+
return -EOPNOTSUPP;
1601+
}
1602+
1603+
if ((fs->h_u.tcp_ip4_spec.psrc &
1604+
fs->m_u.tcp_ip4_spec.psrc) != fs->h_u.tcp_ip4_spec.psrc) {
1605+
DP_INFO(edev, "Don't support port-masks\n");
1606+
return -EOPNOTSUPP;
1607+
}
1608+
1609+
if ((fs->h_u.tcp_ip4_spec.pdst &
1610+
fs->m_u.tcp_ip4_spec.pdst) != fs->h_u.tcp_ip4_spec.pdst) {
1611+
DP_INFO(edev, "Don't support port-masks\n");
1612+
return -EOPNOTSUPP;
1613+
}
1614+
1615+
if (fs->h_u.tcp_ip4_spec.tos) {
1616+
DP_INFO(edev, "Don't support tos\n");
1617+
return -EOPNOTSUPP;
1618+
}
1619+
15671620
t->eth_proto = htons(ETH_P_IP);
15681621
t->src_ipv4 = fs->h_u.tcp_ip4_spec.ip4src;
15691622
t->dst_ipv4 = fs->h_u.tcp_ip4_spec.ip4dst;
@@ -1619,6 +1672,23 @@ static int qede_flow_spec_to_tuple_ipv6_common(struct qede_dev *edev,
16191672
p = &zero_addr;
16201673
memset(p, 0, sizeof(zero_addr));
16211674

1675+
if ((fs->h_u.tcp_ip6_spec.psrc &
1676+
fs->m_u.tcp_ip6_spec.psrc) != fs->h_u.tcp_ip6_spec.psrc) {
1677+
DP_INFO(edev, "Don't support port-masks\n");
1678+
return -EOPNOTSUPP;
1679+
}
1680+
1681+
if ((fs->h_u.tcp_ip6_spec.pdst &
1682+
fs->m_u.tcp_ip6_spec.pdst) != fs->h_u.tcp_ip6_spec.pdst) {
1683+
DP_INFO(edev, "Don't support port-masks\n");
1684+
return -EOPNOTSUPP;
1685+
}
1686+
1687+
if (fs->h_u.tcp_ip6_spec.tclass) {
1688+
DP_INFO(edev, "Don't support tclass\n");
1689+
return -EOPNOTSUPP;
1690+
}
1691+
16221692
t->eth_proto = htons(ETH_P_IPV6);
16231693
memcpy(&t->src_ipv6, &fs->h_u.tcp_ip6_spec.ip6src,
16241694
sizeof(struct in6_addr));
@@ -1673,6 +1743,9 @@ static int qede_flow_spec_to_tuple(struct qede_dev *edev,
16731743
{
16741744
memset(t, 0, sizeof(*t));
16751745

1746+
if (qede_flow_spec_validate_unused(edev, fs))
1747+
return -EOPNOTSUPP;
1748+
16761749
switch ((fs->flow_type & ~FLOW_EXT)) {
16771750
case TCP_V4_FLOW:
16781751
return qede_flow_spec_to_tuple_tcpv4(edev, t, fs);

0 commit comments

Comments
 (0)