Commit 0c2204a4 authored by Manivannan Sadhasivam's avatar Manivannan Sadhasivam Committed by David S. Miller

net: qrtr: Migrate nameservice to kernel from userspace

The QRTR nameservice has been maintained in userspace for some time. This
commit migrates it to Linux kernel. This change is required in order to
eliminate the need of starting a userspace daemon for making the WiFi
functional for ath11k based devices. Since the QRTR NS is not usually
packed in most of the distros, users need to clone, build and install it
to get the WiFi working. It will become a hassle when the user doesn't
have any other source of network connectivity.
Signed-off-by: default avatarManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cd26d72d
# SPDX-License-Identifier: GPL-2.0-only
obj-$(CONFIG_QRTR) := qrtr.o
obj-$(CONFIG_QRTR) := qrtr.o ns.o
obj-$(CONFIG_QRTR_SMD) += qrtr-smd.o
qrtr-smd-y := smd.o
......
This diff is collapsed.
......@@ -10,6 +10,7 @@
#include <linux/numa.h>
#include <linux/spinlock.h>
#include <linux/wait.h>
#include <linux/workqueue.h>
#include <net/sock.h>
......@@ -110,6 +111,8 @@ static DEFINE_MUTEX(qrtr_node_lock);
static DEFINE_IDR(qrtr_ports);
static DEFINE_MUTEX(qrtr_port_lock);
static struct delayed_work qrtr_ns_work;
/**
* struct qrtr_node - endpoint node
* @ep_lock: lock for endpoint management and callbacks
......@@ -1241,38 +1244,6 @@ static int qrtr_create(struct net *net, struct socket *sock,
return 0;
}
static const struct nla_policy qrtr_policy[IFA_MAX + 1] = {
[IFA_LOCAL] = { .type = NLA_U32 },
};
static int qrtr_addr_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
struct netlink_ext_ack *extack)
{
struct nlattr *tb[IFA_MAX + 1];
struct ifaddrmsg *ifm;
int rc;
if (!netlink_capable(skb, CAP_NET_ADMIN))
return -EPERM;
if (!netlink_capable(skb, CAP_SYS_ADMIN))
return -EPERM;
ASSERT_RTNL();
rc = nlmsg_parse_deprecated(nlh, sizeof(*ifm), tb, IFA_MAX,
qrtr_policy, extack);
if (rc < 0)
return rc;
ifm = nlmsg_data(nlh);
if (!tb[IFA_LOCAL])
return -EINVAL;
qrtr_local_nid = nla_get_u32(tb[IFA_LOCAL]);
return 0;
}
static const struct net_proto_family qrtr_family = {
.owner = THIS_MODULE,
.family = AF_QIPCRTR,
......@@ -1293,11 +1264,11 @@ static int __init qrtr_proto_init(void)
return rc;
}
rc = rtnl_register_module(THIS_MODULE, PF_QIPCRTR, RTM_NEWADDR, qrtr_addr_doit, NULL, 0);
if (rc) {
sock_unregister(qrtr_family.family);
proto_unregister(&qrtr_proto);
}
/* FIXME: Currently, this 2s delay is required to catch the NEW_SERVER
* messages from routers. But the fix could be somewhere else.
*/
INIT_DELAYED_WORK(&qrtr_ns_work, qrtr_ns_init);
schedule_delayed_work(&qrtr_ns_work, msecs_to_jiffies(2000));
return rc;
}
......@@ -1305,7 +1276,8 @@ postcore_initcall(qrtr_proto_init);
static void __exit qrtr_proto_fini(void)
{
rtnl_unregister(PF_QIPCRTR, RTM_NEWADDR);
cancel_delayed_work_sync(&qrtr_ns_work);
qrtr_ns_remove();
sock_unregister(qrtr_family.family);
proto_unregister(&qrtr_proto);
}
......
......@@ -29,4 +29,8 @@ void qrtr_endpoint_unregister(struct qrtr_endpoint *ep);
int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len);
void qrtr_ns_init(struct work_struct *work);
void qrtr_ns_remove(void);
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment