summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* build: libnftnl 1.2.6 releaselibnftnl-1.2.6Pablo Neira Ayuso2023-07-111-1/+1
| | | | Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* tests: nft-rule-test: Add test cases to improve code coverageshixuantong2023-06-021-0/+8
| | | | | Signed-off-by: shixuantong <tongxiaoge1001@126.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* tests: nft-table-test: fix typoshixuantong2023-06-021-1/+1
| | | | | Signed-off-by: shixuantong <tongxiaoge1001@126.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* expr: meta: introduce broute meta expressionSriram Yagnaraman2023-03-152-1/+4
| | | | | | | | libnftnl support for broute meta statement introduced in: https://patchwork.ozlabs.org/project/netfilter-devel/patch/20230224095251.11249-1-sriram.yagnaraman@est.tech/ Signed-off-by: Sriram Yagnaraman <sriram.yagnaraman@est.tech> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* build: libnftnl 1.2.5 releaselibnftnl-1.2.5Pablo Neira Ayuso2023-03-091-1/+1
| | | | Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* chain: relax logic to build NFTA_CHAIN_HOOKPablo Neira Ayuso2023-01-031-16/+25
| | | | | | | | The logic to build NFTA_CHAIN_HOOK enforces the presence of the hook number and priority to include the devices. Relax this to allow for incremental device updates. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* expr: add inner supportPablo Neira Ayuso2023-01-026-3/+256
| | | | | | | This patch adds support for the inner expression which allows you to match on the inner tunnel headers, eg. VxLAN. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* Makefile: Create LZMA-compressed dist-filesPhil Sutter2022-12-091-1/+1
| | | | | | | | Use a more modern alternative to bzip2. Suggested-by: Jan Engelhardt <jengelh@inai.de> Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Phil Sutter <phil@nwl.cc>
* src: replace nftnl_*_nlmsg_build_hdr() by nftnl_nlmsg_build_hdr()Pablo Neira Ayuso2022-11-1553-123/+112
| | | | | | Use nftnl_nlmsg_build_hdr() instead of nftnl_*_nlmsg_build_hdr(). Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* examples: remove nftnl_batch_is_supported() callPablo Neira Ayuso2022-11-152-30/+9
| | | | | | | | | | | | Linux kernel <= 3.13 needs for this check, remove it from examples. Kernel commit: 958bee14d071 ("netfilter: nf_tables: use new transaction infrastructure to handle sets") added support for set into the batch. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* build: libnftnl 1.2.4 releaselibnftnl-1.2.4Pablo Neira Ayuso2022-11-101-1/+1
| | | | Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* libnftnl: Fix res_id byte orderIan Pilcher2022-10-251-1/+2
| | | | | | | | | | | | | | | | | | | | | The res_id member of struct nfgenmsg is supposed to be in network byte order (big endian). Call htons() in __nftnl_nlmsg_build_hdr() to ensure that this is true on little endian systems. There is a kernel workaround that was introduced in 4.3 to address this issue: commit a9de9777d613500b089a7416f936bf3ae5f070d2 Author: Pablo Neira Ayuso <pablo@netfilter.org> Date: Fri Aug 28 21:01:43 2015 +0200 netfilter: nfnetlink: work around wrong endianess in res_id field And current oldest stable kernel branch in 4.9, merge this to fix the incorrect endianness from userspace. Signed-off-by: Ian Pilcher <arequipeno@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* expr: payload: remove unused functionPablo Neira Ayuso2022-09-071-14/+0
| | | | | | nftnl_str2base() not used anymore, remove it. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* rule, set_elem: remove trailing \n in userdata snprintfPablo Neira Ayuso2022-08-312-2/+2
| | | | | | | 212479ad2c92 ("rule, set_elem: fix printing of user data") uncovered another an extra line break in the userdata printing, remove it. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* rule, set_elem: fix printing of user dataJeremy Sowden2022-08-292-5/+7
| | | | | | | | | | | | Hitherto, alphanumeric characters have been printed as-is, but anything else was replaced by '\0'. However, this effectively truncates the output. Instead, print any printable character as-is and print anything else as a hexadecimal escape sequence: userdata = { \x01\x04\x01\x00\x00\x00 } Signed-off-by: Jeremy Sowden <jeremy@azazel.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* build: libnftnl 1.2.3 releaselibnftnl-1.2.3Pablo Neira Ayuso2022-08-091-1/+1
| | | | Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* build: fix clang+glibc snprintf substitution errorNicholas Vinson2022-06-1551-52/+52
| | | | | | | | | | | | | | | | | | | | When building with clang and glibc and -D_FORTIFY_SOURCE=2 is passed to clang, the snprintf member of the expr_ops and obj_ops structures will be incorrectly replaced with __builtin_snprintf_chk() which results in "error: no member named '__builtin___snprintf_chk'" errors at build time. This patch changes the member name from 'snprintf' to 'output' to prevent the replacement. This bug can be emulated using GCC by undefining the __va_arg_pack macro before stdio.h is included. This patch is based on the notes provided in https://bugs.gentoo.org/807766. Signed-off-by: Nicholas Vinson <nvinson234@gmail.com> Signed-off-by: Florian Westphal <fw@strlen.de>
* build: libnftnl 1.2.2 releaselibnftnl-1.2.2Pablo Neira Ayuso2022-06-071-1/+1
| | | | Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* set_elem: missing export symbolPablo Neira Ayuso2022-06-031-0/+1
| | | | | | | nftnl_set_elem_nlmsg_build_payload() is already available through .map file and headers, add missing EXPORT_SYMBOL. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* exthdr: tcp option reset supportFlorian Westphal2022-03-011-1/+6
| | | | | | Adds print debug support for tcp reset feature. Signed-off-by: Florian Westphal <fw@strlen.de>
* build: libnftnl 1.2.1 releaselibnftnl-1.2.1Pablo Neira Ayuso2021-11-172-2/+2
| | | | | | | Bump libversion, because this release adds new API: nftnl_set_elem_nlmsg_build(). Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* expr: payload: print inner header base offsetPablo Neira Ayuso2021-11-172-2/+5
| | | | | | | Update string array to print the "inner" header string, instead of printing "unknown". Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* set: use NFTNL_SET_ELEM_VERDICT to print verdictPablo Neira Ayuso2021-11-043-9/+9
| | | | | | | | This patch reworks 228e8b174627 ("set_elem: Fix printing of verdict map elements"), check if NFTNL_SET_ELEM_VERDICT is set then print the set element verdict. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* set: expose nftnl_set_elem_nlmsg_build()Pablo Neira Ayuso2021-11-043-4/+11
| | | | | | Expose a function to build one single set element netlink message. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* expr: last: add NFTNL_EXPR_LAST_SETPablo Neira Ayuso2021-07-052-1/+22
| | | | | | | Honor NFTA_LAST_SET netlink attribute, it tells us if a packet has ever updated this expression. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* expr: missing netlink attribute in last expressionPablo Neira Ayuso2021-06-101-0/+2
| | | | | | | NFTA_LAST_SET is missing, add it. Fixes: ed7c442c2d04 ("expr: add last match time support") Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* expr: add last match time supportPablo Neira Ayuso2021-06-084-0/+125
| | | | | | This new expression displays when last matching has happened. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* include: update nf_tables.hPablo Neira Ayuso2021-06-081-1/+47
| | | | | | Get header in sync with 5.13.0-rc. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* build: libnftnl 1.2.0 releaselibnftnl-1.2.0Pablo Neira Ayuso2021-05-251-1/+1
| | | | Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* expr: socket: add cgroups v2 supportPablo Neira Ayuso2021-05-033-0/+21
| | | | | | Add NFT_SOCKET_CGROUPSV2 key type and NFTA_SOCKET_LEVEL attribute. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* src: incorrect header refers to GPLv2 onlyPablo Neira Ayuso2021-04-202-5/+6
| | | | | | | libnftnl is GPLv2+, fix incorrect headers. Acked-by: Arturo Borrero Gonzalez <arturo@netfilter.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* ruleset: Eliminate tag and separator helpersPhil Sutter2021-03-151-92/+59
| | | | | | | | | Those were used for JSON and XML output only with the exception of separator helper which at the same time served as conditional nop if no "previous" object as passed. Replace it by a string variable updated at the end of each loop iteration and just drop the other helpers. Signed-off-by: Phil Sutter <phil@nwl.cc>
* Get rid of single option switch statementsPhil Sutter2021-03-159-101/+31
| | | | | | | | | | | | Replace each by a conditional testing the only valid case. There is one odd example, namely src/set.c: When printing a set with type NFTNL_OUTPUT_XML, the relevant function would return 0 instead of -1 like all others. Just drop it assuming nothing depends on that (faulty) behaviour. Cc: Arturo Borrero <arturo.borrero.glez@gmail.com> Signed-off-by: Phil Sutter <phil@nwl.cc>
* Drop pointless local variable in snprintf callbacksPhil Sutter2021-03-1537-105/+102
| | | | | | | | | | A common idiom among snprintf callbacks was to copy the unsigned parameter 'size' (or 'len') into a signed variable for further use. Though since snprintf() itself casts it to unsigned and SNPRINTF_BUFFER_SIZE() does not allow it to become negative, this is not needed. Drop the local variable and rename the parameter accordingly. Signed-off-by: Phil Sutter <phil@nwl.cc>
* obj: Drop type parameter from snprintf callbackPhil Sutter2021-03-1511-176/+27
| | | | | | | Objects don't support any other output type than NFTNL_OUTPUT_DEFAULT, so just drop the parameter. Signed-off-by: Phil Sutter <phil@nwl.cc>
* expr/data_reg: Drop output_format parameterPhil Sutter2021-03-157-39/+16
| | | | | | | | The function nftnl_data_reg_snprintf is exclusively called with NFTNL_OUTPUT_DEFAULT as parameter, others are not supported - just drop it. Signed-off-by: Phil Sutter <phil@nwl.cc>
* expr: Check output type once and for allPhil Sutter2021-03-1539-617/+102
| | | | | | | | | | | There is but a single supported output type left, so check it in expr.c and drop all the single option switch statements in individual expressions. Since the parameter is now unused (and to ensure code correctness), drop 'type' parameter from struct expr_ops' snprintf callback. Signed-off-by: Phil Sutter <phil@nwl.cc>
* object: Fix for wrong parameter passed to snprintf callbackPhil Sutter2021-03-151-2/+2
| | | | | | | | Instead of the remaining buffer length, the used buffer length was passed to object's snprintf callback (and the final snprintf call). Fixes: 5573d0146c1ae ("src: support for stateful objects") Signed-off-by: Phil Sutter <phil@nwl.cc>
* obj/ct_timeout: Fix snprintf buffer length updatesPhil Sutter2021-03-151-5/+5
| | | | | | | | Have to pass shrinking 'remain' variable to consecutive snprintf calls instead of the unchanged 'len' parameter. Fixes: 0adceeab1597a ("src: add ct timeout support") Signed-off-by: Phil Sutter <phil@nwl.cc>
* obj/ct_expect: Fix snprintf buffer length updatesPhil Sutter2021-03-151-5/+9
| | | | | | | | Have to pass shrinking 'remain' variable to consecutive snprintf calls instead of the unchanged 'len' parameter. Fixes: c4b6aa09b85d2 ("src: add ct expectation support") Signed-off-by: Phil Sutter <phil@nwl.cc>
* expr: Fix snprintf buffer length updatesPhil Sutter2021-03-154-12/+12
| | | | | | | | Subsequent calls to snprintf() sometimes reuse 'len' variable although they should refer to the updated value in 'remain' instead. Fixes: 676ea569bbe5a ("src: Change parameters of SNPRINTF_BUFFER_SIZE macro.") Signed-off-by: Phil Sutter <phil@nwl.cc>
* set_elem: Fix printing of verdict map elementsPhil Sutter2021-03-093-6/+14
| | | | | | | | | | | | | | | | Elements' data was printed as type DATA_VALUE no matter the actual type. For verdicts, this meant no printing at all (because reg->len is either zero or garbage). To fix this, nftnl_set_elem_snprintf_default() needs type info held in struct nftnl_set. Pass it via parameter to that function, make it non-static and call it from nftnl_set_snprintf_default() instead of the generic nftnl_set_elem_snprintf(). This way no changes have to be done to exported functions, also the output type is already defined when nftnl_set_snprintf_default() runs so checking type value again is pointless. Signed-off-by: Phil Sutter <phil@nwl.cc>
* expr/{masq,nat}: Don't print unused regsPhil Sutter2021-03-092-7/+21
| | | | | | | No point in printing the unset register value (which is zero then). Fixes: af0c182670837 ("expr: masq: Add support for port selection") Signed-off-by: Phil Sutter <phil@nwl.cc>
* rule: Avoid printing trailing spacesPhil Sutter2021-03-091-9/+18
| | | | | | | | Introduce 'sep' variable to track whether something was printed already. While being at it, introduce PRIu64 for 'handle' and 'position' attributes. Signed-off-by: Phil Sutter <phil@nwl.cc>
* expr/xfrm: Kill dead codePhil Sutter2021-03-091-28/+0
| | | | | | | These functions were used by removed JSON parser only. Fixes: 80077787f8f21 ("src: remove json support") Signed-off-by: Phil Sutter <phil@nwl.cc>
* expr/tunnel: Kill dead codePhil Sutter2021-03-091-13/+0
| | | | | | | Function str2tunnel_key() was never used. Fixes: 42468fb6df61a ("expr: add support for matching tunnel metadata") Signed-off-by: Phil Sutter <phil@nwl.cc>
* expr/socket: Kill dead codePhil Sutter2021-03-091-13/+0
| | | | | | | Function str2socket_key() was never used. Fixes: 038d226f2e6cc ("src: Add support for native socket matching") Signed-off-by: Phil Sutter <phil@nwl.cc>
* table: add table owner supportPablo Neira Ayuso2021-03-013-1/+15
| | | | | | Add support for NFTA_TABLE_OWNER. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* build: libnftnl 1.1.9 releaselibnftnl-1.1.9Pablo Neira Ayuso2021-01-132-2/+2
| | | | Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* dynset: add NFTNL_EXPR_DYNSET_FLAGSPablo Neira Ayuso2021-01-132-0/+16
| | | | | | This patch adds support for the dynset flags. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>