Commit 29b3705f authored by Rahul Lakkireddy's avatar Rahul Lakkireddy Committed by David S. Miller

cxgb4: fix extracting IP addresses in TC-FLOWER rules

commit c8729cac ("cxgb4: add ethtool n-tuple filter insertion")
has removed checking control key for determining IP address types
for TC-FLOWER rules, which causes all the rules being inserted to
hardware to become IPv6 rule type always. So, add back the check
to select the correct IP address type to extract and hence fix the
correct rule type being inserted to hardware.

Also, ethtool_rx_flow_key doesn't have any control key and instead
directly sets the IPv4/IPv6 address keys. So, explicitly set the
IP address type for ethtool n-tuple filters to reuse the same code.

Fixes: c8729cac ("cxgb4: add ethtool n-tuple filter insertion")
Signed-off-by: default avatarRahul Lakkireddy <rahul.lakkireddy@chelsio.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fd4ec076
...@@ -80,6 +80,19 @@ static void cxgb4_process_flow_match(struct net_device *dev, ...@@ -80,6 +80,19 @@ static void cxgb4_process_flow_match(struct net_device *dev,
struct flow_rule *rule, struct flow_rule *rule,
struct ch_filter_specification *fs) struct ch_filter_specification *fs)
{ {
u16 addr_type = 0;
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_CONTROL)) {
struct flow_match_control match;
flow_rule_match_control(rule, &match);
addr_type = match.key->addr_type;
} else if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IPV4_ADDRS)) {
addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS;
} else if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IPV6_ADDRS)) {
addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
}
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_BASIC)) { if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_BASIC)) {
struct flow_match_basic match; struct flow_match_basic match;
u16 ethtype_key, ethtype_mask; u16 ethtype_key, ethtype_mask;
...@@ -102,7 +115,7 @@ static void cxgb4_process_flow_match(struct net_device *dev, ...@@ -102,7 +115,7 @@ static void cxgb4_process_flow_match(struct net_device *dev,
fs->mask.proto = match.mask->ip_proto; fs->mask.proto = match.mask->ip_proto;
} }
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IPV4_ADDRS)) { if (addr_type == FLOW_DISSECTOR_KEY_IPV4_ADDRS) {
struct flow_match_ipv4_addrs match; struct flow_match_ipv4_addrs match;
flow_rule_match_ipv4_addrs(rule, &match); flow_rule_match_ipv4_addrs(rule, &match);
...@@ -117,7 +130,7 @@ static void cxgb4_process_flow_match(struct net_device *dev, ...@@ -117,7 +130,7 @@ static void cxgb4_process_flow_match(struct net_device *dev,
memcpy(&fs->nat_fip[0], &match.key->src, sizeof(match.key->src)); memcpy(&fs->nat_fip[0], &match.key->src, sizeof(match.key->src));
} }
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IPV6_ADDRS)) { if (addr_type == FLOW_DISSECTOR_KEY_IPV6_ADDRS) {
struct flow_match_ipv6_addrs match; struct flow_match_ipv6_addrs match;
flow_rule_match_ipv6_addrs(rule, &match); flow_rule_match_ipv6_addrs(rule, &match);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment