summaryrefslogtreecommitdiffstats
path: root/extensions
Commit message (Collapse)AuthorAgeFilesLines
* extensions: mark: Test double bitwise in a rulePhil Sutter2022-11-161-0/+1
| | | | | | | In v1.8.8, the second bitwise changed the first one, messing iptables-nft-save output. Signed-off-by: Phil Sutter <phil@nwl.cc>
* Drop extra newline from xtables_error() callsPhil Sutter2022-11-1512-61/+49
| | | | | | | | | | Since basic_exit_err() appends a newline to the message itself, drop explicit ones. While being at it, fix indentation and join texts split over multiple lines. Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: Unify ICMP parser into libxt_icmp.hPhil Sutter2022-11-155-260/+131
| | | | | | Merge all four copies of the ICMP/ICMPv6/IGMP parameter parsing code. Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: Collate ICMP types/codes in libxt_icmp.hPhil Sutter2022-11-155-206/+107
| | | | | | | | Put the most extensive version of icmp_codes, icmpv6_codes and igmp_codes into the header. Have to rename the function xt_print_icmp_types's parameter to avoid a compiler warning. Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: libebt_arp, libebt_ip: Use xtables_ipparse_any()Phil Sutter2022-11-153-157/+21
| | | | | | | The libxtables function covers all formerly supported inputs (and more). The extended libebt_arp.t passes before and after this patch. Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: libebt_ip: Include kernel headerPhil Sutter2022-11-151-31/+1
| | | | | | | Update the local copy of linux/netfilter_bridge/ebt_ip.h and include it instead of keeping the local copy of struct ebt_ip_info et al. Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: libip*t_LOG: Merge extensionsPhil Sutter2022-11-152-350/+58
| | | | | | | | | | | Data structures were identical already, make use of the names in xt_LOG.h and merge all code into a single extension of family NFPROTO_UNSPEC. While being at it, define SYSLOG_NAMES and use the array in syslog.h instead of dragging along an own level->name mapping two times. Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: Merge SNAT, DNAT, REDIRECT and MASQUERADEPhil Sutter2022-11-1110-954/+163
| | | | | | | | | REDIRECT was already merged into DNAT. Given the callback generator and generalized inner parsing routines, merging the other "flavors" is relatively simple. Rename the extension into "libxt_NAT.so" while doing so and turn the old DSOs into symlinks. Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: DNAT: Rename some symbolsPhil Sutter2022-11-111-14/+14
| | | | | | | No functional change intended, just a more generic name for some symbols which won't be DNAT-specific soon. Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: DNAT: Generate print, save and xlate callbacksPhil Sutter2022-11-111-180/+86
| | | | | | | | | | | Each extension's callbacks follow the same scheme so introduce a generator which accepts the specifics as parameter - including the method to transform from per-extension data into struct nf_nat_range2. Also move the different parser frontends and fcheck callbacks in one spot for clarity. Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: DNAT: Use __DNAT_xlate for REDIRECT, tooPhil Sutter2022-11-111-22/+11
| | | | | | | Make the common function a bit more versatile and give it a more generic name, then use it for REDIRECT target, too. Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: *NAT: Drop NF_NAT_RANGE_PROTO_RANDOM* flag checksPhil Sutter2022-11-115-49/+19
| | | | | | | | | | | | | | | SNAT, DNAT and REDIRECT extensions tried to prevent NF_NAT_RANGE_PROTO_RANDOM flag from being set if no port or address was also given. With SNAT and DNAT, this is not possible as the respective --to-destination or --to-source parameters are mandatory anyway. Looking at the kernel code, doing so with REDIRECT seems harmless. Moreover, nftables supports 'redirect random' without specifying a port-range. Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: DNAT: Fix bad IP address error reportingPhil Sutter2022-11-111-1/+1
| | | | | | | | When introducing 'start' variable to cover for IPv6 addresses enclosed in brackets, this single spot was missed. Fixes: 14d77c8aa29a7 ("extensions: Merge IPv4 and IPv6 DNAT targets") Signed-off-by: Phil Sutter <phil@nwl.cc>
* tests: *.t: Add missing all-one's netmasks to expected outputPhil Sutter2022-10-264-8/+8
| | | | Signed-off-by: Phil Sutter <phil@nwl.cc>
* tests: libxt_connlimit.t: Add missing default valuesPhil Sutter2022-10-261-6/+6
| | | | | | | This extension always prints --connlimit-mask and (the default) --connlimit-saddr options. Signed-off-by: Phil Sutter <phil@nwl.cc>
* tests: libebt_vlan.t: Drop trailing whitespace from rulesPhil Sutter2022-10-261-2/+2
| | | | | | | | Fast iptables-test.py mode is picky and it has to: Plain redirect target prints a trailing whitespace, generally stripping the rules in test cases won't work therefore. Signed-off-by: Phil Sutter <phil@nwl.cc>
* tests: libxt_tos.t, libxt_TOS.t: Add missing masks in outputPhil Sutter2022-10-262-10/+10
| | | | | | | Mask differs between numeric --set-tos values and symbolic ones, make sure it is covered by the tests. Signed-off-by: Phil Sutter <phil@nwl.cc>
* tests: libxt_recent.t: Add missing default valuesPhil Sutter2022-10-261-2/+2
| | | | Signed-off-by: Phil Sutter <phil@nwl.cc>
* tests: libxt_length.t: Fix odd use-case outputPhil Sutter2022-10-261-1/+1
| | | | | | | Specifying the lower boundary suffixed by colon is an undocumented feature. Explicitly printing the upper boundary in that case seems sane. Signed-off-by: Phil Sutter <phil@nwl.cc>
* tests: libebt_redirect.t: Plain redirect prints with trailing whitespacePhil Sutter2022-10-261-1/+1
| | | | Signed-off-by: Phil Sutter <phil@nwl.cc>
* tests: *.t: Fix for hexadecimal outputPhil Sutter2022-10-265-6/+6
| | | | | | | Use hex input to avoid having to specify an expected output in trivial cases. Signed-off-by: Phil Sutter <phil@nwl.cc>
* tests: *.t: Fix expected output for simple callsPhil Sutter2022-10-265-5/+5
| | | | | | | These minimal extension uses print in more detailed form. Track this, the output is desired. Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: NFQUEUE: Document queue-balance limitationPhil Sutter2022-10-263-4/+5
| | | | | | | | | | | The range is not communicated as "min and max queue number", but "first queue number and count" instead. With 16bits for each value, it is not possible to balance between all 65536 possible queues. Although probably never used in practice, point this detail out in man page and make the parser complain instead of the cryptic "xt_NFQUEUE: number of total queues is 0" emitted by the kernel module. Signed-off-by: Phil Sutter <phil@nwl.cc>
* tests: libebt_stp.t: Drop duplicate whitespacePhil Sutter2022-10-061-1/+1
| | | | | | Code was fixed but the testcase adjustment slipped through. Fixes: 262dff31a998e ("extensions: libebt_stp: Eliminate duplicate space in output")
* tests: IDLETIMER.t: Fix syntax, support for restore inputPhil Sutter2022-10-051-1/+1
| | | | | | | | | Expected output was wrong in the last OK test, probably defeating rule search check. Also use a different label, otherwise the kernel will reject the second idletimer with same label but different type if both rules are added at once. Fixes: 85b9ec8615428 ("extensions: IDLETIMER: Add alarm timer option")
* extensions: libebt_log: Avoid empty log-prefix in outputPhil Sutter2022-10-052-5/+6
| | | | | Just like iptables LOG target, omit --log-prefix from output if the string is empty.
* extensions: TCPOPTSTRIP: Do not print empty optionsPhil Sutter2022-10-021-0/+13
| | | | | | | No point in printing anything if none of the bits are set. Fixes: aef4c1e727563 ("libxt_TCPOPTSTRIP") Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: libip6t_dst: Fix output for empty optionsPhil Sutter2022-10-021-3/+3
| | | | | | | | If no --dst-opts were given, print_options() would print just a whitespace. Fixes: 73866357e4a7a ("iptables: do not print trailing whitespaces") Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: libebt_stp: Eliminate duplicate space in outputPhil Sutter2022-10-021-2/+2
| | | | | | | | No need for print_range() to print a trailing whitespace, caller does this already. Fixes: fd8d7d7e5d911 ("ebtables-nft: add stp match") Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: among: Fix for use with ebtables-restorePhil Sutter2022-10-011-8/+6
| | | | | | | | | | When restoring multiple rules which use among match, new size may be smaller than the old one which caused invalid writes by the memcpy() call. Expect this and realloc the match only if it needs to grow. Also use realloc instead of freeing and allocating from scratch. Fixes: 26753888720d8 ("nft: bridge: Rudimental among extension support") Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: among: Remove pointless fall throughPhil Sutter2022-10-011-3/+2
| | | | | | | | | This seems to be a leftover from an earlier version of the switch(). This fall through is never effective as the next case's code will never apply. So just break instead. Fixes: 26753888720d8 ("nft: bridge: Rudimental among extension support") Signed-off-by: Phil Sutter <phil@nwl.cc>
* ebtables: Support '-p Length'Phil Sutter2022-09-282-2/+10
| | | | | | | | | | | | | | | | | | To match on Ethernet frames using the etherproto field as length value, ebtables accepts the special protocol name "LENGTH". Implement this in ebtables-nft using a native match for 'ether type < 0x0600'. Since extension 802_3 matches are valid only with such Ethernet frames, add a local add_match() wrapper which complains if the extension is used without '-p Length' parameter. Legacy ebtables does this within the extension's final_check callback, but it's not possible here due for lack of fw->bitmask field access. While being at it, add xlate support, adjust tests and make ebtables-nft print the case-insensitive argument with capital 'L' like legacy ebtables does. Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: libxt_pkttype: support otherhostFlorian Westphal2022-09-081-1/+1
| | | | | | | | | | Makes no sense for iptables/ip6tables but it does make sense for ebtables. Classic ebtables uses libebt_pkttype which isn't compatible, but iptables-nft can use the libxt_pkttype version when printing native 'meta pkttype'. Signed-off-by: Florian Westphal <fw@strlen.de> Reviewed-by: Phil Sutter <phil@nwl.cc>
* extensions: libxt_conntrack: remove always-false conditionalsFlorian Westphal2022-07-231-12/+0
| | | | | | | libxt_conntrack.c:1292: warning: the comparison will always evaluate as false for the address of origsrc_addr will never be NULL [-Waddress] Signed-off-by: Florian Westphal <fw@strlen.de>
* xt_sctp: support a couple of new chunk typesYuxuan Luo2022-07-134-2/+12
| | | | | | | | | | There are new chunks added in Linux SCTP not being traced by iptables. This patch introduces the following chunks for tracing: I_DATA, I_FORWARD_TSN (RFC8260), RE_CONFIG(RFC6525) and PAD(RFC4820) Signed-off-by: Yuxuan Luo <luoyuxuan.carl@gmail.com> Signed-off-by: Phil Sutter <phil@nwl.cc>
* libxtables: Move struct xtables_afinfo into xtables.hPhil Sutter2022-06-232-1/+6
| | | | | | | | | | | | | The library "owns" this structure and maintains 'afinfo' pointer to instances of it. With libxt_set, there's even an extension making use of the data. To avoid impact on library users, guard it by XTABLES_INTERNAL. To eliminate the xshared.h include by libxt_set, DEBUGP has to be redefined. Other extensions have similar defines, fix this later. Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: string: Fix and enable testsPhil Sutter2022-06-111-14/+7
| | | | | | | | | | Some minor fixes were necessary: * --algo is printed after the pattern * Second long string test must fail, that string is 129 chars long * --from 0 and --to 65535 are not printed (default values) Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: string: Review parse_string() functionPhil Sutter2022-06-111-7/+6
| | | | | | | | | | | * Compare against sizeof(info->pattern) which is more clear than having to know that this buffer is of size XT_STRING_MAX_PATTERN_SIZE * Invert the check and error early to reduce indenting * Pass info->patlen to memcpy() to avoid reading past end of 's' Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: string: Do not print default --to valuePhil Sutter2022-06-111-2/+2
| | | | | | | Default value is UINT16_MAX, not 0. Fix the conditional printing. Fixes: c6fbf41cdd157 ("update string match to reflect new kernel implementation (Pablo Neira)") Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: libebt_standard.t: Test logical-{in,out} as wellPhil Sutter2022-06-111-0/+5
| | | | | | | These weren't used anywhere before. At least ensure they are only allowed where claimed. Signed-off-by: Phil Sutter <phil@nwl.cc>
* Makefile: Add --enable-profiling configure optionPhil Sutter2022-06-111-1/+1
| | | | | | A little convenience to prepare a build for analysis with gcov/gprof. Signed-off-by: Phil Sutter <phil@nwl.cc>
* treewide: use uint* instead of u_int*Nick Hainke2022-05-181-1/+1
| | | | | | | | | | | | | | | | | | | | Gcc complains about missing types. Some commits introduced u_int* instead of uint*. Use uint treewide. Fixes errors in the form of: In file included from xtables-legacy-multi.c:5: xshared.h:83:56: error: unknown type name 'u_int16_t'; did you mean 'uint16_t'? 83 | set_option(unsigned int *options, unsigned int option, u_int16_t *invflg, | ^~~~~~~~~ | uint16_t make[6]: *** [Makefile:712: xtables_legacy_multi-xtables-legacy-multi.o] Error 1 Avoid libipq API breakage by adjusting libipq.h include accordingly. For arpt_mangle.h kernel uAPI header, apply same change as in kernel commit e91ded8db5747 ("uapi: netfilter_arp: use __u8 instead of u_int8_t"). Signed-off-by: Nick Hainke <vincent@systemli.org> Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: LOG: Document --log-macdecode in man pagePhil Sutter2022-05-111-0/+3
| | | | | | | Help text already contains it, so no update needed there. Fixes: 127647892c7ca ("extensions: libipt_LOG/libip6t_LOG: support macdecode option") Signed-off-by: Phil Sutter <phil@nwl.cc>
* man: *NAT: Review --random* option descriptionsPhil Sutter2022-05-114-20/+6
| | | | | | | | Stating the option again in the first (single?) sentence is pointless. Get rid of that initial half-sentence in MASQUERADE options and unify the texts a bit. Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: DNAT: Merge core printing functionsPhil Sutter2022-05-111-31/+27
| | | | | | | | | | | Have a versatile __NAT_print() function providing enough flexibility for DNAT and REDIRECT, IPv4 and IPv6 and 'print' and 'save' output. Then define macros to simplify calling it. As a side effect, this fixes ip6tables DNAT revision 1 print output. Fixes: 14d77c8aa29a7 ("extensions: Merge IPv4 and IPv6 DNAT targets") Signed-off-by: Phil Sutter <phil@nwl.cc>
* xshared: Move arp_opcodes into shared spacePhil Sutter2022-05-111-1/+0
| | | | | | | It will be referenced by xtables_printhelp() if printing for arptables and therefore must be present in legacy as well even if unused. Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: MARK: Drop extra newline at end of helpPhil Sutter2022-05-111-2/+1
| | | | | Fixes: f4b737fb0c52a ("libxt_MARK r2") Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: man: Document service name support in DNAT and REDIRECTPhil Sutter2022-04-082-0/+3
| | | | | | | Unless as part of a range, service names may be used. Point this out to avoid confusion. Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: Merge REDIRECT into DNATPhil Sutter2022-04-0812-380/+204
| | | | | | | | | Code is very similar, join them to reuse parsing code at least. As a side-effect, this enables parsing of service names for ports in DNAT as well as using port number 0 as that's what REDIRECT allows. Signed-off-by: Phil Sutter <phil@nwl.cc>
* extensions: Merge IPv4 and IPv6 DNAT targetsPhil Sutter2022-04-085-468/+218
| | | | | | | | | Make parse_to() family-aware so it serves for both IPv4 and IPv6. Have a core _DNAT_parse() function which parses into the most modern (nf_nat_range2) data structure and a bunch of wrappers to copy into legacy data structures if needed. Treat other callbacks analogous. Signed-off-by: Phil Sutter <phil@nwl.cc>