[ovs-dev] [PATCH v2 4/5] Changes needed to netlink-socket for MSVC

Alin Serdean aserdean at cloudbasesolutions.com
Tue Jul 29 16:53:16 UTC 2014


Thank you for review and the changes. 

Kind Regards,
Alin.
________________________________________
From: Ben Pfaff [blp at nicira.com]
Sent: Tuesday, July 29, 2014 7:38 PM
To: Alin Serdean
Cc: dev at openvswitch.org
Subject: Re: [ovs-dev] [PATCH v2 4/5] Changes needed to netlink-socket for MSVC

On Tue, Jul 29, 2014 at 03:23:28PM +0000, Alin Serdean wrote:
> Add two functions set_sock_pid_in_kernel and portid_next. This will allow
> the channel identification for the kernel extension to send back messages.
>
> Replace send with WriteFile equivalent and ignore nl_sock_drain for the moment
> under MSVC.
>
> Replace sendmsg and recvmsg with ReadFile and WriteFile equivalents.
>
> On MSVC put in handle instead of fd(sock->fd becomes sock->handle).
>
> Creation of the netlink socket will be replaced by CreateFile equivalent.
>
> Add MAX_STACK_LENGTH for MSVC this will be our maximmum for on-stack copy buffer.
>
> Signed-off-by: Alin Gabriel Serdean <aserdean at cloudbasesolutions.com>

I'm not convinced that this will be the final Netlink implementation
for Windows, but it seems like an OK place to start.

I'm folding in the following, which is mostly coding style change but
the removal of the ovs_mutex_init() call is actually important.

diff --git a/lib/netlink-socket.c b/lib/netlink-socket.c
index d648761..3dbfe59 100644
--- a/lib/netlink-socket.c
+++ b/lib/netlink-socket.c
@@ -53,15 +53,17 @@ static struct ovs_mutex portid_mutex = OVS_MUTEX_INITIALIZER;
 static uint32_t g_last_portid = 0;

 /* Port IDs must be unique! */
-uint32_t
-portid_next() OVS_GUARDED_BY(portid_mutex)
+static uint32_t
+portid_next(void)
+    OVS_GUARDED_BY(portid_mutex)
 {
     g_last_portid++;
     return g_last_portid;
 }

-void
-set_sock_pid_in_kernel(HANDLE handle, uint32_t pid) OVS_GUARDED_BY(portid_mutex)
+static void
+set_sock_pid_in_kernel(HANDLE handle, uint32_t pid)
+    OVS_GUARDED_BY(portid_mutex)
 {
     struct nlmsghdr msg = { 0 };

@@ -73,7 +75,7 @@ set_sock_pid_in_kernel(HANDLE handle, uint32_t pid) OVS_GUARDED_BY(portid_mutex)

     WriteFile(handle, &msg, sizeof(struct nlmsghdr), NULL, NULL);
 }
-#endif
+#endif  /* _WIN32 */

 /* A single (bad) Netlink message can in theory dump out many, many log
  * messages, so the burst size is set quite high here to avoid missing useful
@@ -174,7 +176,6 @@ nl_sock_create(int protocol, struct nl_sock **sockp)
     rcvbuf = 1024 * 1024;
 #ifdef _WIN32
     sock->rcvbuf = rcvbuf;
-    ovs_mutex_init(&portid_mutex);
     ovs_mutex_lock(&portid_mutex);
     sock->pid = portid_next();
     set_sock_pid_in_kernel(sock->handle, sock->pid);



More information about the dev mailing list