Re: [PATCH v13 net-next 1/1] hv_sock: introduce Hyper-V Sockets
From: David Miller <davem@davemloft.net>
Date: 2016-06-30 12:56:08
Also in:
lkml
From: Dexuan Cui <decui@microsoft.com> Date: Wed, 29 Jun 2016 11:30:40 +0000
quoted hunk ↗ jump to hunk
@@ -1509,4 +1509,18 @@ static inline void commit_rd_index(struct vmbus_channel *channel) } +struct vmpipe_proto_header { + u32 pkt_type;
It is wasteful to have two empty lines before this structure definition, one is sufficient.
+/* + * This is the address fromat of Hyper-V Sockets. + * Note: here we just borrow the kernel's built-in type uuid_le. When + * an application calls bind() or connect(), the 2 members of struct + * sockaddr_hv must be of GUID. + * The GUID format differs from the UUID format only in the byte order of + * the first 3 fields. Refer to: + * https://en.wikipedia.org/wiki/Globally_unique_identifier + */
Comments should be of the form: /* Like * this. */ Rather than: /* * Like * this. */
+ __le16 reserved; /* Must be Zero */
Why does an ignored, reserved, field need an endianness? Just use plain "u16" for this.
+static +void hvsock_enqueue_accept(struct sock *listener, struct sock *connected)
Don't split the declaration after "static" with a newline, instead use: ==================== static void hvsock_enqueue_accept(struct sock *listener, struct sock *connected) ====================
+{
+ struct hvsock_sock *hvlistener;
+ struct hvsock_sock *hvconnected;Please order local variables from logest to shortest line.
+static struct sock *hvsock_dequeue_accept(struct sock *listener)
+{
+ struct hvsock_sock *hvlistener;
+ struct hvsock_sock *hvconnected;Likewise.
+static void hvsock_sk_destruct(struct sock *sk)
+{
+ struct hvsock_sock *hvsk = sk_to_hvsock(sk);
+ struct vmbus_channel *channel = hvsk->channel;Likewise.
+/* This function runs in the tasklet context of process_chn_event() */
+static void hvsock_on_channel_cb(void *ctx)
+{
+ struct sock *sk = (struct sock *)ctx;
+ struct hvsock_sock *hvsk = sk_to_hvsock(sk);
+ struct vmbus_channel *channel = hvsk->channel;
+ bool can_read, can_write;Likewise.
+static int hvsock_open_connection(struct vmbus_channel *channel)
+{
+ struct hvsock_sock *hvsk, *new_hvsk;
+ struct sockaddr_hv hv_addr;
+ struct sock *sk, *new_sk;
+ unsigned char conn_from_host;Likewise.
+static int hvsock_connect_wait(struct socket *sock,
+ int flags, int current_ret)
+{
+ struct sock *sk = sock->sk;
+ struct hvsock_sock *hvsk = sk_to_hvsock(sk);Likewise.