projects
/
openvswitch
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ofproto: Add extra comments and checking for expiring a pending rule.
[openvswitch]
/
lib
/
dpif-netdev.c
diff --git
a/lib/dpif-netdev.c
b/lib/dpif-netdev.c
index a38e56bbe74a8bc25e46b30a019ee9dd2546a234..5f7ce8ff2a87714a1dce75c450a3a07e2fe7838b 100644
(file)
--- a/
lib/dpif-netdev.c
+++ b/
lib/dpif-netdev.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (c) 2009, 2010, 2011, 2012 Nicira
Networks
.
+ * Copyright (c) 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.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-113,7
+113,7
@@
struct dp_netdev_flow {
long long int used; /* Last used time, in monotonic msecs. */
long long int packet_count; /* Number of packets matched. */
long long int byte_count; /* Number of bytes matched. */
long long int used; /* Last used time, in monotonic msecs. */
long long int packet_count; /* Number of packets matched. */
long long int byte_count; /* Number of bytes matched. */
-
ovs_be16 tcp_ctl; /* Bitwise-OR of seen tcp_ctl
values. */
+
uint8_t tcp_flags; /* Bitwise-OR of seen tcp_flags
values. */
/* Actions. */
struct nlattr *actions;
/* Actions. */
struct nlattr *actions;
@@
-165,6
+165,17
@@
get_dp_netdev(const struct dpif *dpif)
return dpif_netdev_cast(dpif)->dp;
}
return dpif_netdev_cast(dpif)->dp;
}
+static int
+dpif_netdev_enumerate(struct sset *all_dps)
+{
+ struct shash_node *node;
+
+ SHASH_FOR_EACH(node, &dp_netdevs) {
+ sset_add(all_dps, node->name);
+ }
+ return 0;
+}
+
static struct dpif *
create_dpif_netdev(struct dp_netdev *dp)
{
static struct dpif *
create_dpif_netdev(struct dp_netdev *dp)
{
@@
-627,7
+638,7
@@
get_dpif_flow_stats(struct dp_netdev_flow *flow, struct dpif_flow_stats *stats)
stats->n_packets = flow->packet_count;
stats->n_bytes = flow->byte_count;
stats->used = flow->used;
stats->n_packets = flow->packet_count;
stats->n_bytes = flow->byte_count;
stats->used = flow->used;
- stats->tcp_flags =
TCP_FLAGS(flow->tcp_ctl)
;
+ stats->tcp_flags =
flow->tcp_flags
;
}
static int
}
static int
@@
-702,10
+713,9
@@
set_flow_actions(struct dp_netdev_flow *flow,
}
static int
}
static int
-
add_flow(struct dpif *dpif
, const struct flow *key,
- const struct nlattr *actions, size_t actions_len)
+
dp_netdev_flow_add(struct dp_netdev *dp
, const struct flow *key,
+
const struct nlattr *actions, size_t actions_len)
{
{
- struct dp_netdev *dp = get_dp_netdev(dpif);
struct dp_netdev_flow *flow;
int error;
struct dp_netdev_flow *flow;
int error;
@@
-728,7
+738,7
@@
clear_stats(struct dp_netdev_flow *flow)
flow->used = 0;
flow->packet_count = 0;
flow->byte_count = 0;
flow->used = 0;
flow->packet_count = 0;
flow->byte_count = 0;
- flow->tcp_
ctl
= 0;
+ flow->tcp_
flags
= 0;
}
static int
}
static int
@@
-751,7
+761,8
@@
dpif_netdev_flow_put(struct dpif *dpif, const struct dpif_flow_put *put)
if (put->stats) {
memset(put->stats, 0, sizeof *put->stats);
}
if (put->stats) {
memset(put->stats, 0, sizeof *put->stats);
}
- return add_flow(dpif, &key, put->actions, put->actions_len);
+ return dp_netdev_flow_add(dp, &key, put->actions,
+ put->actions_len);
} else {
return EFBIG;
}
} else {
return EFBIG;
}
@@
-777,24
+788,22
@@
dpif_netdev_flow_put(struct dpif *dpif, const struct dpif_flow_put *put)
}
static int
}
static int
-dpif_netdev_flow_del(struct dpif *dpif,
- const struct nlattr *nl_key, size_t nl_key_len,
- struct dpif_flow_stats *stats)
+dpif_netdev_flow_del(struct dpif *dpif, const struct dpif_flow_del *del)
{
struct dp_netdev *dp = get_dp_netdev(dpif);
struct dp_netdev_flow *flow;
struct flow key;
int error;
{
struct dp_netdev *dp = get_dp_netdev(dpif);
struct dp_netdev_flow *flow;
struct flow key;
int error;
- error = dpif_netdev_flow_from_nlattrs(
nl_key, nl_
key_len, &key);
+ error = dpif_netdev_flow_from_nlattrs(
del->key, del->
key_len, &key);
if (error) {
return error;
}
flow = dp_netdev_lookup_flow(dp, &key);
if (flow) {
if (error) {
return error;
}
flow = dp_netdev_lookup_flow(dp, &key);
if (flow) {
- if (stats) {
- get_dpif_flow_stats(flow, stats);
+ if (
del->
stats) {
+ get_dpif_flow_stats(flow,
del->
stats);
}
dp_netdev_free_flow(dp, flow);
return 0;
}
dp_netdev_free_flow(dp, flow);
return 0;
@@
-937,7
+946,8
@@
find_nonempty_queue(struct dpif *dpif)
}
static int
}
static int
-dpif_netdev_recv(struct dpif *dpif, struct dpif_upcall *upcall)
+dpif_netdev_recv(struct dpif *dpif, struct dpif_upcall *upcall,
+ struct ofpbuf *buf)
{
struct dp_netdev_queue *q = find_nonempty_queue(dpif);
if (q) {
{
struct dp_netdev_queue *q = find_nonempty_queue(dpif);
if (q) {
@@
-945,6
+955,9
@@
dpif_netdev_recv(struct dpif *dpif, struct dpif_upcall *upcall)
*upcall = *u;
free(u);
*upcall = *u;
free(u);
+ ofpbuf_uninit(buf);
+ *buf = *upcall->packet;
+
return 0;
} else {
return EAGAIN;
return 0;
} else {
return EAGAIN;
@@
-976,12
+989,7
@@
dp_netdev_flow_used(struct dp_netdev_flow *flow, struct flow *key,
flow->used = time_msec();
flow->packet_count++;
flow->byte_count += packet->size;
flow->used = time_msec();
flow->packet_count++;
flow->byte_count += packet->size;
- if ((key->dl_type == htons(ETH_TYPE_IP) ||
- key->dl_type == htons(ETH_TYPE_IPV6)) &&
- key->nw_proto == IPPROTO_TCP && packet->l7) {
- struct tcp_header *th = packet->l4;
- flow->tcp_ctl |= th->tcp_ctl;
- }
+ flow->tcp_flags |= packet_get_tcp_flags(packet, key);
}
static void
}
static void
@@
-1244,7
+1252,7
@@
dp_netdev_execute_actions(struct dp_netdev *dp,
const struct dpif_class dpif_netdev_class = {
"netdev",
const struct dpif_class dpif_netdev_class = {
"netdev",
- NULL, /* enumerate */
+ dpif_netdev_enumerate,
dpif_netdev_open,
dpif_netdev_close,
dpif_netdev_destroy,
dpif_netdev_open,
dpif_netdev_close,
dpif_netdev_destroy,