linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: courtney.cavin@sonymobile.com (Courtney Cavin)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] net: add Qualcomm IPC router
Date: Wed, 16 Dec 2015 15:28:50 -0800	[thread overview]
Message-ID: <20151216232849.GF28026@sonymobile.com> (raw)
In-Reply-To: <1449866519-14551-1-git-send-email-bjorn.andersson@sonymobile.com>

On Fri, Dec 11, 2015 at 09:41:59PM +0100, Bjorn Andersson wrote:
> From: Courtney Cavin <courtney.cavin@sonymobile.com>
> 
> Add an implementation of Qualcomm's IPC router protocol, used to
> communicate with service providing remote processors.
> 
> Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> ---
[...]
> +static int qrtr_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
> +{
> +       DECLARE_SOCKADDR(struct sockaddr_qrtr *, addr, msg->msg_name);
> +       int (*enqueue_fn)(struct qrtr_node *, struct sk_buff *);
> +       struct qrtr_sock *ipc = qrtr_sk(sock->sk);
> +       struct sock *sk = sock->sk;
> +       struct qrtr_node *node;
> +       struct qrtr_hdr *hdr;
> +       struct sk_buff *skb;
> +       size_t plen;
> +       int rc;
> +
> +       if (msg->msg_flags & ~(MSG_DONTWAIT))
> +               return -EINVAL;
> +
> +       if (len > 65535)
> +               return -EMSGSIZE;
> +
> +       lock_sock(sk);
> +
> +       if (addr) {
> +               if (msg->msg_namelen < sizeof(*addr)) {
> +                       release_sock(sk);
> +                       return -EINVAL;
> +               }
> +
> +               if (addr->sq_family != AF_QIPCRTR) {
> +                       release_sock(sk);
> +                       return -EINVAL;
> +               }
> +
> +               rc = qrtr_autobind(sock);
> +               if (rc) {
> +                       release_sock(sk);
> +                       return rc;
> +               }
> +       } else if (sk->sk_state == TCP_ESTABLISHED) {
> +               addr = &ipc->peer;
> +       } else {
> +               release_sock(sk);
> +               return -ENOTCONN;
> +       }
> +
> +       node = NULL;
> +       if (addr->sq_node == QRTR_NODE_BCAST) {
> +               enqueue_fn = qrtr_bcast_enqueue;
> +       } else if (addr->sq_node == 0 || addr->sq_node == ipc->us.sq_node) {

'addr->sq_node == 0' should be removed from this if-condition.  Zero is
a valid node id.  Clients needing the local address can use
getsockname(2).

> +               enqueue_fn = qrtr_local_enqueue;
> +       } else {
> +               enqueue_fn = qrtr_node_enqueue;
> +               node = qrtr_node_lookup(addr->sq_node);
> +               if (!node) {
> +                       release_sock(sk);
> +                       return -ECONNRESET;
> +               }
> +       }

-Courtney

      parent reply	other threads:[~2015-12-16 23:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-11 20:41 [PATCH] net: add Qualcomm IPC router Bjorn Andersson
2015-12-15 21:01 ` David Miller
2015-12-15 21:13   ` Dan Williams
2015-12-15 21:14     ` Dan Williams
2015-12-17  0:01   ` Courtney Cavin
2015-12-17  0:16     ` David Miller
2015-12-16 23:28 ` Courtney Cavin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151216232849.GF28026@sonymobile.com \
    --to=courtney.cavin@sonymobile.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).