[ovs-dev,03/10] userspace: Filter field packet_type in table_features

Message ID AM2PR07MB1042F87936471750A3E476EB8A190@AM2PR07MB1042.eurprd07.prod.outlook.com
State Deferred
Headers show

Commit Message

Zoltan Balogh April 18, 2017, 11:19 a.m.
From: Jan Scheurich <jan.scheurich@ericsson.com>

Only include field MFF_PACKET_TYPE in matchabale and maskable fields
if the ofproto bridge is packet-type-aware.

Removed packet_type from list of matching properties in tests/ofproto.at.

Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com>
---
 lib/nx-match.c    | 10 ++++++++--
 lib/nx-match.h    |  4 ++--
 ofproto/ofproto.c |  4 ++--
 tests/ofproto.at  |  1 -
 4 files changed, 12 insertions(+), 7 deletions(-)

Patch

diff --git a/lib/nx-match.c b/lib/nx-match.c
index af19fb2..f9d8565 100644
--- a/lib/nx-match.c
+++ b/lib/nx-match.c
@@ -2071,12 +2071,15 @@  oxm_writable_fields(void)
 /* Returns a bitmap of fields that can be encoded in OXM and that can be
  * matched in a flow table.  */
 struct mf_bitmap
-oxm_matchable_fields(void)
+oxm_matchable_fields(bool packet_type_aware)
 {
     struct mf_bitmap b = MF_BITMAP_INITIALIZER;
     int i;
 
     for (i = 0; i < MFF_N_IDS; i++) {
+        if (i == MFF_PACKET_TYPE && !packet_type_aware) {
+            continue;
+        }
         if (mf_oxm_header(i, 0)) {
             bitmap_set1(b.bm, i);
         }
@@ -2087,12 +2090,15 @@  oxm_matchable_fields(void)
 /* Returns a bitmap of fields that can be encoded in OXM and that can be
  * matched in a flow table with an arbitrary bitmask.  */
 struct mf_bitmap
-oxm_maskable_fields(void)
+oxm_maskable_fields(bool packet_type_aware)
 {
     struct mf_bitmap b = MF_BITMAP_INITIALIZER;
     int i;
 
     for (i = 0; i < MFF_N_IDS; i++) {
+        if (i == MFF_PACKET_TYPE && !packet_type_aware) {
+            continue;
+        }
         if (mf_oxm_header(i, 0) && mf_from_id(i)->maskable == MFM_FULLY) {
             bitmap_set1(b.bm, i);
         }
diff --git a/lib/nx-match.h b/lib/nx-match.h
index 6afb310..f75ce10 100644
--- a/lib/nx-match.h
+++ b/lib/nx-match.h
@@ -147,8 +147,8 @@  ovs_be64 oxm_bitmap_from_mf_bitmap(const struct mf_bitmap *, enum ofp_version);
 struct mf_bitmap oxm_bitmap_to_mf_bitmap(ovs_be64 oxm_bitmap,
                                          enum ofp_version);
 struct mf_bitmap oxm_writable_fields(void);
-struct mf_bitmap oxm_matchable_fields(void);
-struct mf_bitmap oxm_maskable_fields(void);
+struct mf_bitmap oxm_matchable_fields(bool packet_type_aware);
+struct mf_bitmap oxm_maskable_fields(bool packet_type_aware);
 
 /* Dealing with the 'ofs_nbits' members in several Nicira extensions. */
 
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 81fe02a..c21a6e1 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -3213,8 +3213,8 @@  query_tables(struct ofproto *ofproto,
              struct ofputil_table_stats **statsp)
 {
     struct mf_bitmap rw_fields = oxm_writable_fields();
-    struct mf_bitmap match = oxm_matchable_fields();
-    struct mf_bitmap mask = oxm_maskable_fields();
+    struct mf_bitmap match = oxm_matchable_fields(ofproto->packet_type_aware);
+    struct mf_bitmap mask = oxm_maskable_fields(ofproto->packet_type_aware);
 
     struct ofputil_table_features *features;
     struct ofputil_table_stats *stats;
diff --git a/tests/ofproto.at b/tests/ofproto.at
index 66ee695..5c0d076 100644
--- a/tests/ofproto.at
+++ b/tests/ofproto.at
@@ -2390,7 +2390,6 @@  metadata in_port in_port_oxm pkt_mark ct_mark ct_label reg0 reg1 reg2 reg3 reg4
     matching:
       dp_hash: arbitrary mask
       recirc_id: exact match or wildcard
-      packet_type: exact match or wildcard
       conj_id: exact match or wildcard
       tun_id: arbitrary mask
       tun_src: arbitrary mask