summaryrefslogtreecommitdiff
path: root/ofproto
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2015-01-06 09:27:32 -0800
committerBen Pfaff <blp@nicira.com>2015-01-06 09:27:32 -0800
commit3fbbcba77615e6f14d0ee4f8d40b9b4838c2ac20 (patch)
tree8398912ecc4e67645cd95c7924c3d717cae96f0c /ofproto
parent9e917416f87a18e9deb2480f32a4ff9c0f9d194c (diff)
downloadopenvswitch-3fbbcba77615e6f14d0ee4f8d40b9b4838c2ac20.tar.gz
ofproto: Don't count hidden rules in table stats.
The hidden rules created by in-band control and fail-open should not be included in the table stats reported via OpenFlow. I seem to recall that this was done correctly in some previous version but it has broken since then. This commit fixes the problem and adds a test that should make it harder to break again in the future. Reported-by: Ashok Chippa <a.n.chippa@gmail.com> Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
Diffstat (limited to 'ofproto')
-rw-r--r--ofproto/connmgr.c19
-rw-r--r--ofproto/connmgr.h4
-rw-r--r--ofproto/fail-open.c13
-rw-r--r--ofproto/fail-open.h4
-rw-r--r--ofproto/in-band.c10
-rw-r--r--ofproto/in-band.h4
-rw-r--r--ofproto/ofproto.c6
7 files changed, 53 insertions, 7 deletions
diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c
index 08abe1edd..3d691227c 100644
--- a/ofproto/connmgr.c
+++ b/ofproto/connmgr.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1980,6 +1980,23 @@ connmgr_flushed(struct connmgr *mgr)
ofpbuf_uninit(&ofpacts);
}
}
+
+/* Returns the number of hidden rules created by the in-band and fail-open
+ * implementations in table 0. (Subtracting this count from the number of
+ * rules in the table 0 classifier, as returned by classifier_count(), yields
+ * the number of flows that OVS should report via OpenFlow for table 0.) */
+int
+connmgr_count_hidden_rules(const struct connmgr *mgr)
+{
+ int n_hidden = 0;
+ if (mgr->in_band) {
+ n_hidden += in_band_count_rules(mgr->in_band);
+ }
+ if (mgr->fail_open) {
+ n_hidden += fail_open_count_rules(mgr->fail_open);
+ }
+ return n_hidden;
+}
/* Creates a new ofservice for 'target' in 'mgr'. Returns 0 if successful,
* otherwise a positive errno value.
diff --git a/ofproto/connmgr.h b/ofproto/connmgr.h
index c0f7c3579..dd1a027e3 100644
--- a/ofproto/connmgr.h
+++ b/ofproto/connmgr.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -193,6 +193,8 @@ bool connmgr_has_in_band(struct connmgr *);
/* Fail-open and in-band implementation. */
void connmgr_flushed(struct connmgr *);
+int connmgr_count_hidden_rules(const struct connmgr *);
+
/* A flow monitor managed by NXST_FLOW_MONITOR and related requests. */
struct ofmonitor {
struct ofconn *ofconn; /* Owning 'ofconn'. */
diff --git a/ofproto/fail-open.c b/ofproto/fail-open.c
index ecdba4467..75c7d1c80 100644
--- a/ofproto/fail-open.c
+++ b/ofproto/fail-open.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2015 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -76,6 +76,7 @@ struct fail_open {
int last_disconn_secs;
long long int next_bogus_packet_in;
struct rconn_packet_counter *bogus_packet_counter;
+ bool fail_open_active;
};
static void fail_open_recover(struct fail_open *);
@@ -234,6 +235,15 @@ fail_open_flushed(struct fail_open *fo)
ofpbuf_uninit(&ofpacts);
}
+ fo->fail_open_active = open;
+}
+
+/* Returns the number of fail-open rules currently installed in the flow
+ * table. */
+int
+fail_open_count_rules(const struct fail_open *fo)
+{
+ return fo->fail_open_active != 0;
}
/* Creates and returns a new struct fail_open for 'ofproto' and 'mgr'. */
@@ -246,6 +256,7 @@ fail_open_create(struct ofproto *ofproto, struct connmgr *mgr)
fo->last_disconn_secs = 0;
fo->next_bogus_packet_in = LLONG_MAX;
fo->bogus_packet_counter = rconn_packet_counter_create();
+ fo->fail_open_active = false;
return fo;
}
diff --git a/ofproto/fail-open.h b/ofproto/fail-open.h
index 725b82ddf..4056b3e8d 100644
--- a/ofproto/fail-open.h
+++ b/ofproto/fail-open.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2013 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2013, 2015 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,4 +47,6 @@ void fail_open_run(struct fail_open *);
void fail_open_maybe_recover(struct fail_open *) OVS_EXCLUDED(ofproto_mutex);
void fail_open_flushed(struct fail_open *) OVS_EXCLUDED(ofproto_mutex);
+int fail_open_count_rules(const struct fail_open *);
+
#endif /* fail-open.h */
diff --git a/ofproto/in-band.c b/ofproto/in-band.c
index bde893a22..01950facc 100644
--- a/ofproto/in-band.c
+++ b/ofproto/in-band.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -235,6 +235,14 @@ in_band_must_output_to_local_port(const struct flow *flow)
&& flow->tp_dst == htons(DHCP_CLIENT_PORT));
}
+/* Returns the number of in-band rules currently installed in the flow
+ * table. */
+int
+in_band_count_rules(const struct in_band *ib)
+{
+ return hmap_count(&ib->rules);
+}
+
static void
add_rule(struct in_band *ib, const struct match *match, int priority)
{
diff --git a/ofproto/in-band.h b/ofproto/in-band.h
index ad16dc2cb..6e0585ad3 100644
--- a/ofproto/in-band.h
+++ b/ofproto/in-band.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2013 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2013, 2015 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,4 +42,6 @@ void in_band_wait(struct in_band *);
bool in_band_must_output_to_local_port(const struct flow *);
+int in_band_count_rules(const struct in_band *);
+
#endif /* in-band.h */
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 6d78fe4a9..34defce63 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
+ * Copyright (c) 2009-2015 Nicira, Inc.
* Copyright (c) 2010 Jean Tourrilhes - HP-Labs.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -2963,6 +2963,10 @@ query_tables(struct ofproto *ofproto,
s->table_id = i;
s->active_count = classifier_count(cls);
+ if (i == 0) {
+ s->active_count -= connmgr_count_hidden_rules(
+ ofproto->connmgr);
+ }
}
} else {
stats = NULL;