This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 670
2924: Preserve the client source IP #3298
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
039750a
Re-expose weave bridge in EnsureBridge
brb 27c9807
Move npc/ipset package to net/ipset
brb 21fb953
Create weave-no-masq-local ipset
brb 62c30d9
Extern LocalRangeTracker interface with String method
brb 4f99efa
Export tracker.RemoveCommon and tracker.Merge
brb ebf4b4b
Implement and start using NoMasqLocalTracker
brb a0ec06a
Destroy weave-no-masq-local ipset upon "weave reset"
brb 6dbe95a
Add NO_MASQ_LOCAL to weave-kube/launch.sh
brb efd5d0e
Add /client_ip to network-tester
brb 45a9ea6
Add k8s integration test case for preserving client IP addr
brb 7fdf8fe
Mention NO_MASQ_LOCAL opt in the docs
brb b6115f0
Address the PR comments
brb 2f8aa7a
Add random nonce to test ipset name to prevent race
brb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package tracker | ||
|
||
import ( | ||
"github.com/weaveworks/weave/net/address" | ||
) | ||
|
||
// Merge merges adjacent range entries. | ||
// The given slice has to be sorted in increasing order. | ||
func Merge(r []address.Range) []address.Range { | ||
var merged []address.Range | ||
|
||
for i := range r { | ||
if prev := len(merged) - 1; prev >= 0 && merged[prev].End == r[i].Start { | ||
merged[prev].End = r[i].End | ||
} else { | ||
merged = append(merged, r[i]) | ||
} | ||
} | ||
|
||
return merged | ||
} | ||
|
||
// RemoveCommon filters out CIDR ranges which are contained in both a and b slices. | ||
// Both slices have to be sorted in increasing order. | ||
func RemoveCommon(a, b []address.CIDR) (newA, newB []address.CIDR) { | ||
i, j := 0, 0 | ||
|
||
for i < len(a) && j < len(b) { | ||
switch { | ||
case a[i].Start() < b[j].Start() || a[i].End() < b[j].End(): | ||
newA = append(newA, a[i]) | ||
i++ | ||
case a[i].Start() > b[j].Start() || a[i].End() > b[j].End(): | ||
newB = append(newB, b[j]) | ||
j++ | ||
default: | ||
i++ | ||
j++ | ||
} | ||
|
||
} | ||
newA = append(newA, a[i:]...) | ||
newB = append(newB, b[j:]...) | ||
|
||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
Sorry, something went wrong.