[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CADXeF1F7eXj5K+rvLmRCVbi7ZoqxE8Y0b_Baqawe5P-dF8eCdw@mail.gmail.com>
Date: Fri, 10 Jan 2025 00:52:33 +0900
From: Yuyang Huang <yuyanghuang@...gle.com>
To: David Ahern <dsahern@...nel.org>
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 net-next, v4] netlink: support dumping IPv4 multicast addresses
>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.
>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?
> 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
On Fri, Jan 10, 2025 at 12:33 AM David Ahern <dsahern@...nel.org> wrote:
>
> On 1/9/25 12:22 AM, Yuyang Huang wrote:
> > @@ -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,
> > + 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.
>
> > };
> > 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)
> > {
>
Powered by blists - more mailing lists