Netdev List
 help / color / mirror / Atom feed
* [PATCH 0/8] [RESEND] netlink error magngement + others
@ 2007-03-22 22:18 Thomas Graf
  2007-03-22 22:18 ` [PATCH 1/8] [TCP] vegas: Use type safe netlink interface Thomas Graf
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Thomas Graf @ 2007-03-22 22:18 UTC (permalink / raw)
  To: davem; +Cc: netdev

Dave,
I've rediffed all patches and combined the two patchsets into
one.  Patrick has already queued the NLM_F_REQUEST change for
nfnetlink.

[PATCH 0/5] [PATCHSET] Netlink Patches
Converts westwood and vegas netlink code to use the typesafe
interface, removes an unused varaible, and move some netlink
queue management code into the generic layer.

[PATCH 0/3] [PATCHSET] netlink error management
This series of patches simplifies the error management and
signalization of dump starts of netlink_run_queue() message
handlers. It touches a fair bit of nfnetlink code as the
error pointer has been passed on to subsystems.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/8] [TCP] vegas: Use type safe netlink interface
  2007-03-22 22:18 [PATCH 0/8] [RESEND] netlink error magngement + others Thomas Graf
@ 2007-03-22 22:18 ` Thomas Graf
  2007-03-22 22:18 ` [PATCH 2/8] [TCP] westwood: " Thomas Graf
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Graf @ 2007-03-22 22:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, Thomas Graf

[-- Attachment #1: nl_tcp_vegas --]
[-- Type: text/plain, Size: 985 bytes --]

Signed-off-by: Thomas Graf <tgraf@suug.ch>

Index: net-2.6.22/net/ipv4/tcp_vegas.c
===================================================================
--- net-2.6.22.orig/net/ipv4/tcp_vegas.c	2007-03-22 23:08:48.000000000 +0100
+++ net-2.6.22/net/ipv4/tcp_vegas.c	2007-03-22 23:09:21.000000000 +0100
@@ -341,16 +341,14 @@ static void tcp_vegas_get_info(struct so
 {
 	const struct vegas *ca = inet_csk_ca(sk);
 	if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) {
-		struct tcpvegas_info *info;
+		struct tcpvegas_info info = {
+			.tcpv_enabled = ca->doing_vegas_now,
+			.tcpv_rttcnt = ca->cntRTT,
+			.tcpv_rtt = ca->baseRTT,
+			.tcpv_minrtt = ca->minRTT,
+		};
 
-		info = RTA_DATA(__RTA_PUT(skb, INET_DIAG_VEGASINFO,
-					  sizeof(*info)));
-
-		info->tcpv_enabled = ca->doing_vegas_now;
-		info->tcpv_rttcnt = ca->cntRTT;
-		info->tcpv_rtt = ca->baseRTT;
-		info->tcpv_minrtt = ca->minRTT;
-	rtattr_failure:	;
+		nla_put(skb, INET_DIAG_VEGASINFO, sizeof(info), &info);
 	}
 }
 

--


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 2/8] [TCP] westwood: Use type safe netlink interface
  2007-03-22 22:18 [PATCH 0/8] [RESEND] netlink error magngement + others Thomas Graf
  2007-03-22 22:18 ` [PATCH 1/8] [TCP] vegas: Use type safe netlink interface Thomas Graf
@ 2007-03-22 22:18 ` Thomas Graf
  2007-03-22 22:18 ` [PATCH 3/8] [NETLINK]: Remove unused groups variable Thomas Graf
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Graf @ 2007-03-22 22:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, Thomas Graf

[-- Attachment #1: nl_tcp_westwood --]
[-- Type: text/plain, Size: 1014 bytes --]

Signed-off-by: Thomas Graf <tgraf@suug.ch>

Index: net-2.6.22/net/ipv4/tcp_westwood.c
===================================================================
--- net-2.6.22.orig/net/ipv4/tcp_westwood.c	2007-03-22 23:08:48.000000000 +0100
+++ net-2.6.22/net/ipv4/tcp_westwood.c	2007-03-22 23:09:23.000000000 +0100
@@ -260,16 +260,13 @@ static void tcp_westwood_info(struct soc
 {
 	const struct westwood *ca = inet_csk_ca(sk);
 	if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) {
-		struct rtattr *rta;
-		struct tcpvegas_info *info;
+		struct tcpvegas_info info = {
+			.tcpv_enabled = 1,
+			.tcpv_rtt = jiffies_to_usecs(ca->rtt),
+			.tcpv_minrtt = jiffies_to_usecs(ca->rtt_min),
+		};
 
-		rta = __RTA_PUT(skb, INET_DIAG_VEGASINFO, sizeof(*info));
-		info = RTA_DATA(rta);
-		info->tcpv_enabled = 1;
-		info->tcpv_rttcnt = 0;
-		info->tcpv_rtt = jiffies_to_usecs(ca->rtt);
-		info->tcpv_minrtt = jiffies_to_usecs(ca->rtt_min);
-	rtattr_failure:	;
+		nla_put(skb, INET_DIAG_VEGASINFO, sizeof(info), &info);
 	}
 }
 

--


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 3/8] [NETLINK]: Remove unused groups variable
  2007-03-22 22:18 [PATCH 0/8] [RESEND] netlink error magngement + others Thomas Graf
  2007-03-22 22:18 ` [PATCH 1/8] [TCP] vegas: Use type safe netlink interface Thomas Graf
  2007-03-22 22:18 ` [PATCH 2/8] [TCP] westwood: " Thomas Graf
@ 2007-03-22 22:18 ` Thomas Graf
  2007-03-22 22:18 ` [PATCH 4/8] [NETLINK]: Ignore !NLM_F_REQUEST messages directly in netlink_run_queue() Thomas Graf
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Graf @ 2007-03-22 22:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, Thomas Graf

[-- Attachment #1: netlink_create_unused_variable --]
[-- Type: text/plain, Size: 876 bytes --]

Leftover from dynamic multicast groups allocation work.

Signed-off-by: Thomas Graf <tgraf@suug.ch>

Index: net-2.6.22/net/netlink/af_netlink.c
===================================================================
--- net-2.6.22.orig/net/netlink/af_netlink.c	2007-03-22 23:08:48.000000000 +0100
+++ net-2.6.22/net/netlink/af_netlink.c	2007-03-22 23:09:24.000000000 +0100
@@ -396,7 +396,6 @@ static int netlink_create(struct socket 
 {
 	struct module *module = NULL;
 	struct netlink_sock *nlk;
-	unsigned int groups;
 	int err = 0;
 
 	sock->state = SS_UNCONNECTED;
@@ -418,7 +417,6 @@ static int netlink_create(struct socket 
 	if (nl_table[protocol].registered &&
 	    try_module_get(nl_table[protocol].module))
 		module = nl_table[protocol].module;
-	groups = nl_table[protocol].groups;
 	netlink_unlock_table();
 
 	if ((err = __netlink_create(sock, protocol)) < 0)

--


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 4/8] [NETLINK]: Ignore !NLM_F_REQUEST messages directly in netlink_run_queue()
  2007-03-22 22:18 [PATCH 0/8] [RESEND] netlink error magngement + others Thomas Graf
                   ` (2 preceding siblings ...)
  2007-03-22 22:18 ` [PATCH 3/8] [NETLINK]: Remove unused groups variable Thomas Graf
@ 2007-03-22 22:18 ` Thomas Graf
  2007-03-22 22:18 ` [PATCH 5/8] [NETLINK]: Ignore control " Thomas Graf
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Graf @ 2007-03-22 22:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, Thomas Graf

[-- Attachment #1: netlink_run_queue_ignore_non_request --]
[-- Type: text/plain, Size: 2795 bytes --]

netlink_rcv_skb() is changed to skip messages which don't have the
NLM_F_REQUEST bit to avoid every netlink family having to perform this
check on their own.

Signed-off-by: Thomas Graf <tgraf@suug.ch>

Index: net-2.6.22/net/netlink/af_netlink.c
===================================================================
--- net-2.6.22.orig/net/netlink/af_netlink.c	2007-03-22 23:09:24.000000000 +0100
+++ net-2.6.22/net/netlink/af_netlink.c	2007-03-22 23:15:33.000000000 +0100
@@ -1470,10 +1470,15 @@ static int netlink_rcv_skb(struct sk_buf
 
 	while (skb->len >= nlmsg_total_size(0)) {
 		nlh = nlmsg_hdr(skb);
+		err = 0;
 
 		if (nlh->nlmsg_len < NLMSG_HDRLEN || skb->len < nlh->nlmsg_len)
 			return 0;
 
+		/* Only requests are handled by the kernel */
+		if (!(nlh->nlmsg_flags & NLM_F_REQUEST))
+			goto skip;
+
 		if (cb(skb, nlh, &err) < 0) {
 			/* Not an error, but we have to interrupt processing
 			 * here. Note: that in this case we do not pull
@@ -1481,9 +1486,10 @@ static int netlink_rcv_skb(struct sk_buf
 			 */
 			if (err == 0)
 				return -1;
+		}
+skip:
+		if (nlh->nlmsg_flags & NLM_F_ACK || err)
 			netlink_ack(skb, nlh, err);
-		} else if (nlh->nlmsg_flags & NLM_F_ACK)
-			netlink_ack(skb, nlh, 0);
 
 		netlink_queue_skip(nlh, skb);
 	}
Index: net-2.6.22/net/xfrm/xfrm_user.c
===================================================================
--- net-2.6.22.orig/net/xfrm/xfrm_user.c	2007-03-22 23:08:48.000000000 +0100
+++ net-2.6.22/net/xfrm/xfrm_user.c	2007-03-22 23:15:33.000000000 +0100
@@ -1859,9 +1859,6 @@ static int xfrm_user_rcv_msg(struct sk_b
 	struct xfrm_link *link;
 	int type, min_len;
 
-	if (!(nlh->nlmsg_flags & NLM_F_REQUEST))
-		return 0;
-
 	type = nlh->nlmsg_type;
 
 	/* A control message: ignore them */
Index: net-2.6.22/net/netlink/genetlink.c
===================================================================
--- net-2.6.22.orig/net/netlink/genetlink.c	2007-03-22 23:08:48.000000000 +0100
+++ net-2.6.22/net/netlink/genetlink.c	2007-03-22 23:15:33.000000000 +0100
@@ -304,9 +304,6 @@ static int genl_rcv_msg(struct sk_buff *
 	struct genlmsghdr *hdr = nlmsg_data(nlh);
 	int hdrlen, err = -EINVAL;
 
-	if (!(nlh->nlmsg_flags & NLM_F_REQUEST))
-		goto ignore;
-
 	if (nlh->nlmsg_type < NLMSG_MIN_TYPE)
 		goto ignore;
 
Index: net-2.6.22/net/core/rtnetlink.c
===================================================================
--- net-2.6.22.orig/net/core/rtnetlink.c	2007-03-22 23:08:48.000000000 +0100
+++ net-2.6.22/net/core/rtnetlink.c	2007-03-22 23:15:33.000000000 +0100
@@ -861,10 +861,6 @@ rtnetlink_rcv_msg(struct sk_buff *skb, s
 	int type;
 	int err;
 
-	/* Only requests are handled by kernel now */
-	if (!(nlh->nlmsg_flags&NLM_F_REQUEST))
-		return 0;
-
 	type = nlh->nlmsg_type;
 
 	/* A control message: ignore them */

--


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 5/8] [NETLINK]: Ignore control messages directly in netlink_run_queue()
  2007-03-22 22:18 [PATCH 0/8] [RESEND] netlink error magngement + others Thomas Graf
                   ` (3 preceding siblings ...)
  2007-03-22 22:18 ` [PATCH 4/8] [NETLINK]: Ignore !NLM_F_REQUEST messages directly in netlink_run_queue() Thomas Graf
@ 2007-03-22 22:18 ` Thomas Graf
  2007-03-22 22:18 ` [PATCH 6/8] [NETLINK]: Remove error pointer from netlink message handler Thomas Graf
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Graf @ 2007-03-22 22:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, Thomas Graf

[-- Attachment #1: netlink_run_queue_ignore_ctrl_msgs --]
[-- Type: text/plain, Size: 2540 bytes --]

Changes netlink_rcv_skb() to skip netlink controll messages and don't
pass them on to the message handler.

Signed-off-by: Thomas Graf <tgraf@suug.ch>

Index: net-2.6.22/net/netlink/af_netlink.c
===================================================================
--- net-2.6.22.orig/net/netlink/af_netlink.c	2007-03-22 23:15:33.000000000 +0100
+++ net-2.6.22/net/netlink/af_netlink.c	2007-03-22 23:15:58.000000000 +0100
@@ -1479,6 +1479,10 @@ static int netlink_rcv_skb(struct sk_buf
 		if (!(nlh->nlmsg_flags & NLM_F_REQUEST))
 			goto skip;
 
+		/* Skip control messages */
+		if (nlh->nlmsg_type < NLMSG_MIN_TYPE)
+			goto skip;
+
 		if (cb(skb, nlh, &err) < 0) {
 			/* Not an error, but we have to interrupt processing
 			 * here. Note: that in this case we do not pull
Index: net-2.6.22/net/core/rtnetlink.c
===================================================================
--- net-2.6.22.orig/net/core/rtnetlink.c	2007-03-22 23:15:33.000000000 +0100
+++ net-2.6.22/net/core/rtnetlink.c	2007-03-22 23:15:58.000000000 +0100
@@ -863,10 +863,6 @@ rtnetlink_rcv_msg(struct sk_buff *skb, s
 
 	type = nlh->nlmsg_type;
 
-	/* A control message: ignore them */
-	if (type < RTM_BASE)
-		return 0;
-
 	/* Unknown message: reply with EINVAL */
 	if (type > RTM_MAX)
 		goto err_inval;
Index: net-2.6.22/net/netlink/genetlink.c
===================================================================
--- net-2.6.22.orig/net/netlink/genetlink.c	2007-03-22 23:15:33.000000000 +0100
+++ net-2.6.22/net/netlink/genetlink.c	2007-03-22 23:15:58.000000000 +0100
@@ -304,9 +304,6 @@ static int genl_rcv_msg(struct sk_buff *
 	struct genlmsghdr *hdr = nlmsg_data(nlh);
 	int hdrlen, err = -EINVAL;
 
-	if (nlh->nlmsg_type < NLMSG_MIN_TYPE)
-		goto ignore;
-
 	family = genl_family_find_byid(nlh->nlmsg_type);
 	if (family == NULL) {
 		err = -ENOENT;
@@ -364,9 +361,6 @@ static int genl_rcv_msg(struct sk_buff *
 	*errp = err = ops->doit(skb, &info);
 	return err;
 
-ignore:
-	return 0;
-
 errout:
 	*errp = err;
 	return -1;
Index: net-2.6.22/net/xfrm/xfrm_user.c
===================================================================
--- net-2.6.22.orig/net/xfrm/xfrm_user.c	2007-03-22 23:15:33.000000000 +0100
+++ net-2.6.22/net/xfrm/xfrm_user.c	2007-03-22 23:15:58.000000000 +0100
@@ -1861,10 +1861,6 @@ static int xfrm_user_rcv_msg(struct sk_b
 
 	type = nlh->nlmsg_type;
 
-	/* A control message: ignore them */
-	if (type < XFRM_MSG_BASE)
-		return 0;
-
 	/* Unknown message: reply with EINVAL */
 	if (type > XFRM_MSG_MAX)
 		goto err_einval;

--


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 6/8] [NETLINK]: Remove error pointer from netlink message handler
  2007-03-22 22:18 [PATCH 0/8] [RESEND] netlink error magngement + others Thomas Graf
                   ` (4 preceding siblings ...)
  2007-03-22 22:18 ` [PATCH 5/8] [NETLINK]: Ignore control " Thomas Graf
@ 2007-03-22 22:18 ` Thomas Graf
  2007-03-22 22:18 ` [PATCH 7/8] [IPv4] diag: Use netlink_run_queue() to process the receive queue Thomas Graf
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Graf @ 2007-03-22 22:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, Thomas Graf

[-- Attachment #1: netlink_run_queue_remove_errp --]
[-- Type: text/plain, Size: 18220 bytes --]

The error pointer argument in netlink message handlers is used
to signal the special case where processing has to be interrupted
because a dump was started but no error happened. Instead it is
simpler and more clear to return -EINTR and have netlink_run_queue()
deal with getting the queue right.

nfnetlink passed on this error pointer to its subsystem handlers
but only uses it to signal the start of a netlink dump. Therefore
it can be removed there as well.

This patch also cleans up the error handling in the affected
message handlers to be consistent since it had to be touched anyway.

Signed-off-by: Thomas Graf <tgraf@suug.ch>

Index: net-2.6.22/net/core/rtnetlink.c
===================================================================
--- net-2.6.22.orig/net/core/rtnetlink.c	2007-03-22 23:15:58.000000000 +0100
+++ net-2.6.22/net/core/rtnetlink.c	2007-03-22 23:15:59.000000000 +0100
@@ -851,8 +851,7 @@ static int rtattr_max;
 
 /* Process one rtnetlink message. */
 
-static __inline__ int
-rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, int *errp)
+static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 {
 	rtnl_doit_func doit;
 	int sz_idx, kind;
@@ -862,10 +861,8 @@ rtnetlink_rcv_msg(struct sk_buff *skb, s
 	int err;
 
 	type = nlh->nlmsg_type;
-
-	/* Unknown message: reply with EINVAL */
 	if (type > RTM_MAX)
-		goto err_inval;
+		return -EINVAL;
 
 	type -= RTM_BASE;
 
@@ -874,40 +871,33 @@ rtnetlink_rcv_msg(struct sk_buff *skb, s
 		return 0;
 
 	family = ((struct rtgenmsg*)NLMSG_DATA(nlh))->rtgen_family;
-	if (family >= NPROTO) {
-		*errp = -EAFNOSUPPORT;
-		return -1;
-	}
+	if (family >= NPROTO)
+		return -EAFNOSUPPORT;
 
 	sz_idx = type>>2;
 	kind = type&3;
 
-	if (kind != 2 && security_netlink_recv(skb, CAP_NET_ADMIN)) {
-		*errp = -EPERM;
-		return -1;
-	}
+	if (kind != 2 && security_netlink_recv(skb, CAP_NET_ADMIN))
+		return -EPERM;
 
 	if (kind == 2 && nlh->nlmsg_flags&NLM_F_DUMP) {
 		rtnl_dumpit_func dumpit;
 
 		dumpit = rtnl_get_dumpit(family, type);
 		if (dumpit == NULL)
-			goto err_inval;
+			return -EINVAL;
 
-		if ((*errp = netlink_dump_start(rtnl, skb, nlh,
-						dumpit, NULL)) != 0) {
-			return -1;
-		}
-
-		netlink_queue_skip(nlh, skb);
-		return -1;
+		err = netlink_dump_start(rtnl, skb, nlh, dumpit, NULL);
+		if (err == 0)
+			err = -EINTR;
+		return err;
 	}
 
 	memset(rta_buf, 0, (rtattr_max * sizeof(struct rtattr *)));
 
 	min_len = rtm_min[sz_idx];
 	if (nlh->nlmsg_len < min_len)
-		goto err_inval;
+		return -EINVAL;
 
 	if (nlh->nlmsg_len > min_len) {
 		int attrlen = nlh->nlmsg_len - NLMSG_ALIGN(min_len);
@@ -917,7 +907,7 @@ rtnetlink_rcv_msg(struct sk_buff *skb, s
 			unsigned flavor = attr->rta_type;
 			if (flavor) {
 				if (flavor > rta_max[sz_idx])
-					goto err_inval;
+					return -EINVAL;
 				rta_buf[flavor-1] = attr;
 			}
 			attr = RTA_NEXT(attr, attrlen);
@@ -926,15 +916,9 @@ rtnetlink_rcv_msg(struct sk_buff *skb, s
 
 	doit = rtnl_get_doit(family, type);
 	if (doit == NULL)
-		goto err_inval;
-	err = doit(skb, nlh, (void *)&rta_buf[0]);
-
-	*errp = err;
-	return err;
+		return -EINVAL;
 
-err_inval:
-	*errp = -EINVAL;
-	return -1;
+	return doit(skb, nlh, (void *)&rta_buf[0]);
 }
 
 static void rtnetlink_rcv(struct sock *sk, int len)
Index: net-2.6.22/net/netlink/genetlink.c
===================================================================
--- net-2.6.22.orig/net/netlink/genetlink.c	2007-03-22 23:15:58.000000000 +0100
+++ net-2.6.22/net/netlink/genetlink.c	2007-03-22 23:15:59.000000000 +0100
@@ -295,60 +295,49 @@ int genl_unregister_family(struct genl_f
 	return -ENOENT;
 }
 
-static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
-			       int *errp)
+static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 {
 	struct genl_ops *ops;
 	struct genl_family *family;
 	struct genl_info info;
 	struct genlmsghdr *hdr = nlmsg_data(nlh);
-	int hdrlen, err = -EINVAL;
+	int hdrlen, err;
 
 	family = genl_family_find_byid(nlh->nlmsg_type);
-	if (family == NULL) {
-		err = -ENOENT;
-		goto errout;
-	}
+	if (family == NULL)
+		return -ENOENT;
 
 	hdrlen = GENL_HDRLEN + family->hdrsize;
 	if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen))
-		goto errout;
+		return -EINVAL;
 
 	ops = genl_get_cmd(hdr->cmd, family);
-	if (ops == NULL) {
-		err = -EOPNOTSUPP;
-		goto errout;
-	}
+	if (ops == NULL)
+		return -EOPNOTSUPP;
 
-	if ((ops->flags & GENL_ADMIN_PERM) && security_netlink_recv(skb, CAP_NET_ADMIN)) {
-		err = -EPERM;
-		goto errout;
-	}
+	if ((ops->flags & GENL_ADMIN_PERM) &&
+	    security_netlink_recv(skb, CAP_NET_ADMIN))
+		return -EPERM;
 
 	if (nlh->nlmsg_flags & NLM_F_DUMP) {
-		if (ops->dumpit == NULL) {
-			err = -EOPNOTSUPP;
-			goto errout;
-		}
+		if (ops->dumpit == NULL)
+			return -EOPNOTSUPP;
 
-		*errp = err = netlink_dump_start(genl_sock, skb, nlh,
-						 ops->dumpit, ops->done);
+		err = netlink_dump_start(genl_sock, skb, nlh,
+					 ops->dumpit, ops->done);
 		if (err == 0)
-			skb_pull(skb, min(NLMSG_ALIGN(nlh->nlmsg_len),
-					  skb->len));
-		return -1;
+			err = -EINTR;
+		return err;
 	}
 
-	if (ops->doit == NULL) {
-		err = -EOPNOTSUPP;
-		goto errout;
-	}
+	if (ops->doit == NULL)
+		return -EOPNOTSUPP;
 
 	if (family->attrbuf) {
 		err = nlmsg_parse(nlh, hdrlen, family->attrbuf, family->maxattr,
 				  ops->policy);
 		if (err < 0)
-			goto errout;
+			return err;
 	}
 
 	info.snd_seq = nlh->nlmsg_seq;
@@ -358,12 +347,7 @@ static int genl_rcv_msg(struct sk_buff *
 	info.userhdr = nlmsg_data(nlh) + GENL_HDRLEN;
 	info.attrs = family->attrbuf;
 
-	*errp = err = ops->doit(skb, &info);
-	return err;
-
-errout:
-	*errp = err;
-	return -1;
+	return ops->doit(skb, &info);
 }
 
 static void genl_rcv(struct sock *sk, int len)
Index: net-2.6.22/net/xfrm/xfrm_user.c
===================================================================
--- net-2.6.22.orig/net/xfrm/xfrm_user.c	2007-03-22 23:15:58.000000000 +0100
+++ net-2.6.22/net/xfrm/xfrm_user.c	2007-03-22 23:15:59.000000000 +0100
@@ -1853,46 +1853,39 @@ static struct xfrm_link {
 	[XFRM_MSG_MIGRATE     - XFRM_MSG_BASE] = { .doit = xfrm_do_migrate    },
 };
 
-static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, int *errp)
+static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 {
 	struct rtattr *xfrma[XFRMA_MAX];
 	struct xfrm_link *link;
-	int type, min_len;
+	int type, min_len, err;
 
 	type = nlh->nlmsg_type;
-
-	/* Unknown message: reply with EINVAL */
 	if (type > XFRM_MSG_MAX)
-		goto err_einval;
+		return -EINVAL;
 
 	type -= XFRM_MSG_BASE;
 	link = &xfrm_dispatch[type];
 
 	/* All operations require privileges, even GET */
-	if (security_netlink_recv(skb, CAP_NET_ADMIN)) {
-		*errp = -EPERM;
-		return -1;
-	}
+	if (security_netlink_recv(skb, CAP_NET_ADMIN))
+		return -EPERM;
 
 	if ((type == (XFRM_MSG_GETSA - XFRM_MSG_BASE) ||
 	     type == (XFRM_MSG_GETPOLICY - XFRM_MSG_BASE)) &&
 	    (nlh->nlmsg_flags & NLM_F_DUMP)) {
 		if (link->dump == NULL)
-			goto err_einval;
-
-		if ((*errp = netlink_dump_start(xfrm_nl, skb, nlh,
-						link->dump, NULL)) != 0) {
-			return -1;
-		}
+			return -EINVAL;
 
-		netlink_queue_skip(nlh, skb);
-		return -1;
+		err = netlink_dump_start(xfrm_nl, skb, nlh, link->dump, NULL);
+		if (err == 0)
+			err = -EINTR;
+		return err;
 	}
 
 	memset(xfrma, 0, sizeof(xfrma));
 
 	if (nlh->nlmsg_len < (min_len = xfrm_msg_min[type]))
-		goto err_einval;
+		return -EINVAL;
 
 	if (nlh->nlmsg_len > min_len) {
 		int attrlen = nlh->nlmsg_len - NLMSG_ALIGN(min_len);
@@ -1902,7 +1895,7 @@ static int xfrm_user_rcv_msg(struct sk_b
 			unsigned short flavor = attr->rta_type;
 			if (flavor) {
 				if (flavor > XFRMA_MAX)
-					goto err_einval;
+					return -EINVAL;
 				xfrma[flavor - 1] = attr;
 			}
 			attr = RTA_NEXT(attr, attrlen);
@@ -1910,14 +1903,9 @@ static int xfrm_user_rcv_msg(struct sk_b
 	}
 
 	if (link->doit == NULL)
-		goto err_einval;
-	*errp = link->doit(skb, nlh, xfrma);
-
-	return *errp;
+		return -EINVAL;
 
-err_einval:
-	*errp = -EINVAL;
-	return -1;
+	return link->doit(skb, nlh, xfrma);
 }
 
 static void xfrm_netlink_rcv(struct sock *sk, int len)
Index: net-2.6.22/net/netfilter/nfnetlink.c
===================================================================
--- net-2.6.22.orig/net/netfilter/nfnetlink.c	2007-03-22 23:15:51.000000000 +0100
+++ net-2.6.22/net/netfilter/nfnetlink.c	2007-03-22 23:15:59.000000000 +0100
@@ -195,17 +195,14 @@ int nfnetlink_unicast(struct sk_buff *sk
 EXPORT_SYMBOL_GPL(nfnetlink_unicast);
 
 /* Process one complete nfnetlink message. */
-static int nfnetlink_rcv_msg(struct sk_buff *skb,
-				    struct nlmsghdr *nlh, int *errp)
+static int nfnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 {
 	struct nfnl_callback *nc;
 	struct nfnetlink_subsystem *ss;
-	int type, err = 0;
+	int type, err;
 
-	if (security_netlink_recv(skb, CAP_NET_ADMIN)) {
-		*errp = -EPERM;
-		return -1;
-	}
+	if (security_netlink_recv(skb, CAP_NET_ADMIN))
+		return -EPERM;
 
 	/* Only requests are handled by kernel now. */
 	if (!(nlh->nlmsg_flags & NLM_F_REQUEST))
@@ -227,12 +224,12 @@ static int nfnetlink_rcv_msg(struct sk_b
 		ss = nfnetlink_get_subsys(type);
 		if (!ss)
 #endif
-			goto err_inval;
+			return -EINVAL;
 	}
 
 	nc = nfnetlink_find_client(type, ss);
 	if (!nc)
-		goto err_inval;
+		return -EINVAL;
 
 	{
 		u_int16_t attr_count =
@@ -243,16 +240,9 @@ static int nfnetlink_rcv_msg(struct sk_b
 
 		err = nfnetlink_check_attributes(ss, nlh, cda);
 		if (err < 0)
-			goto err_inval;
-
-		err = nc->call(nfnl, skb, nlh, cda, errp);
-		*errp = err;
-		return err;
+			return err;
+		return nc->call(nfnl, skb, nlh, cda);
 	}
-
-err_inval:
-	*errp = -EINVAL;
-	return -1;
 }
 
 static void nfnetlink_rcv(struct sock *sk, int len)
Index: net-2.6.22/include/net/netlink.h
===================================================================
--- net-2.6.22.orig/include/net/netlink.h	2007-03-22 23:15:31.000000000 +0100
+++ net-2.6.22/include/net/netlink.h	2007-03-22 23:15:59.000000000 +0100
@@ -214,7 +214,7 @@ struct nl_info {
 
 extern void		netlink_run_queue(struct sock *sk, unsigned int *qlen,
 					  int (*cb)(struct sk_buff *,
-						    struct nlmsghdr *, int *));
+						    struct nlmsghdr *));
 extern void		netlink_queue_skip(struct nlmsghdr *nlh,
 					   struct sk_buff *skb);
 extern int		nlmsg_notify(struct sock *sk, struct sk_buff *skb,
Index: net-2.6.22/net/netlink/af_netlink.c
===================================================================
--- net-2.6.22.orig/net/netlink/af_netlink.c	2007-03-22 23:15:58.000000000 +0100
+++ net-2.6.22/net/netlink/af_netlink.c	2007-03-22 23:15:59.000000000 +0100
@@ -1463,7 +1463,7 @@ void netlink_ack(struct sk_buff *in_skb,
 }
 
 static int netlink_rcv_skb(struct sk_buff *skb, int (*cb)(struct sk_buff *,
-						     struct nlmsghdr *, int *))
+						     struct nlmsghdr *))
 {
 	struct nlmsghdr *nlh;
 	int err;
@@ -1483,13 +1483,11 @@ static int netlink_rcv_skb(struct sk_buf
 		if (nlh->nlmsg_type < NLMSG_MIN_TYPE)
 			goto skip;
 
-		if (cb(skb, nlh, &err) < 0) {
-			/* Not an error, but we have to interrupt processing
-			 * here. Note: that in this case we do not pull
-			 * message from skb, it will be processed later.
-			 */
-			if (err == 0)
-				return -1;
+		err = cb(skb, nlh);
+		if (err == -EINTR) {
+			/* Not an error, but we interrupt processing */
+			netlink_queue_skip(nlh, skb);
+			return err;
 		}
 skip:
 		if (nlh->nlmsg_flags & NLM_F_ACK || err)
@@ -1515,9 +1513,14 @@ skip:
  *
  * qlen must be initialized to 0 before the initial entry, afterwards
  * the function may be called repeatedly until qlen reaches 0.
+ *
+ * The callback function may return -EINTR to signal that processing
+ * of netlink messages shall be interrupted. In this case the message
+ * currently being processed will NOT be requeued onto the receive
+ * queue.
  */
 void netlink_run_queue(struct sock *sk, unsigned int *qlen,
-		       int (*cb)(struct sk_buff *, struct nlmsghdr *, int *))
+		       int (*cb)(struct sk_buff *, struct nlmsghdr *))
 {
 	struct sk_buff *skb;
 
Index: net-2.6.22/net/netfilter/nf_conntrack_netlink.c
===================================================================
--- net-2.6.22.orig/net/netfilter/nf_conntrack_netlink.c	2007-03-22 23:15:32.000000000 +0100
+++ net-2.6.22/net/netfilter/nf_conntrack_netlink.c	2007-03-22 23:15:59.000000000 +0100
@@ -661,7 +661,7 @@ static const size_t cta_min[CTA_MAX] = {
 
 static int
 ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb,
-			struct nlmsghdr *nlh, struct nfattr *cda[], int *errp)
+			struct nlmsghdr *nlh, struct nfattr *cda[])
 {
 	struct nf_conntrack_tuple_hash *h;
 	struct nf_conntrack_tuple tuple;
@@ -709,7 +709,7 @@ ctnetlink_del_conntrack(struct sock *ctn
 
 static int
 ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
-			struct nlmsghdr *nlh, struct nfattr *cda[], int *errp)
+			struct nlmsghdr *nlh, struct nfattr *cda[])
 {
 	struct nf_conntrack_tuple_hash *h;
 	struct nf_conntrack_tuple tuple;
@@ -720,22 +720,15 @@ ctnetlink_get_conntrack(struct sock *ctn
 	int err = 0;
 
 	if (nlh->nlmsg_flags & NLM_F_DUMP) {
-		u32 rlen;
-
 #ifndef CONFIG_NF_CT_ACCT
 		if (NFNL_MSG_TYPE(nlh->nlmsg_type) == IPCTNL_MSG_CT_GET_CTRZERO)
 			return -ENOTSUPP;
 #endif
-		if ((*errp = netlink_dump_start(ctnl, skb, nlh,
-						ctnetlink_dump_table,
-						ctnetlink_done)) != 0)
-			return -EINVAL;
-
-		rlen = NLMSG_ALIGN(nlh->nlmsg_len);
-		if (rlen > skb->len)
-			rlen = skb->len;
-		skb_pull(skb, rlen);
-		return 0;
+		err = netlink_dump_start(ctnl, skb, nlh, ctnetlink_dump_table,
+					 ctnetlink_done);
+		if (err == 0)
+			err = -EINTR;
+		return err;
 	}
 
 	if (nfattr_bad_size(cda, CTA_MAX, cta_min))
@@ -1009,7 +1002,7 @@ err:
 
 static int
 ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
-			struct nlmsghdr *nlh, struct nfattr *cda[], int *errp)
+			struct nlmsghdr *nlh, struct nfattr *cda[])
 {
 	struct nf_conntrack_tuple otuple, rtuple;
 	struct nf_conntrack_tuple_hash *h = NULL;
@@ -1260,7 +1253,7 @@ static const size_t cta_min_exp[CTA_EXPE
 
 static int
 ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
-		     struct nlmsghdr *nlh, struct nfattr *cda[], int *errp)
+		     struct nlmsghdr *nlh, struct nfattr *cda[])
 {
 	struct nf_conntrack_tuple tuple;
 	struct nf_conntrack_expect *exp;
@@ -1273,17 +1266,12 @@ ctnetlink_get_expect(struct sock *ctnl, 
 		return -EINVAL;
 
 	if (nlh->nlmsg_flags & NLM_F_DUMP) {
-		u32 rlen;
-
-		if ((*errp = netlink_dump_start(ctnl, skb, nlh,
-						ctnetlink_exp_dump_table,
-						ctnetlink_done)) != 0)
-			return -EINVAL;
-		rlen = NLMSG_ALIGN(nlh->nlmsg_len);
-		if (rlen > skb->len)
-			rlen = skb->len;
-		skb_pull(skb, rlen);
-		return 0;
+		err = netlink_dump_start(ctnl, skb, nlh,
+					 ctnetlink_exp_dump_table,
+					 ctnetlink_done);
+		if (err == 0)
+			err = -EINTR;
+		return err;
 	}
 
 	if (cda[CTA_EXPECT_MASTER-1])
@@ -1330,7 +1318,7 @@ out:
 
 static int
 ctnetlink_del_expect(struct sock *ctnl, struct sk_buff *skb,
-		     struct nlmsghdr *nlh, struct nfattr *cda[], int *errp)
+		     struct nlmsghdr *nlh, struct nfattr *cda[])
 {
 	struct nf_conntrack_expect *exp, *tmp;
 	struct nf_conntrack_tuple tuple;
@@ -1464,7 +1452,7 @@ out:
 
 static int
 ctnetlink_new_expect(struct sock *ctnl, struct sk_buff *skb,
-		     struct nlmsghdr *nlh, struct nfattr *cda[], int *errp)
+		     struct nlmsghdr *nlh, struct nfattr *cda[])
 {
 	struct nf_conntrack_tuple tuple;
 	struct nf_conntrack_expect *exp;
Index: net-2.6.22/net/netfilter/nfnetlink_log.c
===================================================================
--- net-2.6.22.orig/net/netfilter/nfnetlink_log.c	2007-03-22 23:15:32.000000000 +0100
+++ net-2.6.22/net/netfilter/nfnetlink_log.c	2007-03-22 23:15:59.000000000 +0100
@@ -759,7 +759,7 @@ static struct notifier_block nfulnl_rtnl
 
 static int
 nfulnl_recv_unsupp(struct sock *ctnl, struct sk_buff *skb,
-		  struct nlmsghdr *nlh, struct nfattr *nfqa[], int *errp)
+		  struct nlmsghdr *nlh, struct nfattr *nfqa[])
 {
 	return -ENOTSUPP;
 }
@@ -797,7 +797,7 @@ static const int nfula_cfg_min[NFULA_CFG
 
 static int
 nfulnl_recv_config(struct sock *ctnl, struct sk_buff *skb,
-		   struct nlmsghdr *nlh, struct nfattr *nfula[], int *errp)
+		   struct nlmsghdr *nlh, struct nfattr *nfula[])
 {
 	struct nfgenmsg *nfmsg = NLMSG_DATA(nlh);
 	u_int16_t group_num = ntohs(nfmsg->res_id);
Index: net-2.6.22/net/netfilter/nfnetlink_queue.c
===================================================================
--- net-2.6.22.orig/net/netfilter/nfnetlink_queue.c	2007-03-22 23:15:32.000000000 +0100
+++ net-2.6.22/net/netfilter/nfnetlink_queue.c	2007-03-22 23:15:59.000000000 +0100
@@ -783,7 +783,7 @@ static const int nfqa_verdict_min[NFQA_M
 
 static int
 nfqnl_recv_verdict(struct sock *ctnl, struct sk_buff *skb,
-		   struct nlmsghdr *nlh, struct nfattr *nfqa[], int *errp)
+		   struct nlmsghdr *nlh, struct nfattr *nfqa[])
 {
 	struct nfgenmsg *nfmsg = NLMSG_DATA(nlh);
 	u_int16_t queue_num = ntohs(nfmsg->res_id);
@@ -848,7 +848,7 @@ err_out_put:
 
 static int
 nfqnl_recv_unsupp(struct sock *ctnl, struct sk_buff *skb,
-		  struct nlmsghdr *nlh, struct nfattr *nfqa[], int *errp)
+		  struct nlmsghdr *nlh, struct nfattr *nfqa[])
 {
 	return -ENOTSUPP;
 }
@@ -865,7 +865,7 @@ static struct nf_queue_handler nfqh = {
 
 static int
 nfqnl_recv_config(struct sock *ctnl, struct sk_buff *skb,
-		  struct nlmsghdr *nlh, struct nfattr *nfqa[], int *errp)
+		  struct nlmsghdr *nlh, struct nfattr *nfqa[])
 {
 	struct nfgenmsg *nfmsg = NLMSG_DATA(nlh);
 	u_int16_t queue_num = ntohs(nfmsg->res_id);
Index: net-2.6.22/include/linux/netfilter/nfnetlink.h
===================================================================
--- net-2.6.22.orig/include/linux/netfilter/nfnetlink.h	2007-03-22 23:15:31.000000000 +0100
+++ net-2.6.22/include/linux/netfilter/nfnetlink.h	2007-03-22 23:15:59.000000000 +0100
@@ -111,7 +111,7 @@ struct nfgenmsg {
 struct nfnl_callback
 {
 	int (*call)(struct sock *nl, struct sk_buff *skb, 
-		struct nlmsghdr *nlh, struct nfattr *cda[], int *errp);
+		struct nlmsghdr *nlh, struct nfattr *cda[]);
 	u_int16_t attr_count;	/* number of nfattr's */
 };
 

--


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 7/8] [IPv4] diag: Use netlink_run_queue() to process the receive queue
  2007-03-22 22:18 [PATCH 0/8] [RESEND] netlink error magngement + others Thomas Graf
                   ` (5 preceding siblings ...)
  2007-03-22 22:18 ` [PATCH 6/8] [NETLINK]: Remove error pointer from netlink message handler Thomas Graf
@ 2007-03-22 22:18 ` Thomas Graf
  2007-03-22 22:18 ` [PATCH 8/8] [NETLINK]: Directly return -EINTR from netlink_dump_start() Thomas Graf
  2007-03-23  6:31 ` [PATCH 0/8] [RESEND] netlink error magngement + others David Miller
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Graf @ 2007-03-22 22:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, Thomas Graf

[-- Attachment #1: inet_diag_queue_run --]
[-- Type: text/plain, Size: 3041 bytes --]

Makes use of netlink_run_queue() to process the receive queue and
converts inet_diag_rcv_msg() to use the type safe netlink interface.

Signed-off-by: Thomas Graf <tgraf@suug.ch>

Index: net-2.6.22/net/ipv4/inet_diag.c
===================================================================
--- net-2.6.22.orig/net/ipv4/inet_diag.c	2007-03-22 23:15:31.000000000 +0100
+++ net-2.6.22/net/ipv4/inet_diag.c	2007-03-22 23:16:05.000000000 +0100
@@ -806,68 +806,48 @@ done:
 	return skb->len;
 }
 
-static inline int inet_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
+static int inet_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 {
-	if (!(nlh->nlmsg_flags&NLM_F_REQUEST))
-		return 0;
+	int hdrlen = sizeof(struct inet_diag_req);
 
-	if (nlh->nlmsg_type >= INET_DIAG_GETSOCK_MAX)
-		goto err_inval;
+	if (nlh->nlmsg_type >= INET_DIAG_GETSOCK_MAX ||
+	    nlmsg_len(nlh) < hdrlen)
+		return -EINVAL;
 
 	if (inet_diag_table[nlh->nlmsg_type] == NULL)
 		return -ENOENT;
 
-	if (NLMSG_LENGTH(sizeof(struct inet_diag_req)) > skb->len)
-		goto err_inval;
-
-	if (nlh->nlmsg_flags&NLM_F_DUMP) {
-		if (nlh->nlmsg_len >
-		    (4 + NLMSG_SPACE(sizeof(struct inet_diag_req)))) {
-			struct rtattr *rta = (void *)(NLMSG_DATA(nlh) +
-						 sizeof(struct inet_diag_req));
-			if (rta->rta_type != INET_DIAG_REQ_BYTECODE ||
-			    rta->rta_len < 8 ||
-			    rta->rta_len >
-			    (nlh->nlmsg_len -
-			     NLMSG_SPACE(sizeof(struct inet_diag_req))))
-				goto err_inval;
-			if (inet_diag_bc_audit(RTA_DATA(rta), RTA_PAYLOAD(rta)))
-				goto err_inval;
-		}
-		return netlink_dump_start(idiagnl, skb, nlh,
-					  inet_diag_dump, NULL);
-	} else
-		return inet_diag_get_exact(skb, nlh);
-
-err_inval:
-	return -EINVAL;
-}
+	if (nlh->nlmsg_flags & NLM_F_DUMP) {
+		int err;
 
+		if (nlmsg_attrlen(nlh, hdrlen)) {
+			struct nlattr *attr;
 
-static inline void inet_diag_rcv_skb(struct sk_buff *skb)
-{
-	if (skb->len >= NLMSG_SPACE(0)) {
-		int err;
-		struct nlmsghdr *nlh = nlmsg_hdr(skb);
+			attr = nlmsg_find_attr(nlh, hdrlen,
+					       INET_DIAG_REQ_BYTECODE);
+			if (attr == NULL ||
+			    nla_len(attr) < sizeof(struct inet_diag_bc_op) ||
+			    inet_diag_bc_audit(nla_data(attr), nla_len(attr)))
+				return -EINVAL;
+		}
 
-		if (nlh->nlmsg_len < sizeof(*nlh) ||
-		    skb->len < nlh->nlmsg_len)
-			return;
-		err = inet_diag_rcv_msg(skb, nlh);
-		if (err || nlh->nlmsg_flags & NLM_F_ACK)
-			netlink_ack(skb, nlh, err);
+		err = netlink_dump_start(idiagnl, skb, nlh,
+					 inet_diag_dump, NULL);
+		if (err == 0)
+			err = -EINTR;
+		return err;
 	}
+
+	return inet_diag_get_exact(skb, nlh);
 }
 
 static void inet_diag_rcv(struct sock *sk, int len)
 {
-	struct sk_buff *skb;
-	unsigned int qlen = skb_queue_len(&sk->sk_receive_queue);
+	unsigned int qlen = 0;
 
-	while (qlen-- && (skb = skb_dequeue(&sk->sk_receive_queue))) {
-		inet_diag_rcv_skb(skb);
-		kfree_skb(skb);
-	}
+	do {
+		netlink_run_queue(sk, &qlen, &inet_diag_rcv_msg);
+	} while (qlen);
 }
 
 static DEFINE_SPINLOCK(inet_diag_register_lock);

--


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 8/8] [NETLINK]: Directly return -EINTR from netlink_dump_start()
  2007-03-22 22:18 [PATCH 0/8] [RESEND] netlink error magngement + others Thomas Graf
                   ` (6 preceding siblings ...)
  2007-03-22 22:18 ` [PATCH 7/8] [IPv4] diag: Use netlink_run_queue() to process the receive queue Thomas Graf
@ 2007-03-22 22:18 ` Thomas Graf
  2007-03-23  6:31 ` [PATCH 0/8] [RESEND] netlink error magngement + others David Miller
  8 siblings, 0 replies; 10+ messages in thread
From: Thomas Graf @ 2007-03-22 22:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, Thomas Graf

[-- Attachment #1: netlink_dump_start_retval --]
[-- Type: text/plain, Size: 5101 bytes --]

Now that all users of netlink_dump_start() use netlink_run_queue()
to process the receive queue, it is possible to return -EINTR from
netlink_dump_start() directly, therefore simplying the callers.

Signed-off-by: Thomas Graf <tgraf@suug.ch>

Index: net-2.6.22/net/core/rtnetlink.c
===================================================================
--- net-2.6.22.orig/net/core/rtnetlink.c	2007-03-22 23:15:59.000000000 +0100
+++ net-2.6.22/net/core/rtnetlink.c	2007-03-22 23:16:07.000000000 +0100
@@ -858,7 +858,6 @@ static int rtnetlink_rcv_msg(struct sk_b
 	int min_len;
 	int family;
 	int type;
-	int err;
 
 	type = nlh->nlmsg_type;
 	if (type > RTM_MAX)
@@ -887,10 +886,7 @@ static int rtnetlink_rcv_msg(struct sk_b
 		if (dumpit == NULL)
 			return -EINVAL;
 
-		err = netlink_dump_start(rtnl, skb, nlh, dumpit, NULL);
-		if (err == 0)
-			err = -EINTR;
-		return err;
+		return netlink_dump_start(rtnl, skb, nlh, dumpit, NULL);
 	}
 
 	memset(rta_buf, 0, (rtattr_max * sizeof(struct rtattr *)));
Index: net-2.6.22/net/ipv4/inet_diag.c
===================================================================
--- net-2.6.22.orig/net/ipv4/inet_diag.c	2007-03-22 23:16:05.000000000 +0100
+++ net-2.6.22/net/ipv4/inet_diag.c	2007-03-22 23:16:07.000000000 +0100
@@ -818,8 +818,6 @@ static int inet_diag_rcv_msg(struct sk_b
 		return -ENOENT;
 
 	if (nlh->nlmsg_flags & NLM_F_DUMP) {
-		int err;
-
 		if (nlmsg_attrlen(nlh, hdrlen)) {
 			struct nlattr *attr;
 
@@ -831,11 +829,8 @@ static int inet_diag_rcv_msg(struct sk_b
 				return -EINVAL;
 		}
 
-		err = netlink_dump_start(idiagnl, skb, nlh,
-					 inet_diag_dump, NULL);
-		if (err == 0)
-			err = -EINTR;
-		return err;
+		return netlink_dump_start(idiagnl, skb, nlh,
+					  inet_diag_dump, NULL);
 	}
 
 	return inet_diag_get_exact(skb, nlh);
Index: net-2.6.22/net/netfilter/nf_conntrack_netlink.c
===================================================================
--- net-2.6.22.orig/net/netfilter/nf_conntrack_netlink.c	2007-03-22 23:15:59.000000000 +0100
+++ net-2.6.22/net/netfilter/nf_conntrack_netlink.c	2007-03-22 23:16:07.000000000 +0100
@@ -724,11 +724,8 @@ ctnetlink_get_conntrack(struct sock *ctn
 		if (NFNL_MSG_TYPE(nlh->nlmsg_type) == IPCTNL_MSG_CT_GET_CTRZERO)
 			return -ENOTSUPP;
 #endif
-		err = netlink_dump_start(ctnl, skb, nlh, ctnetlink_dump_table,
-					 ctnetlink_done);
-		if (err == 0)
-			err = -EINTR;
-		return err;
+		return netlink_dump_start(ctnl, skb, nlh, ctnetlink_dump_table,
+					  ctnetlink_done);
 	}
 
 	if (nfattr_bad_size(cda, CTA_MAX, cta_min))
@@ -1266,12 +1263,9 @@ ctnetlink_get_expect(struct sock *ctnl, 
 		return -EINVAL;
 
 	if (nlh->nlmsg_flags & NLM_F_DUMP) {
-		err = netlink_dump_start(ctnl, skb, nlh,
-					 ctnetlink_exp_dump_table,
-					 ctnetlink_done);
-		if (err == 0)
-			err = -EINTR;
-		return err;
+		return netlink_dump_start(ctnl, skb, nlh,
+					  ctnetlink_exp_dump_table,
+					  ctnetlink_done);
 	}
 
 	if (cda[CTA_EXPECT_MASTER-1])
Index: net-2.6.22/net/netlink/af_netlink.c
===================================================================
--- net-2.6.22.orig/net/netlink/af_netlink.c	2007-03-22 23:15:59.000000000 +0100
+++ net-2.6.22/net/netlink/af_netlink.c	2007-03-22 23:16:07.000000000 +0100
@@ -1426,7 +1426,12 @@ int netlink_dump_start(struct sock *ssk,
 
 	netlink_dump(sk);
 	sock_put(sk);
-	return 0;
+
+	/* We successfully started a dump, by returning -EINTR we
+	 * signal the queue mangement to interrupt processing of
+	 * any netlink messages so userspace gets a chance to read
+	 * the results. */
+	return -EINTR;
 }
 
 void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err)
Index: net-2.6.22/net/netlink/genetlink.c
===================================================================
--- net-2.6.22.orig/net/netlink/genetlink.c	2007-03-22 23:15:59.000000000 +0100
+++ net-2.6.22/net/netlink/genetlink.c	2007-03-22 23:16:07.000000000 +0100
@@ -323,11 +323,8 @@ static int genl_rcv_msg(struct sk_buff *
 		if (ops->dumpit == NULL)
 			return -EOPNOTSUPP;
 
-		err = netlink_dump_start(genl_sock, skb, nlh,
-					 ops->dumpit, ops->done);
-		if (err == 0)
-			err = -EINTR;
-		return err;
+		return netlink_dump_start(genl_sock, skb, nlh,
+					  ops->dumpit, ops->done);
 	}
 
 	if (ops->doit == NULL)
Index: net-2.6.22/net/xfrm/xfrm_user.c
===================================================================
--- net-2.6.22.orig/net/xfrm/xfrm_user.c	2007-03-22 23:15:59.000000000 +0100
+++ net-2.6.22/net/xfrm/xfrm_user.c	2007-03-22 23:16:07.000000000 +0100
@@ -1857,7 +1857,7 @@ static int xfrm_user_rcv_msg(struct sk_b
 {
 	struct rtattr *xfrma[XFRMA_MAX];
 	struct xfrm_link *link;
-	int type, min_len, err;
+	int type, min_len;
 
 	type = nlh->nlmsg_type;
 	if (type > XFRM_MSG_MAX)
@@ -1876,10 +1876,7 @@ static int xfrm_user_rcv_msg(struct sk_b
 		if (link->dump == NULL)
 			return -EINVAL;
 
-		err = netlink_dump_start(xfrm_nl, skb, nlh, link->dump, NULL);
-		if (err == 0)
-			err = -EINTR;
-		return err;
+		return netlink_dump_start(xfrm_nl, skb, nlh, link->dump, NULL);
 	}
 
 	memset(xfrma, 0, sizeof(xfrma));

--


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/8] [RESEND] netlink error magngement + others
  2007-03-22 22:18 [PATCH 0/8] [RESEND] netlink error magngement + others Thomas Graf
                   ` (7 preceding siblings ...)
  2007-03-22 22:18 ` [PATCH 8/8] [NETLINK]: Directly return -EINTR from netlink_dump_start() Thomas Graf
@ 2007-03-23  6:31 ` David Miller
  8 siblings, 0 replies; 10+ messages in thread
From: David Miller @ 2007-03-23  6:31 UTC (permalink / raw)
  To: tgraf; +Cc: netdev, kaber

From: Thomas Graf <tgraf@suug.ch>
Date: Thu, 22 Mar 2007 23:18:04 +0100

> I've rediffed all patches and combined the two patchsets into
> one.  Patrick has already queued the NLM_F_REQUEST change for
> nfnetlink.
> 
> [PATCH 0/5] [PATCHSET] Netlink Patches
> Converts westwood and vegas netlink code to use the typesafe
> interface, removes an unused varaible, and move some netlink
> queue management code into the generic layer.
> 
> [PATCH 0/3] [PATCHSET] netlink error management
> This series of patches simplifies the error management and
> signalization of dump starts of netlink_run_queue() message
> handlers. It touches a fair bit of nfnetlink code as the
> error pointer has been passed on to subsystems.

I've applied everything here, that is what works best
for me, thanks.

If I merged something Patrick was going to take care of
I'm sure he can deal with that :-)

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-03-23  6:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-22 22:18 [PATCH 0/8] [RESEND] netlink error magngement + others Thomas Graf
2007-03-22 22:18 ` [PATCH 1/8] [TCP] vegas: Use type safe netlink interface Thomas Graf
2007-03-22 22:18 ` [PATCH 2/8] [TCP] westwood: " Thomas Graf
2007-03-22 22:18 ` [PATCH 3/8] [NETLINK]: Remove unused groups variable Thomas Graf
2007-03-22 22:18 ` [PATCH 4/8] [NETLINK]: Ignore !NLM_F_REQUEST messages directly in netlink_run_queue() Thomas Graf
2007-03-22 22:18 ` [PATCH 5/8] [NETLINK]: Ignore control " Thomas Graf
2007-03-22 22:18 ` [PATCH 6/8] [NETLINK]: Remove error pointer from netlink message handler Thomas Graf
2007-03-22 22:18 ` [PATCH 7/8] [IPv4] diag: Use netlink_run_queue() to process the receive queue Thomas Graf
2007-03-22 22:18 ` [PATCH 8/8] [NETLINK]: Directly return -EINTR from netlink_dump_start() Thomas Graf
2007-03-23  6:31 ` [PATCH 0/8] [RESEND] netlink error magngement + others David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox