Blame SOURCES/0035-mergesort-unbreak-listing-with-binops.patch

fdae68
From 9d67918643e7d17c433e82eb6cdb039cb103c50f Mon Sep 17 00:00:00 2001
fdae68
From: Phil Sutter <psutter@redhat.com>
fdae68
Date: Mon, 7 Dec 2020 18:26:24 +0100
fdae68
Subject: [PATCH] mergesort: unbreak listing with binops
fdae68
fdae68
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1891790
fdae68
Upstream Status: nftables commit 3926a3369bb5a
fdae68
fdae68
commit 3926a3369bb5ada5c0706dadcbcf938517822a35
fdae68
Author: Pablo Neira Ayuso <pablo@netfilter.org>
fdae68
Date:   Thu Aug 20 01:05:04 2020 +0200
fdae68
fdae68
    mergesort: unbreak listing with binops
fdae68
fdae68
    tcp flags == {syn, syn|ack}
fdae68
    tcp flags & (fin|syn|rst|psh|ack|urg) == {ack, psh|ack, fin, fin|psh|ack}
fdae68
fdae68
    results in:
fdae68
fdae68
    BUG: Unknown expression binop
fdae68
    nft: mergesort.c:47: expr_msort_cmp: Assertion `0' failed.
fdae68
    Aborted (core dumped)
fdae68
fdae68
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
fdae68
---
fdae68
 src/mergesort.c             |  2 ++
fdae68
 tests/py/inet/tcp.t         |  2 ++
fdae68
 tests/py/inet/tcp.t.payload | 21 +++++++++++++++++++++
fdae68
 3 files changed, 25 insertions(+)
fdae68
fdae68
diff --git a/src/mergesort.c b/src/mergesort.c
fdae68
index 649b780..02094b4 100644
fdae68
--- a/src/mergesort.c
fdae68
+++ b/src/mergesort.c
fdae68
@@ -43,6 +43,8 @@ static int expr_msort_cmp(const struct expr *e1, const struct expr *e2)
fdae68
 		return concat_expr_msort_cmp(e1, e2);
fdae68
 	case EXPR_MAPPING:
fdae68
 		return expr_msort_cmp(e1->left, e2->left);
fdae68
+	case EXPR_BINOP:
fdae68
+		return expr_msort_cmp(e1->left, e2->left);
fdae68
 	default:
fdae68
 		BUG("Unknown expression %s\n", expr_name(e1));
fdae68
 	}
fdae68
diff --git a/tests/py/inet/tcp.t b/tests/py/inet/tcp.t
fdae68
index e0a83e2..29f06f5 100644
fdae68
--- a/tests/py/inet/tcp.t
fdae68
+++ b/tests/py/inet/tcp.t
fdae68
@@ -79,6 +79,8 @@ tcp flags != cwr;ok
fdae68
 tcp flags == syn;ok
fdae68
 tcp flags & (syn|fin) == (syn|fin);ok;tcp flags & (fin | syn) == fin | syn
fdae68
 tcp flags & (fin | syn | rst | psh | ack | urg | ecn | cwr) == fin | syn | rst | psh | ack | urg | ecn | cwr;ok;tcp flags == 0xff
fdae68
+tcp flags { syn, syn | ack };ok
fdae68
+tcp flags & (fin | syn | rst | psh | ack | urg) == { fin, ack, psh | ack, fin | psh | ack };ok
fdae68
 
fdae68
 tcp window 22222;ok
fdae68
 tcp window 22;ok
fdae68
diff --git a/tests/py/inet/tcp.t.payload b/tests/py/inet/tcp.t.payload
fdae68
index 55f1bc2..076e562 100644
fdae68
--- a/tests/py/inet/tcp.t.payload
fdae68
+++ b/tests/py/inet/tcp.t.payload
fdae68
@@ -680,3 +680,24 @@ inet test-inet input
fdae68
   [ bitwise reg 1 = (reg=1 & 0x000000f0 ) ^ 0x00000000 ]
fdae68
   [ cmp eq reg 1 0x00000080 ]
fdae68
 
fdae68
+# tcp flags & (fin | syn | rst | psh | ack | urg) == { fin, ack, psh | ack, fin | psh | ack }
fdae68
+__set%d test-inet 3
fdae68
+__set%d test-inet 0
fdae68
+        element 00000001  : 0 [end]     element 00000010  : 0 [end]     element 00000018  : 0 [end]     element 00000019  : 0 [end]
fdae68
+ip
fdae68
+  [ meta load l4proto => reg 1 ]
fdae68
+  [ cmp eq reg 1 0x00000006 ]
fdae68
+  [ payload load 1b @ transport header + 13 => reg 1 ]
fdae68
+  [ bitwise reg 1 = (reg=1 & 0x0000003f ) ^ 0x00000000 ]
fdae68
+  [ lookup reg 1 set __set%d ]
fdae68
+
fdae68
+# tcp flags { syn, syn | ack }
fdae68
+__set%d test-inet 3
fdae68
+__set%d test-inet 0
fdae68
+        element 00000002  : 0 [end]     element 00000012  : 0 [end]
fdae68
+inet
fdae68
+  [ meta load l4proto => reg 1 ]
fdae68
+  [ cmp eq reg 1 0x00000006 ]
fdae68
+  [ payload load 1b @ transport header + 13 => reg 1 ]
fdae68
+  [ lookup reg 1 set __set%d ]
fdae68
+
fdae68
-- 
252916
2.31.1
fdae68