From patchwork Tue Feb 16 16:32:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102762 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1766301lbl; Tue, 16 Feb 2016 08:33:06 -0800 (PST) X-Received: by 10.66.253.169 with SMTP id ab9mr14997212pad.62.1455640386801; Tue, 16 Feb 2016 08:33:06 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sm4si52144332pac.245.2016.02.16.08.33.06; Tue, 16 Feb 2016 08:33:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755526AbcBPQdE (ORCPT + 30 others); Tue, 16 Feb 2016 11:33:04 -0500 Received: from mout.kundenserver.de ([212.227.17.10]:52459 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751477AbcBPQdC (ORCPT ); Tue, 16 Feb 2016 11:33:02 -0500 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue101) with ESMTPA (Nemesis) id 0MEmRm-1akbj51u1a-00FzkU; Tue, 16 Feb 2016 17:32:21 +0100 From: Arnd Bergmann To: "David S. Miller" , Alexey Kuznetsov , James Morris , Hideaki YOSHIFUJI , Patrick McHardy Cc: linux-arm-kernel@lists.infradead.org, Arnd Bergmann , Nikolay Borisov , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] net: igmp: use IS_ENABLED(CONFIG_IP_MULTICAST) instead of ifdef Date: Tue, 16 Feb 2016 17:32:06 +0100 Message-Id: <1455640333-3769837-1-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 X-Provags-ID: V03:K0:x0GmhSPKaUn9wpwFpElknACnlORL+zc7qBTjT0skGuW7dHf01hN snVaHE4OfqCqsGFcfS8IUQgp/9xK4jHf8sDCFX7RufZN51CFfIU9/kkEhRlq0CB2RNj7NIk u7ATtSiieNbgFzMC9SH/ldsKyexNK66jsxjsw6l1NdmOWuWBIhq+5gVz92K7vYRSS2lNtam foQEdpGfK+wlFe0KsQ3nw== X-UI-Out-Filterresults: notjunk:1; V01:K0:xJzajVA8j+U=:0v72sq7spI1Cr+80eTNq0O 8xD+uvrIysV39YhKNk+LrlKnJRn5AvpSwUdIXTwZssyVbDXXaj8PV+vTXyJ+miK2tuR/kudDt 8G+tm676Erla3hv9WTsNbEVpabDrum0qLXX7fWRGYUoE834zy5P0U9EXXoc/atiIteWmT5tdN T3sprakLImer6/viAWYWu03YQpWnRn0l0zBBiPbpfs/orgYTFg7ExF/586aYPLQ4C5lq+loEK Z1wPkgkC61yOaNpnyt7r3yCXpvoy1uvJeHiYnSATtDYocBEv73kxgAlF8oST2oIFAGoi89p8Q wQQnEjw9YTkloIV++yF7KV+7tq8MgRFkIncCtnLtp7HzgW97rQW4d6pggTwSwdUBzaXLVNXX4 7veLaNGIjODM/qaM8jT3mYrsuCpCvOmYcK2Zt08VsdsVuMYbNa7SBPt+Y6t5Zxi8FA7Tj6hb4 41xnrrEiVfKEGGlp3pODorfizJj2QFmbpdqdxg6vschvkMMvneP1+hobbhDiOtAGQHXGOCW7g 7zr1m7jfW8UA0xprXa6wMYER+mDis+bKuw8aeCCL4By0Lg8jkb+gdnirlo0AnejOvYNfbah89 UM6rAkUBGoDisitkGYOFvZOkfbMs9YWEKSc/eDjH+phndy0zDocOdCmTohfy43mJ+n6LYQ59S MPNjXB+CYIshKNZ7xpnnekN2AFGQ2xYTbBp44GISzV1hl/hr8BKOQkNIvNkwtD56AM3o= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A recent change to use correct network namespace in net/ipv4/igmp.c caused a couple of harmless build warnings when CONFIG_MULTICAST is disabled: net/ipv4/igmp.c: In function 'igmp_group_added': net/ipv4/igmp.c:1227:14: error: unused variable 'net' [-Werror=unused-variable] net/ipv4/igmp.c: In function 'ip_mc_inc_group': net/ipv4/igmp.c:1319:14: error: unused variable 'net' [-Werror=unused-variable] net/ipv4/igmp.c: In function 'ip_mc_init_dev': net/ipv4/igmp.c:1646:14: error: unused variable 'net' [-Werror=unused-variable] net/ipv4/igmp.c: In function 'ip_mc_up': net/ipv4/igmp.c:1665:14: error: unused variable 'net' [-Werror=unused-variable] This reworks the entire file to change each instance if '#ifdef CONFIG_IP_MULTICAST' to 'if (IS_ENABLED(CONFIG_IP_MULTICAST)', which should avoid these problems forever, and makes the whole file more readable. Build-tested only. Signed-off-by: Arnd Bergmann Reviewed-by: Nikolay Borisov Fixes: 87a8a2ae65b7 ("igmp: Namespaceify igmp_llm_reports sysctl knob") --- net/ipv4/igmp.c | 142 ++++++++++++++++++++++++++------------------------------ 1 file changed, 66 insertions(+), 76 deletions(-) -- 2.7.0 diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 7c95335bf85e..2b6dd53adaa4 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c @@ -107,7 +107,6 @@ #include #endif -#ifdef CONFIG_IP_MULTICAST /* Parameter names and values are taken from igmp-v2-06 draft */ #define IGMP_V1_ROUTER_PRESENT_TIMEOUT (400*HZ) @@ -166,7 +165,6 @@ static void igmpv3_del_delrec(struct in_device *in_dev, __be32 multiaddr); static void igmpv3_clear_delrec(struct in_device *in_dev); static int sf_setstate(struct ip_mc_list *pmc); static void sf_markstate(struct ip_mc_list *pmc); -#endif static void ip_mc_clear_src(struct ip_mc_list *pmc); static int ip_mc_add_src(struct in_device *in_dev, __be32 *pmca, int sfmode, int sfcount, __be32 *psfsrc, int delta); @@ -189,8 +187,6 @@ static void ip_ma_put(struct ip_mc_list *im) pmc != NULL; \ pmc = rtnl_dereference(pmc->next_rcu)) -#ifdef CONFIG_IP_MULTICAST - /* * Timer management */ @@ -763,7 +759,9 @@ static void igmp_ifc_timer_expire(unsigned long data) static void igmp_ifc_event(struct in_device *in_dev) { struct net *net = dev_net(in_dev->dev); - if (IGMP_V1_SEEN(in_dev) || IGMP_V2_SEEN(in_dev)) + + if (!IS_ENABLED(CONFIG_IP_MULTICAST) || + IGMP_V1_SEEN(in_dev) || IGMP_V2_SEEN(in_dev)) return; in_dev->mr_ifc_count = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv; igmp_ifc_start_timer(in_dev, 1); @@ -1044,9 +1042,6 @@ drop: return 0; } -#endif - - /* * Add a filter to a device */ @@ -1080,7 +1075,6 @@ static void ip_mc_filter_del(struct in_device *in_dev, __be32 addr) dev_mc_del(dev, buf); } -#ifdef CONFIG_IP_MULTICAST /* * deleted ip_mc_list manipulation */ @@ -1181,22 +1175,20 @@ static void igmpv3_clear_delrec(struct in_device *in_dev) } rcu_read_unlock(); } -#endif static void igmp_group_dropped(struct ip_mc_list *im) { struct in_device *in_dev = im->interface; -#ifdef CONFIG_IP_MULTICAST struct net *net = dev_net(in_dev->dev); int reporter; -#endif if (im->loaded) { im->loaded = 0; ip_mc_filter_del(in_dev, im->multiaddr); } -#ifdef CONFIG_IP_MULTICAST + if (!IS_ENABLED(CONFIG_IP_MULTICAST)) + return; if (im->multiaddr == IGMP_ALL_HOSTS) return; if (ipv4_is_local_multicast(im->multiaddr) && !net->ipv4.sysctl_igmp_llm_reports) @@ -1218,7 +1210,6 @@ static void igmp_group_dropped(struct ip_mc_list *im) igmp_ifc_event(in_dev); } -#endif } static void igmp_group_added(struct ip_mc_list *im) @@ -1231,7 +1222,9 @@ static void igmp_group_added(struct ip_mc_list *im) ip_mc_filter_add(in_dev, im->multiaddr); } -#ifdef CONFIG_IP_MULTICAST + if (!IS_ENABLED(CONFIG_IP_MULTICAST)) + return; + if (im->multiaddr == IGMP_ALL_HOSTS) return; if (ipv4_is_local_multicast(im->multiaddr) && !net->ipv4.sysctl_igmp_llm_reports) @@ -1249,7 +1242,6 @@ static void igmp_group_added(struct ip_mc_list *im) im->crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv; igmp_ifc_event(in_dev); -#endif } @@ -1341,10 +1333,10 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr) im->sfcount[MCAST_EXCLUDE] = 1; atomic_set(&im->refcnt, 1); spin_lock_init(&im->lock); -#ifdef CONFIG_IP_MULTICAST - setup_timer(&im->timer, igmp_timer_expire, (unsigned long)im); - im->unsolicit_count = net->ipv4.sysctl_igmp_qrv; -#endif + if (IS_ENABLED(CONFIG_IP_MULTICAST)) { + setup_timer(&im->timer, igmp_timer_expire, (unsigned long)im); + im->unsolicit_count = net->ipv4.sysctl_igmp_qrv; + } im->next_rcu = in_dev->mc_list; in_dev->mc_count++; @@ -1352,9 +1344,9 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr) ip_mc_hash_add(in_dev, im); -#ifdef CONFIG_IP_MULTICAST - igmpv3_del_delrec(in_dev, im->multiaddr); -#endif + if (IS_ENABLED(CONFIG_IP_MULTICAST)) + igmpv3_del_delrec(in_dev, im->multiaddr); + igmp_group_added(im); if (!in_dev->dead) ip_rt_multicast_event(in_dev); @@ -1533,11 +1525,13 @@ EXPORT_SYMBOL(ip_mc_check_igmp); */ static void ip_mc_rejoin_groups(struct in_device *in_dev) { -#ifdef CONFIG_IP_MULTICAST struct ip_mc_list *im; int type; struct net *net = dev_net(in_dev->dev); + if (!IS_ENABLED(CONFIG_IP_MULTICAST)) + return; + ASSERT_RTNL(); for_each_pmc_rtnl(in_dev, im) { @@ -1558,7 +1552,6 @@ static void ip_mc_rejoin_groups(struct in_device *in_dev) type = IGMPV3_HOST_MEMBERSHIP_REPORT; igmp_send_report(in_dev, im, type); } -#endif } /* @@ -1628,15 +1621,15 @@ void ip_mc_down(struct in_device *in_dev) for_each_pmc_rtnl(in_dev, pmc) igmp_group_dropped(pmc); -#ifdef CONFIG_IP_MULTICAST - in_dev->mr_ifc_count = 0; - if (del_timer(&in_dev->mr_ifc_timer)) - __in_dev_put(in_dev); - in_dev->mr_gq_running = 0; - if (del_timer(&in_dev->mr_gq_timer)) - __in_dev_put(in_dev); - igmpv3_clear_delrec(in_dev); -#endif + if (IS_ENABLED(CONFIG_IP_MULTICAST)) { + in_dev->mr_ifc_count = 0; + if (del_timer(&in_dev->mr_ifc_timer)) + __in_dev_put(in_dev); + in_dev->mr_gq_running = 0; + if (del_timer(&in_dev->mr_gq_timer)) + __in_dev_put(in_dev); + igmpv3_clear_delrec(in_dev); + } ip_mc_dec_group(in_dev, IGMP_ALL_HOSTS); } @@ -1646,13 +1639,13 @@ void ip_mc_init_dev(struct in_device *in_dev) struct net *net = dev_net(in_dev->dev); ASSERT_RTNL(); -#ifdef CONFIG_IP_MULTICAST - setup_timer(&in_dev->mr_gq_timer, igmp_gq_timer_expire, - (unsigned long)in_dev); - setup_timer(&in_dev->mr_ifc_timer, igmp_ifc_timer_expire, - (unsigned long)in_dev); - in_dev->mr_qrv = net->ipv4.sysctl_igmp_qrv; -#endif + if (IS_ENABLED(CONFIG_IP_MULTICAST)) { + setup_timer(&in_dev->mr_gq_timer, igmp_gq_timer_expire, + (unsigned long)in_dev); + setup_timer(&in_dev->mr_ifc_timer, igmp_ifc_timer_expire, + (unsigned long)in_dev); + in_dev->mr_qrv = net->ipv4.sysctl_igmp_qrv; + } spin_lock_init(&in_dev->mc_tomb_lock); } @@ -1666,9 +1659,9 @@ void ip_mc_up(struct in_device *in_dev) ASSERT_RTNL(); -#ifdef CONFIG_IP_MULTICAST - in_dev->mr_qrv = net->ipv4.sysctl_igmp_qrv; -#endif + if (IS_ENABLED(CONFIG_IP_MULTICAST)) + in_dev->mr_qrv = net->ipv4.sysctl_igmp_qrv; + ip_mc_inc_group(in_dev, IGMP_ALL_HOSTS); for_each_pmc_rtnl(in_dev, pmc) @@ -1755,34 +1748,27 @@ static int ip_mc_del1_src(struct ip_mc_list *pmc, int sfmode, ip_rt_multicast_event(pmc->interface); } if (!psf->sf_count[MCAST_INCLUDE] && !psf->sf_count[MCAST_EXCLUDE]) { -#ifdef CONFIG_IP_MULTICAST struct in_device *in_dev = pmc->interface; struct net *net = dev_net(in_dev->dev); -#endif /* no more filters for this source */ if (psf_prev) psf_prev->sf_next = psf->sf_next; else pmc->sources = psf->sf_next; -#ifdef CONFIG_IP_MULTICAST - if (psf->sf_oldin && + if (IS_ENABLED(CONFIG_IP_MULTICAST) && psf->sf_oldin && !IGMP_V1_SEEN(in_dev) && !IGMP_V2_SEEN(in_dev)) { psf->sf_crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv; psf->sf_next = pmc->tomb; pmc->tomb = psf; rv = 1; - } else -#endif + } else { kfree(psf); + } } return rv; } -#ifndef CONFIG_IP_MULTICAST -#define igmp_ifc_event(x) do { } while (0) -#endif - static int ip_mc_del_src(struct in_device *in_dev, __be32 *pmca, int sfmode, int sfcount, __be32 *psfsrc, int delta) { @@ -1804,9 +1790,9 @@ static int ip_mc_del_src(struct in_device *in_dev, __be32 *pmca, int sfmode, } spin_lock_bh(&pmc->lock); rcu_read_unlock(); -#ifdef CONFIG_IP_MULTICAST + sf_markstate(pmc); -#endif + if (!delta) { err = -EINVAL; if (!pmc->sfcount[sfmode]) @@ -1824,14 +1810,15 @@ static int ip_mc_del_src(struct in_device *in_dev, __be32 *pmca, int sfmode, if (pmc->sfmode == MCAST_EXCLUDE && pmc->sfcount[MCAST_EXCLUDE] == 0 && pmc->sfcount[MCAST_INCLUDE]) { -#ifdef CONFIG_IP_MULTICAST struct ip_sf_list *psf; struct net *net = dev_net(in_dev->dev); -#endif /* filter mode change */ pmc->sfmode = MCAST_INCLUDE; -#ifdef CONFIG_IP_MULTICAST + + if (!IS_ENABLED(CONFIG_IP_MULTICAST)) + goto out_unlock; + pmc->crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv; in_dev->mr_ifc_count = pmc->crcount; for (psf = pmc->sources; psf; psf = psf->sf_next) @@ -1839,7 +1826,6 @@ static int ip_mc_del_src(struct in_device *in_dev, __be32 *pmca, int sfmode, igmp_ifc_event(pmc->interface); } else if (sf_setstate(pmc) || changerec) { igmp_ifc_event(pmc->interface); -#endif } out_unlock: spin_unlock_bh(&pmc->lock); @@ -1877,11 +1863,15 @@ static int ip_mc_add1_src(struct ip_mc_list *pmc, int sfmode, return 0; } -#ifdef CONFIG_IP_MULTICAST static void sf_markstate(struct ip_mc_list *pmc) { struct ip_sf_list *psf; - int mca_xcount = pmc->sfcount[MCAST_EXCLUDE]; + int mca_xcount; + + if (!IS_ENABLED(CONFIG_IP_MULTICAST)) + return; + + mca_xcount = pmc->sfcount[MCAST_EXCLUDE]; for (psf = pmc->sources; psf; psf = psf->sf_next) if (pmc->sfcount[MCAST_EXCLUDE]) { @@ -1895,10 +1885,15 @@ static void sf_markstate(struct ip_mc_list *pmc) static int sf_setstate(struct ip_mc_list *pmc) { struct ip_sf_list *psf, *dpsf; - int mca_xcount = pmc->sfcount[MCAST_EXCLUDE]; - int qrv = pmc->interface->mr_qrv; + int mca_xcount; + int qrv; int new_in, rv; + if (!IS_ENABLED(CONFIG_IP_MULTICAST)) + return 0; + + mca_xcount = pmc->sfcount[MCAST_EXCLUDE]; + qrv = pmc->interface->mr_qrv; rv = 0; for (psf = pmc->sources; psf; psf = psf->sf_next) { if (pmc->sfcount[MCAST_EXCLUDE]) { @@ -1950,7 +1945,6 @@ static int sf_setstate(struct ip_mc_list *pmc) } return rv; } -#endif /* * Add multicast source filter list to the interface list @@ -1977,9 +1971,7 @@ static int ip_mc_add_src(struct in_device *in_dev, __be32 *pmca, int sfmode, spin_lock_bh(&pmc->lock); rcu_read_unlock(); -#ifdef CONFIG_IP_MULTICAST sf_markstate(pmc); -#endif isexclude = pmc->sfmode == MCAST_EXCLUDE; if (!delta) pmc->sfcount[sfmode]++; @@ -1997,18 +1989,19 @@ static int ip_mc_add_src(struct in_device *in_dev, __be32 *pmca, int sfmode, for (j = 0; j < i; j++) (void) ip_mc_del1_src(pmc, sfmode, &psfsrc[j]); } else if (isexclude != (pmc->sfcount[MCAST_EXCLUDE] != 0)) { -#ifdef CONFIG_IP_MULTICAST struct ip_sf_list *psf; struct net *net = dev_net(pmc->interface->dev); in_dev = pmc->interface; -#endif /* filter mode change */ if (pmc->sfcount[MCAST_EXCLUDE]) pmc->sfmode = MCAST_EXCLUDE; else if (pmc->sfcount[MCAST_INCLUDE]) pmc->sfmode = MCAST_INCLUDE; -#ifdef CONFIG_IP_MULTICAST + + if (!IS_ENABLED(CONFIG_IP_MULTICAST)) + goto out_unlock; + /* else no filters; keep old mode for reports */ pmc->crcount = in_dev->mr_qrv ?: net->ipv4.sysctl_igmp_qrv; @@ -2018,8 +2011,8 @@ static int ip_mc_add_src(struct in_device *in_dev, __be32 *pmca, int sfmode, igmp_ifc_event(in_dev); } else if (sf_setstate(pmc)) { igmp_ifc_event(in_dev); -#endif } +out_unlock: spin_unlock_bh(&pmc->lock); return err; } @@ -2711,13 +2704,10 @@ static int igmp_mc_seq_show(struct seq_file *seq, void *v) char *querier; long delta; -#ifdef CONFIG_IP_MULTICAST - querier = IGMP_V1_SEEN(state->in_dev) ? "V1" : + querier = !IS_ENABLED(CONFIG_IP_MULTICAST) ? "NONE" : + IGMP_V1_SEEN(state->in_dev) ? "V1" : IGMP_V2_SEEN(state->in_dev) ? "V2" : "V3"; -#else - querier = "NONE"; -#endif if (rcu_access_pointer(state->in_dev->mc_list) == im) { seq_printf(seq, "%d\t%-10s: %5d %7s\n",