aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/mcast.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv6/mcast.c')
-rw-r--r--net/ipv6/mcast.c71
1 files changed, 35 insertions, 36 deletions
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index b2869cab2092..6d0f5dc8e3a6 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -606,13 +606,13 @@ done:
606 return err; 606 return err;
607} 607}
608 608
609int inet6_mc_check(struct sock *sk, const struct in6_addr *mc_addr, 609bool inet6_mc_check(struct sock *sk, const struct in6_addr *mc_addr,
610 const struct in6_addr *src_addr) 610 const struct in6_addr *src_addr)
611{ 611{
612 struct ipv6_pinfo *np = inet6_sk(sk); 612 struct ipv6_pinfo *np = inet6_sk(sk);
613 struct ipv6_mc_socklist *mc; 613 struct ipv6_mc_socklist *mc;
614 struct ip6_sf_socklist *psl; 614 struct ip6_sf_socklist *psl;
615 int rv = 1; 615 bool rv = true;
616 616
617 rcu_read_lock(); 617 rcu_read_lock();
618 for_each_pmc_rcu(np, mc) { 618 for_each_pmc_rcu(np, mc) {
@@ -621,7 +621,7 @@ int inet6_mc_check(struct sock *sk, const struct in6_addr *mc_addr,
621 } 621 }
622 if (!mc) { 622 if (!mc) {
623 rcu_read_unlock(); 623 rcu_read_unlock();
624 return 1; 624 return true;
625 } 625 }
626 read_lock(&mc->sflock); 626 read_lock(&mc->sflock);
627 psl = mc->sflist; 627 psl = mc->sflist;
@@ -635,9 +635,9 @@ int inet6_mc_check(struct sock *sk, const struct in6_addr *mc_addr,
635 break; 635 break;
636 } 636 }
637 if (mc->sfmode == MCAST_INCLUDE && i >= psl->sl_count) 637 if (mc->sfmode == MCAST_INCLUDE && i >= psl->sl_count)
638 rv = 0; 638 rv = false;
639 if (mc->sfmode == MCAST_EXCLUDE && i < psl->sl_count) 639 if (mc->sfmode == MCAST_EXCLUDE && i < psl->sl_count)
640 rv = 0; 640 rv = false;
641 } 641 }
642 read_unlock(&mc->sflock); 642 read_unlock(&mc->sflock);
643 rcu_read_unlock(); 643 rcu_read_unlock();
@@ -931,15 +931,15 @@ int ipv6_dev_mc_dec(struct net_device *dev, const struct in6_addr *addr)
931/* 931/*
932 * identify MLD packets for MLD filter exceptions 932 * identify MLD packets for MLD filter exceptions
933 */ 933 */
934int ipv6_is_mld(struct sk_buff *skb, int nexthdr) 934bool ipv6_is_mld(struct sk_buff *skb, int nexthdr)
935{ 935{
936 struct icmp6hdr *pic; 936 struct icmp6hdr *pic;
937 937
938 if (nexthdr != IPPROTO_ICMPV6) 938 if (nexthdr != IPPROTO_ICMPV6)
939 return 0; 939 return false;
940 940
941 if (!pskb_may_pull(skb, sizeof(struct icmp6hdr))) 941 if (!pskb_may_pull(skb, sizeof(struct icmp6hdr)))
942 return 0; 942 return false;
943 943
944 pic = icmp6_hdr(skb); 944 pic = icmp6_hdr(skb);
945 945
@@ -948,22 +948,22 @@ int ipv6_is_mld(struct sk_buff *skb, int nexthdr)
948 case ICMPV6_MGM_REPORT: 948 case ICMPV6_MGM_REPORT:
949 case ICMPV6_MGM_REDUCTION: 949 case ICMPV6_MGM_REDUCTION:
950 case ICMPV6_MLD2_REPORT: 950 case ICMPV6_MLD2_REPORT:
951 return 1; 951 return true;
952 default: 952 default:
953 break; 953 break;
954 } 954 }
955 return 0; 955 return false;
956} 956}
957 957
958/* 958/*
959 * check if the interface/address pair is valid 959 * check if the interface/address pair is valid
960 */ 960 */
961int ipv6_chk_mcast_addr(struct net_device *dev, const struct in6_addr *group, 961bool ipv6_chk_mcast_addr(struct net_device *dev, const struct in6_addr *group,
962 const struct in6_addr *src_addr) 962 const struct in6_addr *src_addr)
963{ 963{
964 struct inet6_dev *idev; 964 struct inet6_dev *idev;
965 struct ifmcaddr6 *mc; 965 struct ifmcaddr6 *mc;
966 int rv = 0; 966 bool rv = false;
967 967
968 rcu_read_lock(); 968 rcu_read_lock();
969 idev = __in6_dev_get(dev); 969 idev = __in6_dev_get(dev);
@@ -990,7 +990,7 @@ int ipv6_chk_mcast_addr(struct net_device *dev, const struct in6_addr *group,
990 rv = mc->mca_sfcount[MCAST_EXCLUDE] !=0; 990 rv = mc->mca_sfcount[MCAST_EXCLUDE] !=0;
991 spin_unlock_bh(&mc->mca_lock); 991 spin_unlock_bh(&mc->mca_lock);
992 } else 992 } else
993 rv = 1; /* don't filter unspecified source */ 993 rv = true; /* don't filter unspecified source */
994 } 994 }
995 read_unlock_bh(&idev->lock); 995 read_unlock_bh(&idev->lock);
996 } 996 }
@@ -1046,8 +1046,8 @@ static void igmp6_group_queried(struct ifmcaddr6 *ma, unsigned long resptime)
1046} 1046}
1047 1047
1048/* mark EXCLUDE-mode sources */ 1048/* mark EXCLUDE-mode sources */
1049static int mld_xmarksources(struct ifmcaddr6 *pmc, int nsrcs, 1049static bool mld_xmarksources(struct ifmcaddr6 *pmc, int nsrcs,
1050 const struct in6_addr *srcs) 1050 const struct in6_addr *srcs)
1051{ 1051{
1052 struct ip6_sf_list *psf; 1052 struct ip6_sf_list *psf;
1053 int i, scount; 1053 int i, scount;
@@ -1061,7 +1061,7 @@ static int mld_xmarksources(struct ifmcaddr6 *pmc, int nsrcs,
1061 if (psf->sf_count[MCAST_INCLUDE] || 1061 if (psf->sf_count[MCAST_INCLUDE] ||
1062 pmc->mca_sfcount[MCAST_EXCLUDE] != 1062 pmc->mca_sfcount[MCAST_EXCLUDE] !=
1063 psf->sf_count[MCAST_EXCLUDE]) 1063 psf->sf_count[MCAST_EXCLUDE])
1064 continue; 1064 break;
1065 if (ipv6_addr_equal(&srcs[i], &psf->sf_addr)) { 1065 if (ipv6_addr_equal(&srcs[i], &psf->sf_addr)) {
1066 scount++; 1066 scount++;
1067 break; 1067 break;
@@ -1070,12 +1070,12 @@ static int mld_xmarksources(struct ifmcaddr6 *pmc, int nsrcs,
1070 } 1070 }
1071 pmc->mca_flags &= ~MAF_GSQUERY; 1071 pmc->mca_flags &= ~MAF_GSQUERY;
1072 if (scount == nsrcs) /* all sources excluded */ 1072 if (scount == nsrcs) /* all sources excluded */
1073 return 0; 1073 return false;
1074 return 1; 1074 return true;
1075} 1075}
1076 1076
1077static int mld_marksources(struct ifmcaddr6 *pmc, int nsrcs, 1077static bool mld_marksources(struct ifmcaddr6 *pmc, int nsrcs,
1078 const struct in6_addr *srcs) 1078 const struct in6_addr *srcs)
1079{ 1079{
1080 struct ip6_sf_list *psf; 1080 struct ip6_sf_list *psf;
1081 int i, scount; 1081 int i, scount;
@@ -1099,10 +1099,10 @@ static int mld_marksources(struct ifmcaddr6 *pmc, int nsrcs,
1099 } 1099 }
1100 if (!scount) { 1100 if (!scount) {
1101 pmc->mca_flags &= ~MAF_GSQUERY; 1101 pmc->mca_flags &= ~MAF_GSQUERY;
1102 return 0; 1102 return false;
1103 } 1103 }
1104 pmc->mca_flags |= MAF_GSQUERY; 1104 pmc->mca_flags |= MAF_GSQUERY;
1105 return 1; 1105 return true;
1106} 1106}
1107 1107
1108/* called with rcu_read_lock() */ 1108/* called with rcu_read_lock() */
@@ -1276,17 +1276,17 @@ int igmp6_event_report(struct sk_buff *skb)
1276 return 0; 1276 return 0;
1277} 1277}
1278 1278
1279static int is_in(struct ifmcaddr6 *pmc, struct ip6_sf_list *psf, int type, 1279static bool is_in(struct ifmcaddr6 *pmc, struct ip6_sf_list *psf, int type,
1280 int gdeleted, int sdeleted) 1280 int gdeleted, int sdeleted)
1281{ 1281{
1282 switch (type) { 1282 switch (type) {
1283 case MLD2_MODE_IS_INCLUDE: 1283 case MLD2_MODE_IS_INCLUDE:
1284 case MLD2_MODE_IS_EXCLUDE: 1284 case MLD2_MODE_IS_EXCLUDE:
1285 if (gdeleted || sdeleted) 1285 if (gdeleted || sdeleted)
1286 return 0; 1286 return false;
1287 if (!((pmc->mca_flags & MAF_GSQUERY) && !psf->sf_gsresp)) { 1287 if (!((pmc->mca_flags & MAF_GSQUERY) && !psf->sf_gsresp)) {
1288 if (pmc->mca_sfmode == MCAST_INCLUDE) 1288 if (pmc->mca_sfmode == MCAST_INCLUDE)
1289 return 1; 1289 return true;
1290 /* don't include if this source is excluded 1290 /* don't include if this source is excluded
1291 * in all filters 1291 * in all filters
1292 */ 1292 */
@@ -1295,29 +1295,29 @@ static int is_in(struct ifmcaddr6 *pmc, struct ip6_sf_list *psf, int type,
1295 return pmc->mca_sfcount[MCAST_EXCLUDE] == 1295 return pmc->mca_sfcount[MCAST_EXCLUDE] ==
1296 psf->sf_count[MCAST_EXCLUDE]; 1296 psf->sf_count[MCAST_EXCLUDE];
1297 } 1297 }
1298 return 0; 1298 return false;
1299 case MLD2_CHANGE_TO_INCLUDE: 1299 case MLD2_CHANGE_TO_INCLUDE:
1300 if (gdeleted || sdeleted) 1300 if (gdeleted || sdeleted)
1301 return 0; 1301 return false;
1302 return psf->sf_count[MCAST_INCLUDE] != 0; 1302 return psf->sf_count[MCAST_INCLUDE] != 0;
1303 case MLD2_CHANGE_TO_EXCLUDE: 1303 case MLD2_CHANGE_TO_EXCLUDE:
1304 if (gdeleted || sdeleted) 1304 if (gdeleted || sdeleted)
1305 return 0; 1305 return false;
1306 if (pmc->mca_sfcount[MCAST_EXCLUDE] == 0 || 1306 if (pmc->mca_sfcount[MCAST_EXCLUDE] == 0 ||
1307 psf->sf_count[MCAST_INCLUDE]) 1307 psf->sf_count[MCAST_INCLUDE])
1308 return 0; 1308 return false;
1309 return pmc->mca_sfcount[MCAST_EXCLUDE] == 1309 return pmc->mca_sfcount[MCAST_EXCLUDE] ==
1310 psf->sf_count[MCAST_EXCLUDE]; 1310 psf->sf_count[MCAST_EXCLUDE];
1311 case MLD2_ALLOW_NEW_SOURCES: 1311 case MLD2_ALLOW_NEW_SOURCES:
1312 if (gdeleted || !psf->sf_crcount) 1312 if (gdeleted || !psf->sf_crcount)
1313 return 0; 1313 return false;
1314 return (pmc->mca_sfmode == MCAST_INCLUDE) ^ sdeleted; 1314 return (pmc->mca_sfmode == MCAST_INCLUDE) ^ sdeleted;
1315 case MLD2_BLOCK_OLD_SOURCES: 1315 case MLD2_BLOCK_OLD_SOURCES:
1316 if (pmc->mca_sfmode == MCAST_INCLUDE) 1316 if (pmc->mca_sfmode == MCAST_INCLUDE)
1317 return gdeleted || (psf->sf_crcount && sdeleted); 1317 return gdeleted || (psf->sf_crcount && sdeleted);
1318 return psf->sf_crcount && !gdeleted && !sdeleted; 1318 return psf->sf_crcount && !gdeleted && !sdeleted;
1319 } 1319 }
1320 return 0; 1320 return false;
1321} 1321}
1322 1322
1323static int 1323static int
@@ -2627,8 +2627,7 @@ static int __net_init igmp6_net_init(struct net *net)
2627 err = inet_ctl_sock_create(&net->ipv6.igmp_sk, PF_INET6, 2627 err = inet_ctl_sock_create(&net->ipv6.igmp_sk, PF_INET6,
2628 SOCK_RAW, IPPROTO_ICMPV6, net); 2628 SOCK_RAW, IPPROTO_ICMPV6, net);
2629 if (err < 0) { 2629 if (err < 0) {
2630 printk(KERN_ERR 2630 pr_err("Failed to initialize the IGMP6 control socket (err %d)\n",
2631 "Failed to initialize the IGMP6 control socket (err %d).\n",
2632 err); 2631 err);
2633 goto out; 2632 goto out;
2634 } 2633 }