Thread (14 messages) 14 messages, 4 authors, 2016-09-20

Re: [PATCH RFC 5/6] net: Generic resolver backend

flat view

From: Thomas Graf <tgraf@suug.ch>
Date: 2016-09-14 09:49:13

On 09/09/16 at 04:19pm, Tom Herbert wrote:
quoted hunk ↗ jump to hunk
diff --git a/net/core/resolver.c b/net/core/resolver.c
new file mode 100644
index 0000000..61b36c5
--- /dev/null
+++ b/net/core/resolver.c
@@ -0,0 +1,267 @@
+#include <linux/errno.h>
+#include <linux/ip.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/netlink.h>
+#include <linux/skbuff.h>
+#include <linux/socket.h>
+#include <linux/types.h>
+#include <linux/vmalloc.h>
+#include <net/checksum.h>
+#include <net/ip.h>
+#include <net/ip6_fib.h>
+#include <net/lwtunnel.h>
+#include <net/protocol.h>
+#include <net/resolver.h>
+#include <uapi/linux/ila.h>
This include list could be stripped down a bit. ila, lwt, fib, ...
quoted hunk ↗ jump to hunk
+
+static struct net_rslv_ent *net_rslv_new_ent(struct net_rslv *nrslv,
+					     void *key)
Comment above that net_rslv_get_lock() must be held?
quoted hunk ↗ jump to hunk
+{
+	struct net_rslv_ent *nrent;
+	int err;
+
+	nrent = kzalloc(sizeof(*nrent) + nrslv->obj_size, GFP_KERNEL);
GFP_ATOMIC since you typically hold net_rslv_get_lock() spinlock?
quoted hunk ↗ jump to hunk
+	if (!nrent)
+		return ERR_PTR(-EAGAIN);
+
+	/* Key is always at beginning of object data */
+	memcpy(nrent->object, key, nrslv->params.key_len);
+
+	/* Initialize user data */
+	if (nrslv->rslv_init)
+		nrslv->rslv_init(nrslv, nrent);
+
+	/* Put in hash table */
+	err = rhashtable_lookup_insert_fast(&nrslv->rhash_table,
+					    &nrent->node, nrslv->params);
+	if (err)
+		return ERR_PTR(err);
+
+	if (nrslv->timeout) {
+		/* Schedule timeout for resolver */
+		INIT_DELAYED_WORK(&nrent->timeout_work, net_rslv_delayed_work);
Should this be done before inserting into rhashtable?
quoted hunk ↗ jump to hunk
+		schedule_delayed_work(&nrent->timeout_work, nrslv->timeout);
+	}
+
+	nrent->nrslv = nrslv;
Same here.  net_rslv_cancel_all_delayed_work() walking the rhashtable could
see ->nrslv as NULL.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help