Skip to contentSkip to conversation

netlink: support dumping IPv4 multicast addresses

PATCH Superseded Yuyang Huang 4 participants 11 messages Jan 9, 2025

Subsystems (3)

v4 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 netlink: support dumping IPv4 multicast addresses

Extended RTM_GETMULTICAST to support dumping joined IPv4 multicast addresses, in addition to the existing IPv6 functionality. This allows userspace applications to retrieve both IPv4 and IPv6 multicast addresses through similar netlink command and then monitor future changes by registering to RTNLGRP_IPV4_MCADDR and RTNLGRP_IPV6_MCADDR.

Cc Maciej Żenczykowski <[email protected]>
Cc Lorenzo Colitti <[email protected]>

---

Changelog since v3:
- Refactor in_dev_dump_addr() to break down the logic into two separate functions to simplify the logic.

Changelog since v2:
- Fix checkpatch.pl warnings.
- Remove one redundant EXPORT_SYMBOL().

Changelog since v1:
- Minor style fixes.
- Use for_each_pmc_rcu() instead of for_each_pmc_rtnl().

 include/linux/igmp.h |  2 ++
 net/ipv4/devinet.c   | 73 +++++++++++++++++++++++++++++++++++++++++---
 net/ipv4/igmp.c      |  8 ++---
 3 files changed, 74 insertions(+), 9 deletions(-)
include/linux/igmp.h +2 -0
index 073b30a9b850..757c0aeea1ac 100644
@@ -142,4 +142,6 @@ extern void __ip_mc_inc_group(struct in_device *in_dev, __be32 addr,
 extern void ip_mc_inc_group(struct in_device *in_dev, __be32 addr);
 int ip_mc_check_igmp(struct sk_buff *skb);
 
+int inet_fill_ifmcaddr(struct sk_buff *skb, struct net_device *dev,
+		       const struct ip_mc_list *im, int event, int flags);
 #endif
net/ipv4/devinet.c +68 -5

116 lines not on this page · raw message

net/ipv4/igmp.c +4 -4
index 3da126cea884..3e6faaab54c0 100644
@@ -1432,14 +1432,14 @@ static void ip_mc_hash_remove(struct in_device *in_dev,
 	*mc_hash = im->next_hash;
 }
 
-static int inet_fill_ifmcaddr(struct sk_buff *skb, struct net_device *dev,
-			      const struct ip_mc_list *im, int event)
+int inet_fill_ifmcaddr(struct sk_buff *skb, struct net_device *dev,
+		       const struct ip_mc_list *im, int event, int flags)
 {
 	struct ifa_cacheinfo ci;
 	struct ifaddrmsg *ifm;
 	struct nlmsghdr *nlh;
 
-	nlh = nlmsg_put(skb, 0, 0, event, sizeof(struct ifaddrmsg), 0);
+	nlh = nlmsg_put(skb, 0, 0, event, sizeof(struct ifaddrmsg), flags);
 	if (!nlh)
 		return -EMSGSIZE;
 
@@ -1479,7 +1479,7 @@ static void inet_ifmcaddr_notify(struct net_device *dev,
 	if (!skb)
 		goto error;
 
-	err = inet_fill_ifmcaddr(skb, dev, im, event);
+	err = inet_fill_ifmcaddr(skb, dev, im, event, 0);
 	if (err < 0) {
 		WARN_ON_ONCE(err == -EMSGSIZE);
 		nlmsg_free(skb);
Signature · 1 line
2.47.1.613.gc27f4b7a9f-goog
maintainer
#1 lore raw
Quoted 6 lines · Yuyang Huang
net/ipv4/devinet.c +1 -1
@@ -1889,15 +1935,16 @@ static u32 inet_base_seq(const struct net *net)
 	return res;
 }
 
-static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
+static int inet_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,

net/ipv4/devinet.c static u32 inet_base_seq(const struct net *net) · line 1947

Quoted 10 lines
net/ipv4/devinet.c +2 -1
+			  enum addr_type_t type)
 {
 	const struct nlmsghdr *nlh = cb->nlh;
 	struct inet_fill_args fillargs = {
 		.portid = NETLINK_CB(cb->skb).portid,
 		.seq = nlh->nlmsg_seq,
-		.event = RTM_NEWADDR,
 		.flags = NLM_F_MULTI,
 		.netnsid = -1,
+		.type = type,

This patch is apparently breaking a few tests:

https://netdev.bots.linux.dev/contest.html?branch=net-next-2025-01-09--09-00&executor=vmksft-net-dbg&pw-n=0&pass=0
https://netdev.bots.linux.dev/contest.html?branch=net-next-2025-01-09--09-00&executor=vmksft-nf-dbg&pw-n=0&pass=0
https://netdev.bots.linux.dev/contest.html?branch=net-next-2025-01-09--09-00&executor=vmksft-nf&pw-n=0&pass=0

I suspect the above chunk confuses the user-space as inet_fill_ifaddr() still get the 'event' value from fillargs->event

Also, this will need a paired self-test - even something very simple just exercising the new code.

Thanks,

Paolo

#2 lore raw

Hi Paolo

Thanks for the review feedback.

Quoted 2 lines

I suspect the above chunk confuses the user-space as inet_fill_ifaddr() still get the 'event' value from fillargs->event

You're right, I missed initializing the event field in the fillargs structure. It's a bug introduced in the v4 patch during refactoring. I will fix it in the v5 patch.

Quoted 2 lines

Also, this will need a paired self-test - even something very simple just exercising the new code.

Sure, I can send separate patch for adding self-test, but please let me know if I should include the self-test in the same patch

Thanks
Yuyang

Quoted 35 lines · Paolo Abeni
Quoted 6 lines · Yuyang Huang
net/ipv4/devinet.c +1 -1
@@ -1889,15 +1935,16 @@ static u32 inet_base_seq(const struct net *net)
      return res;
 }
 
-static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
+static int inet_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,

net/ipv4/devinet.c static u32 inet_base_seq(const struct net *net) · line 1947

Quoted 10 lines
net/ipv4/devinet.c +2 -1
+                       enum addr_type_t type)
 {
      const struct nlmsghdr *nlh = cb->nlh;
      struct inet_fill_args fillargs = {
              .portid = NETLINK_CB(cb->skb).portid,
              .seq = nlh->nlmsg_seq,
-             .event = RTM_NEWADDR,
              .flags = NLM_F_MULTI,
              .netnsid = -1,
+             .type = type,

This patch is apparently breaking a few tests:

https://netdev.bots.linux.dev/contest.html?branch=net-next-2025-01-09--09-00&executor=vmksft-net-dbg&pw-n=0&pass=0
https://netdev.bots.linux.dev/contest.html?branch=net-next-2025-01-09--09-00&executor=vmksft-nf-dbg&pw-n=0&pass=0
https://netdev.bots.linux.dev/contest.html?branch=net-next-2025-01-09--09-00&executor=vmksft-nf&pw-n=0&pass=0

I suspect the above chunk confuses the user-space as inet_fill_ifaddr() still get the 'event' value from fillargs->event

Also, this will need a paired self-test - even something very simple just exercising the new code.

Thanks,

Paolo

#3 lore raw
Quoted 2 lines

Also, this will need a paired self-test - even something very simple just exercising the new code.

After looking into the existing selftest, I feel writing C program selftests might be a little bit anti-pattern. The existing test cases primarily use iproute2. This approach appears to be more common and easier to implement. I do plan to migrate ip maddress to use netlink instead of parsing procfs, which enables me to write selftests using iproute2.

I intend to add similar selftests for my other patches (anycast/multicast notifications), which already have corresponding iproute2 patches under review or merged.

For this patch, my proposed steps for adding test are:

1. Fix this patch and get it merged.
2. Update iproute2(ip maddress) to use netlink.
3. Write selftests using iproute2.

Please let me know if you have any concerns.

Thanks,
Yuyang

Quoted 58 lines · Yuyang Huang

Hi Paolo

Thanks for the review feedback.

Quoted 2 lines

I suspect the above chunk confuses the user-space as inet_fill_ifaddr() still get the 'event' value from fillargs->event

You're right, I missed initializing the event field in the fillargs structure. It's a bug introduced in the v4 patch during refactoring. I will fix it in the v5 patch.

Quoted 2 lines

Also, this will need a paired self-test - even something very simple just exercising the new code.

Sure, I can send separate patch for adding self-test, but please let me know if I should include the self-test in the same patch

Thanks
Yuyang

Quoted 35 lines · Paolo Abeni
Quoted 6 lines · Yuyang Huang
net/ipv4/devinet.c +1 -1
@@ -1889,15 +1935,16 @@ static u32 inet_base_seq(const struct net *net)
      return res;
 }
 
-static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
+static int inet_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,

net/ipv4/devinet.c static u32 inet_base_seq(const struct net *net) · line 1947

Quoted 10 lines
net/ipv4/devinet.c +2 -1
+                       enum addr_type_t type)
 {
      const struct nlmsghdr *nlh = cb->nlh;
      struct inet_fill_args fillargs = {
              .portid = NETLINK_CB(cb->skb).portid,
              .seq = nlh->nlmsg_seq,
-             .event = RTM_NEWADDR,
              .flags = NLM_F_MULTI,
              .netnsid = -1,
+             .type = type,

This patch is apparently breaking a few tests:

https://netdev.bots.linux.dev/contest.html?branch=net-next-2025-01-09--09-00&executor=vmksft-net-dbg&pw-n=0&pass=0
https://netdev.bots.linux.dev/contest.html?branch=net-next-2025-01-09--09-00&executor=vmksft-nf-dbg&pw-n=0&pass=0
https://netdev.bots.linux.dev/contest.html?branch=net-next-2025-01-09--09-00&executor=vmksft-nf&pw-n=0&pass=0

I suspect the above chunk confuses the user-space as inet_fill_ifaddr() still get the 'event' value from fillargs->event

Also, this will need a paired self-test - even something very simple just exercising the new code.

Thanks,

Paolo

maintainer
#4 lore raw
Quoted 14 lines · Yuyang Huang
Quoted 2 lines

Also, this will need a paired self-test - even something very simple just exercising the new code.

After looking into the existing selftest, I feel writing C program selftests might be a little bit anti-pattern. The existing test cases primarily use iproute2. This approach appears to be more common and easier to implement. I do plan to migrate ip maddress to use netlink instead of parsing procfs, which enables me to write selftests using iproute2.

I intend to add similar selftests for my other patches (anycast/multicast notifications), which already have corresponding iproute2 patches under review or merged.

Quoted 7 lines

For this patch, my proposed steps for adding test are:

1. Fix this patch and get it merged.
2. Update iproute2(ip maddress) to use netlink.
3. Write selftests using iproute2.

Please let me know if you have any concerns.

Fine by me. FTR we used the C program way for mptcp - before ynl advent
- and it was quite a pain.

Cheers,

Paolo

maintainer
#5 lore raw
In reply to Yuyang Huang
Quoted 5 lines · On Fri, 10 Jan 2025 00:01:31 +0900 Yuyang Huang wrote:

For this patch, my proposed steps for adding test are:

1. Fix this patch and get it merged.
2. Update iproute2(ip maddress) to use netlink.
3. Write selftests using iproute2.

You don't have to wait for iproute2 changes to be merged. Push them somewhere we can pull from, and when you post v5 (with the self-test) just add a link to that iproute2 git repo to the cover letter.
We'll pull your changes to the iproute2 used by the CI image.

maintainer
#6 lore raw
In reply to Yuyang Huang
Quoted 6 lines · Yuyang Huang
net/ipv4/devinet.c +1 -1
@@ -1889,15 +1935,16 @@ static u32 inet_base_seq(const struct net *net)
 	return res;
 }
 
-static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
+static int inet_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,

net/ipv4/devinet.c static u32 inet_base_seq(const struct net *net) · line 1947

Quoted 10 lines
net/ipv4/devinet.c +2 -1
+			  enum addr_type_t type)
 {
 	const struct nlmsghdr *nlh = cb->nlh;
 	struct inet_fill_args fillargs = {
 		.portid = NETLINK_CB(cb->skb).portid,
 		.seq = nlh->nlmsg_seq,
-		.event = RTM_NEWADDR,
 		.flags = NLM_F_MULTI,
 		.netnsid = -1,
+		.type = type,

my comment meant that this type should be removed and the wrappers below just call the intended function. No need for the extra layers.

Quoted 24 lines
net/ipv4/devinet.c +14 -0
 	};
 	struct net *net = sock_net(skb->sk);
 	struct net *tgt_net = net;
@@ -1949,6 +1996,20 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
 	return err;
 }
 
+static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
+{
+	enum addr_type_t type = UNICAST_ADDR;
+
+	return inet_dump_addr(skb, cb, type);
+}
+
+static int inet_dump_ifmcaddr(struct sk_buff *skb, struct netlink_callback *cb)
+{
+	enum addr_type_t type = MULTICAST_ADDR;
+
+	return inet_dump_addr(skb, cb, type);
+}
+
 static void rtmsg_ifa(int event, struct in_ifaddr *ifa, struct nlmsghdr *nlh,
 		      u32 portid)
 {
#7 lore raw
Quoted 2 lines

my comment meant that this type should be removed and the wrappers below just call the intended function. No need for the extra layers.

Sorry, I still do not fully understand the suggestions.

In the current inet_dump_ifaddr() function, there are two places where in_dev_dump_addr() is called.

For example, we have the following code snippet.

Quoted 6 lines

if (!in_dev)
goto done;
err = in_dev_dump_addr(in_dev, skb, cb, &ctx->ip_idx,

      &fillargs);

goto done;
}

Do you suggest we do the following way?

Quoted 6 lines

If (type == UNICAST_ADDR)
err = in_dev_dump_ifaddr(in_dev, skb, cb, &ctx->ip_idx,

                                            &fillargs);
else if (type == MULTICAST_ADDR)
   in_dev_dump_ifmcaddr(in_dev, skb, cb, s_ip_idx,
                                        &fillargs);

The current functional call stack is as follows:

inet_dump_ifaddr()/inet_dump_ifmcaddr() -> inet_dump_addr() -> in_dev_dump_ifaddr()/in_dev_dump_ifmcaddr().

The ifaddr and ifmcaddr dump code paths share common logic inside inet_dump_addr(). If we don't do the dispatching in in_dev_dump_addr(), we have to do the dispatching in inet_dump_addr() instead, and the dispatching logic will be duplicated twice. I don't think this will simplify the code.

Or do you suggest I should pass a function pointer for in_dev_dump_ifaddr()/in_dev_dump_ifmcaddr() into inet_dump_addr()?

Thanks,

Yuyang

Quoted 47 lines · David Ahern
Quoted 6 lines · Yuyang Huang
net/ipv4/devinet.c +1 -1
@@ -1889,15 +1935,16 @@ static u32 inet_base_seq(const struct net *net)
      return res;
 }
 
-static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
+static int inet_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,

net/ipv4/devinet.c static u32 inet_base_seq(const struct net *net) · line 1947

Quoted 10 lines
net/ipv4/devinet.c +2 -1
+                       enum addr_type_t type)
 {
      const struct nlmsghdr *nlh = cb->nlh;
      struct inet_fill_args fillargs = {
              .portid = NETLINK_CB(cb->skb).portid,
              .seq = nlh->nlmsg_seq,
-             .event = RTM_NEWADDR,
              .flags = NLM_F_MULTI,
              .netnsid = -1,
+             .type = type,

my comment meant that this type should be removed and the wrappers below just call the intended function. No need for the extra layers.

Quoted 24 lines
net/ipv4/devinet.c +14 -0
      };
      struct net *net = sock_net(skb->sk);
      struct net *tgt_net = net;
@@ -1949,6 +1996,20 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
      return err;
 }
 
+static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
+{
+     enum addr_type_t type = UNICAST_ADDR;
+
+     return inet_dump_addr(skb, cb, type);
+}
+
+static int inet_dump_ifmcaddr(struct sk_buff *skb, struct netlink_callback *cb)
+{
+     enum addr_type_t type = MULTICAST_ADDR;
+
+     return inet_dump_addr(skb, cb, type);
+}
+
 static void rtmsg_ifa(int event, struct in_ifaddr *ifa, struct nlmsghdr *nlh,
                    u32 portid)
 {
#8 lore raw
Quoted 2 lines

my comment meant that this type should be removed and the wrappers below just call the intended function. No need for the extra layers.

This patch was trying to follow the similar pattern in addrconf.c. We have a similar addr_type_t based dispatching mechanism to handle the dumping of ANYCAST, MULTICAST, and UNICAST addresses.

inet6_dump_ifaddr()/inet6_dump_ifmcaddr()/inet6_dump_ifacaddr() -> inet6_dump_addr() -> in6_dump_addrs()

The dispatching switch statement resides within in6_dump_addrs(), and those dump functions share the common code path in inet6_dump_addr().

Thanks,
Yuyang

Quoted 93 lines · Yuyang Huang
Quoted 3 lines

my comment meant that this type should be removed and the wrappers below just call the intended function. No need for the extra layers.

Sorry, I still do not fully understand the suggestions.

In the current inet_dump_ifaddr() function, there are two places where in_dev_dump_addr() is called.

For example, we have the following code snippet.

Quoted 6 lines

if (!in_dev)
goto done;
err = in_dev_dump_addr(in_dev, skb, cb, &ctx->ip_idx,

      &fillargs);

goto done;
}

Do you suggest we do the following way?

Quoted 6 lines

If (type == UNICAST_ADDR)
err = in_dev_dump_ifaddr(in_dev, skb, cb, &ctx->ip_idx,

                                            &fillargs);
else if (type == MULTICAST_ADDR)
   in_dev_dump_ifmcaddr(in_dev, skb, cb, s_ip_idx,
                                        &fillargs);

The current functional call stack is as follows:

inet_dump_ifaddr()/inet_dump_ifmcaddr() -> inet_dump_addr() -> in_dev_dump_ifaddr()/in_dev_dump_ifmcaddr().

The ifaddr and ifmcaddr dump code paths share common logic inside inet_dump_addr(). If we don't do the dispatching in in_dev_dump_addr(), we have to do the dispatching in inet_dump_addr() instead, and the dispatching logic will be duplicated twice. I don't think this will simplify the code.

Or do you suggest I should pass a function pointer for in_dev_dump_ifaddr()/in_dev_dump_ifmcaddr() into inet_dump_addr()?

Thanks,

Yuyang

Quoted 47 lines · David Ahern
Quoted 6 lines · Yuyang Huang
net/ipv4/devinet.c +1 -1
@@ -1889,15 +1935,16 @@ static u32 inet_base_seq(const struct net *net)
      return res;
 }
 
-static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
+static int inet_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,

net/ipv4/devinet.c static u32 inet_base_seq(const struct net *net) · line 1947

Quoted 10 lines
net/ipv4/devinet.c +2 -1
+                       enum addr_type_t type)
 {
      const struct nlmsghdr *nlh = cb->nlh;
      struct inet_fill_args fillargs = {
              .portid = NETLINK_CB(cb->skb).portid,
              .seq = nlh->nlmsg_seq,
-             .event = RTM_NEWADDR,
              .flags = NLM_F_MULTI,
              .netnsid = -1,
+             .type = type,

my comment meant that this type should be removed and the wrappers below just call the intended function. No need for the extra layers.

Quoted 24 lines
net/ipv4/devinet.c +14 -0
      };
      struct net *net = sock_net(skb->sk);
      struct net *tgt_net = net;
@@ -1949,6 +1996,20 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
      return err;
 }
 
+static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
+{
+     enum addr_type_t type = UNICAST_ADDR;
+
+     return inet_dump_addr(skb, cb, type);
+}
+
+static int inet_dump_ifmcaddr(struct sk_buff *skb, struct netlink_callback *cb)
+{
+     enum addr_type_t type = MULTICAST_ADDR;
+
+     return inet_dump_addr(skb, cb, type);
+}
+
 static void rtmsg_ifa(int event, struct in_ifaddr *ifa, struct nlmsghdr *nlh,
                    u32 portid)
 {
#9 lore raw
Quoted 5 lines

You don't have to wait for iproute2 changes to be merged. Push them somewhere we can pull from, and when you post v5 (with the self-test) just add a link to that iproute2 git repo to the cover letter.
We'll pull your changes to the iproute2 used by the CI image.

Thanks for the suggestion, I will include the iproute2 based self-test in v5 patch.

Thanks
Yuyang

Quoted 112 lines · Yuyang Huang
Quoted 3 lines

my comment meant that this type should be removed and the wrappers below just call the intended function. No need for the extra layers.

This patch was trying to follow the similar pattern in addrconf.c. We have a similar addr_type_t based dispatching mechanism to handle the dumping of ANYCAST, MULTICAST, and UNICAST addresses.

inet6_dump_ifaddr()/inet6_dump_ifmcaddr()/inet6_dump_ifacaddr() -> inet6_dump_addr() -> in6_dump_addrs()

The dispatching switch statement resides within in6_dump_addrs(), and those dump functions share the common code path in inet6_dump_addr().

Thanks,
Yuyang

Quoted 93 lines · Yuyang Huang
Quoted 3 lines

my comment meant that this type should be removed and the wrappers below just call the intended function. No need for the extra layers.

Sorry, I still do not fully understand the suggestions.

In the current inet_dump_ifaddr() function, there are two places where in_dev_dump_addr() is called.

For example, we have the following code snippet.

Quoted 6 lines

if (!in_dev)
goto done;
err = in_dev_dump_addr(in_dev, skb, cb, &ctx->ip_idx,

      &fillargs);

goto done;
}

Do you suggest we do the following way?

Quoted 6 lines

If (type == UNICAST_ADDR)
err = in_dev_dump_ifaddr(in_dev, skb, cb, &ctx->ip_idx,

                                            &fillargs);
else if (type == MULTICAST_ADDR)
   in_dev_dump_ifmcaddr(in_dev, skb, cb, s_ip_idx,
                                        &fillargs);

The current functional call stack is as follows:

inet_dump_ifaddr()/inet_dump_ifmcaddr() -> inet_dump_addr() -> in_dev_dump_ifaddr()/in_dev_dump_ifmcaddr().

The ifaddr and ifmcaddr dump code paths share common logic inside inet_dump_addr(). If we don't do the dispatching in in_dev_dump_addr(), we have to do the dispatching in inet_dump_addr() instead, and the dispatching logic will be duplicated twice. I don't think this will simplify the code.

Or do you suggest I should pass a function pointer for in_dev_dump_ifaddr()/in_dev_dump_ifmcaddr() into inet_dump_addr()?

Thanks,

Yuyang

Quoted 47 lines · David Ahern
Quoted 6 lines · Yuyang Huang
net/ipv4/devinet.c +1 -1
@@ -1889,15 +1935,16 @@ static u32 inet_base_seq(const struct net *net)
      return res;
 }
 
-static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
+static int inet_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,

net/ipv4/devinet.c static u32 inet_base_seq(const struct net *net) · line 1947

Quoted 10 lines
net/ipv4/devinet.c +2 -1
+                       enum addr_type_t type)
 {
      const struct nlmsghdr *nlh = cb->nlh;
      struct inet_fill_args fillargs = {
              .portid = NETLINK_CB(cb->skb).portid,
              .seq = nlh->nlmsg_seq,
-             .event = RTM_NEWADDR,
              .flags = NLM_F_MULTI,
              .netnsid = -1,
+             .type = type,

my comment meant that this type should be removed and the wrappers below just call the intended function. No need for the extra layers.

Quoted 24 lines
net/ipv4/devinet.c +14 -0
      };
      struct net *net = sock_net(skb->sk);
      struct net *tgt_net = net;
@@ -1949,6 +1996,20 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
      return err;
 }
 
+static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
+{
+     enum addr_type_t type = UNICAST_ADDR;
+
+     return inet_dump_addr(skb, cb, type);
+}
+
+static int inet_dump_ifmcaddr(struct sk_buff *skb, struct netlink_callback *cb)
+{
+     enum addr_type_t type = MULTICAST_ADDR;
+
+     return inet_dump_addr(skb, cb, type);
+}
+
 static void rtmsg_ifa(int event, struct in_ifaddr *ifa, struct nlmsghdr *nlh,
                    u32 portid)
 {
maintainer
#10 lore raw
In reply to Yuyang Huang
Quoted 8 lines · Yuyang Huang
Quoted 2 lines

my comment meant that this type should be removed and the wrappers below just call the intended function. No need for the extra layers.

Sorry, I still do not fully understand the suggestions.

In the current inet_dump_ifaddr() function, there are two places where in_dev_dump_addr() is called.

nevermind. I forgot how IPv6 address dumps are coded, and keeping the 2 protocols aligned is best. So, I guess you just need to resolve the failures Paolo noted.