diff options
author | Ben Pfaff <blp@ovn.org> | 2017-11-13 12:40:29 -0800 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2017-11-14 10:14:18 -0800 |
commit | 0d8efdc9ca3587ea919cd18a7733fcbb7de08f83 (patch) | |
tree | f8c826a9b7fd0246fd7c0e21429b0e0ea410a740 /lib/netdev.c | |
parent | 1f3c6b2d2399be47e63e3e5b65c2dc7efaa09905 (diff) | |
download | openvswitch-0d8efdc9ca3587ea919cd18a7733fcbb7de08f83.tar.gz |
netdev: Change macro to function.
There was no reason that this should have been a macro.
Signed-off-by: Ben Pfaff <blp@ovn.org>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>
Diffstat (limited to 'lib/netdev.c')
-rw-r--r-- | lib/netdev.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/lib/netdev.c b/lib/netdev.c index 0c1545a83..7aa3e0aed 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -2179,22 +2179,25 @@ struct ifindex_to_port_data { const struct dpif_class *dpif_class; }; -#define NETDEV_PORTS_HASH_INT(port, dpif) \ - hash_int(odp_to_u32(port),\ - hash_pointer(dpif, 0)); +static uint32_t +netdev_ports_hash(odp_port_t port, const struct dpif_class *dpif_class) +{ + return hash_int(odp_to_u32(port), hash_pointer(dpif_class, 0)); +} static struct port_to_netdev_data * netdev_ports_lookup(odp_port_t port_no, const struct dpif_class *dpif_class) OVS_REQUIRES(netdev_hmap_mutex) { - size_t hash = NETDEV_PORTS_HASH_INT(port_no, dpif_class); struct port_to_netdev_data *data; - HMAP_FOR_EACH_WITH_HASH(data, node, hash, &port_to_netdev) { - if (data->dpif_class == dpif_class - && data->dpif_port.port_no == port_no) { - return data; - } + HMAP_FOR_EACH_WITH_HASH (data, node, + netdev_ports_hash(port_no, dpif_class), + &port_to_netdev) { + if (data->dpif_class == dpif_class + && data->dpif_port.port_no == port_no) { + return data; + } } return NULL; } @@ -2203,7 +2206,6 @@ int netdev_ports_insert(struct netdev *netdev, const struct dpif_class *dpif_class, struct dpif_port *dpif_port) { - size_t hash = NETDEV_PORTS_HASH_INT(dpif_port->port_no, dpif_class); struct port_to_netdev_data *data; struct ifindex_to_port_data *ifidx; int ifindex = netdev_get_ifindex(netdev); @@ -2228,7 +2230,8 @@ netdev_ports_insert(struct netdev *netdev, const struct dpif_class *dpif_class, ifidx->port = dpif_port->port_no; ifidx->dpif_class = dpif_class; - hmap_insert(&port_to_netdev, &data->node, hash); + hmap_insert(&port_to_netdev, &data->node, + netdev_ports_hash(dpif_port->port_no, dpif_class)); hmap_insert(&ifindex_to_port, &ifidx->node, ifidx->ifindex); ovs_mutex_unlock(&netdev_hmap_mutex); |