Skip to contentSkip to conversation

mld: convert ifmcaddr6 to list macros

PATCH Superseded Taehee Yoo 1 participant 1 message Feb 8, 2021

Subsystems (6)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Taehee Yoo

author
#0 lore raw

PATCH 1/8 mld: convert ifmcaddr6 to list macros

Currently, struct ifmcaddr6 doesn't use list API so that code shape is a little bit different from others.
So it converts ifmcaddr6 to use list API so it would improve readability.

---
 drivers/s390/net/qeth_l3_main.c |   2 +-
 include/net/if_inet6.h          |   9 +-
 net/batman-adv/multicast.c      |   2 +-
 net/ipv6/addrconf.c             |   7 +-
 net/ipv6/addrconf_core.c        |   3 +-
 net/ipv6/mcast.c                | 999 ++++++++++++++++----------------
 6 files changed, 523 insertions(+), 499 deletions(-)
drivers/s390/net/qeth_l3_main.c +1 -1
index dd441eaec66e..e49abdeff69c 100644
@@ -1099,7 +1099,7 @@ static int qeth_l3_add_mcast_rtnl(struct net_device *dev, int vid, void *arg)
 	tmp.is_multicast = 1;
 
 	read_lock_bh(&in6_dev->lock);
-	for (im6 = in6_dev->mc_list; im6 != NULL; im6 = im6->next) {
+	list_for_each_entry(im6, in6_dev->mc_list, list) {
 		tmp.u.a6.addr = im6->mca_addr;
 
 		ipm = qeth_l3_find_addr_by_ip(card, &tmp);
include/net/if_inet6.h +4 -5
index 8bf5906073bc..1262ccd5221e 100644
@@ -114,7 +114,7 @@ struct ip6_sf_list {
 struct ifmcaddr6 {
 	struct in6_addr		mca_addr;
 	struct inet6_dev	*idev;
-	struct ifmcaddr6	*next;
+	struct list_head	list;
 	struct ip6_sf_list	*mca_sources;
 	struct ip6_sf_list	*mca_tomb;
 	unsigned int		mca_sfmode;
@@ -164,10 +164,9 @@ struct inet6_dev {
 	struct net_device	*dev;
 
 	struct list_head	addr_list;
-
-	struct ifmcaddr6	*mc_list;
-	struct ifmcaddr6	*mc_tomb;
-	spinlock_t		mc_lock;
+	struct list_head	mc_list;
+	struct list_head	mc_tomb_list;
+	spinlock_t		mc_tomb_lock;
 
 	unsigned char		mc_qrv;		/* Query Robustness Variable */
 	unsigned char		mc_gq_running;
net/batman-adv/multicast.c +1 -1
index 854e5ff28a3f..1a9ad5a9257b 100644
@@ -455,7 +455,7 @@ batadv_mcast_mla_softif_get_ipv6(struct net_device *dev,
 	}
 
 	read_lock_bh(&in6_dev->lock);
-	for (pmc6 = in6_dev->mc_list; pmc6; pmc6 = pmc6->next) {
+	list_for_each_entry(pmc6, &in6_dev->mc_list, list) {
 		if (IPV6_ADDR_MC_SCOPE(&pmc6->mca_addr) <
 		    IPV6_ADDR_SCOPE_LINKLOCAL)
 			continue;
net/ipv6/addrconf.c +4 -3
index f2337fb756ac..e9fe0eee5768 100644
@@ -5110,13 +5110,14 @@ static int in6_dump_addrs(struct inet6_dev *idev, struct sk_buff *skb,
 		fillargs->event = RTM_GETMULTICAST;
 
 		/* multicast address */
-		for (ifmca = idev->mc_list; ifmca;
-		     ifmca = ifmca->next, ip_idx++) {
+		list_for_each_entry(ifmca, &idev->mc_list, list) {
 			if (ip_idx < s_ip_idx)
-				continue;
+				goto next2;
 			err = inet6_fill_ifmcaddr(skb, ifmca, fillargs);
 			if (err < 0)
 				break;
+next2:
+			ip_idx++;
 		}
 		break;
 	case ANYCAST_ADDR:
net/ipv6/addrconf_core.c +2 -1
index c70c192bc91b..b55f85dcfd74 100644
@@ -250,7 +250,8 @@ void in6_dev_finish_destroy(struct inet6_dev *idev)
 	struct net_device *dev = idev->dev;
 
 	WARN_ON(!list_empty(&idev->addr_list));
-	WARN_ON(idev->mc_list);
+	WARN_ON(!list_empty(&idev->mc_list));
+	WARN_ON(!list_empty(&idev->mc_tomb_list));
 	WARN_ON(timer_pending(&idev->rs_timer));
 
 #ifdef NET_REFCNT_DEBUG
net/ipv6/mcast.c +511 -488

1,961 lines not on this page · raw message

Signature · 1 line
2.17.1