All of lore.kernel.org
 help / color / mirror / Atom feed
* [libnftables PATCH next-3.14] expr: fix registers datatypes
@ 2014-01-10 12:07 Arturo Borrero Gonzalez
  2014-01-10 12:42 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Arturo Borrero Gonzalez @ 2014-01-10 12:07 UTC (permalink / raw)
  To: netfilter-devel

Registers datatypes must be enum nft_registers.

Pablo Neira says:
<< From the kernel representation point of view, it doesn't make any
sense to have set both sreg and dreg, but we should not make such
assumption from userspace. If the user sets both sreg and dreg, it's
wrong and the kernel should reply -EINVAL so the user knows that it
has to fix its userspace code. This requires a bit more memory in
userspace, but we don't have the memory restrictions that we have in
kernelspace, so a bit more consumption won't harm. >>

So, while at it, delete the meta expr union for registers.

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
---
 src/expr/cmp.c  |    2 +-
 src/expr/meta.c |    6 ++----
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/expr/cmp.c b/src/expr/cmp.c
index 246f22f..ab244ac 100644
--- a/src/expr/cmp.c
+++ b/src/expr/cmp.c
@@ -26,7 +26,7 @@
 
 struct nft_expr_cmp {
 	union nft_data_reg	data;
-	uint8_t			sreg;	/* enum nft_registers */
+	enum nft_registers	sreg;
 	uint8_t			op;	/* enum nft_cmp_ops */
 };
 
diff --git a/src/expr/meta.c b/src/expr/meta.c
index 490d64a..7fd0af1 100644
--- a/src/expr/meta.c
+++ b/src/expr/meta.c
@@ -28,10 +28,8 @@
 
 struct nft_expr_meta {
 	uint8_t			key;	/* enum nft_meta_keys */
-	union {
-		uint8_t		dreg;	/* enum nft_registers */
-		uint8_t		sreg;   /* enum nft_registers */
-	};
+	enum nft_registers	dreg;
+	enum nft_registers	sreg;
 };
 
 static int


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [libnftables PATCH next-3.14] expr: fix registers datatypes
  2014-01-10 12:07 [libnftables PATCH next-3.14] expr: fix registers datatypes Arturo Borrero Gonzalez
@ 2014-01-10 12:42 ` Pablo Neira Ayuso
  0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2014-01-10 12:42 UTC (permalink / raw)
  To: Arturo Borrero Gonzalez; +Cc: netfilter-devel

On Fri, Jan 10, 2014 at 01:07:51PM +0100, Arturo Borrero Gonzalez wrote:
> Registers datatypes must be enum nft_registers.
> 
> Pablo Neira says:
> << From the kernel representation point of view, it doesn't make any
> sense to have set both sreg and dreg, but we should not make such
> assumption from userspace. If the user sets both sreg and dreg, it's
> wrong and the kernel should reply -EINVAL so the user knows that it
> has to fix its userspace code. This requires a bit more memory in
> userspace, but we don't have the memory restrictions that we have in
> kernelspace, so a bit more consumption won't harm. >>
> 
> So, while at it, delete the meta expr union for registers.

Need a fix for this in master, I forgot to specify. I just sent several
patches. Thanks anyway.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-01-10 12:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-10 12:07 [libnftables PATCH next-3.14] expr: fix registers datatypes Arturo Borrero Gonzalez
2014-01-10 12:42 ` Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.