summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOr Gerlitz <ogerlitz@mellanox.com>2018-07-31 13:40:37 +0300
committerSimon Horman <simon.horman@netronome.com>2018-08-01 11:32:54 +0200
commitdfa2ccdba8732dc509d1de87b60b827007509989 (patch)
tree951b3a2918368708ae28006ea3851f930cd982a0
parentb4496fc9d57d94b625449dd45291c8da85764b4a (diff)
downloadopenvswitch-dfa2ccdba8732dc509d1de87b60b827007509989.tar.gz
lib/tc: Support matching on ip tos
Add the missing code to match on ip tos when dealing with the TC data-path. Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Reviewed-by: Roi Dayan <roid@mellanox.com> Signed-off-by: Simon Horman <simon.horman@netronome.com>
-rw-r--r--include/openvswitch/match.h1
-rw-r--r--lib/match.c7
-rw-r--r--lib/netdev-tc-offloads.c6
-rw-r--r--lib/tc.c10
-rw-r--r--lib/tc.h1
5 files changed, 23 insertions, 2 deletions
diff --git a/include/openvswitch/match.h b/include/openvswitch/match.h
index b43ecb179..e8c80dd27 100644
--- a/include/openvswitch/match.h
+++ b/include/openvswitch/match.h
@@ -194,6 +194,7 @@ void match_set_nw_dscp(struct match *, uint8_t);
void match_set_nw_ecn(struct match *, uint8_t);
void match_set_nw_ttl(struct match *, uint8_t nw_ttl);
void match_set_nw_ttl_masked(struct match *, uint8_t nw_ttl, uint8_t mask);
+void match_set_nw_tos_masked(struct match *, uint8_t nw_tos, uint8_t mask);
void match_set_nw_frag(struct match *, uint8_t nw_frag);
void match_set_nw_frag_masked(struct match *, uint8_t nw_frag, uint8_t mask);
void match_set_icmp_type(struct match *, uint8_t);
diff --git a/lib/match.c b/lib/match.c
index 2281fa084..a1407a86a 100644
--- a/lib/match.c
+++ b/lib/match.c
@@ -946,6 +946,13 @@ match_set_nw_ttl(struct match *match, uint8_t nw_ttl)
}
void
+match_set_nw_tos_masked(struct match *match, uint8_t nw_tos, uint8_t mask)
+{
+ match->flow.nw_tos = nw_tos & mask;
+ match->wc.masks.nw_tos = mask;
+}
+
+void
match_set_nw_ttl_masked(struct match *match, uint8_t nw_ttl, uint8_t mask)
{
match->flow.nw_ttl = nw_ttl & mask;
diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c
index 2a6dd6d09..c61197aa0 100644
--- a/lib/netdev-tc-offloads.c
+++ b/lib/netdev-tc-offloads.c
@@ -455,6 +455,7 @@ parse_tc_flower_to_match(struct tc_flower *flower,
match_set_nw_proto(match, key->ip_proto);
}
+ match_set_nw_tos_masked(match, key->ip_tos, mask->ip_tos);
match_set_nw_ttl_masked(match, key->ip_ttl, mask->ip_ttl);
if (mask->flags) {
@@ -1026,6 +1027,9 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match,
flower.key.ip_proto = key->nw_proto;
flower.mask.ip_proto = mask->nw_proto;
mask->nw_proto = 0;
+ flower.key.ip_tos = key->nw_tos;
+ flower.mask.ip_tos = mask->nw_tos;
+ mask->nw_tos = 0;
flower.key.ip_ttl = key->nw_ttl;
flower.mask.ip_ttl = mask->nw_ttl;
mask->nw_ttl = 0;
@@ -1074,8 +1078,6 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match,
mask->tp_dst = 0;
}
- mask->nw_tos = 0;
-
if (key->dl_type == htons(ETH_P_IP)) {
flower.key.ipv4.ipv4_src = key->nw_src;
flower.mask.ipv4.ipv4_src = mask->nw_src;
diff --git a/lib/tc.c b/lib/tc.c
index 791f28585..ec7efff69 100644
--- a/lib/tc.c
+++ b/lib/tc.c
@@ -302,6 +302,10 @@ static const struct nl_policy tca_flower_policy[] = {
.optional = true, },
[TCA_FLOWER_KEY_IP_TTL_MASK] = { .type = NL_A_U8,
.optional = true, },
+ [TCA_FLOWER_KEY_IP_TOS] = { .type = NL_A_U8,
+ .optional = true, },
+ [TCA_FLOWER_KEY_IP_TOS_MASK] = { .type = NL_A_U8,
+ .optional = true, },
[TCA_FLOWER_KEY_TCP_FLAGS] = { .type = NL_A_U16,
.optional = true, },
[TCA_FLOWER_KEY_TCP_FLAGS_MASK] = { .type = NL_A_U16,
@@ -497,6 +501,11 @@ nl_parse_flower_ip(struct nlattr **attrs, struct tc_flower *flower) {
key->ip_ttl = nl_attr_get_u8(attrs[TCA_FLOWER_KEY_IP_TTL]);
mask->ip_ttl = nl_attr_get_u8(attrs[TCA_FLOWER_KEY_IP_TTL_MASK]);
}
+
+ if (attrs[TCA_FLOWER_KEY_IP_TOS_MASK]) {
+ key->ip_tos = nl_attr_get_u8(attrs[TCA_FLOWER_KEY_IP_TOS]);
+ mask->ip_tos = nl_attr_get_u8(attrs[TCA_FLOWER_KEY_IP_TOS_MASK]);
+ }
}
static enum tc_offloaded_state
@@ -1626,6 +1635,7 @@ nl_msg_put_flower_options(struct ofpbuf *request, struct tc_flower *flower)
if (host_eth_type == ETH_P_IP || host_eth_type == ETH_P_IPV6) {
FLOWER_PUT_MASKED_VALUE(ip_ttl, TCA_FLOWER_KEY_IP_TTL);
+ FLOWER_PUT_MASKED_VALUE(ip_tos, TCA_FLOWER_KEY_IP_TOS);
if (flower->mask.ip_proto && flower->key.ip_proto) {
nl_msg_put_u8(request, TCA_FLOWER_KEY_IP_PROTO,
diff --git a/lib/tc.h b/lib/tc.h
index 447d85feb..90ef32adb 100644
--- a/lib/tc.h
+++ b/lib/tc.h
@@ -95,6 +95,7 @@ struct tc_flower_key {
uint8_t flags;
uint8_t ip_ttl;
+ uint8_t ip_tos;
struct {
ovs_be32 ipv4_src;