Thread (31 messages) 31 messages, 5 authors, 2011-01-03

Re: [*v3 PATCH 02/22] IPVS: netns to services part 1

From: Jan Engelhardt <hidden>
Date: 2011-01-01 14:57:29
Also in: lvs-devel, netfilter-devel

On Thursday 2010-12-30 11:50, hans@schillstrom.com wrote:
+/*
+ * Get net ptr from skb in traffic cases
+ * use skb_sknet when call is from userland (ioctl or netlink)
+ */
+static inline struct net *skb_net(struct sk_buff *skb) {
+#ifdef CONFIG_NET_NS
+#ifdef CONFIG_IP_VS_DEBUG
+	/*
+	 * This is used for debug only.
+	 * Start with the most likely hit
+	 * End with BUG
+	 */
+	if (likely(skb->dev && skb->dev->nd_net))
+		return dev_net(skb->dev);
+	if (skb_dst(skb)->dev)
+		return dev_net(skb_dst(skb)->dev);
+	WARN(skb->sk,"Maybe skb_sknet should be used instead in %s() line:%d\n",
+		      __func__, __LINE__);
+	if (likely(skb->sk && skb->sk->sk_net))
+		return sock_net(skb->sk);
+	pr_err("There is no net ptr to find in the skb in %s() line:%d\n",
+		__func__, __LINE__);
+	BUG();
+#else
+	return dev_net(skb->dev ? : skb_dst(skb)->dev);
+#endif
+#else
+	return &init_net;
+#endif
+}
Whether NETNS is disabled or not, dev_net(skb->dev) can be used in either case,
so the extra return &init_net case is not really required AFAICS.
quoted hunk ↗ jump to hunk
@@ -3446,43 +3471,48 @@ static struct pernet_operations ipvs_control_ops = {
-	smp_wmb();
+
+	smp_wmb();	/* Do wee really need it now ? */
not "whee" :)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help