Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
055dd068
Commit
055dd068
authored
Feb 04, 2019
by
Fabio Rapposelli
Committed by
Andrew Kim
Feb 07, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix mac filtering in vsphere cloud provider
parent
c6d33995
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
6 deletions
+18
-6
vsphere.go
pkg/cloudprovider/providers/vsphere/vsphere.go
+18
-6
No files found.
pkg/cloudprovider/providers/vsphere/vsphere.go
View file @
055dd068
...
...
@@ -53,8 +53,6 @@ const (
VolDir
=
"kubevols"
RoundTripperDefaultCount
=
3
DummyVMPrefixName
=
"vsphere-k8s"
MacOuiVC
=
"00:50:56"
MacOuiEsx
=
"00:0c:29"
CleanUpDummyVMRoutineInterval
=
5
)
...
...
@@ -529,6 +527,15 @@ func (vs *VSphere) Instances() (cloudprovider.Instances, bool) {
}
func
getLocalIP
()
([]
v1
.
NodeAddress
,
error
)
{
// hashtable with VMware-allocated OUIs for MAC filtering
// List of official OUIs: http://standards-oui.ieee.org/oui.txt
vmwareOUI
:=
map
[
string
]
bool
{
"00:05:69"
:
true
,
"00:0c:29"
:
true
,
"00:1c:14"
:
true
,
"00:50:56"
:
true
,
}
addrs
:=
[]
v1
.
NodeAddress
{}
ifaces
,
err
:=
net
.
Interfaces
()
if
err
!=
nil
{
...
...
@@ -544,9 +551,12 @@ func getLocalIP() ([]v1.NodeAddress, error) {
if
ipnet
,
ok
:=
addr
.
(
*
net
.
IPNet
);
ok
&&
!
ipnet
.
IP
.
IsLoopback
()
{
if
ipnet
.
IP
.
To4
()
!=
nil
{
// Filter external IP by MAC address OUIs from vCenter and from ESX
var
addressType
v1
.
NodeAddressType
if
strings
.
HasPrefix
(
i
.
HardwareAddr
.
String
(),
MacOuiVC
)
||
strings
.
HasPrefix
(
i
.
HardwareAddr
.
String
(),
MacOuiEsx
)
{
vmMACAddr
:=
strings
.
ToLower
(
i
.
HardwareAddr
.
String
())
// Making sure that the MAC address is long enough
if
len
(
vmMACAddr
)
<
17
{
return
addrs
,
fmt
.
Errorf
(
"MAC address %q is invalid"
,
vmMACAddr
)
}
if
vmwareOUI
[
vmMACAddr
[
:
8
]]
{
v1helper
.
AddToNodeAddresses
(
&
addrs
,
v1
.
NodeAddress
{
Type
:
v1
.
NodeExternalIP
,
...
...
@@ -557,8 +567,10 @@ func getLocalIP() ([]v1.NodeAddress, error) {
Address
:
ipnet
.
IP
.
String
(),
},
)
klog
.
V
(
4
)
.
Infof
(
"Detected local IP address as %q"
,
ipnet
.
IP
.
String
())
}
else
{
klog
.
Warningf
(
"Failed to patch IP as MAC address %q does not belong to a VMware platform"
,
vmMACAddr
)
}
klog
.
V
(
4
)
.
Infof
(
"Find local IP address %v and set type to %v"
,
ipnet
.
IP
.
String
(),
addressType
)
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment