From patchwork Tue Feb 16 15:59:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102765 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1747904lbl; Tue, 16 Feb 2016 08:01:08 -0800 (PST) X-Received: by 10.98.16.12 with SMTP id y12mr32138272pfi.6.1455638458911; Tue, 16 Feb 2016 08:00:58 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id lu9si51925314pab.215.2016.02.16.08.00.58; Tue, 16 Feb 2016 08:00:58 -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 S932985AbcBPQAz (ORCPT + 30 others); Tue, 16 Feb 2016 11:00:55 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:56551 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755326AbcBPQAw (ORCPT ); Tue, 16 Feb 2016 11:00:52 -0500 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue101) with ESMTPA (Nemesis) id 0MEVKb-1aktPY2RFx-00FiTo; Tue, 16 Feb 2016 17:00:05 +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] net: igmp: use IS_ENABLED(CONFIG_IP_MULTICAST) instead of ifdef Date: Tue, 16 Feb 2016 16:59:42 +0100 Message-Id: <1455638393-3269483-1-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 X-Provags-ID: V03:K0:ExRUAeEQCNEJ9Nxx3HlBsW+Afu/ev0o2UmLRnul5SHWw/4e6CJv LbdOKvpxC3eIsr1zKnBvK4MBLzht+eufexml3E04gm4FNJ8k/r87O8FI5Cw+id+yjN11oTk HMgjtxUklChfidXYDru8TCp8QQRpCxX+5UzIgY5lGyYFi74DvEsEpBZn+eO4maNM91gJaLU t8hhfo5GRLD3qEiG1ArtA== X-UI-Out-Filterresults: notjunk:1; V01:K0:EngWfTb2mbc=:v0bihiIs7EgzokSmZHfPoF jEVBiJwkjbdwxHTDYKdowacRdMHJUC4pFq5Cr5FkKM5AcR1gFcXeG8MpyBywxbXMDSxvg+PS5 8Oa510g59XwbAFmk3ycXidixm+mZNZRDDgR5Q5m19bnrERXm7tkGiMI1q41J/QTkKn4MCR54s FEppKDkCQcuZ9nx7bC/sfN48/n7fYHrYQB34RT7PG6l9QDJWD6nNsBIH8IVTu1Ru7HaUIrzuA klerWjvRTwFupQML2LIvt3tMgvU6y687YcNCCBdEc2HgODhIVJk4OpT/mfGF4SlauaqLOnUEY lPRWR/iHIGqX28c6p8rmwLWm9AR5AHSpP/FA7sl3qMCYw/gJVXNRbr9zp3ae7r78JgyQfSbn3 GqgLwnOAlhIG0ilA+a9UPRXe4WzbMaBl48P6aZiWzCPSQLSyTm1ByYoqZOKx/mqmTit/Of8El ZczLAjiZjg2Z6rZQQujXkClPZ3NDvkKQG4M71Jo3h+5YD8KMGL+HB4rRNyB5BMxHPwP2+Q8aW Jxn7hxB9hsYqxhCLShMUOYMDqyilzhks3fxiDc3NTkgQI0qC76KAKtUHY82IxKAWOBDjzqDED CMhK2STVsgNMmdqGHwMFPf83mjptl/wDLefqBdIsfi8NYEYr4Z6Sbtccv4EUtUvPX1AQs/AlV Q6ILIhOskjNGo0mZ8DApUXwf2VfMU3v7bvBIBavgVQOB5NzuVFsaH52gyuxwqHBMggBI= 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 Fixes: 87a8a2ae65b7 ("igmp: Namespaceify igmp_llm_reports sysctl knob") --- net/ipv4/igmp.c | 141 ++++++++++++++++++++++++-------------------------------- 1 file changed, 59 insertions(+), 82 deletions(-) -- 2.7.0 diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 7c95335bf85e..bb485b3e2baa 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 (IS_ENABLED(CONFIG_IP_MULTICAST)) + sf_markstate(pmc); + if (!delta) { err = -EINVAL; if (!pmc->sfcount[sfmode]) @@ -1821,17 +1807,15 @@ static int ip_mc_del_src(struct in_device *in_dev, __be32 *pmca, int sfmode, if (!err && rv < 0) err = rv; } - if (pmc->sfmode == MCAST_EXCLUDE && + if (IS_ENABLED(CONFIG_IP_MULTICAST) && + 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 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 +1823,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,12 +1860,14 @@ 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]; + if (!IS_ENABLED(CONFIG_IP_MULTICAST)) + return; + for (psf = pmc->sources; psf; psf = psf->sf_next) if (pmc->sfcount[MCAST_EXCLUDE]) { psf->sf_oldin = mca_xcount == @@ -1950,7 +1935,6 @@ static int sf_setstate(struct ip_mc_list *pmc) } return rv; } -#endif /* * Add multicast source filter list to the interface list @@ -1977,9 +1961,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,28 +1979,26 @@ 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 /* else no filters; keep old mode for reports */ - - 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) - psf->sf_crcount = 0; - igmp_ifc_event(in_dev); - } else if (sf_setstate(pmc)) { + if (IS_ENABLED(CONFIG_IP_MULTICAST)) { + 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) + psf->sf_crcount = 0; + igmp_ifc_event(in_dev); + } + } else if (IS_ENABLED(CONFIG_IP_MULTICAST) && sf_setstate(pmc)) { igmp_ifc_event(in_dev); -#endif } spin_unlock_bh(&pmc->lock); return err; @@ -2711,13 +2691,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",