Thread (7 messages) flat view 7 messages, 2 authors, 2010-08-06

Re: [PATCH 2/2] netfilter: xt_condition: change the value from boolean to u32

From: Jan Engelhardt <hidden>
Date: 2010-08-05 15:12:50
Also in: netfilter-devel

On Thursday 2010-08-05 16:41, luciano.coelho@nokia.com wrote:
struct xt_condition_mtinfo {
-	char name[31];
+	char name[27];
	__u8 invert;
+	__u32 value;
Please also bump the .revision field to 2 with this patch so that
testing can always proceed without an ABI clash.
(rev 2 would then remain over the course of the remaining patches 
you submit.)
(rev 0 = ipt_condition/pom-ng; rev 1 = xt_condition from Xt-a)
+	char buf[14];
	char buf[sizeof("4294967296")];

seems more intuitive :-)
+	unsigned long long value;
+
+	if (length == 0)
+		return 0;
+
+	if (length > sizeof(buf))
+		return -EINVAL;
+
+	if (copy_from_user(buf, input, length) != 0)
+		return -EFAULT;
+
+	buf[length - 1] = '\0';
+
+	if (strict_strtoull(buf, 0, &value) != 0)
+		return -EINVAL;
+
+	if (value > (u32) value)
+		return -EINVAL;
Is it possible to use just strict_strtoul?
-	return var->enabled ^ info->invert;
+	return (var->value == info->value) ^ info->invert;
Since the condition value (cdmark) was thought of an nfmark-style thing, 
would it perhaps make sense to model it after it

	return (var->value & ~info->mask) ^ info->value;

Other opinions?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help