From 9656de8a2858a6d447edd2c509ca04250614445e Mon Sep 17 00:00:00 2001 From: Mikio Hara Date: Wed, 15 Jul 2009 09:38:55 -0700 Subject: [PATCH] Vlan pcp match: Reorder VLAN priority field in ofp_match structure to order their appearance on the wire --- include/openflow/nicira-ext.h | 4 ++-- include/openflow/openflow.h | 16 +++++++++------- .../openflow/packet-openflow.c | 16 ++++++++++------ 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/include/openflow/nicira-ext.h b/include/openflow/nicira-ext.h index df9272b..5aa7154 100644 --- a/include/openflow/nicira-ext.h +++ b/include/openflow/nicira-ext.h @@ -188,9 +188,9 @@ struct nx_flow_end { uint64_t used_time; /* Time entry was last used in milliseconds. */ uint64_t end_time; /* Time flow ended in milliseconds. */ - uint64_t packet_count; + uint64_t packet_count; uint64_t byte_count; }; -OFP_ASSERT(sizeof(struct nx_flow_end) == 104); +OFP_ASSERT(sizeof(struct nx_flow_end) == 108); #endif /* openflow/nicira-ext.h */ diff --git a/include/openflow/openflow.h b/include/openflow/openflow.h index 3f737db..b3905dc 100644 --- a/include/openflow/openflow.h +++ b/include/openflow/openflow.h @@ -511,15 +511,17 @@ struct ofp_match { uint8_t dl_src[OFP_ETH_ALEN]; /* Ethernet source address. */ uint8_t dl_dst[OFP_ETH_ALEN]; /* Ethernet destination address. */ uint16_t dl_vlan; /* Input VLAN id. */ + uint8_t dl_vlan_pcp; /* Input VLAN priority. */ + uint8_t pad1[1]; /* Align to 64-bits */ uint16_t dl_type; /* Ethernet frame type. */ uint8_t nw_proto; /* IP protocol. */ - uint8_t dl_vlan_pcp; /* Input VLAN priority. */ + uint8_t pad2[3]; /* Align to 64-bits */ uint32_t nw_src; /* IP source address. */ uint32_t nw_dst; /* IP destination address. */ uint16_t tp_src; /* TCP/UDP source port. */ uint16_t tp_dst; /* TCP/UDP destination port. */ }; -OFP_ASSERT(sizeof(struct ofp_match) == 36); +OFP_ASSERT(sizeof(struct ofp_match) == 40); /* The match fields for ICMP type and code use the transport source and * destination port fields, respectively. */ @@ -562,7 +564,7 @@ struct ofp_flow_mod { from the length field in the header. */ }; -OFP_ASSERT(sizeof(struct ofp_flow_mod) == 64); +OFP_ASSERT(sizeof(struct ofp_flow_mod) == 68); /* Why was this flow removed? */ enum ofp_flow_removed_reason { @@ -586,7 +588,7 @@ struct ofp_flow_removed { uint64_t packet_count; uint64_t byte_count; }; -OFP_ASSERT(sizeof(struct ofp_flow_removed) == 72); +OFP_ASSERT(sizeof(struct ofp_flow_removed) == 76); /* Values for 'type' in ofp_error_message. These values are immutable: they * will not change in future versions of the protocol (although new values may @@ -726,7 +728,7 @@ struct ofp_flow_stats_request { as an output port. A value of OFPP_NONE indicates no restriction. */ }; -OFP_ASSERT(sizeof(struct ofp_flow_stats_request) == 40); +OFP_ASSERT(sizeof(struct ofp_flow_stats_request) == 44); /* Body of reply to OFPST_FLOW request. */ struct ofp_flow_stats { @@ -744,7 +746,7 @@ struct ofp_flow_stats { uint64_t byte_count; /* Number of bytes in flow. */ struct ofp_action_header actions[0]; /* Actions. */ }; -OFP_ASSERT(sizeof(struct ofp_flow_stats) == 72); +OFP_ASSERT(sizeof(struct ofp_flow_stats) == 76); /* Body for ofp_stats_request of type OFPST_AGGREGATE. */ struct ofp_aggregate_stats_request { @@ -756,7 +758,7 @@ struct ofp_aggregate_stats_request { as an output port. A value of OFPP_NONE indicates no restriction. */ }; -OFP_ASSERT(sizeof(struct ofp_aggregate_stats_request) == 40); +OFP_ASSERT(sizeof(struct ofp_aggregate_stats_request) == 44); /* Body of reply to OFPST_AGGREGATE request. */ struct ofp_aggregate_stats_reply { diff --git a/utilities/wireshark_dissectors/openflow/packet-openflow.c b/utilities/wireshark_dissectors/openflow/packet-openflow.c index d5dcd76..525b5b2 100644 --- a/utilities/wireshark_dissectors/openflow/packet-openflow.c +++ b/utilities/wireshark_dissectors/openflow/packet-openflow.c @@ -99,7 +99,7 @@ static const value_string names_ofp_action_type[] = { { OFPAT_SET_DL_DST, "Ethernet destination address" }, { OFPAT_SET_NW_SRC, "IP source address" }, { OFPAT_SET_NW_DST, "IP destination address" }, - { OFPAT_SET_NW_TOS, "Set IP TOS field" }, + { OFPAT_SET_NW_TOS, "Set IP TOS field" }, { OFPAT_SET_TP_SRC, "TCP/UDP source port" }, { OFPAT_SET_TP_DST, "TCP/UDP destination port"}, { OFPAT_VENDOR, "Vendor-defined action"}, @@ -2095,7 +2095,7 @@ static void dissect_match(proto_tree* tree, proto_item* item, tvbuff_t *tvb, pac proto_item *match_item = proto_tree_add_item(tree, ofp_match, tvb, *offset, sizeof(struct ofp_match), FALSE); proto_tree *match_tree = proto_item_add_subtree(match_item, ett_ofp_match); - /* save wildcards field for later */ + /* save wildcards field for later */ guint32 wildcards = tvb_get_ntohl( tvb, *offset ); dissect_wildcards(match_tree, match_item, tvb, pinfo, offset, ofp_match_wildcards); @@ -2121,6 +2121,13 @@ static void dissect_match(proto_tree* tree, proto_item* item, tvbuff_t *tvb, pac else *offset += 2; + if( ~wildcards & OFPFW_DL_VLAN_PCP ) + add_child(match_tree, ofp_match_dl_vlan_pcp, tvb, offset, 1); + else + *offset += 1; + + dissect_pad(match_tree, offset, 1); + if( ~wildcards & OFPFW_DL_TYPE ) dissect_dl_type(match_tree, ofp_match_dl_type, tvb, offset); else @@ -2134,10 +2141,7 @@ static void dissect_match(proto_tree* tree, proto_item* item, tvbuff_t *tvb, pac else *offset += 1; - if( ~wildcards & OFPFW_DL_VLAN_PCP ) - add_child(match_tree, ofp_match_dl_vlan_pcp, tvb, offset, 1); - else - *offset += 1; + dissect_pad(match_tree, offset, 3); if( ~wildcards & OFPFW_NW_SRC_MASK ) add_child(match_tree, ofp_match_nw_src, tvb, offset, 4);