summaryrefslogtreecommitdiff
path: root/libnetwork/bitseq
Commit message (Collapse)AuthorAgeFilesLines
* libnetwork/bit{seq,map}: delete CheckConsistency()Cory Snider2023-01-272-70/+0
| | | | | | | | That method was only referenced by ipam.Allocator, but as it no longer stores any state persistently there is no possibility for it to load an inconsistent bit-sequence from Docker 1.9.x. Signed-off-by: Cory Snider <csnider@mirantis.com>
* libnetwork/config: remove vestiges of global scopeCory Snider2023-01-261-1/+1
| | | | | | | | | | | | | Without (*Controller).ReloadConfiguration, the only way to configure datastore scopes would be by passing config.Options to libnetwork.New. The only options defined which relate to datastore scopes are limited to configuring the local-scope datastore. Furthermore, the default datastore config only defines configuration for the local-scope datastore. The local-scope datastore is therefore the only datastore scope possible in libnetwork. Start removing code which is only needed to support multiple datastore scopes. Signed-off-by: Cory Snider <csnider@mirantis.com>
* libnetwork/bitseq: refactor JSON marshalingCory Snider2023-01-201-27/+11
| | | | Signed-off-by: Cory Snider <csnider@mirantis.com>
* libnetwork/bitseq: make mutex an unexported fieldCory Snider2023-01-202-48/+48
| | | | | | | | *bitseq.Handle should not implement sync.Locker. The mutex is a private implementation detail which external consumers should not be able to manipulate. Signed-off-by: Cory Snider <csnider@mirantis.com>
* libnetwork/bitseq: refactor in terms of bitmapCory Snider2023-01-203-1619/+87
| | | | Signed-off-by: Cory Snider <csnider@mirantis.com>
* libnetwork/bitseq: add marshal/unmarshal testsCory Snider2023-01-201-0/+64
| | | | | | | Catch any backwards-compatibility hazards with serialization of sequences early. Signed-off-by: Cory Snider <csnider@mirantis.com>
* libnetwork: fix empty-lines (revive)Sebastiaan van Stijn2022-09-261-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libnetwork/etchosts/etchosts_test.go:167:54: empty-lines: extra empty line at the end of a block (revive) libnetwork/osl/route_linux.go:185:74: empty-lines: extra empty line at the start of a block (revive) libnetwork/osl/sandbox_linux_test.go:323:36: empty-lines: extra empty line at the start of a block (revive) libnetwork/bitseq/sequence.go:412:48: empty-lines: extra empty line at the start of a block (revive) libnetwork/datastore/datastore_test.go:67:46: empty-lines: extra empty line at the end of a block (revive) libnetwork/datastore/mock_store.go:34:60: empty-lines: extra empty line at the end of a block (revive) libnetwork/iptables/firewalld.go:202:44: empty-lines: extra empty line at the end of a block (revive) libnetwork/iptables/firewalld_test.go:76:36: empty-lines: extra empty line at the end of a block (revive) libnetwork/iptables/iptables.go:256:67: empty-lines: extra empty line at the end of a block (revive) libnetwork/iptables/iptables.go:303:128: empty-lines: extra empty line at the start of a block (revive) libnetwork/networkdb/cluster.go:183:72: empty-lines: extra empty line at the end of a block (revive) libnetwork/ipams/null/null_test.go:44:38: empty-lines: extra empty line at the end of a block (revive) libnetwork/drivers/macvlan/macvlan_store.go:45:52: empty-lines: extra empty line at the end of a block (revive) libnetwork/ipam/allocator_test.go:1058:39: empty-lines: extra empty line at the start of a block (revive) libnetwork/drivers/bridge/port_mapping.go:88:111: empty-lines: extra empty line at the end of a block (revive) libnetwork/drivers/bridge/link.go:26:90: empty-lines: extra empty line at the end of a block (revive) libnetwork/drivers/bridge/setup_ipv6_test.go:17:34: empty-lines: extra empty line at the end of a block (revive) libnetwork/drivers/bridge/setup_ip_tables.go:392:4: empty-lines: extra empty line at the start of a block (revive) libnetwork/drivers/bridge/bridge.go:804:50: empty-lines: extra empty line at the start of a block (revive) libnetwork/drivers/overlay/ov_serf.go:183:29: empty-lines: extra empty line at the start of a block (revive) libnetwork/drivers/overlay/ov_utils.go:81:64: empty-lines: extra empty line at the end of a block (revive) libnetwork/drivers/overlay/peerdb.go:172:67: empty-lines: extra empty line at the start of a block (revive) libnetwork/drivers/overlay/peerdb.go:209:67: empty-lines: extra empty line at the start of a block (revive) libnetwork/drivers/overlay/peerdb.go:344:89: empty-lines: extra empty line at the start of a block (revive) libnetwork/drivers/overlay/peerdb.go:436:63: empty-lines: extra empty line at the start of a block (revive) libnetwork/drivers/overlay/overlay.go:183:36: empty-lines: extra empty line at the start of a block (revive) libnetwork/drivers/overlay/encryption.go:69:28: empty-lines: extra empty line at the end of a block (revive) libnetwork/drivers/overlay/ov_network.go:563:81: empty-lines: extra empty line at the start of a block (revive) libnetwork/default_gateway.go:32:43: empty-lines: extra empty line at the start of a block (revive) libnetwork/errors_test.go:9:40: empty-lines: extra empty line at the start of a block (revive) libnetwork/service_common.go:184:64: empty-lines: extra empty line at the end of a block (revive) libnetwork/endpoint.go:161:55: empty-lines: extra empty line at the end of a block (revive) libnetwork/store.go:320:33: empty-lines: extra empty line at the end of a block (revive) libnetwork/store_linux_test.go:11:38: empty-lines: extra empty line at the end of a block (revive) libnetwork/sandbox.go:571:36: empty-lines: extra empty line at the start of a block (revive) libnetwork/service_common.go:317:246: empty-lines: extra empty line at the start of a block (revive) libnetwork/endpoint.go:550:17: empty-lines: extra empty line at the end of a block (revive) libnetwork/sandbox_dns_unix.go:213:106: empty-lines: extra empty line at the start of a block (revive) libnetwork/controller.go:676:85: empty-lines: extra empty line at the end of a block (revive) libnetwork/agent.go:876:60: empty-lines: extra empty line at the end of a block (revive) libnetwork/resolver.go:324:69: empty-lines: extra empty line at the end of a block (revive) libnetwork/network.go:1153:92: empty-lines: extra empty line at the end of a block (revive) libnetwork/network.go:1955:67: empty-lines: extra empty line at the start of a block (revive) libnetwork/network.go:2235:9: empty-lines: extra empty line at the start of a block (revive) libnetwork/libnetwork_internal_test.go:336:26: empty-lines: extra empty line at the start of a block (revive) libnetwork/resolver_test.go:76:35: empty-lines: extra empty line at the end of a block (revive) libnetwork/libnetwork_test.go:303:38: empty-lines: extra empty line at the end of a block (revive) libnetwork/libnetwork_test.go:985:46: empty-lines: extra empty line at the end of a block (revive) libnetwork/ipam/allocator_test.go:1263:37: empty-lines: extra empty line at the start of a block (revive) libnetwork/errors_test.go:9:40: empty-lines: extra empty line at the end of a block (revive) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* gofmt GoDoc comments with go1.19Sebastiaan van Stijn2022-07-081-3/+4
| | | | | | | | Older versions of Go don't format comments, so committing this as a separate commit, so that we can already make these changes before we upgrade to Go 1.19. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* refactor: move from io/ioutil to io and os packageEng Zer Jun2021-08-271-2/+1
| | | | | | | | The io/ioutil package has been deprecated in Go 1.16. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
* libnetwork: remove unused "testutils" importsSebastiaan van Stijn2021-08-181-1/+0
| | | | | | | Perhaps the testutils package in the past had an `init()` function to set up specific things, but it no longer has. so these imports were doing nothing. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* Fixup libnetwork lint errorsBrian Goff2021-06-013-19/+2
| | | | Signed-off-by: Brian Goff <cpuguy83@gmail.com>
* Fix issues running libnetwork tests.Brian Goff2021-06-011-6/+8
| | | | | | | | libnetwork does different stuff depending on if you are running the tests in a container or not... without telling it we are in a container a bunch of the tests actually fail. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
* Fix libnetwork importsBrian Goff2021-06-013-6/+6
| | | | | | | | | After moving libnetwork to this repo, we need to update all the import paths for libnetwork to point to docker/docker/libnetwork instead of docker/libnetwork. This change implements that. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
* Fix gofmt in preparation of Go 1.13 updateSebastiaan van Stijn2020-02-271-8/+8
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* doc: fix typoYan Zhu2018-09-071-1/+1
| | | | Signed-off-by: Yan Zhu <yanzhu@alauda.io>
* Spelling fixesJosh Soref2018-07-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * addresses * assigned * at least * attachments * auxiliary * available * cleanup * communicate * communications * configuration * connection * connectivity * destination * encountered * endpoint * example * existing * expansion * expected * external * forwarded * gateway * implementations * implemented * initialize * internally * loses * message * network * occurred * operational * origin * overlapping * reaper * redirector * release * representation * resolver * retrieve * returns * sanbdox * sequence * succesful * synchronizing * update * validates Signed-off-by: Josh Soref <jsoref@gmail.com>
* Adding logs for ipam stateAbhinandan Prativadi2018-05-141-3/+2
| | | | Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
* IPAM and Bitseq test casesAbhinandan Prativadi2018-03-091-6/+55
| | | | | | | This commit contains test cases to verify the changes and to solidify the library. Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
* Fixing Duplicate IP issue in IPAM libraryAbhinandan Prativadi2018-03-081-24/+49
| | | | | | | | | | | | | | This commit contains fixes for duplicate IP with 3 issues addressed: 1) Race condition when datastore is not present in cases like swarmkit 2) Byte Offset calculation depending on where the start of the bit in the bitsequence is, the offset was adding more bytes to the offset when the start of the bit is in the middle of one of the instances in a block 3) Finding the available bit was returning the last bit in the curent instance in a block if the block is not full and the current bit is after the last available bit. Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
* Adding a unit case to verify rolloverAbhinandan Prativadi2017-10-032-155/+113
| | | | Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
* Minor unit test changeAbhinandan Prativadi2017-09-291-10/+192
| | | | | | | | Since bit allocation is no longer first available from the start some verfications are removed/modified to the change allocation model Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
* Serializing bitseq allocAbhinandan Prativadi2017-09-292-3/+29
| | | | | | | | | | Previously the bitseq alloc was allocating the first available bit from the begining of the sequence. With this commit the bitseq alloc will proceed from the current allocation. This change will affect the way ipam and vni allocation is done currently. The ip allocation will be done sequentially from the previous allocation as opposed to the first available IP. Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
* Update logrus to v1.0.1Derek McGowan2017-08-071-1/+1
| | | | | | | Fix case sensitivity issue Update docker and runc vendors Signed-off-by: Derek McGowan <derek@mcgstyle.net>
* Adding a unit test to catch offset scenariosAbhinandan Prativadi2017-07-101-32/+72
| | | | Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
* Fixing issue with bit allocation byteoffset calculationAbhinandan Prativadi2017-06-091-2/+6
| | | | | | | | | | | The byteoffset calculation was skewed to double include the offset value calculated. The double calculation happens if the starting ordinal is part of the head sequence block. This error in calculation could result in duplicate but getting allocated eventually propogating to ipam and vni id allocations Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
* Merge pull request #1568 from likel/refactorAlessandro Boch2016-12-292-12/+13
|\ | | | | Remove unnecessary string formats
| * Remove unnecessary string formatsKe Li2016-11-222-12/+13
| | | | | | | | Signed-off-by: Ke Li <kel@splunk.com>
* | Fixed misspellingDaehyeok Mun2016-11-281-1/+1
|/ | | | Signed-off-by: Daehyeok Mun <daehyeok@gmail.com>
* Refactoring logrus import and formattingDaehyeok Mun2016-11-081-2/+2
| | | | | | | | | | This fix tries to fix logrus formatting by removing `f` from `logrus.[Error|Warn|Debug|Fatal|Panic|Info]f` when formatting string is not present. Also fix import name to use original project name 'logrus' instead of 'log' Signed-off-by: Daehyeok Mun <daehyeok@gmail.com>
* Fix bitseq.SetAnyInRangeAlessandro Boch2016-09-132-5/+6
| | | | | | - size 1 range is a valid input Signed-off-by: Alessandro Boch <aboch@docker.com>
* Merge pull request #1120 from mrjana/storeAlessandro Boch2016-04-151-0/+5
|\ | | | | Remove kvstore backend deps from datastore package
| * Remove kvstore deps from datastore packageJana Radhakrishnan2016-04-151-0/+5
| | | | | | | | | | | | | | | | | | Currently datastore has dependencies on various kv backends. This is undesirable if datastore had to be used as a backend agnostic store management package with it's cache layer. This PR aims to achieve that. Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
* | bitseq: fix racesAlexander Morozov2016-03-292-0/+7
|/ | | | Signed-off-by: Alexander Morozov <lk4d4@docker.com>
* Fix some typos in comments and stringsStefan Weil2016-03-011-1/+1
| | | | | | All of them were found and fixed by codespell. Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Use gofmt with -s instead of goimportsVincent Demeester2016-02-121-3/+3
| | | | Signed-off-by: Vincent Demeester <vincent@sbr.pm>
* Allow bitseq caller to run consistency checkAlessandro Boch2016-01-142-0/+201
| | | | Signed-off-by: Alessandro Boch <aboch@docker.com>
* Increase test coverage in bitsequenceAlessandro Boch2015-12-111-1/+235
| | | | | | - Cover random allocation/deallocation Signed-off-by: Alessandro Boch <aboch@docker.com>
* Adjust ipam errorsAlessandro Boch2015-12-022-10/+13
| | | | | | | | | | | | | | | | - Remove from contract predefined errors which are no longer valid (ex. ErrInvalidIpamService, ErrInvalidIpamConfigService) - Do not use network driver error for ipam load failure in controller.go - Bitseq to expose two well-known errors (no more bit available, bit is already set) - Default ipam to report proper well-known error on RequestAddress() based on bitseq returned error - Default ipam errors to comply with types error interface Signed-off-by: Alessandro Boch <aboch@docker.com>
* bitseq: fix race between CopyTo and setAlexander Morozov2015-11-301-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Race detector message: WARNING: DATA RACE Write by goroutine 269: github.com/docker/libnetwork/bitseq.(*Handle).CopyTo() /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/bitseq/store.go:85 +0x2f6 github.com/docker/libnetwork/datastore.(*cache).get() /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/datastore/cache.go:135 +0x307 github.com/docker/libnetwork/datastore.(*datastore).GetObject() /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/datastore/datastore.go:438 +0x121 github.com/docker/libnetwork/bitseq.(*Handle).set() /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/bitseq/sequence.go:254 +0x1a5 github.com/docker/libnetwork/bitseq.(*Handle).Unset() /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/bitseq/sequence.go:227 +0xb0 github.com/docker/libnetwork/ipam.(*Allocator).ReleaseAddress() /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/ipam/allocator.go:446 +0x10bc github.com/docker/libnetwork.(*endpoint).releaseAddress() /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/endpoint.go:830 +0x731 github.com/docker/libnetwork.(*endpoint).Delete() /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/endpoint.go:624 +0x8d8 github.com/docker/libnetwork.(*sandbox).Delete() /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/sandbox.go:191 +0x1047 github.com/docker/docker/daemon.(*Daemon).releaseNetwork() /home/moroz/project/workspace/src/github.com/docker/docker/daemon/container_unix.go:1180 +0x676 github.com/docker/docker/daemon.(*Daemon).Cleanup() /home/moroz/project/workspace/src/github.com/docker/docker/daemon/start.go:157 +0x5d github.com/docker/docker/daemon.(*containerMonitor).Close() /home/moroz/project/workspace/src/github.com/docker/docker/daemon/monitor.go:111 +0xa4 github.com/docker/docker/daemon.(*containerMonitor).Start.func1() /home/moroz/project/workspace/src/github.com/docker/docker/daemon/monitor.go:142 +0x14b github.com/docker/docker/daemon.(*containerMonitor).Start() /home/moroz/project/workspace/src/github.com/docker/docker/daemon/monitor.go:223 +0x1159 github.com/docker/docker/daemon.(*containerMonitor).Start-fm() /home/moroz/project/workspace/src/github.com/docker/docker/daemon/start.go:147 +0x3b github.com/docker/docker/pkg/promise.Go.func1() /home/moroz/project/workspace/src/github.com/docker/docker/pkg/promise/promise.go:8 +0x2a Previous read by goroutine 340: github.com/docker/libnetwork/bitseq.(*Handle).set() /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/bitseq/sequence.go:254 +0x133 github.com/docker/libnetwork/bitseq.(*Handle).Unset() /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/bitseq/sequence.go:227 +0xb0 github.com/docker/libnetwork/ipam.(*Allocator).ReleaseAddress() /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/ipam/allocator.go:446 +0x10bc github.com/docker/libnetwork.(*endpoint).releaseAddress() /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/endpoint.go:830 +0x731 github.com/docker/libnetwork.(*endpoint).Delete() /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/endpoint.go:624 +0x8d8 github.com/docker/libnetwork.(*sandbox).Delete() /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/sandbox.go:191 +0x1047 github.com/docker/docker/daemon.(*Daemon).releaseNetwork() /home/moroz/project/workspace/src/github.com/docker/docker/daemon/container_unix.go:1180 +0x676 github.com/docker/docker/daemon.(*Daemon).Cleanup() /home/moroz/project/workspace/src/github.com/docker/docker/daemon/start.go:157 +0x5d github.com/docker/docker/daemon.(*containerMonitor).Close() /home/moroz/project/workspace/src/github.com/docker/docker/daemon/monitor.go:111 +0xa4 github.com/docker/docker/daemon.(*containerMonitor).Start.func1() /home/moroz/project/workspace/src/github.com/docker/docker/daemon/monitor.go:142 +0x14b github.com/docker/docker/daemon.(*containerMonitor).Start() /home/moroz/project/workspace/src/github.com/docker/docker/daemon/monitor.go:223 +0x1159 github.com/docker/docker/daemon.(*containerMonitor).Start-fm() /home/moroz/project/workspace/src/github.com/docker/docker/daemon/start.go:147 +0x3b github.com/docker/docker/pkg/promise.Go.func1() /home/moroz/project/workspace/src/github.com/docker/docker/pkg/promise/promise.go:8 +0x2a Signed-off-by: Alexander Morozov <lk4d4@docker.com>
* Fix bug in bitsequence.pushReservationAlessandro Boch2015-11-242-1/+112
| | | | | | | | | | | | | | | | - pushReservation fails to correctly detect when the affected block is the last in the current sequence. It thinks instead the block is in between the sequence. Because of this a couple of issues may happen: 1. The allocation of the last bit causes the creation of a phantom sequence (length 0) at the end. (This has no side effects). 2. The allocation of a bit somewhere in the middle of the bitmask may lead to a completely incorrect sequence pattern. Signed-off-by: Alessandro Boch <aboch@docker.com>
* Remove 2^32 bits restriction on bitsequenceAlessandro Boch2015-10-102-66/+66
| | | | | | | - Allow bitsequence of length 2^64-1 - Updated ID Manager and IPAM Signed-off-by: Alessandro Boch <aboch@docker.com>
* Phase-2 bridge driver changes to support IPAMAlessandro Boch2015-10-082-17/+37
| | | | | | | | - Set bridge ipv4 address when bridge is present - IPv6 changes for bridge - Convert unit tests to the new model Signed-off-by: Alessandro Boch <aboch@docker.com>
* IPAM watch removal and multistore supportJana Radhakrishnan2015-10-062-35/+39
| | | | | | | | | Remove the need for watching for IPAM data structures and add multi store support code and data reorganization to simplify address space management. Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
* Fix in bitseq.NewHandle()Alessandro Boch2015-10-031-0/+7
| | | | | | | | - When creating the handle, write it to store if not present. Currently it is written to store only on first bit allocation. Signed-off-by: Alessandro Boch <aboch@docker.com>
* libnetwork <-> ipam driver interactionAlessandro Boch2015-10-031-1/+16
| | | | Signed-off-by: Alessandro Boch <aboch@docker.com>
* IPAM driverAlessandro Boch2015-10-031-2/+2
| | | | | | | | - Add IPAM cotract and remote IPAM hooks - Add ipam registration in controller - Have default IPAM follow ipamapi contract Signed-off-by: Alessandro Boch <aboch@docker.com>
* Providing KVObject option to skip persisting object in kvstoreMadhu Venugopal2015-09-221-0/+5
| | | | Signed-off-by: Madhu Venugopal <madhu@docker.com>
* Add local datastore to persist states of LocalScope networkChun Chen2015-09-211-0/+5
| | | | Signed-off-by: Chun Chen <ramichen@tencent.com>
* Allow to set bits in a range in bitseqAlessandro Boch2015-09-182-57/+218
| | | | Signed-off-by: Alessandro Boch <aboch@docker.com>
* Move test specific functions to a testutils package.David Calavera2015-09-071-1/+1
| | | | | | | | | This way we won't vendor test related functions in docker anymore. It also moves netns related functions to a new ns package to be able to call the ns init function in tests. I think this also helps with the overall package isolation. Signed-off-by: David Calavera <david.calavera@gmail.com>