[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <8ba3c7f0-4a14-46bb-82b0-ff9fbc0f71b7@kernel.org>
Date: Wed, 8 Jan 2025 12:56:42 -0700
From: David Ahern <dsahern@...nel.org>
To: Yuyang Huang <yuyanghuang@...gle.com>
Cc: "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Simon Horman <horms@...nel.org>,
roopa@...ulusnetworks.com, jiri@...nulli.us, stephen@...workplumber.org,
jimictw@...gle.com, prohr@...gle.com, liuhangbin@...il.com,
nicolas.dichtel@...nd.com, andrew@...n.ch, netdev@...r.kernel.org,
Maciej Żenczykowski <maze@...gle.com>,
Lorenzo Colitti <lorenzo@...gle.com>
Subject: Re: [PATCH RESEND net-next, v3] netlink: support dumping IPv4
multicast addresses
On 1/4/25 7:02 PM, Yuyang Huang wrote:
> @@ -1850,21 +1851,46 @@ static int in_dev_dump_addr(struct in_device *in_dev, struct sk_buff *skb,
> struct netlink_callback *cb, int *s_ip_idx,
> struct inet_fill_args *fillargs)
> {
> + struct ip_mc_list *im;
> struct in_ifaddr *ifa;
> int ip_idx = 0;
> int err;
>
> - in_dev_for_each_ifa_rcu(ifa, in_dev) {
> - if (ip_idx < *s_ip_idx) {
> + switch (fillargs->type) {
> + case UNICAST_ADDR:
> + fillargs->event = RTM_NEWADDR;
> + in_dev_for_each_ifa_rcu(ifa, in_dev) {
> + if (ip_idx < *s_ip_idx) {
> + ip_idx++;
> + continue;
> + }
> + err = inet_fill_ifaddr(skb, ifa, fillargs);
> + if (err < 0)
> + goto done;
> +
> + nl_dump_check_consistent(cb, nlmsg_hdr(skb));
> ip_idx++;
> - continue;
> }
> - err = inet_fill_ifaddr(skb, ifa, fillargs);
> - if (err < 0)
> - goto done;
> + break;
Almost all of the logic is under the switch cases, you are not really
saving a lot here. I think it would be simpler just to have simpler
in_dev_dump_addr for each type.
> + case MULTICAST_ADDR:
> + for (im = rcu_dereference(in_dev->mc_list);
> + im;
> + im = rcu_dereference(im->next_rcu)) {
> + if (ip_idx < *s_ip_idx) {
> + ip_idx++;
> + continue;
> + }
> + err = inet_fill_ifmcaddr(skb, in_dev->dev, im,
> + RTM_GETMULTICAST, NLM_F_MULTI);
> + if (err < 0)
> + goto done;
>
> - nl_dump_check_consistent(cb, nlmsg_hdr(skb));
> - ip_idx++;
> + nl_dump_check_consistent(cb, nlmsg_hdr(skb));
> + ip_idx++;
> + }
> + break;
> + default:
> + break;
> }
> err = 0;
> ip_idx = 0;
Powered by blists - more mailing lists