Skip to content

Commit 62b68e9

Browse files
jmberg-inteldavem330
authored andcommitted
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: Johannes Berg <johannes.berg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c2ebb90 commit 62b68e9

3 files changed

Lines changed: 21 additions & 7 deletions

File tree

‎include/net/genetlink.h‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,5 +351,19 @@ static inline struct sk_buff *genlmsg_new(size_t payload, gfp_t flags)
351351
return nlmsg_new(genlmsg_total_size(payload), flags);
352352
}
353353

354+
/**
355+
* genl_set_err - report error to genetlink broadcast listeners
356+
* @net: the network namespace to report the error to
357+
* @portid: the PORTID of a process that we want to skip (if any)
358+
* @group: the broadcast group that will notice the error
359+
* @code: error code, must be negative (as usual in kernelspace)
360+
*
361+
* This function returns the number of broadcast listeners that have set the
362+
* NETLINK_RECV_NO_ENOBUFS socket option.
363+
*/
364+
static inline int genl_set_err(struct net *net, u32 portid, u32 group, int code)
365+
{
366+
return netlink_set_err(net->genl_sock, portid, group, code);
367+
}
354368

355369
#endif /* __NET_GENERIC_NETLINK_H */

‎net/openvswitch/datapath.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -879,8 +879,8 @@ static int ovs_flow_cmd_new_or_set(struct sk_buff *skb, struct genl_info *info)
879879
if (!IS_ERR(reply))
880880
ovs_notify(reply, info, &ovs_dp_flow_multicast_group);
881881
else
882-
netlink_set_err(sock_net(skb->sk)->genl_sock, 0,
883-
ovs_dp_flow_multicast_group.id, PTR_ERR(reply));
882+
genl_set_err(sock_net(skb->sk), 0,
883+
ovs_dp_flow_multicast_group.id, PTR_ERR(reply));
884884
return 0;
885885

886886
err_flow_free:
@@ -1326,8 +1326,8 @@ static int ovs_dp_cmd_set(struct sk_buff *skb, struct genl_info *info)
13261326
info->snd_seq, OVS_DP_CMD_NEW);
13271327
if (IS_ERR(reply)) {
13281328
err = PTR_ERR(reply);
1329-
netlink_set_err(sock_net(skb->sk)->genl_sock, 0,
1330-
ovs_dp_datapath_multicast_group.id, err);
1329+
genl_set_err(sock_net(skb->sk), 0,
1330+
ovs_dp_datapath_multicast_group.id, err);
13311331
err = 0;
13321332
goto unlock;
13331333
}

‎net/openvswitch/dp_notify.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ static void dp_detach_port_notify(struct vport *vport)
3434
OVS_VPORT_CMD_DEL);
3535
ovs_dp_detach_port(vport);
3636
if (IS_ERR(notify)) {
37-
netlink_set_err(ovs_dp_get_net(dp)->genl_sock, 0,
38-
ovs_dp_vport_multicast_group.id,
39-
PTR_ERR(notify));
37+
genl_set_err(ovs_dp_get_net(dp), 0,
38+
ovs_dp_vport_multicast_group.id,
39+
PTR_ERR(notify));
4040
return;
4141
}
4242

0 commit comments

Comments
 (0)