diff options
author | Eric Dumazet <edumazet@google.com> | 2012-10-28 18:33:23 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-11-03 14:59:04 -0400 |
commit | 6da025fa23bb10c82f80de319c837ed2b02306e4 (patch) | |
tree | 64992521a7fa74c04eff45fffc88dd56dfb10ba7 /include/net/route.h | |
parent | b26ddd813031666293c95e84c997eb8b1f97bd38 (diff) |
ipv4: avoid a test in ip_rt_put()
We can save a test in ip_rt_put(), considering dst_release() accepts
a NULL parameter, and dst is first element in rtable.
Add a BUILD_BUG_ON() to catch any change that could break this
assertion.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Cong Wang <amwang@redhat.com>
Acked-by: Cong Wang <amwang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/route.h')
-rw-r--r-- | include/net/route.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/include/net/route.h b/include/net/route.h index bc40b633a5c4..2ea40c1b5e00 100644 --- a/include/net/route.h +++ b/include/net/route.h | |||
@@ -198,10 +198,13 @@ struct in_ifaddr; | |||
198 | extern void fib_add_ifaddr(struct in_ifaddr *); | 198 | extern void fib_add_ifaddr(struct in_ifaddr *); |
199 | extern void fib_del_ifaddr(struct in_ifaddr *, struct in_ifaddr *); | 199 | extern void fib_del_ifaddr(struct in_ifaddr *, struct in_ifaddr *); |
200 | 200 | ||
201 | static inline void ip_rt_put(struct rtable * rt) | 201 | static inline void ip_rt_put(struct rtable *rt) |
202 | { | 202 | { |
203 | if (rt) | 203 | /* dst_release() accepts a NULL parameter. |
204 | dst_release(&rt->dst); | 204 | * We rely on dst being first structure in struct rtable |
205 | */ | ||
206 | BUILD_BUG_ON(offsetof(struct rtable, dst) != 0); | ||
207 | dst_release(&rt->dst); | ||
205 | } | 208 | } |
206 | 209 | ||
207 | #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3) | 210 | #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3) |