aboutsummaryrefslogtreecommitdiff
path: root/src/openvpn/pool.c
AgeCommit message (Collapse)Author
2023-09-26Remove all traces of the previous MSVC build systemFrank Lichtenheld
Completely replaced by the CMake build system now. v2: - rebase on top of my dist fixes Change-Id: I807cffa40f18faa1adec4e15e84c032877a2b92e Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com> Acked-by: Lev Stipakov <lstipakov@gmail.com> Message-Id: <20230926095118.29924-1-frank@lichtenheld.com> URL: https://www.mail-archive.com/search?l=mid&q=20230926095118.29924-1-frank@lichtenheld.com Signed-off-by: Gert Doering <gert@greenie.muc.de>
2023-05-02Remove unused variable lineArne Schwabe
The newer compilers started to complain about this. Change-Id: I784def4d941b7d21c7979f84f8681719c9ff7a53 Signed-off-by: Arne Schwabe <arne@rfc2549.org> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20230430172202.206528-1-arne@rfc2549.org> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26612.html Signed-off-by: Gert Doering <gert@greenie.muc.de> (cherry picked from commit f9d0994584cd8f42c013db3e8ea2d6ab3e3d7c62)
2023-01-10Update copyright year to 2023Frank Lichtenheld
Manually excluded ovpn_dco_win.h because it is an imported file. ovpn_dco_linux.h is already excluded because it still says 2021. Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20230110160531.81010-1-frank@lichtenheld.com> URL: https://patchwork.openvpn.net/project/openvpn2/patch/20230110160531.81010-1-frank@lichtenheld.com/ Signed-off-by: Gert Doering <gert@greenie.muc.de> (cherry picked from commit ccf9d57249acb9bc9a450aec3e613bda631415f5)
2022-05-22Reformat for sp_after_comma=addFrank Lichtenheld
It is our usual style. Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com> Acked-by: Antonio Quartulli <a@unstable.cc> Message-Id: <20220519085428.6783-2-frank@lichtenheld.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24399.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2022-01-26update copyright year to 2022Antonio Quartulli
Update performed by means of: dev-tools/update-copyright.sh Cc: David Sommerseth <davids@openvpn.net> Signed-off-by: Antonio Quartulli <a@unstable.cc> Acked-by: David Sommerseth <davids@openvpn.net> Message-Id: <20220125142456.18176-1-a@unstable.cc> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23650.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-06-15Update copyrightsDavid Sommerseth
- Update the update-copyright script to include more contributors as well as correcting a few typos - Correct a copyright address in the source code to now used address (dazo) - Update copyright year to 2021 Signed-off-by: David Sommerseth <davids@openvpn.net> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20210609213231.22576-1-openvpn@sf.lists.topphemmelig.net> URL: https://www.mail-archive.com/search?l=mid&q=20210609213231.22576-1-openvpn@sf.lists.topphemmelig.net URL: https://sourceforge.net/p/openvpn/mailman/message/37299719/ Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-05Remove conditionals compilation for P2MP, ENABLE_SHAPER and ↵Arne Schwabe
TIME_BACKTRACK_PROTECTION Using OpenVPN without P2MP support (pull, TLS) is unrealistic and building a binary without it is not something we realistically want to support anyway. Building P2MP support currently only depended on HAVE_GETTIMEOFDAY or _WIN32, which has a compat function for it. So we basically can assume that gettimeofday is always availabe, either natively or through our compat function. Remove all the #ifdef P2MP logic, simplify code and reduce maintenance effort. This also removes the ENABLE_SHAPER and TIME_BACKTRACK_PROTECTION defines, which also depended only on the HAVE_GETTIMEOFDAY or _WIN32. I kept the configure.ac check and ifdef in compat since mingw actually provides a gettimeofday and we will use that instead of our own compat function. Patch V2: Remove dco parts that slipped into the patch, mention the other removed defines that are always enabled. Patch V3: Also remove the TIME_BACKTRACK_PROTECTION defines from otime.h Message-Id: <20210403184626.23067-1-arne@rfc2549.org> Signed-off-by: Arne Schwabe <arne@rfc2549.org> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20210404110602.20374-1-arne@rfc2549.org> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22030.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2020-09-17If IPv6 pool specification sets pool start to ::0 address, increment.Gert Doering
The first IPv6 address in a subnet is not usable (IPv6 anycast address), but our pool code ignored this. Instead of assigning an unusable address or erroring out, just log the fact, and increment the pool start to <pool_base>::1 NOTE: this is a bit simplistic. A pool that is larger than /96 and has non-0 bits in the "uppermost bits" will still get the increment as we only look at the lowermost 32 bits. NOTE2: if the pool is specified with "--server-ipv6 $base/$bits", this is a non-issue, as the address for the pool start will be incremented anyway. v2: make comment more explicit about "we're only talking about the host part here" and "base sees only only 32 bit of the host part" Reported-by: NicolaF_ in Trac Trac: #1282 Signed-off-by: Gert Doering <gert@greenie.muc.de> Acked-by: Antonio Quartulli <a@unstable.cc> Message-Id: <20200917085941.20972-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21039.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2020-06-26Reformat files using uncrustifyArne Schwabe
Some of the commits, especially engine have not strictly used uncrustify clean code. Rerun uncrustify to make them compliant again. Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20200626125332.15385-1-arne@rfc2549.org> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20142.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2020-06-10pool: remove useless 'options.h' includeAntonio Quartulli
Commit 6a8cd033 ("pool: add support for ifconfig-pool-persist with IPv6 only") has accidentally introduced an include for 'options.h', which revealed to not be useful at all. Remove it. Reported-by: Gert Doering <gert@greenie.muc.de> Signed-off-by: Antonio Quartulli <a@unstable.cc> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20200610090100.29738-1-a@unstable.cc> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20011.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2020-06-09Simplify pool size handling, fix possible array overrun on pool reading.Gert Doering
Remove separate ipv4.size and ipv6.size in the pool structure, return to a single pool_size, which is also the allocated array size. All calls to ifconfig_pool_size() change to "pool->size" now. pool->size is set to the size of the active pool, or if both IPv4 and IPv6 are in use, to the smaller size (same underlying logic as in 452113155e7, but really put it into the size field). This fixes a SIGSEGV crash if an ifconfig-pool-persist file is loaded that has IPv6 and no IPv4 (= ipv6 handle is used) and that has more entries than the IPv4 pool size (comparison was done with ipv6.size, not with actual pool size), introduced by commit 6a8cd033b18. While at it, fix pool size calculation for IPv6 pools >= /112 (too many -1), introduced by commit 452113155e7. Signed-off-by: Gert Doering <gert@greenie.muc.de> Acked-by: Antonio Quartulli <a@unstable.cc> Message-Id: <20200609080229.2564-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20006.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2020-06-09ipv6-pool: get rid of size constraintAntonio Quartulli
Signed-off-by: Antonio Quartulli <a@unstable.cc> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20200608201613.23750-1-a@unstable.cc> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20005.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2020-06-07pool: add support for ifconfig-pool-persist with IPv6 onlyAntonio Quartulli
Without altering the pool logic, this patch enables using a persistent IP pool also when the server is configured with IPv6 only. Trac: #208 Signed-off-by: Antonio Quartulli <antonio@openvpn.net> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20200606211624.10877-1-a@unstable.cc> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19990.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2020-06-06pool: allow to configure an IPv6-only ifconfig-poolAntonio Quartulli
With this change a server is allowed to allocate an IPv6-only pool. This is required to make it capable of managing an IPv6-only tunnel. Trac: #208 Signed-off-by: Antonio Quartulli <antonio@openvpn.net> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20200601200624.14765-1-a@unstable.cc> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19957.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2020-05-30pool: prevent IPv6 pools to be larger than 2^16 addressesAntonio Quartulli
Signed-off-by: Antonio Quartulli <a@unstable.cc> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20200530000600.1680-2-a@unstable.cc> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19945.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2018-06-08pool: convert pool 'type' to enumAntonio Quartulli
The pool 'type' member is actually an enumered type, therefore declare it as 'enum' to improve static code analisys and readability. Signed-off-by: Antonio Quartulli <antonio@openvpn.net> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20180608052017.6696-4-a@unstable.cc> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17000.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2018-06-05pool: restyle ipv4/ipv6 members to improve readabilityAntonio Quartulli
(This is only code refactoring) IPv4 and IPv6 members are all part of the same flat hierarchy in the pool data structure, without a proper name convention. Create 2 sub-structures to properly separate IPv4 from IPv6 related members. This should make the structure more organized and also slightly improve code readability. Signed-off-by: Antonio Quartulli <antonio@openvpn.net> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20180605090421.9746-3-a@unstable.cc> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16944.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2018-02-01Update copyright to include 2018 plus company name changeDavid Sommerseth
The autumn of 2017, OpenVPN Technologies, Inc changed name to just OpenVPN Inc. Otherwise, extend the copyright to cover 2018 as well. With the exception of the company name change, all changes have been performed by the dev-tools/update-copyright.sh script. Signed-off-by: David Sommerseth <davids@openvpn.net> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20180131140314.11103-1-davids@openvpn.net> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16418.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
2017-06-16copyright: Update GPLv2 license textsDavid Sommerseth
The COPYRIGHT.GPL file was slightly out-of-sync with the last GPLv2 license from Free Software Foundation, Inc. The changes are primarily a new address, which required touching almost all the project files. Except of that, it is just minor adjustments to formatting, removal of form-feed characters and referencing "GNU Lesser General Public License" instead of "GNU Library General Public License". Signed-off-by: David Sommerseth <davids@openvpn.net> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20170329093648.10156-1-davids@openvpn.net> URL: https://www.mail-archive.com/search?l=mid&q=20170329093648.10156-1-davids@openvpn.net Signed-off-by: Gert Doering <gert@greenie.muc.de>
2017-01-18More broadly enforce Allman style and braces-around-conditionalsSteffan Karger
We want { and } aligned, which means also adding a newline between each for() and {, while() and {, etc. Also, we agreed to always use braces with conditionals. The previous uncrustify config added these for if()s, now also add these for while() and for(). Signed-off-by: Steffan Karger <steffan@karger.me> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <1484403020-6857-1-git-send-email-steffan@karger.me> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13875.html Signed-off-by: David Sommerseth <davids@openvpn.net>
2016-12-21Update copyrightsDavid Sommerseth
Signed-off-by: David Sommerseth <davids@openvpn.net> Acked-by: Steffan Karger <steffan@karger.me> Message-Id: <1482350454-27280-2-git-send-email-davids@openvpn.net> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13653.html
2016-12-14The Great Reformatting - first phaseDavid Sommerseth
This is the first commit of the big reformatting task. This is performed by running the ./dev-tools/reformat-all.sh script. This is based upon the v3 reformat-all.sh/uncrustify.conf version which is now applied to git master. Signed-off-by: David Sommerseth <davids@openvpn.net>
2012-03-22build: move out config.h include from sysheadAlon Bar-Lev
Yet another step in reducing the syshead.h content. Conditional compilation of sources needs to be based on a minimum program prefix (config.h only). Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com> Acked-by: David Sommerseth <davids@redhat.com> Signed-off-by: David Sommerseth <davids@redhat.com>
2012-03-22build: standard directory layoutAlon Bar-Lev
Suitable for mature project. root - administrative stuff doc - documents src - sources tests - tests distro - distro specific files sample - samples SIDE EFFECT: many changes to rpm spec. Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com> Acked-by: Adriaan de Jong <dejong@fox-it.com> Signed-off-by: David Sommerseth <davids@redhat.com>