summaryrefslogtreecommitdiff
path: root/ipsets.c
Commit message (Collapse)AuthorAgeFilesLines
* ipsets: permit default timeout of 0Kevin Darbyshire-Bryant2021-08-141-1/+2
| | | | | | | | | | | | | Allow ipsets to be created with a default timeout of 0. This permits timed entries to be added if required even though the default is 0 (indefinite) Prior to this change a default timeout value of 0 would create a set without timeout support. Fixes: FS#3977 Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
* ipsets: allow blank/commented lines with loadfileDaniel Harding2020-12-061-2/+10
| | | | | | | When loading ipset files using the loadfile option, skip blank lines and lines that start with '#' (disregarding any leading whitespace). Signed-off-by: Daniel Harding <dharding@living180.net>
* firewall3: ipset: Handle reload_set properlyKristian Evensen2019-08-191-2/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The reload_set option was added in commit 509e673dab01 ("firewall3: Improve ipset support"), and the purpose of the option is to control if a set should be flushed or not on a firewall reload. In some cases, the option unfortunately does not work properly. I had fixed the errors locally, but failed to submit a v2 of "Improve ipset support". This patch contains my local fixes, and after the following changes are applied then the option (as well as ipset support) works as at least I expect. The following errors have been fixed: * "family" was not written to the state file, causing all sets read from this file was considered as ipv4. Save family to ensure that sets are handled correctly on firewall reload. * The default value of "reload_set" is false, meaning that the reload-check in "fw3_create_ipsets()" is always true (on reload). A consequence of this is that new sets are never created on firewall reload. In order to ensure that new sets are created, only consider "reload_set" if the set exists. If a set (from configuration) does not exist, we always want to create it. * On reload and before "fw3_destroy_ipsets()" are called, we need to update run_state to ensure that sets are updated correctly. We need to check if the sets in run_state is found in cfg_state, if not the set should be destroyed (done by forcing reload_set to true). If the set is found, then we copy the value of reload_set to the set in run_state so that the elements are updated as the user expects. Since we now always copy the value of reload_set from cfg_state, there is no need to write reload_set to run_state. Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
* firewall3: Improve ipset supportKristian Evensen2019-08-161-9/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch is an attempt at improving the ipset support in firewall3. The following changes have been made: * The enabled option did not work properly for ipsets, as it was not checked on create/destroy of a set. After this commit, sets are only created/destroyed if enabled is set to true. * Add support for reloading, or recreating, ipsets on firewall reload. By setting "reload_set" to true, the set will be destroyed and then re-created when the firewall is reloaded. My use-case for "reload_set" was to reset sets populated by dnsmasq, without having to restart the firewall or resort to scripts. * Add support for the counters and comment extensions. By setting "counters" or "comment" to true, then counters or comments are added to the set. Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com> re-ordered additional variables dropped enum OPT_COMMENT & OPT_COUNTERS as unused implemented exponential delay whilst waiting for ipset deletion/creation fixed delays made firewall unresponsive for too long on reloads Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
* ipsets: add support for specifying entriesJo-Philipp Wich2018-03-101-1/+34
| | | | | | | | | | | | | | | | Introduce a new list option "entry" which can be used to specify entries to add to the ipset, e.g. config ipset option name test ... list entry 1.2.3.4,8080 list entry 5.6.7.8,8081 Also introduce a new option "loadfile" which refers to an external file containing set entries to add, with one item per line. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* firewall3: add UBUS support for ipset sectionsPierre Lebleu2017-05-091-51/+88
| | | | | | | It gives the ability to create ipset rules via procd services and netifd interface firewall data. Signed-off-by: Pierre Lebleu <pme.lebleu@gmail.com>
* firewall3: check the return value of fw3_parse_options()Pierre Lebleu2017-05-091-1/+2
| | | | | | The return value of fw3_parse_options() should be checked. Signed-off-by: Pierre Lebleu <pme.lebleu@gmail.com>
* treewide: replace jow@openwrt.org with jo@mein.ioJo-Philipp Wich2016-06-071-1/+1
| | | | Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* Use netmasks instead of prefix lengths internallyJo-Philipp Wich2014-07-191-1/+1
| | | | | | | | | | | | | | | | | | | | Iptables supports using non-continuous netmasks like FFFF::FFFF which would match the first and last 16bit of an IPv6 address while ignoring the parts in between which is useful fordeclaring rules targeting hosts on rotating prefixes. Instead of storing parsed netmasks as bitcount internally, use a full mask which is passed to iptables as-is. Also support a new shorthand notation "addr/-N" which will construct a mask that matches the *last* N bits of an address - useful for matching the host part only of an IPv4 address, e.g. option dest_ip '::c23f:eff:fe7a:a094/-64' This will convert to a netmask of "::ffff:ffff:ffff:ffff". Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
* use calloc instead of malloc+memsetFelix Fietkau2014-06-301-4/+1
| | | | Signed-off-by: Felix Fietkau <nbd@openwrt.org>
* Several ipset bugfixesJo-Philipp Wich2014-02-211-2/+12
| | | | | | | | | - Do not consider bitmap storage for IPv6 family sets - Move ipset family parameter before any additional option - Only emit family parameter for hash sets - Do not allow IPv6 iprange for IPv4 sets and vice versa Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
* Fix another crash bug if ipsets are supported but none is declaredJo-Philipp Wich2013-05-211-2/+5
|
* Do not print to pipe or close command if nothing was executedJo-Philipp Wich2013-05-211-2/+5
|
* Wait for ipsets to appear before continuingJo-Philipp Wich2013-05-171-8/+54
|
* Family "any" is not applicable to ipsets, default to v4 and disallow "any"Jo-Philipp Wich2013-05-061-4/+8
|
* Simplify ipset external checks and optionally initialize ispet name from ↵Jo-Philipp Wich2013-05-021-3/+11
| | | | external value
* Check whether ipset exists before referencing it in rules or redirectsJo-Philipp Wich2013-05-021-0/+37
|
* Store ipset storage method and matches in state file, keep iprange and ports ↵Jo-Philipp Wich2013-04-301-28/+3
| | | | if set
* Send quit comment in fw3_destroy_ipsets() and initialize ipset objects with ↵Jo-Philipp Wich2013-04-301-0/+4
| | | | enabled = true
* Don't track family of ipsetsJo-Philipp Wich2013-04-301-11/+6
|
* Add common fw3_address_to_string() helper functionJo-Philipp Wich2013-04-301-23/+1
|
* Remove referenced to unused FW3_FLAG_DELETED flagJo-Philipp Wich2013-04-301-2/+1
|
* Remove unused "running" argument form fw3_lookup_ipset()Jo-Philipp Wich2013-04-301-3/+2
|
* Split runtime and config states, store runtime state in UCI formatJo-Philipp Wich2013-04-301-9/+2
|
* Properly handle deleted zones and ipsets on restartsJo-Philipp Wich2013-03-191-2/+3
|
* Rework zone flush logicJo-Philipp Wich2013-03-111-2/+2
|
* Change fw3_no_family() macro to take bit field value directlyJo-Philipp Wich2013-03-111-3/+2
|
* Cosmetic output changesJo-Philipp Wich2013-03-101-2/+2
|
* Introduce fw3_no_family() helper macro and use itJo-Philipp Wich2013-03-101-2/+1
|
* Separate running from current state flags in ipset handling, remove ipsets ↵Jo-Philipp Wich2013-03-101-8/+5
| | | | per family
* introduce support for enabled option in zones, forwards, rules, redirects, ↵Jo-Philipp Wich2013-03-021-0/+2
| | | | ipsets and includes
* remove ip range list hack since fw3_address can now represent true rangesJo-Philipp Wich2013-02-211-21/+17
|
* unify object freeingJo-Philipp Wich2013-02-211-32/+39
|
* rework runtime state trackingJo-Philipp Wich2013-02-211-54/+47
|
* rework ipset removal logic to only purge sets that are not in use by any familyJo-Philipp Wich2013-02-201-13/+45
|
* introduce global string array for enum names, remove private arraysJo-Philipp Wich2013-02-201-7/+1
|
* properly deal with only v4 or only v6 start/stop/restartJo-Philipp Wich2013-02-191-8/+11
|
* selectively delete chains in filter and nat tablesJo-Philipp Wich2013-02-181-24/+7
|
* add missing fclose() in previous commitJo-Philipp Wich2013-02-171-0/+2
|
* separate state and lock files, use state file information to purge ipsetsJo-Philipp Wich2013-02-171-7/+17
|
* initial commitJo-Philipp Wich2013-02-171-0/+399