[PATCH nft v3 00/10] add typeof keyword

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch series adds the typeof keyword.

This depends on Pablos extensions to libnftnls udata parsing facilities.

named set can be configured as follows:

set os {
   typeof osf name
   elements = { "Linux", "Windows" }
}

The type is stored in the kernel via the udata infrastructure.
On listing -- if a udata type is present -- nft will validate that this
type matches the set key length and, if so, will print back the 'typeof'
information.

Note that while 'typeof' can be used with concatenations, they
only work as aliases for known types -- its currently not possible
to use integer/string types via the 'typeof' keyword (its rejected
at evaluation stage due to 0-length sub expression types).

Doing so requires a bit more work to dissect the correct key
geometry on netlink dumps.

In case typeof udata is not there/invalid, the normal 'type' syntax
is used.

This patch set isn't complete -- the test cases will not work
yet because 'meta' and 'osf' lack the udata parse/buil callbacks.

This is caught at the parsing stage.

The following changes since commit ddbe652bf0f4ed300bae9497250130d68e4cbf5b:

  py: load the SONAME-versioned shared object (2019-12-10 19:07:16 +0100)

are available in the Git repository at:

  git://git.breakpoint.cc/fw/nftables.git typeof_rework_09

for you to fetch changes up to 02485d775dea55a067c6dbea0826ab3fc9ff7398:

  tests: add typeof test cases (2019-12-17 12:19:51 +0100)

----------------------------------------------------------------
Florian Westphal (7):
      parser: add a helper for concat expression handling
      src: store expr, not dtype to track data in sets
      src: add "typeof" build/parse/print support
      mnl: round up the map data size too
      evaluate: print a hint about 'typeof' syntax on 0 keylen
      doc: mention 'typeof' as alternative to 'type' keyword
      tests: add typeof test cases

Pablo Neira Ayuso (3):
      proto: add proto_desc_id enumeration
      expr: add expr_ops_by_type()
      parser: add typeof keyword for declarations

 doc/nft.txt                                        |  12 +-
 include/datatype.h                                 |   1 -
 include/expression.h                               |   5 +
 include/netlink.h                                  |   1 -
 include/proto.h                                    |  27 ++++
 include/rule.h                                     |   7 +-
 src/datatype.c                                     |   5 -
 src/evaluate.c                                     |  81 +++++++----
 src/expression.c                                   |  14 +-
 src/json.c                                         |   4 +-
 src/mnl.c                                          |  30 ++++-
 src/monitor.c                                      |   2 +-
 src/netlink.c                                      | 149 +++++++++++++++++----
 src/parser_bison.y                                 | 148 +++++++++++---------
 src/parser_json.c                                  |   8 +-
 src/payload.c                                      |  75 +++++++++++
 src/proto.c                                        |  46 +++++++
 src/rule.c                                         |  48 +++++--
 src/scanner.l                                      |   1 +
 src/segtree.c                                      |   8 +-
 tests/shell/testcases/maps/dumps/typeof_maps_0.nft |  16 +++
 tests/shell/testcases/maps/typeof_maps_0           |  27 ++++
 tests/shell/testcases/sets/dumps/typeof_sets_0.nft |  19 +++
 tests/shell/testcases/sets/typeof_sets_0           |  29 ++++
 24 files changed, 621 insertions(+), 142 deletions(-)
 create mode 100644 tests/shell/testcases/maps/dumps/typeof_maps_0.nft
 create mode 100755 tests/shell/testcases/maps/typeof_maps_0
 create mode 100644 tests/shell/testcases/sets/dumps/typeof_sets_0.nft
 create mode 100755 tests/shell/testcases/sets/typeof_sets_0




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux