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=-7.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no 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 5456DC2D0E4 for ; Tue, 17 Nov 2020 19:50:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E10092463B for ; Tue, 17 Nov 2020 19:50:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Lm0ry1bU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730734AbgKQTuf (ORCPT ); Tue, 17 Nov 2020 14:50:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728309AbgKQTue (ORCPT ); Tue, 17 Nov 2020 14:50:34 -0500 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E4F0C0613CF; Tue, 17 Nov 2020 11:50:34 -0800 (PST) Received: by mail-pf1-x441.google.com with SMTP id v12so17967306pfm.13; Tue, 17 Nov 2020 11:50:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LDAEmhNdku9VAWF7fGVJyr3eF+5Nl9MfyP1c5wCk+Qg=; b=Lm0ry1bUCaP1i76eXxbXB695bO5Z9mRG8713U6+3u15LHetOu1oB3JAwSaD9bZtvcC /wyLo0KKvWQTKGowO5utZS58GfnQC08x5pAJcm/ehyy5v3dciOXl6wptSQuqLxxzUmb3 8Tx/wikGTWiMWXarqZWrxvgIKWKM25YNwcQ370iQQEwRBe8r2EHpWoUKAo6lqYQM4XDB hZPpPymDK7V3Uy9ON8H/9oODLOFcf98mfcG0bFSq4RKzXwiX35gQuGJH7/wEZCqDNtJd Qj6QNC22AbtezIceA5870sZ3qKZlgw5FNFZ0LUM5GlRMb3QDQeRzpc4tboYr9s10VifI Gvsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LDAEmhNdku9VAWF7fGVJyr3eF+5Nl9MfyP1c5wCk+Qg=; b=OHw+OFZpAd2Vki/n/PWToApnn+bC+dwmcOPTmzFuibsaLffdxKoJ8XwmuuFspJ0Up+ WC/ZN64KW0uFnSEkufVh5bMaROI44CTaW3ZsFVAg0fXez71CW3QHYCg2xMyReoeXRZ0K lqYyiIDhNtDQLVp6rlCQ19dKF2OlH8//naVdFwAz+ZcXUkEliBuFzVIEtoSFHT7HqlbH JKFNuaqzcwcnzfwpvipFWiuZDCmoWw3bHJseKDAt8A3D+WvdQyyPqp4aH2YsInMFM7qM bOCINaeZfpvWUDcODYl221ood3Ljl3frApGpIDUwZ4CvFgfGIUJEa2Yv4J3hn+OCPI3Q w8KA== X-Gm-Message-State: AOAM532dhN3B75dGVXNPqMJSs7k5/HZ73mmY/2qpnf9sMch6x14rREot ITRVRcvZrR8AHnYahRdrmB1nevwSWDFmm7+s7pwFUOZEDPM= X-Google-Smtp-Source: ABdhPJyrt2/yEdjoVLA8SLqCI1GEtqRtkALsHHeiQczj/+I6NgFaSf4UAPq4bnKwzIwZcwb4Wv1D8MJJCMcSeWnmZ9I= X-Received: by 2002:a63:1d0b:: with SMTP id d11mr2265333pgd.368.1605642634151; Tue, 17 Nov 2020 11:50:34 -0800 (PST) MIME-Version: 1.0 References: <20201116135522.21791-1-ms@dev.tdt.de> <20201116135522.21791-4-ms@dev.tdt.de> In-Reply-To: <20201116135522.21791-4-ms@dev.tdt.de> From: Xie He Date: Tue, 17 Nov 2020 11:50:23 -0800 Message-ID: Subject: Re: [PATCH net-next v2 3/6] net/x25: replace x25_kill_by_device with x25_kill_by_neigh To: Martin Schiller Cc: Andrew Hendry , "David S. Miller" , Jakub Kicinski , Linux X25 , Linux Kernel Network Developers , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 16, 2020 at 6:00 AM Martin Schiller wrote: > > Remove unnecessary function x25_kill_by_device. > -/* > - * Kill all bound sockets on a dropped device. > - */ > -static void x25_kill_by_device(struct net_device *dev) > -{ > - struct sock *s; > - > - write_lock_bh(&x25_list_lock); > - > - sk_for_each(s, &x25_list) > - if (x25_sk(s)->neighbour && x25_sk(s)->neighbour->dev == dev) > - x25_disconnect(s, ENETUNREACH, 0, 0); > - > - write_unlock_bh(&x25_list_lock); > -} > - > /* > * Handle device status changes. > */ > @@ -273,7 +257,11 @@ static int x25_device_event(struct notifier_block *this, unsigned long event, > case NETDEV_DOWN: > pr_debug("X.25: got event NETDEV_DOWN for device: %s\n", > dev->name); > - x25_kill_by_device(dev); > + nb = x25_get_neigh(dev); > + if (nb) { > + x25_kill_by_neigh(nb); > + x25_neigh_put(nb); > + } > x25_route_device_down(dev); > x25_link_device_down(dev); > break; This patch might not be entirely necessary. x25_kill_by_neigh and x25_kill_by_device are just two helper functions. One function takes nb as the argument and the other one takes dev as the argument. But they do almost the same things. It doesn't harm to keep both. In C++ we often have different functions with the same name doing almost the same things. The original code also seems to be a little more efficient than the new code.