mirror of
https://github.com/openvswitch/ovs
synced 2025-09-03 07:45:30 +00:00
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>
This commit is contained in:
@@ -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);
|
||||
|
@@ -945,6 +945,13 @@ match_set_nw_ttl(struct match *match, uint8_t nw_ttl)
|
||||
match->flow.nw_ttl = 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)
|
||||
{
|
||||
|
@@ -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;
|
||||
|
10
lib/tc.c
10
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,
|
||||
|
Reference in New Issue
Block a user