[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1538283637-7802-1-git-send-email-lirongqing@baidu.com>
Date: Sun, 30 Sep 2018 13:00:37 +0800
From: Li RongQing <lirongqing@...du.com>
To: netdev@...r.kernel.org
Subject: [PATCH][net-next] net: drop container_of in dst_cache_get_ip4
we can save container_of computation and return dst directly,
since dst is always first member of struct rtable, and any
breaking will be caught by BUILD_BUG_ON in route.h
include/net/route.h: BUILD_BUG_ON(offsetof(struct rtable, dst) != 0);
Signed-off-by: Li RongQing <lirongqing@...du.com>
---
net/core/dst_cache.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/dst_cache.c b/net/core/dst_cache.c
index 64cef977484a..0753838480fd 100644
--- a/net/core/dst_cache.c
+++ b/net/core/dst_cache.c
@@ -87,7 +87,7 @@ struct rtable *dst_cache_get_ip4(struct dst_cache *dst_cache, __be32 *saddr)
return NULL;
*saddr = idst->in_saddr.s_addr;
- return container_of(dst, struct rtable, dst);
+ return (struct rtable *)dst;
}
EXPORT_SYMBOL_GPL(dst_cache_get_ip4);
--
2.16.2
Powered by blists - more mailing lists