From 788c986343bc24bd0272e8aa409121ffe51f1ef3 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Mon, 15 Aug 2016 13:14:18 +0200 Subject: src: quote user-defined strings when used from rule selectors The following selectors display strings using quotes: * meta iifname * meta oifname * meta ibriport * meta obriport However, the following do not: * meta oif * meta iif * meta skuid * meta skgid * meta iifgroup * meta oifgroup * meta rtclassid * ct label Given they refer to user-defined values, neither keywords nor internal built-in known values, let's quote the output of this. This patch modifies symbolic_constant_print() so we can signal this to indicate if the string needs to be quoted. Signed-off-by: Pablo Neira Ayuso --- tests/py/ip6/dup.t | 4 ++-- tests/py/ip6/dup.t.payload | 4 ++-- tests/py/ip6/ip6.t | 24 ++++++++++++------------ tests/py/ip6/ip6.t.payload.inet | 18 +++++++++--------- tests/py/ip6/ip6.t.payload.ip6 | 18 +++++++++--------- 5 files changed, 34 insertions(+), 34 deletions(-) (limited to 'tests/py/ip6') diff --git a/tests/py/ip6/dup.t b/tests/py/ip6/dup.t index e6bb78b8..f3c8c839 100644 --- a/tests/py/ip6/dup.t +++ b/tests/py/ip6/dup.t @@ -3,5 +3,5 @@ *ip6;test-ip6;input dup to abcd::1;ok -dup to abcd::1 device eth0;ok -dup to ip6 saddr map { abcd::1 : cafe::cafe } device eth0;ok +dup to abcd::1 device "eth0";ok +dup to ip6 saddr map { abcd::1 : cafe::cafe } device "eth0";ok diff --git a/tests/py/ip6/dup.t.payload b/tests/py/ip6/dup.t.payload index be507780..30015cc9 100644 --- a/tests/py/ip6/dup.t.payload +++ b/tests/py/ip6/dup.t.payload @@ -3,13 +3,13 @@ ip6 test test [ immediate reg 1 0x0000cdab 0x00000000 0x00000000 0x01000000 ] [ dup sreg_addr 1 ] -# dup to abcd::1 device eth0 +# dup to abcd::1 device "eth0" ip6 test test [ immediate reg 1 0x0000cdab 0x00000000 0x00000000 0x01000000 ] [ immediate reg 2 0x00000002 ] [ dup sreg_addr 1 sreg_dev 2 ] -# dup to ip6 saddr map { abcd::1 : cafe::cafe } device eth0 +# dup to ip6 saddr map { abcd::1 : cafe::cafe } device "eth0" __map%d test-ip6 b __map%d test-ip6 0 element 0000cdab 00000000 00000000 01000000 : 0000feca 00000000 00000000 feca0000 0 [end] diff --git a/tests/py/ip6/ip6.t b/tests/py/ip6/ip6.t index 7dea2f75..9a18f7a4 100644 --- a/tests/py/ip6/ip6.t +++ b/tests/py/ip6/ip6.t @@ -143,17 +143,17 @@ ip6 saddr ::1 ip6 daddr ::2;ok ip6 daddr != ::1234:1234:1234:1234:1234:1234:1234-1234:1234::1234:1234:1234:1234:1234;ok;ip6 daddr != 0:1234:1234:1234:1234:1234:1234:1234-1234:1234:0:1234:1234:1234:1234:1234 # limit impact to lo -iif lo ip6 daddr set ::1;ok -iif lo ip6 hoplimit set 1;ok -iif lo ip6 dscp set af42;ok -iif lo ip6 dscp set 63;ok;iif lo ip6 dscp set 0x3f -iif lo ip6 ecn set ect0;ok -iif lo ip6 ecn set ce;ok +iif "lo" ip6 daddr set ::1;ok +iif "lo" ip6 hoplimit set 1;ok +iif "lo" ip6 dscp set af42;ok +iif "lo" ip6 dscp set 63;ok;iif "lo" ip6 dscp set 0x3f +iif "lo" ip6 ecn set ect0;ok +iif "lo" ip6 ecn set ce;ok -iif lo ip6 flowlabel set 0;ok -iif lo ip6 flowlabel set 12345;ok -iif lo ip6 flowlabel set 0xfffff;ok;iif lo ip6 flowlabel set 1048575 +iif "lo" ip6 flowlabel set 0;ok +iif "lo" ip6 flowlabel set 12345;ok +iif "lo" ip6 flowlabel set 0xfffff;ok;iif "lo" ip6 flowlabel set 1048575 -iif lo ip6 ecn set 4;fail -iif lo ip6 dscp set 64;fail -iif lo ip6 flowlabel set 1048576;fail +iif "lo" ip6 ecn set 4;fail +iif "lo" ip6 dscp set 64;fail +iif "lo" ip6 flowlabel set 1048576;fail diff --git a/tests/py/ip6/ip6.t.payload.inet b/tests/py/ip6/ip6.t.payload.inet index bf21b5ba..f9512154 100644 --- a/tests/py/ip6/ip6.t.payload.inet +++ b/tests/py/ip6/ip6.t.payload.inet @@ -513,7 +513,7 @@ inet test-inet input [ cmp lt reg 1 0x34120000 0x34123412 0x34123412 0x34123412 ] [ cmp gt reg 1 0x34123412 0x34120000 0x34123412 0x34123412 ] -# iif lo ip6 daddr set ::1 +# iif "lo" ip6 daddr set ::1 inet test-inet input [ meta load iif => reg 1 ] [ cmp eq reg 1 0x00000001 ] @@ -522,7 +522,7 @@ inet test-inet input [ immediate reg 1 0x00000000 0x00000000 0x00000000 0x01000000 ] [ payload write reg 1 => 16b @ network header + 24 csum_type 0 csum_off 0 ] -# iif lo ip6 hoplimit set 1 +# iif "lo" ip6 hoplimit set 1 inet test-inet input [ meta load iif => reg 1 ] [ cmp eq reg 1 0x00000001 ] @@ -531,7 +531,7 @@ inet test-inet input [ immediate reg 1 0x00000001 ] [ payload write reg 1 => 1b @ network header + 7 csum_type 0 csum_off 0 ] -# iif lo ip6 dscp set af42 +# iif "lo" ip6 dscp set af42 inet test-inet input [ meta load iif => reg 1 ] [ cmp eq reg 1 0x00000001 ] @@ -541,7 +541,7 @@ inet test-inet input [ bitwise reg 1 = (reg=1 & 0x00003ff0 ) ^ 0x00000009 ] [ payload write reg 1 => 2b @ network header + 0 csum_type 0 csum_off 0 ] -# iif lo ip6 dscp set 63 +# iif "lo" ip6 dscp set 63 inet test-inet input [ meta load iif => reg 1 ] [ cmp eq reg 1 0x00000001 ] @@ -551,7 +551,7 @@ inet test-inet input [ bitwise reg 1 = (reg=1 & 0x00003ff0 ) ^ 0x0000c00f ] [ payload write reg 1 => 2b @ network header + 0 csum_type 0 csum_off 0 ] -# iif lo ip6 ecn set ect0 +# iif "lo" ip6 ecn set ect0 inet test-inet input [ meta load iif => reg 1 ] [ cmp eq reg 1 0x00000001 ] @@ -561,7 +561,7 @@ inet test-inet input [ bitwise reg 1 = (reg=1 & 0x000000cf ) ^ 0x00000020 ] [ payload write reg 1 => 1b @ network header + 1 csum_type 0 csum_off 0 ] -# iif lo ip6 ecn set ce +# iif "lo" ip6 ecn set ce inet test-inet input [ meta load iif => reg 1 ] [ cmp eq reg 1 0x00000001 ] @@ -571,7 +571,7 @@ inet test-inet input [ bitwise reg 1 = (reg=1 & 0x000000cf ) ^ 0x00000030 ] [ payload write reg 1 => 1b @ network header + 1 csum_type 0 csum_off 0 ] -# iif lo ip6 flowlabel set 0 +# iif "lo" ip6 flowlabel set 0 inet test-inet input [ meta load iif => reg 1 ] [ cmp eq reg 1 0x00000001 ] @@ -581,7 +581,7 @@ inet test-inet input [ bitwise reg 1 = (reg=1 & 0x000000f0 ) ^ 0x00000000 ] [ payload write reg 1 => 3b @ network header + 1 csum_type 0 csum_off 0 ] -# iif lo ip6 flowlabel set 12345 +# iif "lo" ip6 flowlabel set 12345 inet test-inet input [ meta load iif => reg 1 ] [ cmp eq reg 1 0x00000001 ] @@ -591,7 +591,7 @@ inet test-inet input [ bitwise reg 1 = (reg=1 & 0x000000f0 ) ^ 0x00393000 ] [ payload write reg 1 => 3b @ network header + 1 csum_type 0 csum_off 0 ] -# iif lo ip6 flowlabel set 0xfffff +# iif "lo" ip6 flowlabel set 0xfffff inet test-inet input [ meta load iif => reg 1 ] [ cmp eq reg 1 0x00000001 ] diff --git a/tests/py/ip6/ip6.t.payload.ip6 b/tests/py/ip6/ip6.t.payload.ip6 index 70d2ea06..422fabdb 100644 --- a/tests/py/ip6/ip6.t.payload.ip6 +++ b/tests/py/ip6/ip6.t.payload.ip6 @@ -379,21 +379,21 @@ ip6 test-ip6 input [ cmp lt reg 1 0x34120000 0x34123412 0x34123412 0x34123412 ] [ cmp gt reg 1 0x34123412 0x34120000 0x34123412 0x34123412 ] -# iif lo ip6 daddr set ::1 +# iif "lo" ip6 daddr set ::1 ip6 test-ip6 input [ meta load iif => reg 1 ] [ cmp eq reg 1 0x00000001 ] [ immediate reg 1 0x00000000 0x00000000 0x00000000 0x01000000 ] [ payload write reg 1 => 16b @ network header + 24 csum_type 0 csum_off 0 ] -# iif lo ip6 hoplimit set 1 +# iif "lo" ip6 hoplimit set 1 ip6 test-ip6 input [ meta load iif => reg 1 ] [ cmp eq reg 1 0x00000001 ] [ immediate reg 1 0x00000001 ] [ payload write reg 1 => 1b @ network header + 7 csum_type 0 csum_off 0 ] -# iif lo ip6 dscp set af42 +# iif "lo" ip6 dscp set af42 ip6 test-ip6 input [ meta load iif => reg 1 ] [ cmp eq reg 1 0x00000001 ] @@ -401,7 +401,7 @@ ip6 test-ip6 input [ bitwise reg 1 = (reg=1 & 0x00003ff0 ) ^ 0x00000009 ] [ payload write reg 1 => 2b @ network header + 0 csum_type 0 csum_off 0 ] -# iif lo ip6 dscp set 63 +# iif "lo" ip6 dscp set 63 ip6 test-ip6 input [ meta load iif => reg 1 ] [ cmp eq reg 1 0x00000001 ] @@ -409,7 +409,7 @@ ip6 test-ip6 input [ bitwise reg 1 = (reg=1 & 0x00003ff0 ) ^ 0x0000c00f ] [ payload write reg 1 => 2b @ network header + 0 csum_type 0 csum_off 0 ] -# iif lo ip6 ecn set ect0 +# iif "lo" ip6 ecn set ect0 ip6 test-ip6 input [ meta load iif => reg 1 ] [ cmp eq reg 1 0x00000001 ] @@ -417,7 +417,7 @@ ip6 test-ip6 input [ bitwise reg 1 = (reg=1 & 0x000000cf ) ^ 0x00000020 ] [ payload write reg 1 => 1b @ network header + 1 csum_type 0 csum_off 0 ] -# iif lo ip6 ecn set ce +# iif "lo" ip6 ecn set ce ip6 test-ip6 input [ meta load iif => reg 1 ] [ cmp eq reg 1 0x00000001 ] @@ -425,7 +425,7 @@ ip6 test-ip6 input [ bitwise reg 1 = (reg=1 & 0x000000cf ) ^ 0x00000030 ] [ payload write reg 1 => 1b @ network header + 1 csum_type 0 csum_off 0 ] -# iif lo ip6 flowlabel set 0 +# iif "lo" ip6 flowlabel set 0 ip6 test-ip6 input [ meta load iif => reg 1 ] [ cmp eq reg 1 0x00000001 ] @@ -433,7 +433,7 @@ ip6 test-ip6 input [ bitwise reg 1 = (reg=1 & 0x000000f0 ) ^ 0x00000000 ] [ payload write reg 1 => 3b @ network header + 1 csum_type 0 csum_off 0 ] -# iif lo ip6 flowlabel set 12345 +# iif "lo" ip6 flowlabel set 12345 ip6 test-ip6 input [ meta load iif => reg 1 ] [ cmp eq reg 1 0x00000001 ] @@ -441,7 +441,7 @@ ip6 test-ip6 input [ bitwise reg 1 = (reg=1 & 0x000000f0 ) ^ 0x00393000 ] [ payload write reg 1 => 3b @ network header + 1 csum_type 0 csum_off 0 ] -# iif lo ip6 flowlabel set 0xfffff +# iif "lo" ip6 flowlabel set 0xfffff ip6 test-ip6 input [ meta load iif => reg 1 ] [ cmp eq reg 1 0x00000001 ] -- cgit v1.2.3