File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change 66
77 "github.com/Azure/azure-container-networking/bpf-prog/block-iptables/pkg/bpfprogram"
88 "github.com/fsnotify/fsnotify"
9+ "github.com/pkg/errors"
910)
1011
1112func TestHandleFileEventWithMock (t * testing.T ) {
@@ -28,7 +29,7 @@ func TestHandleFileEventWithMock(t *testing.T) {
2829 // Create empty file
2930 file , err := os .Create (path )
3031 if err != nil {
31- return err
32+ return errors . Wrap ( err , "failed to create file" )
3233 }
3334 return file .Close ()
3435 },
Original file line number Diff line number Diff line change @@ -64,10 +64,9 @@ func (p *Program) unpinEventCounterMap() error {
6464
6565 if err := os .Remove (pinPath ); err != nil && ! os .IsNotExist (err ) {
6666 return errors .Wrapf (err , "failed to remove pinned map %s" , pinPath )
67- } else {
68- log .Printf ("Event counter map unpinned from %s" , pinPath )
6967 }
7068
69+ log .Printf ("Event counter map unpinned from %s" , pinPath )
7170 return nil
7271}
7372
@@ -108,7 +107,6 @@ func (p *Program) Attach() error {
108107 }
109108
110109 // Set the host_netns_inode variable in the BPF program before loading
111- // Note: The C program sets it to hostNetnsInode + 1, so we do the same
112110 if err = spec .RewriteConstants (map [string ]interface {}{
113111 "host_netns_inode" : hostNetnsInode ,
114112 }); err != nil {
@@ -143,6 +141,7 @@ func (p *Program) Attach() error {
143141 })
144142 if err != nil {
145143 p .objs .Close ()
144+ p .objs = nil
146145 return errors .Wrap (err , "failed to attach iptables_legacy_block LSM" )
147146 }
148147 links = append (links , l )
@@ -157,8 +156,10 @@ func (p *Program) Attach() error {
157156 // Clean up previous links
158157 for _ , link := range links {
159158 link .Close ()
159+ link = nil
160160 }
161161 p .objs .Close ()
162+ p .objs = nil
162163 return errors .Wrap (err , "failed to attach block_nf_netlink LSM" )
163164 }
164165 links = append (links , l )
You can’t perform that action at this time.
0 commit comments