-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Currently YANET only supports the IPIP tunneling scheme for packet delivery to service backends. However, there is no native support for IPIP encapsulation on Windows platform we want to support services on, so we had to implement GRE tunnelling protocol. This commit allows one to configure a tunneling mode, whether IPIP or GRE, for each service inside balancer configuration using lvs_method option set to TUN (for IPIP) or GRE respectively. Commited by Steve Balayan (https://github.com/SteveBalayanAKAMedian)
- Loading branch information
Showing
22 changed files
with
348 additions
and
18 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
31 changes: 31 additions & 0 deletions
31
autotests/units/001_one_port/065_balancer_gre/autotest.yaml
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,31 @@ | ||
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 10.0.0.1 tcp 80 2000::1 80 | ||
- balancer real enable balancer0 10.0.0.42 tcp 80 100.0.0.42 80 | ||
- balancer real enable balancer0 2001:dead:beef::1 tcp 80 2000::1 80 | ||
- balancer real enable balancer0 2001:dead:beef::2 tcp 80 100.0.0.6 80 | ||
- balancer real flush | ||
- sleep: 1 | ||
- sendPackets: | ||
- port: kni0 | ||
send: 001-send.pcap | ||
expect: 001-expect.pcap | ||
- sleep: 1 | ||
- sendPackets: | ||
- port: kni0 | ||
send: 002-send.pcap | ||
expect: 002-expect.pcap | ||
- sleep: 1 | ||
- sendPackets: | ||
- port: kni0 | ||
send: 003-send.pcap | ||
expect: 003-expect.pcap | ||
- sleep: 1 | ||
- sendPackets: | ||
- port: kni0 | ||
send: 004-send.pcap | ||
expect: 004-expect.pcap |
49 changes: 49 additions & 0 deletions
49
autotests/units/001_one_port/065_balancer_gre/controlplane.conf
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,49 @@ | ||
{ | ||
"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", | ||
"default_wlc_power": 10, | ||
"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 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,80 @@ | ||
#!/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) | ||
|
||
|
||
write_pcap("001-send.pcap", | ||
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02") / Dot1Q(vlan=200) / IP(dst="10.0.0.1", src="1.1.0.1", ttl=64) / TCP(dport=80, sport=12380), | ||
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02") / Dot1Q(vlan=200) / IP(dst="10.0.0.1", src="1.1.0.2", ttl=64) / TCP(dport=80, sport=12380), | ||
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02") / Dot1Q(vlan=200) / IP(dst="10.0.0.1", src="1.1.0.3", ttl=64) / TCP(dport=80, sport=12380), | ||
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02") / Dot1Q(vlan=200) / IP(dst="10.0.0.1", src="1.1.0.4", ttl=64) / TCP(dport=80, sport=12380), | ||
) | ||
|
||
write_pcap("001-expect.pcap", | ||
Ether(dst="00:00:00:00:00:01", src="00:11:22:33:44:55")/Dot1Q(vlan=100)/IPv6(dst="2000::1", src="2000:51b::0101:0001:0:1", hlim=63, fl=0, nh=0x2f)/GRE(proto=0x0800)/IP(dst="10.0.0.1", src="1.1.0.1", ttl=64)/TCP(dport=80, sport=12380), | ||
Ether(dst="00:00:00:00:00:01", src="00:11:22:33:44:55")/Dot1Q(vlan=100)/IPv6(dst="2000::1", src="2000:51b::0101:0002:0:1", hlim=63, fl=0, nh=0x2f)/GRE(proto=0x0800)/IP(dst="10.0.0.1", src="1.1.0.2", ttl=64)/TCP(dport=80, sport=12380), | ||
Ether(dst="00:00:00:00:00:01", src="00:11:22:33:44:55")/Dot1Q(vlan=100)/IPv6(dst="2000::1", src="2000:51b::0101:0003:0:1", hlim=63, fl=0, nh=0x2f)/GRE(proto=0x0800)/IP(dst="10.0.0.1", src="1.1.0.3", ttl=64)/TCP(dport=80, sport=12380), | ||
Ether(dst="00:00:00:00:00:01", src="00:11:22:33:44:55")/Dot1Q(vlan=100)/IPv6(dst="2000::1", src="2000:51b::0101:0004:0:1", hlim=63, fl=0, nh=0x2f)/GRE(proto=0x0800)/IP(dst="10.0.0.1", src="1.1.0.4", ttl=64)/TCP(dport=80, sport=12380), | ||
) | ||
|
||
|
||
write_pcap("002-send.pcap", | ||
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02")/Dot1Q(vlan=200)/IP(dst="10.0.0.42", src="1.1.0.1", ttl=64)/TCP(dport=80, sport=12380), | ||
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02")/Dot1Q(vlan=200)/IP(dst="10.0.0.42", src="1.1.0.2", ttl=64)/TCP(dport=80, sport=12380), | ||
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02")/Dot1Q(vlan=200)/IP(dst="10.0.0.42", src="1.1.0.3", ttl=64)/TCP(dport=80, sport=12380), | ||
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02")/Dot1Q(vlan=200)/IP(dst="10.0.0.42", src="1.1.0.4", ttl=64)/TCP(dport=80, sport=12380), | ||
) | ||
|
||
write_pcap("002-expect.pcap", | ||
Ether(dst="00:00:00:00:00:01", src="00:11:22:33:44:55")/Dot1Q(vlan=100)/IP(dst="100.0.0.42", src="100.0.0.22", ttl=63)/GRE(proto=0x0800)/IP(dst="10.0.0.42", src="1.1.0.1", ttl=64)/TCP(dport=80, sport=12380), | ||
Ether(dst="00:00:00:00:00:01", src="00:11:22:33:44:55")/Dot1Q(vlan=100)/IP(dst="100.0.0.42", src="100.0.0.22", ttl=63)/GRE(proto=0x0800)/IP(dst="10.0.0.42", src="1.1.0.2", ttl=64)/TCP(dport=80, sport=12380), | ||
Ether(dst="00:00:00:00:00:01", src="00:11:22:33:44:55")/Dot1Q(vlan=100)/IP(dst="100.0.0.42", src="100.0.0.22", ttl=63)/GRE(proto=0x0800)/IP(dst="10.0.0.42", src="1.1.0.3", ttl=64)/TCP(dport=80, sport=12380), | ||
Ether(dst="00:00:00:00:00:01", src="00:11:22:33:44:55")/Dot1Q(vlan=100)/IP(dst="100.0.0.42", src="100.0.0.22", ttl=63)/GRE(proto=0x0800)/IP(dst="10.0.0.42", src="1.1.0.4", ttl=64)/TCP(dport=80, sport=12380), | ||
) | ||
|
||
write_pcap("003-send.pcap", | ||
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02") / Dot1Q(vlan=200) / IPv6(dst="2001:dead:beef::1", src="2002::1", hlim=64) / TCP(dport=80, sport=12443), | ||
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02") / Dot1Q(vlan=200) / IPv6(dst="2001:dead:beef::1", src="2002::2", hlim=64) / TCP(dport=80, sport=12443), | ||
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02") / Dot1Q(vlan=200) / IPv6(dst="2001:dead:beef::1", src="2002::3", hlim=64) / TCP(dport=80, sport=12443), | ||
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02") / Dot1Q(vlan=200) / IPv6(dst="2001:dead:beef::1", src="2002::4", hlim=64) / TCP(dport=80, sport=12443) | ||
) | ||
|
||
write_pcap("003-expect.pcap", | ||
Ether(dst="00:00:00:00:00:01", src="00:11:22:33:44:55") / Dot1Q(vlan=100) / IPv6(dst="2000::1", src="2000:51b::0001:0:1", hlim=63, fl=0, nh=0x2f) / GRE(proto=0x86DD) / IPv6(dst="2001:dead:beef::1", src="2002::1", hlim=64) / TCP(dport=80, sport=12443), | ||
Ether(dst="00:00:00:00:00:01", src="00:11:22:33:44:55") / Dot1Q(vlan=100) / IPv6(dst="2000::1", src="2000:51b::0002:0:1", hlim=63, fl=0, nh=0x2f) / GRE(proto=0x86DD) / IPv6(dst="2001:dead:beef::1", src="2002::2", hlim=64) / TCP(dport=80, sport=12443), | ||
Ether(dst="00:00:00:00:00:01", src="00:11:22:33:44:55") / Dot1Q(vlan=100) / IPv6(dst="2000::1", src="2000:51b::0003:0:1", hlim=63, fl=0, nh=0x2f) / GRE(proto=0x86DD) / IPv6(dst="2001:dead:beef::1", src="2002::3", hlim=64) / TCP(dport=80, sport=12443), | ||
Ether(dst="00:00:00:00:00:01", src="00:11:22:33:44:55") / Dot1Q(vlan=100) / IPv6(dst="2000::1", src="2000:51b::0004:0:1", hlim=63, fl=0, nh=0x2f) / GRE(proto=0x86DD) / IPv6(dst="2001:dead:beef::1", src="2002::4", hlim=64) / TCP(dport=80, sport=12443) | ||
) | ||
|
||
|
||
write_pcap("004-send.pcap", | ||
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02")/Dot1Q(vlan=200)/IPv6(dst="2001:dead:beef::2", src="2002::10", hlim=64)/TCP(dport=80, sport=12380), | ||
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02")/Dot1Q(vlan=200)/IPv6(dst="2001:dead:beef::2", src="2002::11", hlim=64)/TCP(dport=80, sport=12380), | ||
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02")/Dot1Q(vlan=200)/IPv6(dst="2001:dead:beef::2", src="2002::12", hlim=64)/TCP(dport=80, sport=12380), | ||
Ether(dst="00:11:22:33:44:55", src="00:00:00:00:00:02")/Dot1Q(vlan=200)/IPv6(dst="2001:dead:beef::2", src="2002::13", hlim=64)/TCP(dport=80, sport=12380), | ||
) | ||
|
||
write_pcap("004-expect.pcap", | ||
Ether(dst="00:00:00:00:00:01", src="00:11:22:33:44:55")/Dot1Q(vlan=100)/IP(dst="100.0.0.6", src="100.0.0.22", ttl=63)/ GRE(proto=0x86DD) /IPv6(dst="2001:dead:beef::2", src="2002::10", hlim=64)/TCP(dport=80, sport=12380), | ||
Ether(dst="00:00:00:00:00:01", src="00:11:22:33:44:55")/Dot1Q(vlan=100)/IP(dst="100.0.0.6", src="100.0.0.22", ttl=63)/ GRE(proto=0x86DD) /IPv6(dst="2001:dead:beef::2", src="2002::11", hlim=64)/TCP(dport=80, sport=12380), | ||
Ether(dst="00:00:00:00:00:01", src="00:11:22:33:44:55")/Dot1Q(vlan=100)/IP(dst="100.0.0.6", src="100.0.0.22", ttl=63)/ GRE(proto=0x86DD) /IPv6(dst="2001:dead:beef::2", src="2002::12", hlim=64)/TCP(dport=80, sport=12380), | ||
Ether(dst="00:00:00:00:00:01", src="00:11:22:33:44:55")/Dot1Q(vlan=100)/IP(dst="100.0.0.6", src="100.0.0.22", ttl=63)/ GRE(proto=0x86DD) /IPv6(dst="2001:dead:beef::2", src="2002::13", hlim=64)/TCP(dport=80, sport=12380), | ||
) |
54 changes: 54 additions & 0 deletions
54
autotests/units/001_one_port/065_balancer_gre/services.conf
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,54 @@ | ||
[ | ||
{ | ||
"vip": "10.0.0.1", | ||
"proto": "tcp", | ||
"vport": "80", | ||
"scheduler": "rr", | ||
"lvs_method": "GRE", | ||
"reals": [ | ||
{ | ||
"ip": "2000::1", | ||
"port": "80" | ||
} | ||
] | ||
}, | ||
{ | ||
"vip": "10.0.0.42", | ||
"proto": "tcp", | ||
"vport": "80", | ||
"scheduler": "rr", | ||
"lvs_method": "GRE", | ||
"reals": [ | ||
{ | ||
"ip": "100.0.0.42", | ||
"port": "80" | ||
} | ||
] | ||
}, | ||
{ | ||
"vip": "2001:dead:beef::1", | ||
"proto": "tcp", | ||
"vport": "80", | ||
"scheduler": "rr", | ||
"lvs_method": "GRE", | ||
"reals": [ | ||
{ | ||
"ip": "2000::1", | ||
"port": "80" | ||
} | ||
] | ||
}, | ||
{ | ||
"vip": "2001:dead:beef::2", | ||
"proto": "tcp", | ||
"vport": "80", | ||
"scheduler": "rr", | ||
"lvs_method": "GRE", | ||
"reals": [ | ||
{ | ||
"ip": "100.0.0.6", | ||
"port": "80" | ||
} | ||
] | ||
} | ||
] |
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,31 @@ | ||
#pragma once | ||
|
||
#include "type.h" | ||
|
||
namespace balancer | ||
{ | ||
|
||
enum class tunnel : uint8_t | ||
{ | ||
ipip, // in services.conf it means lvs_method: TUN | ||
gre, | ||
}; | ||
|
||
constexpr const char* to_string(const tunnel& tunnel) | ||
{ | ||
switch (tunnel) | ||
{ | ||
case tunnel::ipip: | ||
{ | ||
return "ipip"; | ||
} | ||
case tunnel::gre: | ||
{ | ||
return "gre"; | ||
} | ||
} | ||
|
||
return "unknown"; | ||
} | ||
|
||
} |
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
Oops, something went wrong.