Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions nfqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ package nfqueue
#cgo LDFLAGS: -L/usr/lib64/

#include "nfqueue.h"
#include "errno.h"
*/
import "C"

import (
"errors"
"fmt"
"syscall"
"unsafe"
)

Expand Down Expand Up @@ -171,14 +173,17 @@ func (q *Queue) Start() error {

// Stop the netfilter queue.
func (q *Queue) Stop() error {
if C.close(q.fd) < 0 {
return errors.New("Error closing fd")
}
if C.nfq_destroy_queue(q.qh) < 0 {
return errors.New("Error in nfq_destroy_queue")
}
if C.nfq_close(q.h) < 0 {
return errors.New("Error in nfq_close")
}
if _, err := C.close(q.fd); err != nil {
// EBADF(9) error not considered, fd already freed by nfq commands.
if errno := int(err.(syscall.Errno)); errno != C.EBADF {
return fmt.Errorf("Error closing fd(%d): %s (%d)", q.fd, err, errno)
}
}
return nil
}