Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: ipv6: mld: clean up MLD_V1_SEEN macro

Replace the macro with a function to make it more readable. GCC will
eventually decide whether to inline this or not (also, that's not
fast-path anyway).

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Daniel Borkmann and committed by
David S. Miller
6c567b78 89225d1c

+21 -13
+21 -13
net/ipv6/mcast.c
··· 95 95 static void mld_add_delrec(struct inet6_dev *idev, struct ifmcaddr6 *pmc); 96 96 static void mld_del_delrec(struct inet6_dev *idev, const struct in6_addr *addr); 97 97 static void mld_clear_delrec(struct inet6_dev *idev); 98 + static bool mld_in_v1_mode(const struct inet6_dev *idev); 98 99 static int sf_setstate(struct ifmcaddr6 *pmc); 99 100 static void sf_markstate(struct ifmcaddr6 *pmc); 100 101 static void ip6_mc_clear_src(struct ifmcaddr6 *pmc); ··· 118 117 #define MLD_V1_QUERY_LEN 24 119 118 #define MLD_V2_QUERY_LEN_MIN 28 120 119 121 - #define MLD_V1_SEEN(idev) (dev_net((idev)->dev)->ipv6.devconf_all->force_mld_version == 1 || \ 122 - (idev)->cnf.force_mld_version == 1 || \ 123 - ((idev)->mc_v1_seen && \ 124 - time_before(jiffies, (idev)->mc_v1_seen))) 125 - 126 120 #define IPV6_MLD_MAX_MSF 64 127 121 128 122 int sysctl_mld_max_msf __read_mostly = IPV6_MLD_MAX_MSF; ··· 135 139 { 136 140 int iv; 137 141 138 - if (MLD_V1_SEEN(idev)) 142 + if (mld_in_v1_mode(idev)) 139 143 iv = idev->cnf.mldv1_unsolicited_report_interval; 140 144 else 141 145 iv = idev->cnf.mldv2_unsolicited_report_interval; ··· 691 695 if (!(dev->flags & IFF_UP) || (mc->mca_flags & MAF_NOREPORT)) 692 696 return; 693 697 694 - if (MLD_V1_SEEN(mc->idev)) { 698 + if (mld_in_v1_mode(mc->idev)) { 695 699 igmp6_join_group(mc); 696 700 return; 697 701 } ··· 1112 1116 return true; 1113 1117 } 1114 1118 1119 + static bool mld_in_v1_mode(const struct inet6_dev *idev) 1120 + { 1121 + if (dev_net(idev->dev)->ipv6.devconf_all->force_mld_version == 1) 1122 + return true; 1123 + if (idev->cnf.force_mld_version == 1) 1124 + return true; 1125 + if (idev->mc_v1_seen && time_before(jiffies, idev->mc_v1_seen)) 1126 + return true; 1127 + 1128 + return false; 1129 + } 1130 + 1115 1131 static void mld_set_v1_mode(struct inet6_dev *idev) 1116 1132 { 1117 1133 /* RFC3810, relevant sections: ··· 1270 1262 sizeof(struct icmp6hdr); 1271 1263 1272 1264 /* hosts need to stay in MLDv1 mode, discard MLDv2 queries */ 1273 - if (MLD_V1_SEEN(idev)) 1265 + if (mld_in_v1_mode(idev)) 1274 1266 return 0; 1275 1267 if (!pskb_may_pull(skb, srcs_offset)) 1276 1268 return -EINVAL; ··· 1950 1942 1951 1943 static void mld_resend_report(struct inet6_dev *idev) 1952 1944 { 1953 - if (MLD_V1_SEEN(idev)) { 1945 + if (mld_in_v1_mode(idev)) { 1954 1946 struct ifmcaddr6 *mcaddr; 1955 1947 read_lock_bh(&idev->lock); 1956 1948 for (mcaddr = idev->mc_list; mcaddr; mcaddr = mcaddr->next) { ··· 2014 2006 else 2015 2007 pmc->mca_sources = psf->sf_next; 2016 2008 if (psf->sf_oldin && !(pmc->mca_flags & MAF_NOREPORT) && 2017 - !MLD_V1_SEEN(idev)) { 2009 + !mld_in_v1_mode(idev)) { 2018 2010 psf->sf_crcount = idev->mc_qrv; 2019 2011 psf->sf_next = pmc->mca_tomb; 2020 2012 pmc->mca_tomb = psf; ··· 2314 2306 2315 2307 static void igmp6_leave_group(struct ifmcaddr6 *ma) 2316 2308 { 2317 - if (MLD_V1_SEEN(ma->idev)) { 2309 + if (mld_in_v1_mode(ma->idev)) { 2318 2310 if (ma->mca_flags & MAF_LAST_REPORTER) 2319 2311 igmp6_send(&ma->mca_addr, ma->idev->dev, 2320 2312 ICMPV6_MGM_REDUCTION); ··· 2348 2340 2349 2341 static void mld_ifc_event(struct inet6_dev *idev) 2350 2342 { 2351 - if (MLD_V1_SEEN(idev)) 2343 + if (mld_in_v1_mode(idev)) 2352 2344 return; 2353 2345 idev->mc_ifc_count = idev->mc_qrv; 2354 2346 mld_ifc_start_timer(idev, 1); ··· 2359 2351 { 2360 2352 struct ifmcaddr6 *ma = (struct ifmcaddr6 *) data; 2361 2353 2362 - if (MLD_V1_SEEN(ma->idev)) 2354 + if (mld_in_v1_mode(ma->idev)) 2363 2355 igmp6_send(&ma->mca_addr, ma->idev->dev, ICMPV6_MGM_REPORT); 2364 2356 else 2365 2357 mld_send_report(ma->idev, ma);