From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933496AbbI3L12 (ORCPT ); Wed, 30 Sep 2015 07:27:28 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:64749 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933224AbbI3L1X (ORCPT ); Wed, 30 Sep 2015 07:27:23 -0400 From: Arnd Bergmann To: netdev@vger.kernel.org Cc: y2038@lists.linaro.org, linux-kernel@vger.kernel.org, "David S. Miller" , Arnd Bergmann , Alexey Kuznetsov , James Morris , Hideaki YOSHIFUJI , Patrick McHardy Subject: [PATCH 09/12] ipv6: use ktime_t for internal timestamps Date: Wed, 30 Sep 2015 13:26:39 +0200 Message-Id: <1443612402-3000775-10-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.1.0.rc2 In-Reply-To: <1443612402-3000775-1-git-send-email-arnd@arndb.de> References: <1443612402-3000775-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:pxcbV0dc8sdjuZTDWB+OQW72Nk4Awgr48fJEF8pxxezdWZLuhAA jpiUdg2idPPIkkzlY2nz13hFMihRzfZLRB2n7BNNcALvLHFPoXaRtHyduZRdC1Wom4XP7TU lI5INQ8jBtxJBpHOHc3rKfTYROT0BS6kdfSMDLVwNBY85638rFdS0ffz5SKF0EsmJ3LmMy7 TDV75mMnY2w/WM3tnL5LA== X-UI-Out-Filterresults: notjunk:1;V01:K0:i2JQw0IubyY=:mhOXM19qoJs7t0QesIKId8 haZkw4WLFU40WQq9b+lN4NZ6y0wGgWUDyOzh6Y4uKMYx8DT4Tu1rxoSAcg2o8Q7Nd3WHhxEZT +CIy+B3JmAGM/BuymdmWxfRl1+9hZin8fyTuk4Sv9rc9qsB3W7oFOjyuGo1kS99uuBruLqyjy V2PDPu8MYz9wzZ3dATaY20WBsMxUVQ8bwz4JRSLj/jWEc7uGor6snZtRN4ZF84UeVGwx5riQN 5Qvkbrx9puRZR2/xQe+64v6YDvB81S9Yr60QXIUP4bScEvZEhRRgxpJbKEiYS1glb3Wsfsk4E w5IAq6R24eloj38a6iwDYyEueYiPpWsBfH7aGkDaz59FzpgxgTlBkM4dN2aSfzxodmL4QjHL2 K631kGTieGsfTFrzqTI2mu48g3CPJJ4h1Ys02sZ8B3w0j+zuFaRUgb4graWCh6PAlOojEkgHl wnJ8QO4oAFJ2SIJCFEkpVY1AZOJuJos6/pE1vqOXEMxCNzv7gpEWUvbj1BAEaNcJr+I776zeH RquCEYbg1sgIcUX9wncASxNRa6j6SVik34xw1/Ozk81gDBEs5ZuDcPs8KBZqcFdA4fA6PkOEk 0mbPoK4lv4Qz/kK/hnFStp327qDqKTXLGM17DpRxsFBFoGI8bu/uRa8T9JHh6MFmEQEXxofUh 6OTW8iAUWtl8XqhyjugnPk1TgPpoAvUlM7RakmJ6B8cn6wS0hHYNGtF7z4S6AsOHd3wA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ipv6 mip6 implementation is one of only a few users of the skb_get_timestamp() function in the kernel, which is both unsafe on 32-bit architectures because of the 2038 overflow, and slightly less efficient than the skb_get_ktime() based approach. This converts the function call and the mip6_report_rate_limiter structure that stores the time stamp, eliminating all uses of timeval in the ipv6 code. Signed-off-by: Arnd Bergmann Cc: Alexey Kuznetsov Cc: James Morris Cc: Hideaki YOSHIFUJI Cc: Patrick McHardy --- net/ipv6/mip6.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/net/ipv6/mip6.c b/net/ipv6/mip6.c index b9779d441b12..60c79a08e14a 100644 --- a/net/ipv6/mip6.c +++ b/net/ipv6/mip6.c @@ -118,7 +118,7 @@ static int mip6_mh_filter(struct sock *sk, struct sk_buff *skb) struct mip6_report_rate_limiter { spinlock_t lock; - struct timeval stamp; + ktime_t stamp; int iif; struct in6_addr src; struct in6_addr dst; @@ -184,20 +184,18 @@ static int mip6_destopt_output(struct xfrm_state *x, struct sk_buff *skb) return 0; } -static inline int mip6_report_rl_allow(struct timeval *stamp, +static inline int mip6_report_rl_allow(ktime_t stamp, const struct in6_addr *dst, const struct in6_addr *src, int iif) { int allow = 0; spin_lock_bh(&mip6_report_rl.lock); - if (mip6_report_rl.stamp.tv_sec != stamp->tv_sec || - mip6_report_rl.stamp.tv_usec != stamp->tv_usec || + if (!ktime_equal(mip6_report_rl.stamp, stamp) || mip6_report_rl.iif != iif || !ipv6_addr_equal(&mip6_report_rl.src, src) || !ipv6_addr_equal(&mip6_report_rl.dst, dst)) { - mip6_report_rl.stamp.tv_sec = stamp->tv_sec; - mip6_report_rl.stamp.tv_usec = stamp->tv_usec; + mip6_report_rl.stamp = stamp; mip6_report_rl.iif = iif; mip6_report_rl.src = *src; mip6_report_rl.dst = *dst; @@ -216,7 +214,7 @@ static int mip6_destopt_reject(struct xfrm_state *x, struct sk_buff *skb, struct ipv6_destopt_hao *hao = NULL; struct xfrm_selector sel; int offset; - struct timeval stamp; + ktime_t stamp; int err = 0; if (unlikely(fl6->flowi6_proto == IPPROTO_MH && @@ -230,9 +228,9 @@ static int mip6_destopt_reject(struct xfrm_state *x, struct sk_buff *skb, (skb_network_header(skb) + offset); } - skb_get_timestamp(skb, &stamp); + stamp = skb_get_ktime(skb); - if (!mip6_report_rl_allow(&stamp, &ipv6_hdr(skb)->daddr, + if (!mip6_report_rl_allow(stamp, &ipv6_hdr(skb)->daddr, hao ? &hao->addr : &ipv6_hdr(skb)->saddr, opt->iif)) goto out; -- 2.1.0.rc2