mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 06:15:47 +00:00
Create specific types for ofp and odp port
Until now, datapath ports and openflow ports were both represented by unsigned integers of various sizes. With implicit conversions, etc., it is easy to mix them up and use one where the other is expected. This commit creates two typedefs, ofp_port_t and odp_port_t. Both of these two types are marked by "__attribute__((bitwise))" so that sparse can be used to detect any misuse. Signed-off-by: Alex Wang <alexw@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
@@ -355,9 +355,9 @@ learn_execute(const struct ofpact_learn *learn, const struct flow *flow,
|
||||
case NX_LEARN_DST_OUTPUT:
|
||||
if (spec->n_bits <= 16
|
||||
|| is_all_zeros(value.u8, sizeof value - 2)) {
|
||||
uint16_t port = ntohs(value.be16[7]);
|
||||
ofp_port_t port = u16_to_ofp(ntohs(value.be16[7]));
|
||||
|
||||
if (port < OFPP_MAX
|
||||
if (ofp_to_u16(port) < ofp_to_u16(OFPP_MAX)
|
||||
|| port == OFPP_IN_PORT
|
||||
|| port == OFPP_FLOOD
|
||||
|| port == OFPP_LOCAL
|
||||
|
Reference in New Issue
Block a user