diff options
author | Sorin Vinturis <svinturis@cloudbasesolutions.com> | 2015-04-02 19:35:32 +0000 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2015-04-02 12:41:50 -0700 |
commit | 190cf5338956c53596f60b20fa7672ba052ee815 (patch) | |
tree | 4cbd90605677cf32e82b9eabbabb4e06b44bc9cf /lib | |
parent | b3cceba0b7c4013f46b01f8987e8716d7857c6db (diff) | |
download | openvswitch-190cf5338956c53596f60b20fa7672ba052ee815.tar.gz |
datapath-windows: Make GET_PID a separate IOCTL
Added a new IOCTL in order to retrieve the PID from the kernel datapath.
The new method uses a direct and cleaner way, as opposed to the old way
of using a Netlink transaction, avoiding the unnecessary overhead.
Signed-off-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
Reported-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Reported-at: https://github.com/openvswitch/ovs-issues/issues/31
Acked-by: Nithin Raju <nithin@vmware.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Tested-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/netlink-socket.c | 56 |
1 files changed, 10 insertions, 46 deletions
diff --git a/lib/netlink-socket.c b/lib/netlink-socket.c index df889d3eb..fab2a6681 100644 --- a/lib/netlink-socket.c +++ b/lib/netlink-socket.c @@ -273,63 +273,27 @@ nl_sock_destroy(struct nl_sock *sock) #ifdef _WIN32 /* Reads the pid for 'sock' generated in the kernel datapath. The function - * follows a transaction semantic. Eventually this function should call into - * nl_transact. */ + * uses a separate IOCTL instead of a transaction semantic to avoid unnecessary + * message overhead. */ static int get_sock_pid_from_kernel(struct nl_sock *sock) { - struct nl_transaction txn; - struct ofpbuf request; - uint64_t request_stub[128]; - struct ofpbuf reply; - uint64_t reply_stub[128]; - struct ovs_header *ovs_header; - struct nlmsghdr *nlmsg; - uint32_t seq; - int retval; - DWORD bytes; - int ovs_msg_size = sizeof (struct nlmsghdr) + sizeof (struct genlmsghdr) + - sizeof (struct ovs_header); - - ofpbuf_use_stub(&request, request_stub, sizeof request_stub); - txn.request = &request; - ofpbuf_use_stub(&reply, reply_stub, sizeof reply_stub); - txn.reply = &reply; - - seq = nl_sock_allocate_seq(sock, 1); - nl_msg_put_genlmsghdr(&request, 0, OVS_WIN_NL_CTRL_FAMILY_ID, 0, - OVS_CTRL_CMD_WIN_GET_PID, OVS_WIN_CONTROL_VERSION); - nlmsg = nl_msg_nlmsghdr(txn.request); - nlmsg->nlmsg_seq = seq; - - ovs_header = ofpbuf_put_uninit(&request, sizeof *ovs_header); - ovs_header->dp_ifindex = 0; - ovs_header = ofpbuf_put_uninit(&reply, ovs_msg_size); + uint32_t pid = 0; + int retval = 0; + DWORD bytes = 0; - if (!DeviceIoControl(sock->handle, OVS_IOCTL_TRANSACT, - txn.request->data, txn.request->size, - txn.reply->data, txn.reply->size, + if (!DeviceIoControl(sock->handle, OVS_IOCTL_GET_PID, + NULL, 0, &pid, sizeof(pid), &bytes, NULL)) { retval = EINVAL; - goto done; } else { - if (bytes < ovs_msg_size) { + if (bytes < sizeof(pid)) { retval = EINVAL; - goto done; - } - - nlmsg = nl_msg_nlmsghdr(txn.reply); - if (nlmsg->nlmsg_seq != seq) { - retval = EINVAL; - goto done; + } else { + sock->pid = pid; } - sock->pid = nlmsg->nlmsg_pid; } - retval = 0; -done: - ofpbuf_uninit(&request); - ofpbuf_uninit(&reply); return retval; } #endif /* _WIN32 */ |