summaryrefslogtreecommitdiff
path: root/lib/netdev-tc-offloads.c
diff options
context:
space:
mode:
authorAdi Nissim <adin@mellanox.com>2019-01-17 17:41:36 +0200
committerSimon Horman <simon.horman@netronome.com>2019-02-11 11:02:43 +0100
commit0227bf092ee6b5d18e2b79493d44769cb37ecc98 (patch)
tree42318df4b8403dcd97e89b001abead38d8aaac8e /lib/netdev-tc-offloads.c
parent47ab42a0b5f5a7b67f8a6f766144ae2b6052d783 (diff)
downloadopenvswitch-0227bf092ee6b5d18e2b79493d44769cb37ecc98.tar.gz
lib/tc: Support optional tunnel id
Currently the TC tunnel_key action is always initialized with the given tunnel id value. However, some tunneling protocols define the tunnel id as an optional field. This patch initializes the id field of tunnel_key:set and tunnel_key:unset only if a value is provided. In the case that a tunnel key value is not provided by the user the key flag will not be set. Signed-off-by: Adi Nissim <adin@mellanox.com> Acked-by: Paul Blakey <paulb@mellanox.com> Signed-off-by: Simon Horman <simon.horman@netronome.com>
Diffstat (limited to 'lib/netdev-tc-offloads.c')
-rw-r--r--lib/netdev-tc-offloads.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c
index 1c5bd22e4..36bce15b3 100644
--- a/lib/netdev-tc-offloads.c
+++ b/lib/netdev-tc-offloads.c
@@ -582,7 +582,9 @@ parse_tc_flower_to_match(struct tc_flower *flower,
}
if (flower->tunnel) {
- match_set_tun_id(match, flower->key.tunnel.id);
+ if (flower->mask.tunnel.id) {
+ match_set_tun_id(match, flower->key.tunnel.id);
+ }
if (flower->key.tunnel.ipv4.ipv4_dst) {
match_set_tun_src(match, flower->key.tunnel.ipv4.ipv4_src);
match_set_tun_dst(match, flower->key.tunnel.ipv4.ipv4_dst);
@@ -636,7 +638,9 @@ parse_tc_flower_to_match(struct tc_flower *flower,
size_t tunnel_offset =
nl_msg_start_nested(buf, OVS_KEY_ATTR_TUNNEL);
- nl_msg_put_be64(buf, OVS_TUNNEL_KEY_ATTR_ID, action->encap.id);
+ if (action->encap.id_present) {
+ nl_msg_put_be64(buf, OVS_TUNNEL_KEY_ATTR_ID, action->encap.id);
+ }
if (action->encap.ipv4.ipv4_src) {
nl_msg_put_be32(buf, OVS_TUNNEL_KEY_ATTR_IPV4_SRC,
action->encap.ipv4.ipv4_src);
@@ -838,11 +842,13 @@ parse_put_flow_set_action(struct tc_flower *flower, struct tc_action *action,
tunnel_len = nl_attr_get_size(set);
action->type = TC_ACT_ENCAP;
+ action->encap.id_present = false;
flower->action_count++;
NL_ATTR_FOR_EACH_UNSAFE(tun_attr, tun_left, tunnel, tunnel_len) {
switch (nl_attr_type(tun_attr)) {
case OVS_TUNNEL_KEY_ATTR_ID: {
action->encap.id = nl_attr_get_be64(tun_attr);
+ action->encap.id_present = true;
}
break;
case OVS_TUNNEL_KEY_ATTR_IPV4_SRC: {
@@ -1107,6 +1113,7 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match,
flower.key.tunnel.tp_dst = tnl->tp_dst;
flower.mask.tunnel.tos = tnl_mask->ip_tos;
flower.mask.tunnel.ttl = tnl_mask->ip_ttl;
+ flower.mask.tunnel.id = (tnl->flags & FLOW_TNL_F_KEY) ? tnl_mask->tun_id : 0;
flower_match_to_tun_opt(&flower, tnl, tnl_mask);
flower.tunnel = true;
}