* [PATCH] neigh: sysctl - simplify address calculation of gc_* variables
@ 2014-07-12 20:36 Mathias Krause
2014-07-14 21:33 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Mathias Krause @ 2014-07-12 20:36 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Mathias Krause, Brad Spengler
The code in neigh_sysctl_register() relies on a specific layout of
struct neigh_table, namely that the 'gc_*' variables are directly
following the 'parms' member in a specific order. The code, though,
expresses this in the most ugly way.
Get rid of the ugly casts and use the 'tbl' pointer to get a handle to
the table. This way we can refer to the 'gc_*' variables directly.
Similarly seen in the grsecurity patch, written by Brad Spengler.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
Cc: Brad Spengler <spender@grsecurity.net>
---
include/net/neighbour.h | 1 -
net/core/neighbour.c | 9 +++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 7277caf374..47f425464f 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -203,7 +203,6 @@ struct neigh_table {
void (*proxy_redo)(struct sk_buff *skb);
char *id;
struct neigh_parms parms;
- /* HACK. gc_* should follow parms without a gap! */
int gc_interval;
int gc_thresh1;
int gc_thresh2;
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 32d872eec7..559890b0f0 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -3059,11 +3059,12 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
memset(&t->neigh_vars[NEIGH_VAR_GC_INTERVAL], 0,
sizeof(t->neigh_vars[NEIGH_VAR_GC_INTERVAL]));
} else {
+ struct neigh_table *tbl = p->tbl;
dev_name_source = "default";
- t->neigh_vars[NEIGH_VAR_GC_INTERVAL].data = (int *)(p + 1);
- t->neigh_vars[NEIGH_VAR_GC_THRESH1].data = (int *)(p + 1) + 1;
- t->neigh_vars[NEIGH_VAR_GC_THRESH2].data = (int *)(p + 1) + 2;
- t->neigh_vars[NEIGH_VAR_GC_THRESH3].data = (int *)(p + 1) + 3;
+ t->neigh_vars[NEIGH_VAR_GC_INTERVAL].data = &tbl->gc_interval;
+ t->neigh_vars[NEIGH_VAR_GC_THRESH1].data = &tbl->gc_thresh1;
+ t->neigh_vars[NEIGH_VAR_GC_THRESH2].data = &tbl->gc_thresh2;
+ t->neigh_vars[NEIGH_VAR_GC_THRESH3].data = &tbl->gc_thresh3;
}
if (handler) {
--
1.7.10.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] neigh: sysctl - simplify address calculation of gc_* variables
2014-07-12 20:36 [PATCH] neigh: sysctl - simplify address calculation of gc_* variables Mathias Krause
@ 2014-07-14 21:33 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2014-07-14 21:33 UTC (permalink / raw)
To: minipli; +Cc: netdev, spender
From: Mathias Krause <minipli@googlemail.com>
Date: Sat, 12 Jul 2014 22:36:44 +0200
> The code in neigh_sysctl_register() relies on a specific layout of
> struct neigh_table, namely that the 'gc_*' variables are directly
> following the 'parms' member in a specific order. The code, though,
> expresses this in the most ugly way.
>
> Get rid of the ugly casts and use the 'tbl' pointer to get a handle to
> the table. This way we can refer to the 'gc_*' variables directly.
>
> Similarly seen in the grsecurity patch, written by Brad Spengler.
>
> Signed-off-by: Mathias Krause <minipli@googlemail.com>
> Cc: Brad Spengler <spender@grsecurity.net>
Looks good, applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-07-14 21:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-12 20:36 [PATCH] neigh: sysctl - simplify address calculation of gc_* variables Mathias Krause
2014-07-14 21:33 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).