@@ -24,7 +24,9 @@ import (
24
24
25
25
"github.com/vishvananda/netlink"
26
26
27
+ "k8s.io/client-go/util/retry"
27
28
"k8s.io/klog/v2"
29
+ "k8s.io/kubernetes/pkg/proxy/util"
28
30
)
29
31
30
32
// Interface for dealing with conntrack
@@ -57,8 +59,12 @@ func newConntracker(handler netlinkHandler) Interface {
57
59
}
58
60
59
61
// ListEntries list all conntrack entries for connections of the given IP family.
60
- func (ct * conntracker ) ListEntries (ipFamily uint8 ) ([]* netlink.ConntrackFlow , error ) {
61
- return ct .handler .ConntrackTableList (netlink .ConntrackTable , netlink .InetFamily (ipFamily ))
62
+ func (ct * conntracker ) ListEntries (ipFamily uint8 ) (entries []* netlink.ConntrackFlow , err error ) {
63
+ err = retry .OnError (util .MaxAttemptsEINTR , util .ShouldRetryOnEINTR , func () error {
64
+ entries , err = ct .handler .ConntrackTableList (netlink .ConntrackTable , netlink .InetFamily (ipFamily ))
65
+ return err
66
+ })
67
+ return entries , err
62
68
}
63
69
64
70
// ClearEntries deletes conntrack entries for connections of the given IP family,
@@ -69,7 +75,15 @@ func (ct *conntracker) ClearEntries(ipFamily uint8, filters ...netlink.CustomCon
69
75
return 0 , nil
70
76
}
71
77
72
- n , err := ct .handler .ConntrackDeleteFilters (netlink .ConntrackTable , netlink .InetFamily (ipFamily ), filters ... )
78
+ var n uint
79
+ var err error
80
+ err = retry .OnError (util .MaxAttemptsEINTR , util .ShouldRetryOnEINTR , func () error {
81
+ var count uint
82
+ count , err = ct .handler .ConntrackDeleteFilters (netlink .ConntrackTable , netlink .InetFamily (ipFamily ), filters ... )
83
+ n += count
84
+ return err
85
+ })
86
+
73
87
if err != nil {
74
88
return int (n ), fmt .Errorf ("error deleting conntrack entries, error: %w" , err )
75
89
}
0 commit comments