diff mbox

[ovs-dev,2/4] expr: Fix abort when simplifying "x != 0/0".

Message ID 1475811039-31662-2-git-send-email-blp@ovn.org
State Accepted
Headers show

Commit Message

Ben Pfaff Oct. 7, 2016, 3:30 a.m. UTC
The test added by this commit is very specific to the particular problem,
whereas a more general test would be better.  A later commit adds the
general test.

Signed-off-by: Ben Pfaff <blp@ovn.org>
---
 ovn/lib/expr.c | 11 ++++++++++-
 tests/ovn.at   |  2 ++
 2 files changed, 12 insertions(+), 1 deletion(-)

Comments

Andy Zhou Oct. 10, 2016, 11:48 p.m. UTC | #1
On Thu, Oct 6, 2016 at 8:30 PM, Ben Pfaff <blp@ovn.org> wrote:

> The test added by this commit is very specific to the particular problem,
> whereas a more general test would be better.  A later commit adds the
> general test.
>
> Signed-off-by: Ben Pfaff <blp@ovn.org>
>
Acked-by: Andy Zhou <azhou@ovn.org>
diff mbox

Patch

diff --git a/ovn/lib/expr.c b/ovn/lib/expr.c
index a5dbcfa..a197474 100644
--- a/ovn/lib/expr.c
+++ b/ovn/lib/expr.c
@@ -1702,7 +1702,16 @@  expr_simplify_ne(struct expr *expr)
 
         new = expr_combine(EXPR_T_OR, new, e);
     }
-    ovs_assert(new);
+    if (!new) {
+        /* Handle a comparison like "ip4.dst != 0/0", where the mask has no
+         * 1-bits.
+         *
+         * The correct result for this expression may not be obvious.  It's
+         * easier to understand that "ip4.dst == 0/0" should be true, since 0/0
+         * matches every IPv4 address; then, "ip4.dst != 0/0" should have the
+         * opposite result. */
+        new = expr_create_boolean(false);
+    }
 
     expr_destroy(expr);
 
diff --git a/tests/ovn.at b/tests/ovn.at
index b2808e2..47153a4 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -431,6 +431,8 @@  simplify() {
 }
 AT_CHECK([simplify 'eth.dst == 0/0'], [0], [1
 ])
+AT_CHECK([simplify 'eth.dst != 0/0'], [0], [0
+])
 AT_CLEANUP
 
 AT_SETUP([ovn -- 4-term numeric expression normalization])