Skip to content

Commit

Permalink
netdev-offload-tc: Fix offload of tunnel key tp_src.
Browse files Browse the repository at this point in the history
There is no TCA_TUNNEL_KEY_ENC_SRC_PORT in the kernel, so the offload
should not be attempted, if OVS_TUNNEL_KEY_ATTR_TP_SRC is requested
by OVS.  Current code just ignores the attribute in the tunnel(set())
action leading to a flow mismatch and potential incorrect datapath
behavior:

  |tc(handler21)|DBG|tc flower compare failed action compare
  ...
  Action 0 mismatch:
  - Expected Action:
  00000010 01 00 00 00 00 00 00 00-00 00 00 00 00 ff 00 11
  00000020 c0 5b 17 c1 00 40 00 00-0a 01 00 6d 0a 01 01 12
  00000050 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  00000060 01 02 80 01 00 18 00 0b-00 00 00 00 00 00 00 00
  ...
 - Received Action:
  00000010 01 00 00 00 00 00 00 00-00 00 00 00 00 ff 00 11
  00000020 00 00 17 c1 00 40 00 00-0a 01 00 6d 0a 01 01 12
  00000050 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  00000060 01 02 80 01 00 18 00 0b-00 00 00 00 00 00 00 00
  ...

In the tc_action dump above we can see the difference on the second
line.  The action dumped from a kernel is missing 'c0 5b' - source
port for a tunnel(set()) action on the second line.

Removing the field from the tc_action_encap structure entirely to
avoid any potential confusion.

Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
igsilya committed Oct 20, 2023
1 parent a413fed commit 51aee55
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/netdev-offload-tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,9 @@ parse_put_flow_set_action(struct tc_flower *flower, struct tc_action *action,
}
break;
case OVS_TUNNEL_KEY_ATTR_TP_SRC: {
action->encap.tp_src = nl_attr_get_be16(tun_attr);
/* There is no corresponding attribute in TC. */
VLOG_DBG_RL(&rl, "unsupported tunnel key attribute TP_SRC");
return EOPNOTSUPP;
}
break;
case OVS_TUNNEL_KEY_ATTR_TP_DST: {
Expand Down
3 changes: 2 additions & 1 deletion lib/tc.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ enum nat_type {
struct tc_action_encap {
bool id_present;
ovs_be64 id;
ovs_be16 tp_src;
/* ovs_be16 tp_src; Could have been here, but there is no
* TCA_TUNNEL_KEY_ENC_ attribute for it in the kernel. */
ovs_be16 tp_dst;
uint8_t tos;
uint8_t ttl;
Expand Down

0 comments on commit 51aee55

Please sign in to comment.