All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH nft 1/3] datatype: fix parsing of tchandle type
@ 2016-05-29 10:08 Liping Zhang
  2016-05-29 10:08 ` [PATCH nft 2/3] meta: fix endianness in priority Liping Zhang
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Liping Zhang @ 2016-05-29 10:08 UTC (permalink / raw)
  To: pablo; +Cc: netfilter-devel, Liping Zhang

From: Liping Zhang <liping.zhang@spreadtrum.com>

Properly detect tchandle strings in the lexer without quotation marks,
otherwise nft will complain the syntax error like this:

  # nft add rule filter test meta priority set 1:2
  <cmdline>:1:41-41: Error: syntax error, unexpected colon, expecting end of file or newline or semicolon
  add rule filter test meta priority set 1:2
                                          ^

Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
---
 src/scanner.l | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/scanner.l b/src/scanner.l
index b022114..9ca6d4d 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -120,6 +120,8 @@ slash		\/
 
 timestring	([0-9]+d)?([0-9]+h)?([0-9]+m)?([0-9]+s)?
 
+tchstring	([[:xdigit:]]{0,4}:[[:xdigit:]]{0,4})
+
 hex4		([[:xdigit:]]{1,4})
 v680		(({hex4}:){7}{hex4})
 v670		((:)((:{hex4}){7}))
@@ -479,6 +481,11 @@ addrstring	({macaddr}|{ip4addr}|{ip6addr})
 				return STRING;
 			}
 
+{tchstring}		{
+				yylval->string = xstrdup(yytext);
+				return STRING;
+			}
+
 {decstring}		{
 				errno = 0;
 				yylval->val = strtoull(yytext, NULL, 0);
-- 
2.5.5



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH nft 2/3] meta: fix endianness in priority
  2016-05-29 10:08 [PATCH nft 1/3] datatype: fix parsing of tchandle type Liping Zhang
@ 2016-05-29 10:08 ` Liping Zhang
  2016-05-30  9:58   ` Pablo Neira Ayuso
  2016-05-29 10:08 ` [PATCH nft 3/3] meta: fix a format error display when we set priority to root or none Liping Zhang
  2016-05-30  9:59 ` [PATCH nft 1/3] datatype: fix parsing of tchandle type Pablo Neira Ayuso
  2 siblings, 1 reply; 6+ messages in thread
From: Liping Zhang @ 2016-05-29 10:08 UTC (permalink / raw)
  To: pablo; +Cc: netfilter-devel, Liping Zhang

From: Liping Zhang <liping.zhang@spreadtrum.com>

For example, after we add rule to set priority 1:2, it will be displayed in network
byte order as 0200:0100, this is wrong:

  # nft add rule filter test meta priority set 1:2
  # nft list chain filter test
  table ip filter {
      chain test {
          meta priority set 0200:0100
      }
  }

Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
---
 src/meta.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/meta.c b/src/meta.c
index b8db0f8..74d2b4c 100644
--- a/src/meta.c
+++ b/src/meta.c
@@ -128,7 +128,7 @@ static const struct datatype tchandle_type = {
 	.type		= TYPE_TC_HANDLE,
 	.name		= "tc_handle",
 	.desc		= "TC handle",
-	.byteorder	= BYTEORDER_BIG_ENDIAN,
+	.byteorder	= BYTEORDER_HOST_ENDIAN,
 	.size		= 4 * BITS_PER_BYTE,
 	.basetype	= &integer_type,
 	.print		= tchandle_type_print,
-- 
2.5.5



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH nft 3/3] meta: fix a format error display when we set priority to root or none
  2016-05-29 10:08 [PATCH nft 1/3] datatype: fix parsing of tchandle type Liping Zhang
  2016-05-29 10:08 ` [PATCH nft 2/3] meta: fix endianness in priority Liping Zhang
@ 2016-05-29 10:08 ` Liping Zhang
  2016-05-30  9:58   ` Pablo Neira Ayuso
  2016-05-30  9:59 ` [PATCH nft 1/3] datatype: fix parsing of tchandle type Pablo Neira Ayuso
  2 siblings, 1 reply; 6+ messages in thread
From: Liping Zhang @ 2016-05-29 10:08 UTC (permalink / raw)
  To: pablo; +Cc: netfilter-devel, Liping Zhang

From: Liping Zhang <liping.zhang@spreadtrum.com>

Also delete the redundant '\n'.
This fixes:

  # nft add rule filter test meta priority set root
  # nft list chain filter test
  table ip filter {
      chain test {
          meta priority set root
  none
  ffff:ffff
      }
  }

Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
---
 src/meta.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/meta.c b/src/meta.c
index 74d2b4c..75431a2 100644
--- a/src/meta.c
+++ b/src/meta.c
@@ -74,9 +74,11 @@ static void tchandle_type_print(const struct expr *expr)
 
 	switch(handle) {
 	case TC_H_ROOT:
-		printf("root\n");
+		printf("root");
+		break;
 	case TC_H_UNSPEC:
-		printf("none\n");
+		printf("none");
+		break;
 	default:
 		if (TC_H_MAJ(handle) == 0)
 			printf(":%04x", TC_H_MIN(handle));
-- 
2.5.5



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH nft 2/3] meta: fix endianness in priority
  2016-05-29 10:08 ` [PATCH nft 2/3] meta: fix endianness in priority Liping Zhang
@ 2016-05-30  9:58   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 6+ messages in thread
From: Pablo Neira Ayuso @ 2016-05-30  9:58 UTC (permalink / raw)
  To: Liping Zhang; +Cc: netfilter-devel, Liping Zhang

On Sun, May 29, 2016 at 06:08:08PM +0800, Liping Zhang wrote:
> From: Liping Zhang <liping.zhang@spreadtrum.com>
> 
> For example, after we add rule to set priority 1:2, it will be displayed in network
> byte order as 0200:0100, this is wrong:
> 
>   # nft add rule filter test meta priority set 1:2
>   # nft list chain filter test
>   table ip filter {
>       chain test {
>           meta priority set 0200:0100
>       }
>   }

Applied, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH nft 3/3] meta: fix a format error display when we set priority to root or none
  2016-05-29 10:08 ` [PATCH nft 3/3] meta: fix a format error display when we set priority to root or none Liping Zhang
@ 2016-05-30  9:58   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 6+ messages in thread
From: Pablo Neira Ayuso @ 2016-05-30  9:58 UTC (permalink / raw)
  To: Liping Zhang; +Cc: netfilter-devel, Liping Zhang

On Sun, May 29, 2016 at 06:08:09PM +0800, Liping Zhang wrote:
> From: Liping Zhang <liping.zhang@spreadtrum.com>
> 
> Also delete the redundant '\n'.
> This fixes:
> 
>   # nft add rule filter test meta priority set root
>   # nft list chain filter test
>   table ip filter {
>       chain test {
>           meta priority set root
>   none
>   ffff:ffff
>       }
>   }

Also applied, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH nft 1/3] datatype: fix parsing of tchandle type
  2016-05-29 10:08 [PATCH nft 1/3] datatype: fix parsing of tchandle type Liping Zhang
  2016-05-29 10:08 ` [PATCH nft 2/3] meta: fix endianness in priority Liping Zhang
  2016-05-29 10:08 ` [PATCH nft 3/3] meta: fix a format error display when we set priority to root or none Liping Zhang
@ 2016-05-30  9:59 ` Pablo Neira Ayuso
  2 siblings, 0 replies; 6+ messages in thread
From: Pablo Neira Ayuso @ 2016-05-30  9:59 UTC (permalink / raw)
  To: Liping Zhang; +Cc: netfilter-devel, Liping Zhang

On Sun, May 29, 2016 at 06:08:07PM +0800, Liping Zhang wrote:
> From: Liping Zhang <liping.zhang@spreadtrum.com>
> 
> Properly detect tchandle strings in the lexer without quotation marks,
> otherwise nft will complain the syntax error like this:
> 
>   # nft add rule filter test meta priority set 1:2
>   <cmdline>:1:41-41: Error: syntax error, unexpected colon, expecting end of file or newline or semicolon
>   add rule filter test meta priority set 1:2
>                                           ^

This is breaking several tests under tests/py/ (see nft-tests.py
script), so I'll keep this back by now. Let me have a look into this.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-05-30  9:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-29 10:08 [PATCH nft 1/3] datatype: fix parsing of tchandle type Liping Zhang
2016-05-29 10:08 ` [PATCH nft 2/3] meta: fix endianness in priority Liping Zhang
2016-05-30  9:58   ` Pablo Neira Ayuso
2016-05-29 10:08 ` [PATCH nft 3/3] meta: fix a format error display when we set priority to root or none Liping Zhang
2016-05-30  9:58   ` Pablo Neira Ayuso
2016-05-30  9:59 ` [PATCH nft 1/3] datatype: fix parsing of tchandle type Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.