summaryrefslogtreecommitdiff
path: root/libnetwork/bitseq/sequence.go
Commit message (Collapse)AuthorAgeFilesLines
* libnetwork/bit{seq,map}: delete CheckConsistency()Cory Snider2023-01-271-40/+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/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-201-26/+26
| | | | | | | | *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-201-517/+55
| | | | 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>
* Fixup libnetwork lint errorsBrian Goff2021-06-011-6/+1
| | | | Signed-off-by: Brian Goff <cpuguy83@gmail.com>
* Fix libnetwork importsBrian Goff2021-06-011-2/+2
| | | | | | | | | 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>
* 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>
* 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-031-10/+14
| | | | Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
* Serializing bitseq allocAbhinandan Prativadi2017-09-291-3/+28
| | | | | | | | | | 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>
* 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-291-4/+5
|\ | | | | Remove unnecessary string formats
| * Remove unnecessary string formatsKe Li2016-11-221-4/+5
| | | | | | | | 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-131-1/+1
| | | | | | - size 1 range is a valid input Signed-off-by: Alessandro Boch <aboch@docker.com>
* bitseq: fix racesAlexander Morozov2016-03-291-0/+2
| | | | 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>
* Allow bitseq caller to run consistency checkAlessandro Boch2016-01-141-0/+53
| | | | Signed-off-by: Alessandro Boch <aboch@docker.com>
* Adjust ipam errorsAlessandro Boch2015-12-021-7/+10
| | | | | | | | | | | | | | | | - 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-241-1/+1
| | | | | | | | | | | | | | | | - 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-101-39/+39
| | | | | | | - 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-081-0/+33
| | | | | | | | - 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-061-3/+6
| | | | | | | | | 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>
* Allow to set bits in a range in bitseqAlessandro Boch2015-09-181-19/+40
| | | | Signed-off-by: Alessandro Boch <aboch@docker.com>
* Fix bitsequence set()Alessandro Boch2015-09-041-6/+2
| | | | | | - incorrect handling during datastore write Signed-off-by: Alessandro Boch <aboch@docker.com>
* idm and ipam to use bitseq atomic APIsAlessandro Boch2015-08-161-54/+7
| | | | Signed-off-by: Alessandro Boch <aboch@docker.com>
* bitseq to provide atomic functionsAlessandro Boch2015-08-161-25/+164
| | | | | | - Also add validation for passed ordinal Signed-off-by: Alessandro Boch <aboch@docker.com>
* bitseq to only handle and return unsigned typesAlessandro Boch2015-08-161-29/+29
| | | | Signed-off-by: Alessandro Boch <aboch@docker.com>
* Control exported types in bitseqAlessandro Boch2015-08-161-101/+96
| | | | | | - bitseq users only need to know Handle type Signed-off-by: Alessandro Boch <aboch@docker.com>
* network byte order to bitseq serializerAlessandro Boch2015-08-161-12/+12
| | | | Signed-off-by: Alessandro Boch <aboch@docker.com>
* Fix incorrect error handling in bitseq constructorAlessandro Boch2015-07-041-3/+2
| | | | | | | | - We must ignore key not found error when querying datastore for initial state. - Regression introduced by 04bd8f67ad8bcd96e6c9ddf49745d9eea1eae7aa Signed-off-by: Alessandro Boch <aboch@docker.com>
* Datastore handles creating objects atomically.Spike Curtis2015-06-251-19/+15
| | | | | | | | | | | | | | | | | | | | In that commit, AtomicPutCreate takes previous = nil to Atomically create keys that don't exist. We need a create operation that is atomic to prevent races between multiple libnetworks creating the same object. Previously, we just created new KVs with an index of 0 and wrote them to the datastore. Consul accepts this behaviour and interprets index of 0 as non-existing, but other data backends do no. - Add Exists() to the KV interface. SetIndex() should also modify a KV so that it exists. - Call SetIndex() from within the GetObject() method on DataStore interface. - This ensures objects have the updated values for exists and index. - Add SetValue() to the KV interface. This allows implementers to define their own method to marshall and unmarshall (as bitseq and allocator have). - Update existing users of the DataStore (endpoint, network, bitseq, allocator, ov_network) to new interfaces. - Fix UTs.
* Fix datastore value handling in bitseqAlessandro Boch2015-06-181-10/+17
| | | | | | - and do not discard errors Signed-off-by: Alessandro Boch <aboch@docker.com>
* Add datastore to IPAM for configurationAlessandro Boch2015-06-171-29/+87
| | | | | | - IPAM to use datastore for the subnets configurations Signed-off-by: Alessandro Boch <aboch@docker.com>
* Rework push reservation w/ datastoreAlessandro Boch2015-06-171-3/+44
| | | | | | | | | | - At Handle creation, first check if an instance of the the respective object is already present in the datastore. - Handle sequence must be saved only if commit to datastore is succesfull - Caller (ipam) needs to manage the retry Signed-off-by: Alessandro Boch <aboch@docker.com>
* Datastore additions to bitmask managementMadhu Venugopal2015-06-171-7/+16
| | | | Signed-off-by: Madhu Venugopal <madhu@docker.com>
* Make bitseq.Handle thread-safeAlessandro Boch2015-06-171-1/+9
| | | | Signed-off-by: Alessandro Boch <aboch@docker.com>
* Add numerical ids managerAlessandro Boch2015-06-171-8/+8
| | | | Signed-off-by: Alessandro Boch <aboch@docker.com>
* bitseq to provide handleAlessandro Boch2015-06-171-2/+36
| | | | | | | | - Handle contains sequence and identifier. This way datastore integration can be done at bitseq level. Signed-off-by: Alessandro Boch <aboch@docker.com>
* Add serialize/deserialize for sequence listAlessandro Boch2015-06-171-0/+41
| | | | Signed-off-by: Alessandro Boch <aboch@docker.com>