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
b79a12c7
Commit
b79a12c7
authored
Aug 10, 2016
by
Dmitry Shulyak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use netlink.SetPromiscOn instead of iproute2 command
parent
c6eb9e07
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
7 deletions
+15
-7
container_bridge.go
pkg/kubelet/container_bridge.go
+9
-2
kubenet_linux.go
pkg/kubelet/network/kubenet/kubenet_linux.go
+6
-5
No files found.
pkg/kubelet/container_bridge.go
View file @
b79a12c7
...
@@ -24,11 +24,13 @@ import (
...
@@ -24,11 +24,13 @@ import (
"os/exec"
"os/exec"
"regexp"
"regexp"
"syscall"
"github.com/golang/glog"
"github.com/golang/glog"
"github.com/vishvananda/netlink"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/iptables"
"k8s.io/kubernetes/pkg/util/iptables"
"k8s.io/kubernetes/pkg/util/procfs"
"k8s.io/kubernetes/pkg/util/procfs"
"syscall"
)
)
var
cidrRegexp
=
regexp
.
MustCompile
(
`inet ([0-9a-fA-F.:]*/[0-9]*)`
)
var
cidrRegexp
=
regexp
.
MustCompile
(
`inet ([0-9a-fA-F.:]*/[0-9]*)`
)
...
@@ -103,7 +105,12 @@ func ensureCbr0(wantCIDR *net.IPNet, promiscuous, babysitDaemons bool) error {
...
@@ -103,7 +105,12 @@ func ensureCbr0(wantCIDR *net.IPNet, promiscuous, babysitDaemons bool) error {
if
promiscuous
{
if
promiscuous
{
// Checking if the bridge is in promiscuous mode is as expensive and more brittle than
// Checking if the bridge is in promiscuous mode is as expensive and more brittle than
// simply setting the flag every time.
// simply setting the flag every time.
if
err
:=
exec
.
Command
(
"ip"
,
"link"
,
"set"
,
"cbr0"
,
"promisc"
,
"on"
)
.
Run
();
err
!=
nil
{
link
,
err
:=
netlink
.
LinkByName
(
"cbr0"
)
if
err
!=
nil
{
glog
.
Error
(
err
)
return
err
}
if
err
:=
netlink
.
SetPromiscOn
(
link
);
err
!=
nil
{
glog
.
Error
(
err
)
glog
.
Error
(
err
)
return
err
return
err
}
}
...
...
pkg/kubelet/network/kubenet/kubenet_linux.go
View file @
b79a12c7
...
@@ -21,7 +21,6 @@ package kubenet
...
@@ -21,7 +21,6 @@ package kubenet
import
(
import
(
"fmt"
"fmt"
"net"
"net"
"strings"
"sync"
"sync"
"syscall"
"syscall"
"time"
"time"
...
@@ -319,11 +318,13 @@ func (plugin *kubenetNetworkPlugin) setup(namespace string, name string, id kube
...
@@ -319,11 +318,13 @@ func (plugin *kubenetNetworkPlugin) setup(namespace string, name string, id kube
// Put the container bridge into promiscuous mode to force it to accept hairpin packets.
// Put the container bridge into promiscuous mode to force it to accept hairpin packets.
// TODO: Remove this once the kernel bug (#20096) is fixed.
// TODO: Remove this once the kernel bug (#20096) is fixed.
// TODO: check and set promiscuous mode with netlink once vishvananda/netlink supports it
if
plugin
.
hairpinMode
==
componentconfig
.
PromiscuousBridge
{
if
plugin
.
hairpinMode
==
componentconfig
.
PromiscuousBridge
{
output
,
err
:=
plugin
.
execer
.
Command
(
"ip"
,
"link"
,
"show"
,
"dev"
,
BridgeName
)
.
CombinedOutput
()
link
,
err
:=
netlink
.
LinkByName
(
BridgeName
)
if
err
!=
nil
||
strings
.
Index
(
string
(
output
),
"PROMISC"
)
<
0
{
if
err
!=
nil
{
_
,
err
:=
plugin
.
execer
.
Command
(
"ip"
,
"link"
,
"set"
,
BridgeName
,
"promisc"
,
"on"
)
.
CombinedOutput
()
return
err
}
if
link
.
Attrs
()
.
Promisc
!=
1
{
err
:=
netlink
.
SetPromiscOn
(
link
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Error setting promiscuous mode on %s: %v"
,
BridgeName
,
err
)
return
fmt
.
Errorf
(
"Error setting promiscuous mode on %s: %v"
,
BridgeName
,
err
)
}
}
...
...
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