From patchwork Sun Nov 8 19:21:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 541483 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4D64A141406 for ; Mon, 9 Nov 2015 06:21:35 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752671AbbKHTVb (ORCPT ); Sun, 8 Nov 2015 14:21:31 -0500 Received: from orbit.nwl.cc ([176.31.251.142]:39129 "EHLO mail.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751973AbbKHTVO (ORCPT ); Sun, 8 Nov 2015 14:21:14 -0500 Received: from mail.nwl.cc (orbit [127.0.0.1]) by mail.nwl.cc (Postfix) with ESMTP id 16143214B3; Sun, 8 Nov 2015 20:21:12 +0100 (CET) Received: by mail.nwl.cc (Postfix, from userid 1000) id D2361214E9; Sun, 8 Nov 2015 20:21:11 +0100 (CET) From: Phil Sutter To: Stephen Hemminger Cc: netdev@vger.kernel.org Subject: [iproute PATCH 2/6] ipaddress: simplify ipaddr_flush() Date: Sun, 8 Nov 2015 20:21:07 +0100 Message-Id: <1447010471-559-3-git-send-email-phil@nwl.cc> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1447010471-559-1-git-send-email-phil@nwl.cc> References: <1447010471-559-1-git-send-email-phil@nwl.cc> X-Virus-Scanned: ClamAV using ClamSMTP Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Since it's no longer relevant whether an IP address is primary or secondary when flushing, ipaddr_flush() can be simplified a bit. Signed-off-by: Phil Sutter --- ip/ipaddress.c | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/ip/ipaddress.c b/ip/ipaddress.c index 75b3e27..b5b444b 100644 --- a/ip/ipaddress.c +++ b/ip/ipaddress.c @@ -1143,28 +1143,6 @@ brief_exit: return 0; } -static int print_addrinfo_primary(const struct sockaddr_nl *who, - struct nlmsghdr *n, void *arg) -{ - struct ifaddrmsg *ifa = NLMSG_DATA(n); - - if (ifa->ifa_flags & IFA_F_SECONDARY) - return 0; - - return print_addrinfo(who, n, arg); -} - -static int print_addrinfo_secondary(const struct sockaddr_nl *who, - struct nlmsghdr *n, void *arg) -{ - struct ifaddrmsg *ifa = NLMSG_DATA(n); - - if (!(ifa->ifa_flags & IFA_F_SECONDARY)) - return 0; - - return print_addrinfo(who, n, arg); -} - struct nlmsg_list { struct nlmsg_list *next; @@ -1415,26 +1393,12 @@ static int ipaddr_flush(void) filter.flushe = sizeof(flushb); while ((max_flush_loops == 0) || (round < max_flush_loops)) { - const struct rtnl_dump_filter_arg a[3] = { - { - .filter = print_addrinfo_secondary, - .arg1 = stdout, - }, - { - .filter = print_addrinfo_primary, - .arg1 = stdout, - }, - { - .filter = NULL, - .arg1 = NULL, - }, - }; if (rtnl_wilddump_request(&rth, filter.family, RTM_GETADDR) < 0) { perror("Cannot send dump request"); exit(1); } filter.flushed = 0; - if (rtnl_dump_filter_l(&rth, a) < 0) { + if (rtnl_dump_filter(&rth, print_addrinfo, stdout) < 0) { fprintf(stderr, "Flush terminated\n"); exit(1); }