You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Updated nftables package to return syserr.Error (POSIX) errors
Needed to update nftables package to return POSIX errors for better integration
with netfilter sockets. This allows for more precise error handling
and propagation.
PiperOrigin-RevId: 776255695
log.Debugf("Nftables: Table with name: %s already exists and NLM_F_REPLACE is not supported", tabNameBytes.String())
131
-
returnsyserr.ErrNotSupported
141
+
returnsyserr.NewAnnotatedError(syserr.ErrNotSupported, fmt.Sprintf("Nftables: Table with name: %s already exists and NLM_F_REPLACE is not supported", tabNameBytes.String()))
132
142
}
133
143
} else {
134
-
// There does not seem to be a way to add comments to a table using the nft binary.
returnnil, fmt.Errorf("bitwise operation cannot use verdict register as source or destination")
71
+
returnnil, syserr.NewAnnotatedError(syserr.ErrInvalidArgument, fmt.Sprintf("bitwise operation does not support verdict register as source or destination register"))
71
72
}
72
73
blen:=len(mask)
73
74
ifblen!=len(xor) {
74
-
returnnil, fmt.Errorf("bitwise boolean operation mask and xor must be the same length")
75
+
returnnil, syserr.NewAnnotatedError(syserr.ErrInvalidArgument, fmt.Sprintf("bitwise boolean operation mask and xor data lengths must be the same"))
returnnil, fmt.Errorf("bitwise operation length %d is too long for source register %d, destination register %d", blen, sreg, dreg)
78
+
returnnil, syserr.NewAnnotatedError(syserr.ErrInvalidArgument, fmt.Sprintf("bitwise boolean operation cannot use more than %d bytes", linux.NFT_REG_SIZE))
returnnil, fmt.Errorf("bitwise operation cannot use verdict register as source or destination")
86
+
returnnil, syserr.NewAnnotatedError(syserr.ErrInvalidArgument, fmt.Sprintf("bitwise shift operation does not support verdict register as source or destination register"))
returnnil, fmt.Errorf("bitwise operation length %d is too long for source register %d, destination register %d", blen, sreg, dreg)
89
+
returnnil, syserr.NewAnnotatedError(syserr.ErrInvalidArgument, fmt.Sprintf("bitwise operation length %d is too long for source register %d, destination register %d", blen, sreg, dreg))
89
90
}
90
91
ifshift>=bitshiftLimit {
91
-
returnnil, fmt.Errorf("bitwise operation shift %d must be less than %d", shift, bitshiftLimit)
92
+
returnnil, syserr.NewAnnotatedError(syserr.ErrInvalidArgument, fmt.Sprintf("bitwise operation shift %d must be less than %d", shift, bitshiftLimit))
returnnil, fmt.Errorf("byteorder operation cannot use verdict register")
71
+
returnnil, syserr.NewAnnotatedError(syserr.ErrInvalidArgument, fmt.Sprintf("byteorder operation does not support verdict register as source or destination register"))
71
72
}
72
73
iferr:=validateByteorderOp(bop); err!=nil {
73
74
returnnil, err
74
75
}
75
76
ifblen>linux.NFT_REG_SIZE {
76
-
returnnil, fmt.Errorf("byteorder operation cannot have length greater than the max register size of %d bytes", linux.NFT_REG_SIZE)
77
+
returnnil, syserr.NewAnnotatedError(syserr.ErrInvalidArgument, fmt.Sprintf("byteorder operation cannot use more than %d bytes", linux.NFT_REG_SIZE))
77
78
}
78
79
if (is4ByteRegister(sreg) ||is4ByteRegister(dreg)) &&blen>linux.NFT_REG32_SIZE {
79
-
returnnil, fmt.Errorf("byteorder operation cannot have length greater than the max register size of %d bytes", linux.NFT_REG32_SIZE)
80
+
returnnil, syserr.NewAnnotatedError(syserr.ErrInvalidArgument, fmt.Sprintf("byteorder operation cannot use more than %d bytes", linux.NFT_REG32_SIZE))
80
81
}
81
82
ifsize>blen {
82
-
returnnil, fmt.Errorf("byteorder operation cannot have size greater than length")
83
+
returnnil, syserr.NewAnnotatedError(syserr.ErrInvalidArgument, fmt.Sprintf("byteorder operation cannot use more than %d bytes", blen))
83
84
}
84
85
ifsize!=2&&size!=4&&size!=8 {
85
-
returnnil, fmt.Errorf("byteorder operation size must be 2, 4, or 8 bytes")
86
+
returnnil, syserr.NewAnnotatedError(syserr.ErrInvalidArgument, fmt.Sprintf("byteorder operation size %d is not supported", size))
// newComparison creates a new comparison operation.
69
-
funcnewComparison(sreguint8, opint, data []byte) (*comparison, error) {
70
+
funcnewComparison(sreguint8, opint, data []byte) (*comparison, *syserr.AnnotatedError) {
70
71
ifisVerdictRegister(sreg) {
71
-
returnnil, fmt.Errorf("comparison operation cannot use verdict register as source")
72
+
returnnil, syserr.NewAnnotatedError(syserr.ErrInvalidArgument, fmt.Sprintf("comparison operation does not support verdict register as source register"))
returnnil, fmt.Errorf("meta load operation cannot use verdict register as destination")
131
+
returnnil, syserr.NewAnnotatedError(syserr.ErrInvalidArgument, fmt.Sprintf("meta load operation does not support verdict register as destination register"))
returnnil, fmt.Errorf("meta load operation cannot use 4-byte register as destination for key %s", key)
137
+
returnnil, syserr.NewAnnotatedError(syserr.ErrInvalidArgument, fmt.Sprintf("meta load operation cannot use 4-byte register as destination for key %v", key))
returnnil, fmt.Errorf("meta load operation cannot use 4-byte register as destination for key %s", key)
64
+
returnnil, syserr.NewAnnotatedError(syserr.ErrInvalidArgument, fmt.Sprintf("meta load operation cannot use 4-byte register as destination for key %s", key))
0 commit comments