[ovs-dev] [metaflow-cleanup 1/3] meta-flow: Split ICMP into ICMPv4 and ICMPv6.
Ben Pfaff
blp at nicira.com
Tue Nov 8 05:50:23 UTC 2011
NXM breaks ICMP into v4 and v6. An upcoming commit will drop all of the
NXM specific data in favor of mf_field, and so at that point we need to
have a separate mf_field for each NXM field. So, this commit splits
ICMP into v4 and v6 for meta-flow also.
---
lib/meta-flow.c | 74 ++++++++++++++++++++++++++++++++++++++----------------
lib/meta-flow.h | 9 ++++--
lib/nx-match.def | 8 +++---
3 files changed, 62 insertions(+), 29 deletions(-)
diff --git a/lib/meta-flow.c b/lib/meta-flow.c
index 0f00996..4ab212b 100644
--- a/lib/meta-flow.c
+++ b/lib/meta-flow.c
@@ -269,19 +269,33 @@ static const struct mf_field mf_fields[MFF_N_IDS] = {
},
{
- MFF_ICMP_TYPE, "icmp_type", NULL,
+ MFF_ICMPV4_TYPE, "icmp_type", NULL,
MF_FIELD_SIZES(u8),
MFM_NONE, FWW_TP_SRC,
MFS_DECIMAL,
- MFP_ICMP_ANY,
+ MFP_ICMPV4,
NXM_OF_ICMP_TYPE,
}, {
- MFF_ICMP_CODE, "icmp_code", NULL,
+ MFF_ICMPV4_CODE, "icmp_code", NULL,
MF_FIELD_SIZES(u8),
MFM_NONE, FWW_TP_DST,
MFS_DECIMAL,
- MFP_ICMP_ANY,
+ MFP_ICMPV4,
NXM_OF_ICMP_CODE,
+ }, {
+ MFF_ICMPV6_TYPE, "icmpv6_type", NULL,
+ MF_FIELD_SIZES(u8),
+ MFM_NONE, FWW_TP_SRC,
+ MFS_DECIMAL,
+ MFP_ICMPV6,
+ NXM_NX_ICMPV6_TYPE,
+ }, {
+ MFF_ICMPV6_CODE, "icmpv6_code", NULL,
+ MF_FIELD_SIZES(u8),
+ MFM_NONE, FWW_TP_DST,
+ MFS_DECIMAL,
+ MFP_ICMPV6,
+ NXM_NX_ICMPV6_CODE,
},
/* ## ---- ## */
@@ -361,8 +375,10 @@ mf_is_all_wild(const struct mf_field *mf, const struct flow_wildcards *wc)
case MFF_TCP_DST:
case MFF_UDP_SRC:
case MFF_UDP_DST:
- case MFF_ICMP_TYPE:
- case MFF_ICMP_CODE:
+ case MFF_ICMPV4_TYPE:
+ case MFF_ICMPV4_CODE:
+ case MFF_ICMPV6_TYPE:
+ case MFF_ICMPV6_CODE:
case MFF_ND_TARGET:
case MFF_ND_SLL:
case MFF_ND_TLL:
@@ -451,8 +467,10 @@ mf_get_mask(const struct mf_field *mf, const struct flow_wildcards *wc,
case MFF_TCP_DST:
case MFF_UDP_SRC:
case MFF_UDP_DST:
- case MFF_ICMP_TYPE:
- case MFF_ICMP_CODE:
+ case MFF_ICMPV4_TYPE:
+ case MFF_ICMPV4_CODE:
+ case MFF_ICMPV6_TYPE:
+ case MFF_ICMPV6_CODE:
case MFF_ND_TARGET:
case MFF_ND_SLL:
case MFF_ND_TLL:
@@ -601,10 +619,10 @@ mf_are_prereqs_ok(const struct mf_field *mf, const struct flow *flow)
return is_ip_any(flow) && flow->nw_proto == IPPROTO_TCP;
case MFP_UDP:
return is_ip_any(flow) && flow->nw_proto == IPPROTO_UDP;
+ case MFP_ICMPV4:
+ return is_icmpv4(flow);
case MFP_ICMPV6:
return is_icmpv6(flow);
- case MFP_ICMP_ANY:
- return is_icmpv4(flow) || is_icmpv6(flow);
case MFP_ND:
return (is_icmpv6(flow)
@@ -675,8 +693,10 @@ mf_is_value_valid(const struct mf_field *mf, const union mf_value *value)
case MFF_TCP_DST:
case MFF_UDP_SRC:
case MFF_UDP_DST:
- case MFF_ICMP_TYPE:
- case MFF_ICMP_CODE:
+ case MFF_ICMPV4_TYPE:
+ case MFF_ICMPV4_CODE:
+ case MFF_ICMPV6_TYPE:
+ case MFF_ICMPV6_CODE:
case MFF_ND_TARGET:
case MFF_ND_SLL:
case MFF_ND_TLL:
@@ -828,11 +848,13 @@ mf_get_value(const struct mf_field *mf, const struct flow *flow,
value->be16 = flow->tp_dst;
break;
- case MFF_ICMP_TYPE:
+ case MFF_ICMPV4_TYPE:
+ case MFF_ICMPV6_TYPE:
value->u8 = ntohs(flow->tp_src);
break;
- case MFF_ICMP_CODE:
+ case MFF_ICMPV4_CODE:
+ case MFF_ICMPV6_CODE:
value->u8 = ntohs(flow->tp_dst);
break;
@@ -975,11 +997,13 @@ mf_set_value(const struct mf_field *mf,
cls_rule_set_tp_dst(rule, value->be16);
break;
- case MFF_ICMP_TYPE:
+ case MFF_ICMPV4_TYPE:
+ case MFF_ICMPV6_TYPE:
cls_rule_set_icmp_type(rule, value->u8);
break;
- case MFF_ICMP_CODE:
+ case MFF_ICMPV4_CODE:
+ case MFF_ICMPV6_CODE:
cls_rule_set_icmp_code(rule, value->u8);
break;
@@ -1120,14 +1144,16 @@ mf_set_wild(const struct mf_field *mf, struct cls_rule *rule)
case MFF_TCP_SRC:
case MFF_UDP_SRC:
- case MFF_ICMP_TYPE:
+ case MFF_ICMPV4_TYPE:
+ case MFF_ICMPV6_TYPE:
rule->wc.wildcards |= FWW_TP_SRC;
rule->flow.tp_src = htons(0);
break;
case MFF_TCP_DST:
case MFF_UDP_DST:
- case MFF_ICMP_CODE:
+ case MFF_ICMPV4_CODE:
+ case MFF_ICMPV6_CODE:
rule->wc.wildcards |= FWW_TP_DST;
rule->flow.tp_dst = htons(0);
break;
@@ -1182,8 +1208,10 @@ mf_set(const struct mf_field *mf,
case MFF_TCP_DST:
case MFF_UDP_SRC:
case MFF_UDP_DST:
- case MFF_ICMP_TYPE:
- case MFF_ICMP_CODE:
+ case MFF_ICMPV4_TYPE:
+ case MFF_ICMPV4_CODE:
+ case MFF_ICMPV6_TYPE:
+ case MFF_ICMPV6_CODE:
case MFF_ND_TARGET:
case MFF_ND_SLL:
case MFF_ND_TLL:
@@ -1386,8 +1414,10 @@ mf_random_value(const struct mf_field *mf, union mf_value *value)
case MFF_TCP_DST:
case MFF_UDP_SRC:
case MFF_UDP_DST:
- case MFF_ICMP_TYPE:
- case MFF_ICMP_CODE:
+ case MFF_ICMPV4_TYPE:
+ case MFF_ICMPV4_CODE:
+ case MFF_ICMPV6_TYPE:
+ case MFF_ICMPV6_CODE:
case MFF_ND_TARGET:
case MFF_ND_SLL:
case MFF_ND_TLL:
diff --git a/lib/meta-flow.h b/lib/meta-flow.h
index 9f3b2ee..ccab1b7 100644
--- a/lib/meta-flow.h
+++ b/lib/meta-flow.h
@@ -85,8 +85,11 @@ enum mf_field_id {
MFF_UDP_SRC, /* be16 (used for IPv4 or IPv6) */
MFF_UDP_DST, /* be16 (used for IPv4 or IPv6) */
- MFF_ICMP_TYPE, /* u8 (used for IPv4 or IPv6) */
- MFF_ICMP_CODE, /* u8 (used for IPv4 or IPv6) */
+ MFF_ICMPV4_TYPE, /* u8 */
+ MFF_ICMPV4_CODE, /* u8 */
+
+ MFF_ICMPV6_TYPE, /* u8 */
+ MFF_ICMPV6_CODE, /* u8 */
/* ICMPv6 Neighbor Discovery. */
MFF_ND_TARGET, /* ipv6 */
@@ -113,8 +116,8 @@ enum mf_prereqs {
/* L2+L3 requirements. */
MFP_TCP, /* On IPv4 or IPv6. */
MFP_UDP, /* On IPv4 or IPv6. */
+ MFP_ICMPV4,
MFP_ICMPV6,
- MFP_ICMP_ANY,
/* L2+L3+L4 requirements. */
MFP_ND,
diff --git a/lib/nx-match.def b/lib/nx-match.def
index 5c0a238..6b941cb 100644
--- a/lib/nx-match.def
+++ b/lib/nx-match.def
@@ -35,8 +35,8 @@ DEFINE_FIELD (OF_TCP_SRC, MFF_TCP_SRC, true)
DEFINE_FIELD (OF_TCP_DST, MFF_TCP_DST, true)
DEFINE_FIELD (OF_UDP_SRC, MFF_UDP_SRC, true)
DEFINE_FIELD (OF_UDP_DST, MFF_UDP_DST, true)
-DEFINE_FIELD (OF_ICMP_TYPE, MFF_ICMP_TYPE, false)
-DEFINE_FIELD (OF_ICMP_CODE, MFF_ICMP_CODE, false)
+DEFINE_FIELD (OF_ICMP_TYPE, MFF_ICMPV4_TYPE, false)
+DEFINE_FIELD (OF_ICMP_CODE, MFF_ICMPV4_CODE, false)
DEFINE_FIELD (OF_ARP_OP, MFF_ARP_OP, false)
DEFINE_FIELD_M(OF_ARP_SPA, MFF_ARP_SPA, false)
DEFINE_FIELD_M(OF_ARP_TPA, MFF_ARP_TPA, false)
@@ -45,8 +45,8 @@ DEFINE_FIELD (NX_ARP_THA, MFF_ARP_THA, false)
DEFINE_FIELD_M(NX_IPV6_SRC, MFF_IPV6_SRC, false)
DEFINE_FIELD_M(NX_IPV6_DST, MFF_IPV6_DST, false)
/* XXX should we have MFF_ICMPV4_TYPE and MFF_ICMPV6_TYPE? */
-DEFINE_FIELD (NX_ICMPV6_TYPE,MFF_ICMP_TYPE, false)
-DEFINE_FIELD (NX_ICMPV6_CODE,MFF_ICMP_CODE, false)
+DEFINE_FIELD (NX_ICMPV6_TYPE,MFF_ICMPV6_TYPE, false)
+DEFINE_FIELD (NX_ICMPV6_CODE,MFF_ICMPV6_CODE, false)
DEFINE_FIELD (NX_ND_TARGET, MFF_ND_TARGET, false)
DEFINE_FIELD (NX_ND_SLL, MFF_ND_SLL, false)
DEFINE_FIELD (NX_ND_TLL, MFF_ND_TLL, false)
--
1.7.2.5
More information about the dev
mailing list