From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lorenzo Colitti Subject: [PATCH ipsec-next 1/7] net: xfrm: Don't check for TUNNEL_KEY when hashing VTI tunnels. Date: Thu, 21 Dec 2017 02:06:01 +0900 Message-ID: <20171220170607.41516-2-lorenzo@google.com> References: <20171220170607.41516-1-lorenzo@google.com> Cc: steffen.klassert@secunet.com, subashab@codeaurora.org, nharold@google.com, davem@davemloft.net, Lorenzo Colitti To: netdev@vger.kernel.org Return-path: Received: from mail-pf0-f195.google.com ([209.85.192.195]:39211 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755292AbdLTRG2 (ORCPT ); Wed, 20 Dec 2017 12:06:28 -0500 Received: by mail-pf0-f195.google.com with SMTP id l24so12809636pfj.6 for ; Wed, 20 Dec 2017 09:06:28 -0800 (PST) In-Reply-To: <20171220170607.41516-1-lorenzo@google.com> Sender: netdev-owner@vger.kernel.org List-ID: Currently, ip_bucket sets the lookup i_key to 0 if the tunnel's i_flags have VTI_ISVTI flag set but not TUNNEL_KEY. However, it can can never happen that TUNNEL_KEY is set if VTI_ISVTI is also set (see below). Therefore, just drop the check for TUNNEL_KEY and only set i_key to 0 on VTI_ISVTI. This will allow the VTI code to set TUNNEL_KEY on certain tunnels in a future change. None of the callers of ip_bucket pass in TUNNEL_KEY | VTI_ISVTI. The call graph is as follows: - ip_tunnel_add - ip_tunnel_create - ip_tunnel_ioctl - ipgre_tunnel_ioctl: can set TUNNEL_KEY but not VTI_ISVTI - ipip_tunnel_ioctl: hardcodes i_flags to 0 - vti_tunnel_ioctl: hardcodes i_flags to VTI_ISVTI - ip_tunnel_update: doesn't touch i_flags - ip_tunnel_init_net: memsets flags to 0 - ip_tunnel_newlink - ipgre_newlink - ipgre_netlink_parms: can set TUNNEL_KEY but not VTI_ISVTI - vti_newlink: hardcodes i_flags to VTI_ISVTI - ip_tunnel_changelink: doesn't set flags - ip_tunnel_find - ip_tunnel_ioctl (see above) - ip_tunnel_newlink (see above) - ip_tunnel_changelink (see above) VTI_ISVTI has the same value as TUNNEL_DONT_FRAGMENT, but that is never set into tunnel parameters. Signed-off-by: Lorenzo Colitti --- net/ipv4/ip_tunnel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c index 5ddb1cb52b..539c8f22c4 100644 --- a/net/ipv4/ip_tunnel.c +++ b/net/ipv4/ip_tunnel.c @@ -198,7 +198,7 @@ static struct hlist_head *ip_bucket(struct ip_tunnel_net *itn, else remote = 0; - if (!(parms->i_flags & TUNNEL_KEY) && (parms->i_flags & VTI_ISVTI)) + if (parms->i_flags & VTI_ISVTI) i_key = 0; h = ip_tunnel_hash(i_key, remote); -- 2.15.1.620.gb9897f4670-goog