Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp154669pxb; Wed, 18 Nov 2020 00:31:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJyyJg4S08gRHfZjwEabjiCdo3oD+oM9DMLxshnlzDrItHFMqVhepfEwElCv42aHSlF5ipgv X-Received: by 2002:aa7:c612:: with SMTP id h18mr24162850edq.27.1605688309272; Wed, 18 Nov 2020 00:31:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605688309; cv=none; d=google.com; s=arc-20160816; b=K8ILh0rSJmu3igerMbiO3GvBpFpJSKT9AsifZj0tlLRnS48tFCcfDmx+AG4V7CMJhs h1F5+zi65aV+QuCVEiXFBxIG0sVSdhEqHwtRRcDV8fl3HCxV8z2Cg6pPzXMDVf4hTzcM bHiQxM6LiWFVK6ojmcfOWB5tOHLAHNf2xtCBxO7O/W6Pxbf1udbxuqAsELnh/2Sdna2Y nXlAFMoOX5VznwLuutpaAKKpha2MYkETuQwHNl+vaWKa27HXJhiGb0ckmE1JhVtrnHzU RBWWKZ8jL4mgFUb1MN9P92SfFG0xU+jPV49zEe5ACP/MOFcr6uQa56J5qZ48cPty3Lle SgPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:message-id:references:in-reply-to :organization:subject:cc:to:from:date:content-transfer-encoding :mime-version; bh=q+Vjtb5mDo6+rsF6OdKM4+yMK2KkLtxrW7DVIV2izOM=; b=GQ57wZPJWCtwmzZ2taJ8JZYyPNm8rLTACGv6x22IMK2rlwAAgB5egMc0Mx9+gEXHdt izzC3U9VdfuTU884dQmAb9A6CKurcHmXI2VXEIMGh195cz/H14wdOl+EdHw0ecU5bxNu DxONSyruV5Aule8JiWDpwp5P+QoVHQ0oLYUKxyqbrii7/PgGZiJFbn3GmXqnSbW6fPkY VIFOTlf2vsWr7KgDns9l6CBxx69Rdrk8MPVrSu7lJdcmHOyUGuLckkW2Xn9I+MoJq3z/ yxTh7TRgka21vTJEJPMVcTUeorLz49tFkvu1Vlv6uVXhf8TdXU7y+cg5uHJ7cHvWgOsM K3sA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p18si7530486edy.195.2020.11.18.00.31.26; Wed, 18 Nov 2020 00:31:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727364AbgKRI2n (ORCPT + 99 others); Wed, 18 Nov 2020 03:28:43 -0500 Received: from mxout70.expurgate.net ([194.37.255.70]:35959 "EHLO mxout70.expurgate.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726641AbgKRI2n (ORCPT ); Wed, 18 Nov 2020 03:28:43 -0500 Received: from [127.0.0.1] (helo=localhost) by relay.expurgate.net with smtp (Exim 4.90) (envelope-from ) id 1kfIpP-0004fq-Gx; Wed, 18 Nov 2020 09:28:35 +0100 Received: from [195.243.126.94] (helo=securemail.tdt.de) by relay.expurgate.net with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90) (envelope-from ) id 1kfIpO-0008Lm-DO; Wed, 18 Nov 2020 09:28:34 +0100 Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id E4AB5240041; Wed, 18 Nov 2020 09:28:33 +0100 (CET) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id 669A3240040; Wed, 18 Nov 2020 09:28:33 +0100 (CET) Received: from mail.dev.tdt.de (localhost [IPv6:::1]) by mail.dev.tdt.de (Postfix) with ESMTP id 01AC020049; Wed, 18 Nov 2020 09:28:32 +0100 (CET) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 18 Nov 2020 09:28:32 +0100 From: Martin Schiller To: Xie He Cc: Andrew Hendry , "David S. Miller" , Jakub Kicinski , Linux X25 , Linux Kernel Network Developers , LKML Subject: Re: [PATCH net-next v2 3/6] net/x25: replace x25_kill_by_device with x25_kill_by_neigh Organization: TDT AG In-Reply-To: References: <20201116135522.21791-1-ms@dev.tdt.de> <20201116135522.21791-4-ms@dev.tdt.de> Message-ID: <352e0095deb8f1f3b08e335942eabac2@dev.tdt.de> X-Sender: ms@dev.tdt.de User-Agent: Roundcube Webmail/1.3.15 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dev.tdt.de X-purgate: clean X-purgate-type: clean X-purgate-ID: 151534::1605688115-000013A4-791AC271/0/0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-11-17 20:50, Xie He wrote: > 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. > Well I don't like to have 2 functions doing the same thing. But after another look at this code, I've found that I also need to remove the call to x25_clear_forward_by_dev() in the function x25_route_device_down(). Otherwise, it will be called twice. > The original code also seems to be a little more efficient than the new > code. The only difference would be the x25_get_neigh() and x25_neigh_put() calls. That shouldn't cost to much.