Commit 62b68e99 authored by Johannes Berg's avatar Johannes Berg Committed by David S. Miller

genetlink: add and use genl_set_err()

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: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c2ebb908
...@@ -351,5 +351,19 @@ static inline struct sk_buff *genlmsg_new(size_t payload, gfp_t flags) ...@@ -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); 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 */ #endif /* __NET_GENERIC_NETLINK_H */
...@@ -879,8 +879,8 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info) ...@@ -879,8 +879,8 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)
if (!IS_ERR(reply)) if (!IS_ERR(reply))
ovs_notify(reply, info, &ovs_dp_flow_multicast_group); ovs_notify(reply, info, &ovs_dp_flow_multicast_group);
else else
netlink_set_err(sock_net(skb->sk)->genl_sock, 0, genl_set_err(sock_net(skb->sk), 0,
ovs_dp_flow_multicast_group.id, PTR_ERR(reply)); ovs_dp_flow_multicast_group.id, PTR_ERR(reply));
return 0; return 0;
err_flow_free: err_flow_free:
...@@ -1326,8 +1326,8 @@ static int ovs_dp_cmd_set(struct sk_buff *skb, struct genl_info *info) ...@@ -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); info->snd_seq, OVS_DP_CMD_NEW);
if (IS_ERR(reply)) { if (IS_ERR(reply)) {
err = PTR_ERR(reply); err = PTR_ERR(reply);
netlink_set_err(sock_net(skb->sk)->genl_sock, 0, genl_set_err(sock_net(skb->sk), 0,
ovs_dp_datapath_multicast_group.id, err); ovs_dp_datapath_multicast_group.id, err);
err = 0; err = 0;
goto unlock; goto unlock;
} }
......
...@@ -34,9 +34,9 @@ static void dp_detach_port_notify(struct vport *vport) ...@@ -34,9 +34,9 @@ static void dp_detach_port_notify(struct vport *vport)
OVS_VPORT_CMD_DEL); OVS_VPORT_CMD_DEL);
ovs_dp_detach_port(vport); ovs_dp_detach_port(vport);
if (IS_ERR(notify)) { if (IS_ERR(notify)) {
netlink_set_err(ovs_dp_get_net(dp)->genl_sock, 0, genl_set_err(ovs_dp_get_net(dp), 0,
ovs_dp_vport_multicast_group.id, ovs_dp_vport_multicast_group.id,
PTR_ERR(notify)); PTR_ERR(notify));
return; return;
} }
......
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