X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fdpif.c;h=68af298ffaf9c89df3cf4796e673088e6cd36ae5;hb=7a97619ae4484604c15b846ce7268094e048729a;hp=7cf5fba4b3ce82b5eab102253bf9a6ac68bd8563;hpb=112bc5f46f04c46e1d4fbfaa93f76ea39b39b66e;p=sliver-openvswitch.git diff --git a/lib/dpif.c b/lib/dpif.c index 7cf5fba4b..68af298ff 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira Networks. + * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,10 +58,11 @@ COVERAGE_DEFINE(dpif_execute); COVERAGE_DEFINE(dpif_purge); static const struct dpif_class *base_dpif_classes[] = { -#ifdef HAVE_NETLINK +#ifdef LINUX_DATAPATH &dpif_linux_class, #endif &dpif_netdev_class, + &dpif_planetlab_class, }; struct registered_dpif_class { @@ -410,19 +411,27 @@ dpif_get_dp_stats(const struct dpif *dpif, struct dpif_dp_stats *stats) return error; } -/* Attempts to add 'netdev' as a port on 'dpif'. If successful, returns 0 and - * sets '*port_nop' to the new port's port number (if 'port_nop' is non-null). - * On failure, returns a positive errno value and sets '*port_nop' to - * UINT16_MAX (if 'port_nop' is non-null). */ +/* Attempts to add 'netdev' as a port on 'dpif'. If 'port_nop' is + * non-null and its value is not UINT16_MAX, then attempts to use the + * value as the port number. + * + * If successful, returns 0 and sets '*port_nop' to the new port's port + * number (if 'port_nop' is non-null). On failure, returns a positive + * errno value and sets '*port_nop' to UINT16_MAX (if 'port_nop' is + * non-null). */ int dpif_port_add(struct dpif *dpif, struct netdev *netdev, uint16_t *port_nop) { const char *netdev_name = netdev_get_name(netdev); - uint16_t port_no; + uint16_t port_no = UINT16_MAX; int error; COVERAGE_INC(dpif_port_add); + if (port_nop) { + port_no = *port_nop; + } + error = dpif->dpif_class->port_add(dpif, netdev, &port_no); if (!error) { VLOG_DBG_RL(&dpmsg_rl, "%s: added %s as port %"PRIu16, @@ -541,6 +550,9 @@ dpif_get_max_ports(const struct dpif *dpif) * as the OVS_USERSPACE_ATTR_PID attribute's value, for use in flows whose * packets arrived on port 'port_no'. * + * A 'port_no' of UINT16_MAX is a special case: it returns a reserved PID, not + * allocated to any port, that the client may use for special purposes. + * * The return value is only meaningful when DPIF_UC_ACTION has been enabled in * the 'dpif''s listen mask. It is allowed to change when DPIF_UC_ACTION is * disabled and then re-enabled, so a client that does that must be prepared to @@ -674,15 +686,16 @@ dpif_port_poll_wait(const struct dpif *dpif) } /* Extracts the flow stats for a packet. The 'flow' and 'packet' - * arguments must have been initialized through a call to flow_extract(). */ + * arguments must have been initialized through a call to flow_extract(). + * 'used' is stored into stats->used. */ void dpif_flow_stats_extract(const struct flow *flow, const struct ofpbuf *packet, - struct dpif_flow_stats *stats) + long long int used, struct dpif_flow_stats *stats) { stats->tcp_flags = packet_get_tcp_flags(packet, flow); stats->n_bytes = packet->size; stats->n_packets = 1; - stats->used = time_msec(); + stats->used = used; } /* Appends a human-readable representation of 'stats' to 's'. */ @@ -965,7 +978,7 @@ dpif_execute__(struct dpif *dpif, const struct dpif_execute *execute) * the Ethernet frame specified in 'packet' taken from the flow specified in * the 'key_len' bytes of 'key'. ('key' is mostly redundant with 'packet', but * it contains some metadata that cannot be recovered from 'packet', such as - * tun_id and in_port.) + * tunnel and in_port.) * * Returns 0 if successful, otherwise a positive errno value. */ int