-
Notifications
You must be signed in to change notification settings - Fork 22
Consistent hashing for balancer #258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TheRandomCharacter
wants to merge
8
commits into
yanet-platform:main
Choose a base branch
from
TheRandomCharacter:chash
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3e426f9
Refactor balancer service evaluation.
19f266c
Add chash balancer service evaluation stub.
525174d
Switch default meson option to link statically.
28004cd
Add chash submodule.
c128f29
Add handling of chash services to dataplane
9770bf8
Replaces goto with deferer object
a2a9a87
Updates autotest 055_balancer_wlc expected data
60da595
Add autotest for chash balancer service
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 hidden or 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
53 changes: 53 additions & 0 deletions
53
autotest/units/001_one_port/049_balancer_chash/autotest.yaml
This file contains hidden or 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,53 @@ | ||
steps: | ||
- ipv4Update: | ||
- "0.0.0.0/0 -> 200.0.0.1" | ||
- "100.0.0.0/8 -> 100.0.0.5" | ||
- ipv6Update: "::/0 -> fe80::1" | ||
- cli: | ||
- balancer real enable balancer0 2004:dead:beef::1 udp 80 2006::1 80 | ||
- balancer real enable balancer0 2004:dead:beef::1 udp 80 2006::2 80 | ||
- balancer real enable balancer0 2004:dead:beef::1 udp 80 2006::3 80 | ||
- balancer real enable balancer0 2004:dead:beef::1 udp 80 2006::4 80 | ||
- balancer real flush | ||
- cli_check: | | ||
YANET_FORMAT_COLUMNS=module,virtual_ip,proto,virtual_port,scheduler,real_ip,real_port,enabled,weight,connections,packets,bytes balancer real balancer0 any | ||
module virtual_ip proto virtual_port scheduler real_ip real_port enabled weight connections packets bytes | ||
--------- ----------------- ----- ------------ --------- ------- --------- ------- ------ ----------- ------- ----- | ||
balancer0 2004:dead:beef::1 udp 80 chash 2006::1 80 true 1 0 0 0 | ||
balancer0 2004:dead:beef::1 udp 80 chash 2006::2 80 true 1 0 0 0 | ||
balancer0 2004:dead:beef::1 udp 80 chash 2006::3 80 true 1 0 0 0 | ||
balancer0 2004:dead:beef::1 udp 80 chash 2006::4 80 true 1 0 0 0 | ||
- cli: | ||
- balancer real enable balancer0 2004:dead:beef::1 udp 80 2006::3 80 100 | ||
- balancer real flush | ||
- sendPackets: | ||
- port: kni0 | ||
send: 001-send.pcap | ||
expect: 001-expect.pcap | ||
- cli_check: | | ||
YANET_FORMAT_COLUMNS=module,virtual_ip,proto,virtual_port,scheduler,real_ip,real_port,enabled,weight,connections,packets,bytes balancer real balancer0 any | ||
module virtual_ip proto virtual_port scheduler real_ip real_port enabled weight connections packets bytes | ||
--------- ----------------- ----- ------------ --------- ------- --------- ------- ------ ----------- ------- ----- | ||
balancer0 2004:dead:beef::1 udp 80 chash 2006::1 80 true 1 3 3 318 | ||
balancer0 2004:dead:beef::1 udp 80 chash 2006::2 80 true 1 4 4 424 | ||
balancer0 2004:dead:beef::1 udp 80 chash 2006::3 80 true 100 117 117 12402 | ||
balancer0 2004:dead:beef::1 udp 80 chash 2006::4 80 true 1 4 4 424 | ||
- cli: | ||
- balancer real enable balancer0 2004:dead:beef::1 udp 80 2006::1 80 10 | ||
- balancer real enable balancer0 2004:dead:beef::1 udp 80 2006::2 80 10 | ||
- balancer real enable balancer0 2004:dead:beef::1 udp 80 2006::3 80 10 | ||
- balancer real enable balancer0 2004:dead:beef::1 udp 80 2006::4 80 10 | ||
- balancer real flush | ||
- sleep: 1 | ||
- sendPackets: | ||
- port: kni0 | ||
send: 002-send.pcap | ||
expect: 002-expect.pcap | ||
- cli_check: | | ||
YANET_FORMAT_COLUMNS=module,virtual_ip,proto,virtual_port,scheduler,real_ip,real_port,enabled,weight,connections,packets,bytes balancer real balancer0 any | ||
module virtual_ip proto virtual_port scheduler real_ip real_port enabled weight connections packets bytes | ||
--------- ----------------- ----- ------------ --------- ------- --------- ------- ------ ----------- ------- ----- | ||
balancer0 2004:dead:beef::1 udp 80 chash 2006::1 80 true 10 38 38 4028 | ||
balancer0 2004:dead:beef::1 udp 80 chash 2006::2 80 true 10 32 32 3392 | ||
balancer0 2004:dead:beef::1 udp 80 chash 2006::3 80 true 10 150 150 15900 | ||
balancer0 2004:dead:beef::1 udp 80 chash 2006::4 80 true 10 36 36 3816 |
48 changes: 48 additions & 0 deletions
48
autotest/units/001_one_port/049_balancer_chash/controlplane.conf
This file contains hidden or 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,48 @@ | ||
{ | ||
"modules": { | ||
"lp0.100": { | ||
"type": "logicalPort", | ||
"physicalPort": "kni0", | ||
"vlanId": "100", | ||
"macAddress": "00:11:22:33:44:55", | ||
"nextModule": "acl0" | ||
}, | ||
"lp0.200": { | ||
"type": "logicalPort", | ||
"physicalPort": "kni0", | ||
"vlanId": "200", | ||
"macAddress": "00:11:22:33:44:55", | ||
"nextModule": "acl0" | ||
}, | ||
"acl0": { | ||
"type": "acl", | ||
"nextModules": [ | ||
"balancer0", | ||
"route0" | ||
] | ||
}, | ||
"balancer0": { | ||
"type": "balancer", | ||
"source": "2000:51b::1", | ||
"source_ipv4": "100.0.0.22", | ||
"services": "services.conf", | ||
"nextModule": "route0" | ||
}, | ||
"route0": { | ||
"type": "route", | ||
"interfaces": { | ||
"kni0.100": { | ||
"neighborIPv6Address": "fe80::1", | ||
"neighborIPv4Address": "100.0.0.5", | ||
"neighborMacAddress": "00:00:00:00:00:01", | ||
"nextModule": "lp0.100" | ||
}, | ||
"kni0.200": { | ||
"neighborIPv4Address": "200.0.0.1", | ||
"neighborMacAddress": "00:00:00:00:00:02", | ||
"nextModule": "lp0.200" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or 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,31 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
from scapy.all import * | ||
|
||
|
||
def write_pcap(filename, *packetsList): | ||
if len(packetsList) == 0: | ||
PcapWriter(filename)._write_header(Ether()) | ||
return | ||
|
||
PcapWriter(filename) | ||
|
||
for packets in packetsList: | ||
if type(packets) == list: | ||
for packet in packets: | ||
packet.time = 0 | ||
wrpcap(filename, [p for p in packet], append=True) | ||
else: | ||
packets.time = 0 | ||
wrpcap(filename, [p for p in packets], append=True) | ||
|
||
packages1 = [Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02") / Dot1Q(vlan=200) / IPv6(dst="2004:dead:beef::1", src=f"2002::{a_h}:{a_m}:{a_l}", hlim=64) / UDP(dport=80, sport=sport) | ||
for sport in (12443, 12444) for a_h in range(4) for a_m in range(4) for a_l in range(4)] | ||
|
||
write_pcap("001-send.pcap", *packages1) | ||
|
||
packages2 = [Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02") / Dot1Q(vlan=200) / IPv6(dst="2004:dead:beef::1", src=f"2002:2::{a_h}:{a_m}:{a_l}", hlim=64) / UDP(dport=80, sport=sport) | ||
for sport in (12443, 12444) for a_h in range(4) for a_m in range(4) for a_l in range(4)] | ||
|
||
write_pcap("002-send.pcap", *packages2) |
26 changes: 26 additions & 0 deletions
26
autotest/units/001_one_port/049_balancer_chash/services.conf
This file contains hidden or 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,26 @@ | ||
[ | ||
{ | ||
"vip": "2004:dead:beef::1", | ||
"proto": "udp", | ||
"vport": "80", | ||
"scheduler": "chash", | ||
"reals": [ | ||
{ | ||
"ip": "2006::1", | ||
"port": "80" | ||
}, | ||
{ | ||
"ip": "2006::2", | ||
"port": "80" | ||
}, | ||
{ | ||
"ip": "2006::3", | ||
"port": "80" | ||
}, | ||
{ | ||
"ip": "2006::4", | ||
"port": "80" | ||
} | ||
] | ||
} | ||
] |
Binary file modified
BIN
+3.56 KB
(200%)
autotest/units/001_one_port/055_balancer_wlc/001-expect.pcap
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+3.56 KB
(200%)
autotest/units/001_one_port/055_balancer_wlc/002-expect.pcap
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
autotest/units/001_one_port/055_balancer_wlc/003-expect.pcap
Binary file not shown.
This file contains hidden or 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 hidden or 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,35 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
import sys | ||
from scapy.all import * | ||
|
||
def dist(packets): | ||
d = {} | ||
for packet in packets: | ||
dst = packet.getlayer(IPv6).dst | ||
if dst not in d: | ||
d[dst] = 0 | ||
d[dst] += 1 | ||
return d | ||
|
||
def dist_cmd(): | ||
if len(sys.argv) < 3: | ||
print("Provide file name.") | ||
exit(1) | ||
packets = rdpcap(sys.argv[2]) | ||
print(dist(packets)) | ||
exit(0) | ||
|
||
def main(): | ||
if len(sys.argv) < 2: | ||
print("Provide command.") | ||
exit(1) | ||
if sys.argv[1] == "dist": | ||
dist_cmd() | ||
print("Command not found.") | ||
exit(1) | ||
|
||
if __name__ == "__main__": | ||
main() | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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,23 @@ | ||
namespace utils | ||
{ | ||
|
||
template<typename F> | ||
class Deferer | ||
{ | ||
F action_; | ||
|
||
public: | ||
Deferer(F&& action) : | ||
action_{std::move(action)} | ||
{} | ||
Deferer(const Deferer& other) = delete; | ||
Deferer(Deferer&& other) = delete; | ||
Deferer& operator=(const Deferer& other) = delete; | ||
Deferer& operator=(Deferer&& other) = delete; | ||
~Deferer() | ||
{ | ||
action_(); | ||
} | ||
}; | ||
|
||
} // namespace utils |
This file contains hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.