@@ -23,7 +23,7 @@ import (
2323 "strings"
2424
2525 "github.com/k8snetworkplumbingwg/multi-networkpolicy-iptables/pkg/controllers"
26- multiv1beta1 "github.com/k8snetworkplumbingwg/multi-networkpolicy/pkg/apis/k8s.cni.cncf.io/v1beta1 "
26+ multiv1beta2 "github.com/k8snetworkplumbingwg/multi-networkpolicy/pkg/apis/k8s.cni.cncf.io/v1beta2 "
2727 v1 "k8s.io/api/core/v1"
2828 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2929 "k8s.io/apimachinery/pkg/labels"
@@ -141,10 +141,10 @@ func (ipt *iptableBuffer) FinalizeRules() {
141141
142142func (ipt * iptableBuffer ) SaveRules (path string ) error {
143143 file , err := os .Create (path )
144- defer file .Close ()
145144 if err != nil {
146145 return err
147146 }
147+ defer file .Close ()
148148 //_, err = ipt.filterRules.WriteTo(file)
149149 fmt .Fprintf (file , "%s" , ipt .filterRules .String ())
150150 return err
@@ -216,7 +216,7 @@ func (ipt *iptableBuffer) renderIngressCommon(s *Server) {
216216 writeLine (ipt .policyCommon , "-A" , ingressCommonChain , "-m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT" )
217217}
218218
219- func (ipt * iptableBuffer ) renderIngress (s * Server , podInfo * controllers.PodInfo , idx int , policy * multiv1beta1 .MultiNetworkPolicy , policyNetworks []string ) {
219+ func (ipt * iptableBuffer ) renderIngress (s * Server , podInfo * controllers.PodInfo , idx int , policy * multiv1beta2 .MultiNetworkPolicy , policyNetworks []string ) {
220220 chainName := fmt .Sprintf ("MULTI-%d-INGRESS" , idx )
221221 ipt .CreateFilterChain (chainName )
222222
@@ -240,7 +240,7 @@ func (ipt *iptableBuffer) renderIngress(s *Server, podInfo *controllers.PodInfo,
240240 }
241241}
242242
243- func (ipt * iptableBuffer ) renderIngressPorts (_ * Server , podInfo * controllers.PodInfo , pIndex , iIndex int , ports []multiv1beta1 .MultiNetworkPolicyPort , policyNetworks []string ) {
243+ func (ipt * iptableBuffer ) renderIngressPorts (_ * Server , podInfo * controllers.PodInfo , pIndex , iIndex int , ports []multiv1beta2 .MultiNetworkPolicyPort , policyNetworks []string ) {
244244 chainName := fmt .Sprintf ("MULTI-%d-INGRESS-%d-PORTS" , pIndex , iIndex )
245245 ipt .CreateFilterChain (chainName )
246246
@@ -269,10 +269,9 @@ func (ipt *iptableBuffer) renderIngressPorts(_ *Server, podInfo *controllers.Pod
269269 "-m" , "comment" , "--comment" , "\" no ingress ports, skipped\" " ,
270270 "-j" , "MARK" , "--set-xmark" , "0x10000/0x10000" )
271271 }
272- return
273272}
274273
275- func (ipt * iptableBuffer ) renderIngressFrom (s * Server , podInfo * controllers.PodInfo , pIndex , iIndex int , from []multiv1beta1 .MultiNetworkPolicyPeer , policyNetworks []string ) {
274+ func (ipt * iptableBuffer ) renderIngressFrom (s * Server , podInfo * controllers.PodInfo , pIndex , iIndex int , from []multiv1beta2 .MultiNetworkPolicyPeer , policyNetworks []string ) {
276275 chainName := fmt .Sprintf ("MULTI-%d-INGRESS-%d-FROM" , pIndex , iIndex )
277276 ipt .CreateFilterChain (chainName )
278277
@@ -391,7 +390,6 @@ func (ipt *iptableBuffer) renderIngressFrom(s *Server, podInfo *controllers.PodI
391390 "-m" , "comment" , "--comment" , "\" no ingress from, skipped\" " ,
392391 "-j" , "MARK" , "--set-xmark" , "0x20000/0x20000" )
393392 }
394- return
395393}
396394
397395func (ipt * iptableBuffer ) renderEgressCommon (s * Server ) {
@@ -442,7 +440,7 @@ func (ipt *iptableBuffer) renderEgressCommon(s *Server) {
442440 writeLine (ipt .policyCommon , "-A" , egressCommonChain , "-m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT" )
443441}
444442
445- func (ipt * iptableBuffer ) renderEgress (s * Server , podInfo * controllers.PodInfo , idx int , policy * multiv1beta1 .MultiNetworkPolicy , policyNetworks []string ) {
443+ func (ipt * iptableBuffer ) renderEgress (s * Server , podInfo * controllers.PodInfo , idx int , policy * multiv1beta2 .MultiNetworkPolicy , policyNetworks []string ) {
446444 chainName := fmt .Sprintf ("MULTI-%d-EGRESS" , idx )
447445 ipt .CreateFilterChain (chainName )
448446
@@ -465,7 +463,7 @@ func (ipt *iptableBuffer) renderEgress(s *Server, podInfo *controllers.PodInfo,
465463 }
466464}
467465
468- func (ipt * iptableBuffer ) renderEgressPorts (_ * Server , podInfo * controllers.PodInfo , pIndex , iIndex int , ports []multiv1beta1 .MultiNetworkPolicyPort , policyNetworks []string ) {
466+ func (ipt * iptableBuffer ) renderEgressPorts (_ * Server , podInfo * controllers.PodInfo , pIndex , iIndex int , ports []multiv1beta2 .MultiNetworkPolicyPort , policyNetworks []string ) {
469467 chainName := fmt .Sprintf ("MULTI-%d-EGRESS-%d-PORTS" , pIndex , iIndex )
470468 ipt .CreateFilterChain (chainName )
471469
@@ -494,10 +492,9 @@ func (ipt *iptableBuffer) renderEgressPorts(_ *Server, podInfo *controllers.PodI
494492 "-m" , "comment" , "--comment" , "\" no egress ports, skipped\" " ,
495493 "-j" , "MARK" , "--set-xmark" , "0x10000/0x10000" )
496494 }
497- return
498495}
499496
500- func (ipt * iptableBuffer ) renderEgressTo (s * Server , podInfo * controllers.PodInfo , pIndex , iIndex int , to []multiv1beta1 .MultiNetworkPolicyPeer , policyNetworks []string ) {
497+ func (ipt * iptableBuffer ) renderEgressTo (s * Server , podInfo * controllers.PodInfo , pIndex , iIndex int , to []multiv1beta2 .MultiNetworkPolicyPeer , policyNetworks []string ) {
501498 chainName := fmt .Sprintf ("MULTI-%d-EGRESS-%d-TO" , pIndex , iIndex )
502499 ipt .CreateFilterChain (chainName )
503500
@@ -618,7 +615,6 @@ func (ipt *iptableBuffer) renderEgressTo(s *Server, podInfo *controllers.PodInfo
618615 "-m" , "comment" , "--comment" , "\" no egress to, skipped\" " ,
619616 "-j" , "MARK" , "--set-xmark" , "0x20000/0x20000" )
620617 }
621- return
622618}
623619
624620func (ipt * iptableBuffer ) isIPFamilyCompatible (ip string ) bool {
0 commit comments