Message ID | 1431975616-23529-3-git-send-email-kaike.wan@intel.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
On 5/18/2015 10:00 PM, kaike.wan@intel.com wrote: > This patch adds a function to check if listeners for a netlink multicast > group are present. > [...] > --- a/drivers/infiniband/core/netlink.c > +++ b/drivers/infiniband/core/netlink.c > @@ -49,6 +49,14 @@ static DEFINE_MUTEX(ibnl_mutex); > static struct sock *nls; > static LIST_HEAD(client_list); > > +int ibnl_chk_listeners(unsigned int group) > +{ > + if (netlink_has_listeners(nls, group) == 0) > + return -1; > + return 0; > +} > +EXPORT_SYMBOL(ibnl_chk_listeners); I don't see anything here which is special to the IB subsystem, please make it generic helper residing in more of a common place. Or. -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
> > On 5/18/2015 10:00 PM, kaike.wan@intel.com wrote: > > This patch adds a function to check if listeners for a netlink > > multicast group are present. > > > > [...] > > > --- a/drivers/infiniband/core/netlink.c > > +++ b/drivers/infiniband/core/netlink.c > > @@ -49,6 +49,14 @@ static DEFINE_MUTEX(ibnl_mutex); > > static struct sock *nls; > > static LIST_HEAD(client_list); > > > > +int ibnl_chk_listeners(unsigned int group) { > > + if (netlink_has_listeners(nls, group) == 0) > > + return -1; > > + return 0; > > +} > > +EXPORT_SYMBOL(ibnl_chk_listeners); > > I don't see anything here which is special to the IB subsystem, please make it > generic helper residing in more of a common place. > > Or. IB specific netlink support is located in this file and we are making use of the nls (netlink socket) variable in this patch. Kaike -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
> > --- a/drivers/infiniband/core/netlink.c > > +++ b/drivers/infiniband/core/netlink.c > > @@ -49,6 +49,14 @@ static DEFINE_MUTEX(ibnl_mutex); > > static struct sock *nls; > > static LIST_HEAD(client_list); > > > > +int ibnl_chk_listeners(unsigned int group) > > +{ > > + if (netlink_has_listeners(nls, group) == 0) > > + return -1; > > + return 0; > > +} > > +EXPORT_SYMBOL(ibnl_chk_listeners); > > I don't see anything here which is special to the IB subsystem, please > make it generic helper residing in more of a common place. I asked a similar question in an internal review. The alternative to defining this function is to export the nls variable. -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/infiniband/core/netlink.c b/drivers/infiniband/core/netlink.c index 23dd5a5..e0fc913 100644 --- a/drivers/infiniband/core/netlink.c +++ b/drivers/infiniband/core/netlink.c @@ -49,6 +49,14 @@ static DEFINE_MUTEX(ibnl_mutex); static struct sock *nls; static LIST_HEAD(client_list); +int ibnl_chk_listeners(unsigned int group) +{ + if (netlink_has_listeners(nls, group) == 0) + return -1; + return 0; +} +EXPORT_SYMBOL(ibnl_chk_listeners); + int ibnl_add_client(int index, int nops, const struct ibnl_client_cbs cb_table[]) { diff --git a/include/rdma/rdma_netlink.h b/include/rdma/rdma_netlink.h index 0790882..5852661 100644 --- a/include/rdma/rdma_netlink.h +++ b/include/rdma/rdma_netlink.h @@ -77,4 +77,11 @@ int ibnl_unicast(struct sk_buff *skb, struct nlmsghdr *nlh, int ibnl_multicast(struct sk_buff *skb, struct nlmsghdr *nlh, unsigned int group, gfp_t flags); +/** + * Check if there are any listeners to the netlink group + * @group: the netlink group ID + * Returns 0 on success or a negative for no listeners. + */ +int ibnl_chk_listeners(unsigned int group); + #endif /* _RDMA_NETLINK_H */