From: Samuel Gauthier Date: Sat, 20 Sep 2014 13:25:23 +0000 (-0700) Subject: datapath: restore OVS_FLOW_CMD_NEW notifications X-Git-Tag: v2.4.0~1366 X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fovs.git;a=commitdiff_plain;h=114fce23a7f1c48c6bd63e75ef698698c4103c97 datapath: restore OVS_FLOW_CMD_NEW notifications Since commit fb5d1e9e127a ("openvswitch: Build flow cmd netlink reply only if needed."), the new flows are not notified to the listeners of OVS_FLOW_MCGROUP. This commit fixes the problem by using the genl function, ie genl_has_listerners() instead of netlink_has_listeners(). Signed-off-by: Samuel Gauthier Signed-off-by: Nicolas Dichtel Signed-off-by: David S. Miller Acked-by: Pravin B Shelar --- diff --git a/acinclude.m4 b/acinclude.m4 index 6e31d88b3..7590621b0 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -353,6 +353,8 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [ OVS_GREP_IFELSE([$KSRC/include/net/checksum.h], [csum_replace4]) OVS_GREP_IFELSE([$KSRC/include/net/checksum.h], [csum_unfold]) + OVS_GREP_IFELSE([$KSRC/include/net/genetlink.h], [genl_has_listeners]) + OVS_GREP_IFELSE([$KSRC/include/net/genetlink.h], [mcgrp_offset]) OVS_GREP_IFELSE([$KSRC/include/net/genetlink.h], [parallel_ops]) OVS_GREP_IFELSE([$KSRC/include/net/gre.h], [gre_cisco_register]) OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_get_be16]) diff --git a/datapath/datapath.c b/datapath/datapath.c index 3e5ff72c7..8a2db9dbd 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -80,11 +80,12 @@ struct genl_multicast_group ovs_dp_vport_multicast_group = { /* Check if need to build a reply message. * OVS userspace sets the NLM_F_ECHO flag if it needs the reply. */ -static bool ovs_must_notify(struct genl_info *info, - const struct genl_multicast_group *grp) +static bool ovs_must_notify(struct genl_family *family, struct genl_info *info, + unsigned int group) { return info->nlhdr->nlmsg_flags & NLM_F_ECHO || - netlink_has_listeners(genl_info_net(info)->genl_sock, GROUP_ID(grp)); + genl_has_listeners(family, genl_info_net(info)->genl_sock, + group); } static void ovs_notify(struct genl_family *family, struct genl_multicast_group *grp, @@ -809,7 +810,8 @@ static struct sk_buff *ovs_flow_cmd_alloc_info(const struct sw_flow_actions *act { struct sk_buff *skb; - if (!always && !ovs_must_notify(info, &ovs_dp_flow_multicast_group)) + if (!always && !ovs_must_notify(&dp_flow_genl_family, info, + GROUP_ID(&ovs_dp_flow_multicast_group))) return NULL; skb = genlmsg_new_unicast(ovs_flow_cmd_msg_size(acts), info, GFP_KERNEL); diff --git a/datapath/linux/compat/include/net/genetlink.h b/datapath/linux/compat/include/net/genetlink.h index 9f425e5ff..43e7af22a 100644 --- a/datapath/linux/compat/include/net/genetlink.h +++ b/datapath/linux/compat/include/net/genetlink.h @@ -105,4 +105,19 @@ static inline struct sk_buff *genlmsg_new_unicast(size_t payload, } #endif +#ifndef HAVE_GENL_HAS_LISTENERS +static inline int genl_has_listeners(struct genl_family *family, + struct sock *sk, unsigned int group) +{ +#ifdef HAVE_MCGRP_OFFSET + if (WARN_ON_ONCE(group >= family->n_mcgrps)) + return -EINVAL; + group = family->mcgrp_offset + group; + return netlink_has_listeners(sk, group); +#else + return netlink_has_listeners(sk, group); +#endif +} +#endif + #endif /* genetlink.h */