From: Ben Pfaff Date: Fri, 3 Jun 2016 20:15:01 +0000 (-0700) Subject: types: Change ofp_port_t from uint16_t to uint32_t. X-Git-Url: http://git.cascardo.eti.br/?a=commitdiff_plain;h=117d72495467efaa3eb7e7e4f7d110cd1223b967;p=cascardo%2Fovs.git types: Change ofp_port_t from uint16_t to uint32_t. This fixes several tests that failed on big-endian systems because "union flow_in_port" overlays an ofp_port_t and odp_port_t and in some cases it is not easy to determine which one is in use. This commit also fixes up a few places where this broke other code. Signed-off-by: Ben Pfaff Acked-by: Aaron Conole Acked-by: Gerhard Stenzel --- diff --git a/include/openvswitch/flow.h b/include/openvswitch/flow.h index 6f08f3a23..03d406ba2 100644 --- a/include/openvswitch/flow.h +++ b/include/openvswitch/flow.h @@ -92,7 +92,6 @@ struct flow { ovs_u128 ct_label; /* Connection label. */ uint32_t conj_id; /* Conjunction ID. */ ofp_port_t actset_output; /* Output port in action set. */ - uint8_t pad2[2]; /* Pad to 64 bits. */ /* L2, Order the same as in the Ethernet header! (64-bit aligned) */ struct eth_addr dl_dst; /* Ethernet destination address. */ diff --git a/include/openvswitch/types.h b/include/openvswitch/types.h index 5f3347d5e..bc94145ec 100644 --- a/include/openvswitch/types.h +++ b/include/openvswitch/types.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, 2013, 2014 Nicira, Inc. + * Copyright (c) 2010, 2011, 2013, 2014, 2016 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -114,10 +114,21 @@ typedef struct { ovs_be32 hi, lo; } ovs_32aligned_be64; -/* ofp_port_t represents the port number of a OpenFlow switch. - * odp_port_t represents the port number on the datapath. - * ofp11_port_t represents the OpenFlow-1.1 port number. */ -typedef uint16_t OVS_BITWISE ofp_port_t; +/* Port numbers + * ------------ + * + * None of these types are directly interchangeable, hence the OVS_BITWISE + * annotation. + * + * ofp_port_t is an OpenFlow 1.0 port number. It uses a 16-bit range, even + * though it is a 32-bit type. This allows it to be overlaid on an odp_port_t + * for a few situations where this is useful, e.g. in union flow_in_port. + * + * ofp11_port_t is an OpenFlow-1.1 port number. + * + * odp_port_t is a port number within a datapath (e.g. see lib/dpif.h). + */ +typedef uint32_t OVS_BITWISE ofp_port_t; typedef uint32_t OVS_BITWISE odp_port_t; typedef uint32_t OVS_BITWISE ofp11_port_t; diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c index b1578c304..7ddadb8e6 100644 --- a/lib/ofp-actions.c +++ b/lib/ofp-actions.c @@ -1257,7 +1257,7 @@ decode_bundle(bool load, const struct nx_action_bundle *nab, } for (i = 0; i < bundle->n_slaves; i++) { - uint16_t ofp_port = ntohs(((ovs_be16 *)(nab + 1))[i]); + ofp_port_t ofp_port = u16_to_ofp(ntohs(((ovs_be16 *)(nab + 1))[i])); ofpbuf_put(ofpacts, &ofp_port, sizeof ofp_port); bundle = ofpacts->header; } diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index a8116d9ed..207588b5d 100644 --- a/utilities/ovs-ofctl.c +++ b/utilities/ovs-ofctl.c @@ -3723,7 +3723,7 @@ ofctl_parse_pcap(struct ovs_cmdl_context *ctx) ovs_error(error, "%s: read failed", filename); } - pkt_metadata_init(&packet->md, ODPP_NONE); + pkt_metadata_init(&packet->md, u32_to_odp(ofp_to_u16(OFPP_ANY))); flow_extract(packet, &flow); flow_print(stdout, &flow); putchar('\n');