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

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