Alin, I will send out a rebased version. (no short cuts here:-) ) Thank you, Eitan
-----Original Message----- From: Alin Serdean [mailto:aserd...@cloudbasesolutions.com] Sent: Thursday, September 11, 2014 1:27 AM To: Eitan Eliahu; dev@openvswitch.org Subject: RE: [ovs-dev] [PATCH v3] Netlink_socket.c Join/Unjoin an MC group for event subscription Hi Eitan, Still cannot get the patch to apply: $ git apply patch1 error: patch failed: datapath-windows/include/OvsDpInterfaceExt.h:70 error: datapath-windows/include/OvsDpInterfaceExt.h: patch does not apply This part: @@ -70,6 +70,14 @@ /* Commands available under the OVS_WIN_CONTROL_FAMILY. */ enum ovs_win_control_cmd { OVS_CTRL_CMD_WIN_GET_PID, + OVS_CTRL_CMD_WIN_PEND_REQ, + OVS_CTRL_CMD_MC_SUBSCRIBE_REQ, +}; + +/* NL Attributes for joining/unjoining an MC group */ enum +ovs_nl_mcast_attr { + OVS_NL_ATTR_MCAST_GRP, /* (UINT32) Join an MC group */ + OVS_NL_ATTR_MCAST_JOIN, /* (UINT8) 1/0 - Join/Unjoin */ }; #endif /* __OVS_DP_INTERFACE_EXT_H_ */ Should be: diff --git a/datapath-windows/include/OvsDpInterfaceExt.h b/datapath-windows/inc lude/OvsDpInterfaceExt.h index ab2088a..e7f1184 100644 --- a/datapath-windows/include/OvsDpInterfaceExt.h +++ b/datapath-windows/include/OvsDpInterfaceExt.h @@ -70,7 +70,14 @@ /* Commands available under the OVS_WIN_CONTROL_FAMILY. */ enum ovs_win_control_cmd { OVS_CTRL_CMD_WIN_GET_PID, - OVS_CTRL_CMD_WIN_PEND_REQ + OVS_CTRL_CMD_WIN_PEND_REQ, + OVS_CTRL_CMD_MC_SUBSCRIBE_REQ, }; +/* NL Attributes for joining/unjoining an MC group */ enum +ovs_nl_mcast_attr { + OVS_NL_ATTR_MCAST_GRP, /* (UINT32) Join an MC group */ + OVS_NL_ATTR_MCAST_JOIN, /* (UINT8) 1/0 - Join/Unjoin */ }; + #endif /* __OVS_DP_INTERFACE_EXT_H_ */ -----Mesaj original----- De la: dev [mailto:dev-boun...@openvswitch.org] În numele Eitan Eliahu Trimis: Thursday, September 11, 2014 8:57 AM Către: dev@openvswitch.org Subiect: [ovs-dev] [PATCH v3] Netlink_socket.c Join/Unjoin an MC group for event subscription Use a specific out of band device control to subscribe/unsubscribe a socket to the driver event queue for notification. Signed-off-by: Eitan Eliahu <elia...@vmware.com> Acked-by: Nithin Raju <nit...@vmware.com> Acked-by: Saurabh Shah <ssaur...@vmware.com> Acked-by: Ankur Sharma <ankursha...@vmware.com> Acked-by: Alin Gabriel Serdean <aserd...@cloudbasesolutions.com> --- v1 CodingStyle fix alignment v2 Remove white space, rebase, add comment for attr size, seq starts with 1 v3 Remove seq from nl_sock_send() --- datapath-windows/include/OvsDpInterfaceExt.h | 8 +++ lib/netlink-socket.c | 82 +++++++++++++--------------- 2 files changed, 47 insertions(+), 43 deletions(-) diff --git a/datapath-windows/include/OvsDpInterfaceExt.h b/datapath-windows/include/OvsDpInterfaceExt.h index 73dfcbe..877b2ad 100644 --- a/datapath-windows/include/OvsDpInterfaceExt.h +++ b/datapath-windows/include/OvsDpInterfaceExt.h @@ -70,6 +70,14 @@ /* Commands available under the OVS_WIN_CONTROL_FAMILY. */ enum ovs_win_control_cmd { OVS_CTRL_CMD_WIN_GET_PID, + OVS_CTRL_CMD_WIN_PEND_REQ, + OVS_CTRL_CMD_MC_SUBSCRIBE_REQ, +}; + +/* NL Attributes for joining/unjoining an MC group */ enum +ovs_nl_mcast_attr { + OVS_NL_ATTR_MCAST_GRP, /* (UINT32) Join an MC group */ + OVS_NL_ATTR_MCAST_JOIN, /* (UINT8) 1/0 - Join/Unjoin */ }; #endif /* __OVS_DP_INTERFACE_EXT_H_ */ diff --git a/lib/netlink-socket.c b/lib/netlink-socket.c index a6be186..7cce4a9 100644 --- a/lib/netlink-socket.c +++ b/lib/netlink-socket.c @@ -319,6 +319,33 @@ done: } #endif /* _WIN32 */ +#ifdef _WIN32 +static int __inline +nl_sock_mcgroup(struct nl_sock *sock, unsigned int multicast_group, +bool join) { + struct ofpbuf request; + uint64_t request_stub[128]; + struct ovs_header *ovs_header; + struct nlmsghdr *nlmsg; + int error; + + ofpbuf_use_stub(&request, request_stub, sizeof request_stub); + + nl_msg_put_genlmsghdr(&request, 0, OVS_WIN_NL_CTRL_FAMILY_ID, 0, + OVS_CTRL_CMD_MC_SUBSCRIBE_REQ, + OVS_WIN_CONTROL_VERSION); + + ovs_header = ofpbuf_put_uninit(&request, sizeof *ovs_header); + ovs_header->dp_ifindex = 0; + + nl_msg_put_u32(&request, OVS_NL_ATTR_MCAST_GRP, multicast_group); + nl_msg_put_u8(&request, OVS_NL_ATTR_MCAST_JOIN, join ? 1 : 0); + + error = nl_sock_send(sock, &request, true); + ofpbuf_uninit(&request); + return error; +} +#endif /* Tries to add 'sock' as a listener for 'multicast_group'. Returns 0 if * successful, otherwise a positive errno value. * @@ -334,31 +361,12 @@ int nl_sock_join_mcgroup(struct nl_sock *sock, unsigned int multicast_group) { #ifdef _WIN32 -#define OVS_VPORT_MCGROUP_FALLBACK_ID 33 - struct ofpbuf msg_buf; - struct message_multicast - { - struct nlmsghdr; - /* if true, join; if else, leave */ - unsigned char join; - unsigned int groupId; - }; - - struct message_multicast msg = { 0 }; - - msg.nlmsg_len = sizeof(struct message_multicast); - msg.nlmsg_type = OVS_VPORT_MCGROUP_FALLBACK_ID; - msg.nlmsg_flags = 0; - msg.nlmsg_seq = 0; - msg.nlmsg_pid = sock->pid; - - msg.join = 1; - msg.groupId = multicast_group; - msg_buf.base_ = &msg; - msg_buf.data_ = &msg; - msg_buf.size_ = msg.nlmsg_len; - - nl_sock_send__(sock, &msg_buf, msg.nlmsg_seq, 0); + int error = nl_sock_mcgroup(sock, multicast_group, true); + if (error) { + VLOG_WARN("could not join multicast group %u (%s)", + multicast_group, ovs_strerror(errno)); + return errno; + } #else if (setsockopt(sock->fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &multicast_group, sizeof multicast_group) < 0) { @@ -384,24 +392,12 @@ int nl_sock_leave_mcgroup(struct nl_sock *sock, unsigned int multicast_group) { #ifdef _WIN32 - struct ofpbuf msg_buf; - struct message_multicast - { - struct nlmsghdr; - /* if true, join; if else, leave*/ - unsigned char join; - }; - - struct message_multicast msg = { 0 }; - nl_msg_put_nlmsghdr(&msg, sizeof(struct message_multicast), - multicast_group, 0); - msg.join = 0; - - msg_buf.base_ = &msg; - msg_buf.data_ = &msg; - msg_buf.size_ = msg.nlmsg_len; - - nl_sock_send__(sock, &msg_buf, msg.nlmsg_seq, 0); + int error = nl_sock_mcgroup(sock, multicast_group, false); + if (error) { + VLOG_WARN("could not leave multicast group %u (%s)", + multicast_group, ovs_strerror(errno)); + return errno; + } #else if (setsockopt(sock->fd, SOL_NETLINK, NETLINK_DROP_MEMBERSHIP, &multicast_group, sizeof multicast_group) < 0) { -- 1.9.4.msysgit.0 _______________________________________________ dev mailing list dev@openvswitch.org https://urldefense.proofpoint.com/v1/url?u=http://openvswitch.org/mailman/listinfo/dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=yTvML8OxA42Jb6ViHe7fUXbvPVOYDPVq87w43doxtlY%3D%0A&m=hs46fzgvdd6k7mRCoeZgHPK%2F1SPYuWZLIbxvzukoG94%3D%0A&s=a51968e453c40264b678768a646a5759c7d969b446296bc5fcbd3825c4a8aa68 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev