netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: netdev@vger.kernel.org
Cc: Johannes Berg <johannes.berg@intel.com>
Subject: [PATCH 7/9] genetlink: add and use genl_set_err()
Date: Tue, 19 Nov 2013 15:19:37 +0100	[thread overview]
Message-ID: <1384870779-17571-8-git-send-email-johannes@sipsolutions.net> (raw)
In-Reply-To: <1384870779-17571-1-git-send-email-johannes@sipsolutions.net>

From: Johannes Berg <johannes.berg@intel.com>

Add a static inline to generic netlink to wrap netlink_set_err()
to make it easier to use here - use it in openvswitch (the only
generic netlink user of netlink_set_err()).

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 include/net/genetlink.h     | 14 ++++++++++++++
 net/openvswitch/datapath.c  |  8 ++++----
 net/openvswitch/dp_notify.c |  6 +++---
 3 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/include/net/genetlink.h b/include/net/genetlink.h
index d8a8b1f..11ac77f 100644
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -351,5 +351,19 @@ static inline struct sk_buff *genlmsg_new(size_t payload, gfp_t flags)
 	return nlmsg_new(genlmsg_total_size(payload), flags);
 }
 
+/**
+ * genl_set_err - report error to genetlink broadcast listeners
+ * @net: the network namespace to report the error to
+ * @portid: the PORTID of a process that we want to skip (if any)
+ * @group: the broadcast group that will notice the error
+ * @code: error code, must be negative (as usual in kernelspace)
+ *
+ * This function returns the number of broadcast listeners that have set the
+ * NETLINK_RECV_NO_ENOBUFS socket option.
+ */
+static inline int genl_set_err(struct net *net, u32 portid, u32 group, int code)
+{
+	return netlink_set_err(net->genl_sock, portid, group, code);
+}
 
 #endif	/* __NET_GENERIC_NETLINK_H */
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 8ec8b73..3e2bb15 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -879,8 +879,8 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)
 	if (!IS_ERR(reply))
 		ovs_notify(reply, info, &ovs_dp_flow_multicast_group);
 	else
-		netlink_set_err(sock_net(skb->sk)->genl_sock, 0,
-				ovs_dp_flow_multicast_group.id, PTR_ERR(reply));
+		genl_set_err(sock_net(skb->sk), 0,
+			     ovs_dp_flow_multicast_group.id, PTR_ERR(reply));
 	return 0;
 
 err_flow_free:
@@ -1326,8 +1326,8 @@ static int ovs_dp_cmd_set(struct sk_buff *skb, struct genl_info *info)
 				      info->snd_seq, OVS_DP_CMD_NEW);
 	if (IS_ERR(reply)) {
 		err = PTR_ERR(reply);
-		netlink_set_err(sock_net(skb->sk)->genl_sock, 0,
-				ovs_dp_datapath_multicast_group.id, err);
+		genl_set_err(sock_net(skb->sk), 0,
+			     ovs_dp_datapath_multicast_group.id, err);
 		err = 0;
 		goto unlock;
 	}
diff --git a/net/openvswitch/dp_notify.c b/net/openvswitch/dp_notify.c
index 5c2dab2..3d55ead 100644
--- a/net/openvswitch/dp_notify.c
+++ b/net/openvswitch/dp_notify.c
@@ -34,9 +34,9 @@ static void dp_detach_port_notify(struct vport *vport)
 					  OVS_VPORT_CMD_DEL);
 	ovs_dp_detach_port(vport);
 	if (IS_ERR(notify)) {
-		netlink_set_err(ovs_dp_get_net(dp)->genl_sock, 0,
-				ovs_dp_vport_multicast_group.id,
-				PTR_ERR(notify));
+		genl_set_err(ovs_dp_get_net(dp), 0,
+			     ovs_dp_vport_multicast_group.id,
+			     PTR_ERR(notify));
 		return;
 	}
 
-- 
1.8.4.rc3

  parent reply	other threads:[~2013-11-19 14:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-19 14:19 [PATCH 0/9] genetlink: clean up multicast group APIs Johannes Berg
2013-11-19 14:19 ` [PATCH 1/9] genetlink: only pass array to genl_register_family_with_ops() Johannes Berg
2013-11-19 14:19 ` [PATCH 2/9] drop_monitor/genetlink: use proper genetlink multicast APIs Johannes Berg
2013-11-19 14:19 ` [PATCH 3/9] quota/genetlink: " Johannes Berg
2013-11-19 14:19 ` [PATCH 4/9] hsr: don't call genl_unregister_mc_group() Johannes Berg
2013-11-19 14:19 ` [PATCH 5/9] genetlink: remove genl_unregister_mc_group() Johannes Berg
2013-11-19 14:19 ` [PATCH 6/9] genetlink: remove family pointer from genl_multicast_group Johannes Berg
2013-11-19 14:19 ` Johannes Berg [this message]
2013-11-19 14:19 ` [PATCH 8/9] genetlink: pass family to functions using groups Johannes Berg
2013-11-19 14:19 ` [PATCH 9/9] genetlink: make multicast groups const, prevent abuse Johannes Berg
2013-11-19 21:40 ` [PATCH 0/9] genetlink: clean up multicast group APIs David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1384870779-17571-8-git-send-email-johannes@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=johannes.berg@intel.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).