const struct ofputil_flow_mod *,
const struct ofp_header *);
static void delete_flow__(struct rule *, struct ofopgroup *);
-static bool handle_openflow(struct ofconn *, struct ofpbuf *);
+static bool handle_openflow(struct ofconn *, const struct ofpbuf *);
static enum ofperr handle_flow_mod__(struct ofproto *, struct ofconn *,
const struct ofputil_flow_mod *,
const struct ofp_header *);
+static void calc_duration(long long int start, long long int now,
+ uint32_t *sec, uint32_t *nsec);
/* ofproto. */
static uint64_t pick_datapath_id(const struct ofproto *);
static size_t n_ofproto_classes;
static size_t allocated_ofproto_classes;
+unsigned flow_eviction_threshold = OFPROTO_FLOW_EVICTION_THRESHOLD_DEFAULT;
+
/* Map from datapath name to struct ofproto, for use by unixctl commands. */
static struct hmap all_ofprotos = HMAP_INITIALIZER(&all_ofprotos);
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
+/* The default value of true waits for flow restore. */
+static bool flow_restore_wait = true;
+
/* Must be called to initialize the ofproto library.
*
* The caller may pass in 'iface_hints', which contains an shash of
hmap_insert(&all_ofprotos, &ofproto->hmap_node,
hash_string(ofproto->name, 0));
ofproto->datapath_id = 0;
- ofproto_set_flow_eviction_threshold(ofproto,
- OFPROTO_FLOW_EVICTION_THRESHOLD_DEFAULT);
ofproto->forward_bpdu = false;
ofproto->fallback_dpid = pick_fallback_dpid();
ofproto->mfr_desc = NULL;
/* Sets the number of flows at which eviction from the kernel flow table
* will occur. */
void
-ofproto_set_flow_eviction_threshold(struct ofproto *ofproto, unsigned threshold)
+ofproto_set_flow_eviction_threshold(unsigned threshold)
{
- if (threshold < OFPROTO_FLOW_EVICTION_THRESHOLD_MIN) {
- ofproto->flow_eviction_threshold = OFPROTO_FLOW_EVICTION_THRESHOLD_MIN;
- } else {
- ofproto->flow_eviction_threshold = threshold;
- }
+ flow_eviction_threshold = MAX(OFPROTO_FLOW_EVICTION_THRESHOLD_MIN,
+ threshold);
}
/* If forward_bpdu is true, the NORMAL action will forward frames with
return (bo || fo) ? EOPNOTSUPP : 0;
}
}
+
+void
+ofproto_set_flow_restore_wait(bool flow_restore_wait_db)
+{
+ flow_restore_wait = flow_restore_wait_db;
+}
+
+bool
+ofproto_get_flow_restore_wait(void)
+{
+ return flow_restore_wait;
+}
+
\f
/* Spanning Tree Protocol (STP) configuration. */
if (!ofport) {
VLOG_WARN("%s: cannot configure bfd on nonexistent port %"PRIu16,
ofproto->name, ofp_port);
+ return;
}
error = (ofproto->ofproto_class->set_bfd
ofport->change_seq = netdev_change_seq(netdev);
ofport->pp = *pp;
ofport->ofp_port = pp->port_no;
+ ofport->created = time_msec();
/* Add port to 'p'. */
hmap_insert(&p->ports, &ofport->hmap_node, hash_int(ofport->ofp_port, 0));
{
struct ofputil_port_stats ops = { .port_no = port->pp.port_no };
+ calc_duration(port->created, time_msec(),
+ &ops.duration_sec, &ops.duration_nsec);
+
/* Intentionally ignore return value, since errors will set
* 'stats' to all-1s, which is correct for OpenFlow, and
* netdev_get_stats() will log errors. */
}
static void
-calc_flow_duration__(long long int start, long long int now,
- uint32_t *sec, uint32_t *nsec)
+calc_duration(long long int start, long long int now,
+ uint32_t *sec, uint32_t *nsec)
{
long long int msecs = now - start;
*sec = msecs / 1000;
fs.priority = rule->cr.priority;
fs.cookie = rule->flow_cookie;
fs.table_id = rule->table_id;
- calc_flow_duration__(rule->created, now, &fs.duration_sec,
- &fs.duration_nsec);
+ calc_duration(rule->created, now, &fs.duration_sec, &fs.duration_nsec);
fs.idle_timeout = rule->idle_timeout;
fs.hard_timeout = rule->hard_timeout;
fs.idle_age = age_secs(now - rule->used);
struct oftable *table;
struct ofopgroup *group;
struct rule *victim;
- struct cls_rule cr;
struct rule *rule;
+ uint8_t table_id;
int error;
error = check_table_id(ofproto, fm->table_id);
/* Pick table. */
if (fm->table_id == 0xff) {
- uint8_t table_id;
if (ofproto->ofproto_class->rule_choose_table) {
error = ofproto->ofproto_class->rule_choose_table(ofproto,
&fm->match,
return error;
}
ovs_assert(table_id < ofproto->n_tables);
- table = &ofproto->tables[table_id];
} else {
- table = &ofproto->tables[0];
+ table_id = 0;
}
} else if (fm->table_id < ofproto->n_tables) {
- table = &ofproto->tables[fm->table_id];
+ table_id = fm->table_id;
} else {
return OFPERR_OFPBRC_BAD_TABLE_ID;
}
+ table = &ofproto->tables[table_id];
+
if (table->flags & OFTABLE_READONLY) {
return OFPERR_OFPBRC_EPERM;
}
cls_rule_init(&rule->cr, &fm->match, fm->priority);
/* Serialize against pending deletion. */
- if (is_flow_deletion_pending(ofproto, &cr, table - ofproto->tables)) {
+ if (is_flow_deletion_pending(ofproto, &rule->cr, table_id)) {
cls_rule_destroy(&rule->cr);
ofproto->ofproto_class->rule_dealloc(rule);
return OFPROTO_POSTPONE;
fr.cookie = rule->flow_cookie;
fr.reason = reason;
fr.table_id = rule->table_id;
- calc_flow_duration__(rule->created, time_msec(),
- &fr.duration_sec, &fr.duration_nsec);
+ calc_duration(rule->created, time_msec(),
+ &fr.duration_sec, &fr.duration_nsec);
fr.idle_timeout = rule->idle_timeout;
fr.hard_timeout = rule->hard_timeout;
rule->ofproto->ofproto_class->rule_get_stats(rule, &fr.packet_count,
}
static bool
-handle_openflow(struct ofconn *ofconn, struct ofpbuf *ofp_msg)
+handle_openflow(struct ofconn *ofconn, const struct ofpbuf *ofp_msg)
{
int error = handle_openflow__(ofconn, ofp_msg);
if (error && error != OFPROTO_POSTPONE) {