mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 06:15:47 +00:00
lib/tc: add ICMP type and code match offload
Add TC offload support for classifying ICMPv4/6 type and code. $ ovs-appctl dpctl/add-flow 'recirc_id(0),in_port(3),eth(),\ eth_type(0x0800),ipv4(proto=1),icmp(type=9,code=0)' 2 $ ovs-appctl dpctl/dump-flows ... icmp(type=9,code=0) ... $ tc filter show dev <ethx> ingress ... eth_type ipv4 ip_proto icmp icmp_type 9 icmp_code 0 not_in_hw action order 1: mirred (Egress Redirect to device <ethy>) stolen ... Signed-off-by: Maor Dickman <maord@nvidia.com> Reviewed-by: Roi Dayan <roid@nvidia.com> Signed-off-by: Simon Horman <simon.horman@netronome.com>
This commit is contained in:
committed by
Simon Horman
parent
d5c429a303
commit
75e1e6fd2d
48
lib/tc.c
48
lib/tc.c
@@ -426,6 +426,22 @@ static const struct nl_policy tca_flower_policy[] = {
|
||||
[TCA_FLOWER_KEY_CT_LABELS] = { .type = NL_A_U128, .optional = true, },
|
||||
[TCA_FLOWER_KEY_CT_LABELS_MASK] = { .type = NL_A_U128,
|
||||
.optional = true, },
|
||||
[TCA_FLOWER_KEY_ICMPV4_CODE] = { .type = NL_A_U8,
|
||||
.optional = true, },
|
||||
[TCA_FLOWER_KEY_ICMPV4_CODE_MASK] = { .type = NL_A_U8,
|
||||
.optional = true, },
|
||||
[TCA_FLOWER_KEY_ICMPV4_TYPE] = { .type = NL_A_U8,
|
||||
.optional = true, },
|
||||
[TCA_FLOWER_KEY_ICMPV4_TYPE_MASK] = { .type = NL_A_U8,
|
||||
.optional = true, },
|
||||
[TCA_FLOWER_KEY_ICMPV6_CODE] = { .type = NL_A_U8,
|
||||
.optional = true, },
|
||||
[TCA_FLOWER_KEY_ICMPV6_CODE_MASK] = { .type = NL_A_U8,
|
||||
.optional = true, },
|
||||
[TCA_FLOWER_KEY_ICMPV6_TYPE] = { .type = NL_A_U8,
|
||||
.optional = true, },
|
||||
[TCA_FLOWER_KEY_ICMPV6_TYPE_MASK] = { .type = NL_A_U8,
|
||||
.optional = true, },
|
||||
};
|
||||
|
||||
static const struct nl_policy tca_flower_terse_policy[] = {
|
||||
@@ -908,6 +924,32 @@ nl_parse_flower_ip(struct nlattr **attrs, struct tc_flower *flower) {
|
||||
mask->sctp_dst =
|
||||
nl_attr_get_be16(attrs[TCA_FLOWER_KEY_SCTP_DST_MASK]);
|
||||
}
|
||||
} else if (ip_proto == IPPROTO_ICMP) {
|
||||
if (attrs[TCA_FLOWER_KEY_ICMPV4_CODE_MASK]) {
|
||||
key->icmp_code =
|
||||
nl_attr_get_u8(attrs[TCA_FLOWER_KEY_ICMPV4_CODE]);
|
||||
mask->icmp_code =
|
||||
nl_attr_get_u8(attrs[TCA_FLOWER_KEY_ICMPV4_CODE]);
|
||||
}
|
||||
if (attrs[TCA_FLOWER_KEY_ICMPV4_TYPE_MASK]) {
|
||||
key->icmp_type =
|
||||
nl_attr_get_u8(attrs[TCA_FLOWER_KEY_ICMPV4_TYPE_MASK]);
|
||||
mask->icmp_type =
|
||||
nl_attr_get_u8(attrs[TCA_FLOWER_KEY_ICMPV4_TYPE_MASK]);
|
||||
}
|
||||
} else if (ip_proto == IPPROTO_ICMPV6) {
|
||||
if (attrs[TCA_FLOWER_KEY_ICMPV6_CODE_MASK]) {
|
||||
key->icmp_code =
|
||||
nl_attr_get_u8(attrs[TCA_FLOWER_KEY_ICMPV6_CODE]);
|
||||
mask->icmp_code =
|
||||
nl_attr_get_u8(attrs[TCA_FLOWER_KEY_ICMPV6_CODE]);
|
||||
}
|
||||
if (attrs[TCA_FLOWER_KEY_ICMPV6_TYPE_MASK]) {
|
||||
key->icmp_type =
|
||||
nl_attr_get_u8(attrs[TCA_FLOWER_KEY_ICMPV6_TYPE_MASK]);
|
||||
mask->icmp_type =
|
||||
nl_attr_get_u8(attrs[TCA_FLOWER_KEY_ICMPV6_TYPE_MASK]);
|
||||
}
|
||||
}
|
||||
|
||||
if (attrs[TCA_FLOWER_KEY_IP_TTL_MASK]) {
|
||||
@@ -2812,6 +2854,12 @@ nl_msg_put_flower_options(struct ofpbuf *request, struct tc_flower *flower)
|
||||
} else if (flower->key.ip_proto == IPPROTO_SCTP) {
|
||||
FLOWER_PUT_MASKED_VALUE(sctp_src, TCA_FLOWER_KEY_SCTP_SRC);
|
||||
FLOWER_PUT_MASKED_VALUE(sctp_dst, TCA_FLOWER_KEY_SCTP_DST);
|
||||
} else if (flower->key.ip_proto == IPPROTO_ICMP) {
|
||||
FLOWER_PUT_MASKED_VALUE(icmp_code, TCA_FLOWER_KEY_ICMPV4_CODE);
|
||||
FLOWER_PUT_MASKED_VALUE(icmp_type, TCA_FLOWER_KEY_ICMPV4_TYPE);
|
||||
} else if (flower->key.ip_proto == IPPROTO_ICMPV6) {
|
||||
FLOWER_PUT_MASKED_VALUE(icmp_code, TCA_FLOWER_KEY_ICMPV6_CODE);
|
||||
FLOWER_PUT_MASKED_VALUE(icmp_type, TCA_FLOWER_KEY_ICMPV6_TYPE);
|
||||
}
|
||||
|
||||
FLOWER_PUT_MASKED_VALUE(ct_state, TCA_FLOWER_KEY_CT_STATE);
|
||||
|
Reference in New Issue
Block a user