From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 365E1C169C4 for ; Wed, 6 Feb 2019 12:51:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0102020B1F for ; Wed, 6 Feb 2019 12:51:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fs/1Tni9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730107AbfBFMvo (ORCPT ); Wed, 6 Feb 2019 07:51:44 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:45162 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726416AbfBFMvn (ORCPT ); Wed, 6 Feb 2019 07:51:43 -0500 Received: by mail-pf1-f196.google.com with SMTP id j3so882879pfi.12 for ; Wed, 06 Feb 2019 04:51:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nvsbhtYkQk/RGKgjuQ1I3QW7mbgg/qEwr2SMO9y9hyc=; b=fs/1Tni9u3ZM5A5fsUsJlmh67wPceXiFafK3xgUDkg2MmRMzDEhJfEoqJzl0il3RhN Z/+NKgtk9tpWLWbxWyuPWQhBUPC35OIVoAaQj6q14WqUJgyo9laU9Jon6botbjEQjY42 0nd3QvgRLHnlRLfmuJBXIW3wm176bvgEu2mF5kWrwjEAvYqeVhQ2iz8eSZNbkob8cCzh uU/0J9Mj30CCplyOI26NbmvPQGTJpkAk+7cgxM/QE0FKcejcI0cnwunr/MB0lwcrcNUh QRwqPtzOOGMsuMKR2C+AaHjH8JpiGAc8uHlLTlVEhi191sKV5L1fHchqxIEnkLMoggbC xrxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nvsbhtYkQk/RGKgjuQ1I3QW7mbgg/qEwr2SMO9y9hyc=; b=MWJgKjPVlRf4cB0RRKB0/pxb0OhcZ1ASCslUtDPYW9qdzNgtN2DkFocSZTvW44Ztgp T/3LsSGdU14ThfbXSkOeMsVvC5qSWsUGR5Tzz3VkY1dmVjcFzsD8Gv9prwlgQ+LlA7Lx Sqa5y3f8OYptqQkrroOadq3EK9PS0absj8XnXeAtu/L2ZowFdWxIlRsEfq9HjATXs8bs ml6BZAKaFLgdI7Etv89fjPwnl3OpgBnw+wcVYKoOqONAFF5tJbB0mV95JbMBRxjWovf8 TiVBa9R/n9wDGGnlVXbcNqTRFM1AYpsmMO/82gmZfX/c2uSoLHgh9xLE1wfJCeu+aJrA jBLQ== X-Gm-Message-State: AHQUAuZPqcf55ISeSub3QkpV/3IF2LMOduQz9Ti5dtLGnKsCjkg8+H9u NruO/VTjpx/BBwlWYtGilKnyR4tW X-Google-Smtp-Source: AHgI3IZ4389as0x+SqWt6SJzMLBTR3OZKLv9zYzXq4wJ6JN4J4EIs/igAQDbzhijiJmZgyvrhtxtiQ== X-Received: by 2002:a63:d104:: with SMTP id k4mr9216337pgg.227.1549457502192; Wed, 06 Feb 2019 04:51:42 -0800 (PST) Received: from dhcp-12-139.nay.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id 62sm8023665pgc.61.2019.02.06.04.51.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Feb 2019 04:51:41 -0800 (PST) From: Hangbin Liu To: netdev@vger.kernel.org Cc: Stefano Brivio , David Miller , Hangbin Liu Subject: [PATCH net 2/2] sit: check if IPv6 enabled before call ip6_err_gen_icmpv6_unreach() Date: Wed, 6 Feb 2019 20:51:11 +0800 Message-Id: <20190206125111.5286-3-liuhangbin@gmail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190206125111.5286-1-liuhangbin@gmail.com> References: <20190206125111.5286-1-liuhangbin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org If we disabled IPv6 from kernel boot up cmd(ipv6.disable=1), we should not call ip6_err_gen_icmpv6_unreach(). Reproducer: ip link add sit1 type sit local 10.10.0.1 remote 10.10.1.1 ttl 1 ip link set sit1 up ip addr add 192.168.0.1/24 dev sit1 ping 192.168.0.2 Reported-by: Jianlin Shi Signed-off-by: Hangbin Liu --- net/ipv6/sit.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index 1e03305c0549..e43fbac0fd1a 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c @@ -493,6 +493,7 @@ static int ipip6_err(struct sk_buff *skb, u32 info) const int type = icmp_hdr(skb)->type; const int code = icmp_hdr(skb)->code; unsigned int data_len = 0; + struct inet6_dev *idev; struct ip_tunnel *t; int sifindex; int err; @@ -546,8 +547,13 @@ static int ipip6_err(struct sk_buff *skb, u32 info) } err = 0; - if (!ip6_err_gen_icmpv6_unreach(skb, iph->ihl * 4, type, data_len)) + + idev = in6_dev_get(skb->dev); + if (idev && + !ip6_err_gen_icmpv6_unreach(skb, iph->ihl * 4, type, data_len)) { + in6_dev_put(idev); goto out; + } if (t->parms.iph.daddr == 0) goto out; -- 2.19.2