Skip to content

Commit 1defb2f

Browse files
Copilotmatmerr
andcommitted
Add iptables-legacy command constant and update detection logic
Co-authored-by: matmerr <[email protected]>
1 parent 47f95f6 commit 1defb2f

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

npm/pkg/dataplane/policies/chain-management_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ func (pMgr *PolicyManager) detectIptablesVersion() error {
257257
}
258258

259259
klog.Info("second attempt detecting iptables version. looking for hint/canary chain in iptables-legacy")
260-
if pMgr.hintOrCanaryChainExist(util.IptablesLegacy) {
260+
if pMgr.hintOrCanaryChainExist(util.IptablesLegacyCmd) {
261261
util.SetIptablesToLegacy()
262262
return nil
263263
}

npm/pkg/dataplane/policies/chain-management_linux_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ func TestDetectIptablesVersion(t *testing.T) {
936936
ExitCode: 1,
937937
},
938938
{
939-
Cmd: []string{"iptables", "-w", "60", "-L", "KUBE-IPTABLES-HINT", "-t", "mangle", "-n"},
939+
Cmd: []string{"iptables-legacy", "-w", "60", "-L", "KUBE-IPTABLES-HINT", "-t", "mangle", "-n"},
940940
ExitCode: 0,
941941
},
942942
},
@@ -954,11 +954,11 @@ func TestDetectIptablesVersion(t *testing.T) {
954954
ExitCode: 1,
955955
},
956956
{
957-
Cmd: []string{"iptables", "-w", "60", "-L", "KUBE-IPTABLES-HINT", "-t", "mangle", "-n"},
957+
Cmd: []string{"iptables-legacy", "-w", "60", "-L", "KUBE-IPTABLES-HINT", "-t", "mangle", "-n"},
958958
ExitCode: 1,
959959
},
960960
{
961-
Cmd: []string{"iptables", "-w", "60", "-L", "KUBE-KUBELET-CANARY", "-t", "mangle", "-n"},
961+
Cmd: []string{"iptables-legacy", "-w", "60", "-L", "KUBE-KUBELET-CANARY", "-t", "mangle", "-n"},
962962
ExitCode: 1,
963963
},
964964
},
@@ -976,11 +976,11 @@ func TestDetectIptablesVersion(t *testing.T) {
976976
ExitCode: 2,
977977
},
978978
{
979-
Cmd: []string{"iptables", "-w", "60", "-L", "KUBE-IPTABLES-HINT", "-t", "mangle", "-n"},
979+
Cmd: []string{"iptables-legacy", "-w", "60", "-L", "KUBE-IPTABLES-HINT", "-t", "mangle", "-n"},
980980
ExitCode: 2,
981981
},
982982
{
983-
Cmd: []string{"iptables", "-w", "60", "-L", "KUBE-KUBELET-CANARY", "-t", "mangle", "-n"},
983+
Cmd: []string{"iptables-legacy", "-w", "60", "-L", "KUBE-KUBELET-CANARY", "-t", "mangle", "-n"},
984984
ExitCode: 2,
985985
},
986986
},

npm/util/const.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const (
3838
IptablesSaveNft string = "iptables-nft-save"
3939
IptablesRestoreNft string = "iptables-nft-restore"
4040
IptablesLegacy string = "iptables"
41+
IptablesLegacyCmd string = "iptables-legacy"
4142
IptablesSaveLegacy string = "iptables-save"
4243
IptablesRestoreLegacy string = "iptables-restore"
4344
IptablesRestoreNoFlushFlag string = "--noflush"

0 commit comments

Comments
 (0)