From: Hangbin Liu <liuhangbin@gmail.com>
To: Yuyang Huang <yuyanghuang@google.com>
Cc: "David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Simon Horman" <horms@kernel.org>,
"David Ahern" <dsahern@kernel.org>,
roopa@cumulusnetworks.com, jiri@resnulli.us,
stephen@networkplumber.org, jimictw@google.com, prohr@google.com,
nicolas.dichtel@6wind.com, andrew@lunn.ch,
netdev@vger.kernel.org, "Maciej Żenczykowski" <maze@google.com>,
"Lorenzo Colitti" <lorenzo@google.com>,
"Patrick Ruddy" <pruddy@vyatta.att-mail.com>
Subject: Re: [PATCH net-next, v2] netlink: add IGMP/MLD join/leave notifications
Date: Tue, 19 Nov 2024 07:39:22 +0000 [thread overview]
Message-ID: <ZzxAqq-TqLts1o4V@fedora> (raw)
In-Reply-To: <20241117141137.2072899-1-yuyanghuang@google.com>
Hi Yuyang,
On Sun, Nov 17, 2024 at 11:11:37PM +0900, Yuyang Huang wrote:
> +static int inet_fill_ifmcaddr(struct sk_buff *skb, struct net_device *dev,
> + __be32 addr, int event)
> +{
> + struct ifaddrmsg *ifm;
> + struct nlmsghdr *nlh;
> +
> + nlh = nlmsg_put(skb, 0, 0, event, sizeof(struct ifaddrmsg), 0);
> + if (!nlh)
> + return -EMSGSIZE;
> +
> + ifm = nlmsg_data(nlh);
> + ifm->ifa_family = AF_INET;
> + ifm->ifa_prefixlen = 32;
> + ifm->ifa_flags = IFA_F_PERMANENT;
> + ifm->ifa_scope = RT_SCOPE_LINK;
Why the IPv4 scope use RT_SCOPE_LINK,
> +static int inet6_fill_ifmcaddr(struct sk_buff *skb, struct net_device *dev,
> + const struct in6_addr *addr, int event)
> +{
> + struct ifaddrmsg *ifm;
> + struct nlmsghdr *nlh;
> + u8 scope;
> +
> + scope = RT_SCOPE_UNIVERSE;
> + if (ipv6_addr_scope(addr) & IFA_SITE)
> + scope = RT_SCOPE_SITE;
And IPv6 use RT_SCOPE_UNIVERSE by default?
> +
> + nlh = nlmsg_put(skb, 0, 0, event, sizeof(struct ifaddrmsg), 0);
> + if (!nlh)
> + return -EMSGSIZE;
> +
> + ifm = nlmsg_data(nlh);
> + ifm->ifa_family = AF_INET6;
> + ifm->ifa_prefixlen = 128;
> + ifm->ifa_flags = IFA_F_PERMANENT;
> + ifm->ifa_scope = scope;
> + ifm->ifa_index = dev->ifindex;
> +
> +static void inet6_ifmcaddr_notify(struct net_device *dev,
> + const struct in6_addr *addr, int event)
> +{
> + struct net *net = dev_net(dev);
> + struct sk_buff *skb;
> + int err = -ENOBUFS;
> +
> + skb = nlmsg_new(NLMSG_ALIGN(sizeof(struct ifaddrmsg))
> + + nla_total_size(16), GFP_ATOMIC);
> + if (!skb)
> + goto error;
> +
> + err = inet6_fill_ifmcaddr(skb, dev, addr, event);
> + if (err < 0) {
> + WARN_ON(err == -EMSGSIZE);
Not sure if we really need this WARN_ON. Wait for others comments.
Thanks
Hangbin
next prev parent reply other threads:[~2024-11-19 7:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-17 14:11 [PATCH net-next, v2] netlink: add IGMP/MLD join/leave notifications Yuyang Huang
2024-11-19 7:39 ` Hangbin Liu [this message]
2024-11-19 9:21 ` Yuyang Huang
2024-11-19 12:10 ` Paolo Abeni
2024-11-19 13:13 ` Yuyang Huang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZzxAqq-TqLts1o4V@fedora \
--to=liuhangbin@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jimictw@google.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=lorenzo@google.com \
--cc=maze@google.com \
--cc=netdev@vger.kernel.org \
--cc=nicolas.dichtel@6wind.com \
--cc=pabeni@redhat.com \
--cc=prohr@google.com \
--cc=pruddy@vyatta.att-mail.com \
--cc=roopa@cumulusnetworks.com \
--cc=stephen@networkplumber.org \
--cc=yuyanghuang@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).