Skip to content

Commit 072ae63

Browse files
Pravin B Shelarjessegross
authored andcommitted
openvswitch: Validation of IPv6 set port action uses IPv4 header
When the kernel validates set TCP/UDP port actions, it looks at the ports in the existing flow to make sure that the L4 header exists. However, these actions always use the IPv4 version of the struct. Following patch fixes this by checking for flow ip protocol first. Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Signed-off-by: Jesse Gross <jesse@nicira.com>
1 parent 4cb6e11 commit 072ae63

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

‎net/openvswitch/datapath.c‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,19 @@ static int validate_sample(const struct nlattr *attr,
421421
return validate_actions(actions, key, depth + 1);
422422
}
423423

424+
static int validate_tp_port(const struct sw_flow_key *flow_key)
425+
{
426+
if (flow_key->eth.type == htons(ETH_P_IP)) {
427+
if (flow_key->ipv4.tp.src && flow_key->ipv4.tp.dst)
428+
return 0;
429+
} else if (flow_key->eth.type == htons(ETH_P_IPV6)) {
430+
if (flow_key->ipv6.tp.src && flow_key->ipv6.tp.dst)
431+
return 0;
432+
}
433+
434+
return -EINVAL;
435+
}
436+
424437
static int validate_set(const struct nlattr *a,
425438
const struct sw_flow_key *flow_key)
426439
{
@@ -462,18 +475,13 @@ static int validate_set(const struct nlattr *a,
462475
if (flow_key->ip.proto != IPPROTO_TCP)
463476
return -EINVAL;
464477

465-
if (!flow_key->ipv4.tp.src || !flow_key->ipv4.tp.dst)
466-
return -EINVAL;
467-
468-
break;
478+
return validate_tp_port(flow_key);
469479

470480
case OVS_KEY_ATTR_UDP:
471481
if (flow_key->ip.proto != IPPROTO_UDP)
472482
return -EINVAL;
473483

474-
if (!flow_key->ipv4.tp.src || !flow_key->ipv4.tp.dst)
475-
return -EINVAL;
476-
break;
484+
return validate_tp_port(flow_key);
477485

478486
default:
479487
return -EINVAL;

0 commit comments

Comments
 (0)