History

bridge: fix icmpv6 endian bug and other sparse warnings

Fix the warnings reported by sparse on recent bridge multicast changes. Mostly just rcu annotation issues but in this case sparse found a real bug! The ICMPv6 mld2 query mrc values is in network byte order.

stephen hemminger committed 13 years ago

Commit eca2a431 parent dc2e5731 file · +6 −4Browse files

Unified · Split

net/bridge/br_multicast.c+6−4
@@ -622,7 +622,7 @@ out: · 621 unmodified lines
622622 struct net_bridge_port_group *br_multicast_new_port_group(
623623 struct net_bridge_port *port,
624624 struct br_ip *group,
625− struct net_bridge_port_group *next)
625+ struct net_bridge_port_group __rcu *next)
626626 {
627627 struct net_bridge_port_group *p;
628628
@@ -632,7 +632,7 @@ struct net_bridge_port_group *br_multicast_new_port_group( · 3 unmodified lines
632632
633633 p->addr = *group;
634634 p->port = port;
635− p->next = next;
635+ rcu_assign_pointer(p->next, next);
636636 hlist_add_head(&p->mglist, &port->mglist);
637637 setup_timer(&p->timer, br_multicast_port_group_expired,
638638 (unsigned long)p);
@@ -1138,7 +1138,7 @@ static int br_ip6_multicast_query(struct net_bridge *br, · 499 unmodified lines
11381138 struct sk_buff *skb)
11391139 {
11401140 const struct ipv6hdr *ip6h = ipv6_hdr(skb);
1141− struct mld_msg *mld = (struct mld_msg *) icmp6_hdr(skb);
1141+ struct mld_msg *mld;
11421142 struct net_bridge_mdb_entry *mp;
11431143 struct mld2_query *mld2q;
11441144 struct net_bridge_port_group *p;
@@ -1165,6 +1165,7 @@ static int br_ip6_multicast_query(struct net_bridge *br, · 20 unmodified lines
11651165 if (max_delay)
11661166 group = &mld->mld_mca;
11671167 } else if (skb->len >= sizeof(*mld2q)) {
1168+ u16 mrc;
11681169 if (!pskb_may_pull(skb, sizeof(*mld2q))) {
11691170 err = -EINVAL;
11701171 goto out;
@@ -1172,7 +1173,8 @@ static int br_ip6_multicast_query(struct net_bridge *br, · 1 unmodified line
11721173 mld2q = (struct mld2_query *)icmp6_hdr(skb);
11731174 if (!mld2q->mld2q_nsrcs)
11741175 group = &mld2q->mld2q_mca;
1175− max_delay = mld2q->mld2q_mrc ? MLDV2_MRC(mld2q->mld2q_mrc) : 1;
1176+ mrc = ntohs(mld2q->mld2q_mrc);
1177+ max_delay = mrc ? MLDV2_MRC(mrc) : 1;
11761178 }
11771179
11781180 if (!group)