mirror of https://github.com/k3s-io/k3s
Merge pull request #68897 from ksubrmnn/mac_address
Load Balancing is not distributing connections to different endpointspull/58/head
commit
2f349d58df
|
@ -128,12 +128,23 @@ type endpointsInfo struct {
|
||||||
refCount uint16
|
refCount uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Uses mac prefix and IPv4 address to return a mac address
|
||||||
|
//This ensures mac addresses are unique for proper load balancing
|
||||||
|
//Does not support IPv6 and returns a dummy mac
|
||||||
|
func conjureMac(macPrefix string, ip net.IP) string {
|
||||||
|
if ip4 := ip.To4(); ip4 != nil {
|
||||||
|
a, b, c, d := ip4[0], ip4[1], ip4[2], ip4[3]
|
||||||
|
return fmt.Sprintf("%v-%02x-%02x-%02x-%02x", macPrefix, a, b, c, d)
|
||||||
|
}
|
||||||
|
return "02-11-22-33-44-55"
|
||||||
|
}
|
||||||
|
|
||||||
func newEndpointInfo(ip string, port uint16, isLocal bool) *endpointsInfo {
|
func newEndpointInfo(ip string, port uint16, isLocal bool) *endpointsInfo {
|
||||||
info := &endpointsInfo{
|
info := &endpointsInfo{
|
||||||
ip: ip,
|
ip: ip,
|
||||||
port: port,
|
port: port,
|
||||||
isLocal: isLocal,
|
isLocal: isLocal,
|
||||||
macAddress: "00:11:22:33:44:55", // Hardcoding to some Random Mac
|
macAddress: conjureMac("02-11", net.ParseIP(ip)),
|
||||||
refCount: 0,
|
refCount: 0,
|
||||||
hnsID: "",
|
hnsID: "",
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue