From: Eric Dumazet Date: Sun, 28 Oct 2012 22:33:23 +0000 (+0000) Subject: ipv4: avoid a test in ip_rt_put() X-Git-Tag: Ubuntu-5.2.0-15.16~16668^2~461 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=6da025fa23bb10c82f80de319c837ed2b02306e4;p=mirror_ubuntu-eoan-kernel.git 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 Cc: Cong Wang Acked-by: Cong Wang Signed-off-by: David S. Miller --- 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; extern void fib_add_ifaddr(struct in_ifaddr *); extern void fib_del_ifaddr(struct in_ifaddr *, struct in_ifaddr *); -static inline void ip_rt_put(struct rtable * rt) +static inline void ip_rt_put(struct rtable *rt) { - if (rt) - dst_release(&rt->dst); + /* dst_release() accepts a NULL parameter. + * We rely on dst being first structure in struct rtable + */ + BUILD_BUG_ON(offsetof(struct rtable, dst) != 0); + dst_release(&rt->dst); } #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)