Skip to content

Commit

Permalink
fix: support setting iptables mode
Browse files Browse the repository at this point in the history
Signed-off-by: OrangeBao <[email protected]>
  • Loading branch information
OrangeBao committed Dec 7, 2023
1 parent 8847a72 commit f3ab136
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 15 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/bep/debounce v1.2.1
github.com/containerd/console v1.0.3
github.com/containerd/containerd v1.6.14
github.com/coreos/go-iptables v0.6.0
github.com/coreos/go-iptables v0.7.1-0.20231102141700-50d824baaa46
github.com/docker/docker v24.0.6+incompatible
github.com/evanphx/json-patch v4.12.0+incompatible
github.com/go-logr/logr v1.2.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,8 @@ github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-iptables v0.4.5/go.mod h1:/mVI274lEDI2ns62jHCDnCyBF9Iwsmekav8Dbxlm1MU=
github.com/coreos/go-iptables v0.5.0/go.mod h1:/mVI274lEDI2ns62jHCDnCyBF9Iwsmekav8Dbxlm1MU=
github.com/coreos/go-iptables v0.6.0 h1:is9qnZMPYjLd8LYqmm/qlE+wwEgJIkTYdhV3rfZo4jk=
github.com/coreos/go-iptables v0.6.0/go.mod h1:Qe8Bv2Xik5FyTXwgIbLAnv2sWSBmvWdFETJConOQ//Q=
github.com/coreos/go-iptables v0.7.1-0.20231102141700-50d824baaa46 h1:AVVvARdGRuTtYO/DetrN9Z1G0kMbrqV7KLOH/J4byiM=
github.com/coreos/go-iptables v0.7.1-0.20231102141700-50d824baaa46/go.mod h1:Qe8Bv2Xik5FyTXwgIbLAnv2sWSBmvWdFETJConOQ//Q=
github.com/coreos/go-oidc v2.1.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
Expand Down
5 changes: 4 additions & 1 deletion pkg/clusterlink/network/iptables/iptables.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ limitations under the License.
package iptables

import (
"os"

"github.com/coreos/go-iptables/iptables"
"github.com/pkg/errors"
)
Expand Down Expand Up @@ -60,7 +62,8 @@ func New(proto iptables.Protocol) (Interface, error) {
return NewFunc()
}

ipt, err := iptables.New(iptables.IPFamily(proto), iptables.Timeout(5))
// IPTABLES_PATH: the path decision the model of iptable, /sbin/xtables-nft-multi => nf_tables
ipt, err := iptables.New(iptables.IPFamily(proto), iptables.Timeout(5), iptables.Path(os.Getenv("IPTABLES_PATH")))
if err != nil {
return nil, errors.Wrap(err, "error creating IP tables")
}
Expand Down
85 changes: 75 additions & 10 deletions vendor/github.com/coreos/go-iptables/iptables/iptables.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ github.com/containerd/ttrpc
# github.com/containerd/typeurl v1.0.2
## explicit; go 1.13
github.com/containerd/typeurl
# github.com/coreos/go-iptables v0.6.0
# github.com/coreos/go-iptables v0.7.1-0.20231102141700-50d824baaa46
## explicit; go 1.16
github.com/coreos/go-iptables/iptables
# github.com/coreos/go-semver v0.3.1
Expand Down

0 comments on commit f3ab136

Please sign in to comment.