netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@redhat.com>
To: "Rémi Denis-Courmont" <remi.denis-courmont@nokia.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH 08/14] Phonet: receive path socket lookup
Date: Tue, 16 Sep 2008 13:52:05 -0300	[thread overview]
Message-ID: <20080916165205.GK8702@ghostprotocols.net> (raw)
In-Reply-To: <1221577694-4513-8-git-send-email-remi.denis-courmont@nokia.com>

Em Tue, Sep 16, 2008 at 06:08:08PM +0300, Rémi Denis-Courmont escreveu:
> This delivers received packet to the right socket, if any.
> 
> Signed-off-by: Remi Denis-Courmont <remi.denis-courmont@nokia.com>
> ---
>  include/net/phonet/phonet.h |    1 +
>  net/phonet/af_phonet.c      |   13 ++++++++++++-
>  2 files changed, 13 insertions(+), 1 deletions(-)
> 
> diff --git a/include/net/phonet/phonet.h b/include/net/phonet/phonet.h
> index e0fa080..8e7e42d 100644
> --- a/include/net/phonet/phonet.h
> +++ b/include/net/phonet/phonet.h
> @@ -35,6 +35,7 @@
>   */
>  struct pn_sock {
>  	struct sock	sk;
> +	int		(*handler)(struct sock *, struct sk_buff *);
>  	u16		sobject;
>  	u8		resource;
>  };
> diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
> index 12c72e1..317f30c 100644
> --- a/net/phonet/af_phonet.c
> +++ b/net/phonet/af_phonet.c
> @@ -96,7 +96,9 @@ static int phonet_rcv(struct sk_buff *skb, struct net_device *dev,
>  			struct net_device *orig_dev)
>  {
>  	struct phonethdr *ph;
> +	struct sock *sk;
>  	struct sockaddr_pn sa;
> +	int err;
>  	u16 len;
>  
>  	if (dev_net(dev) != &init_net)
> @@ -120,7 +122,15 @@ static int phonet_rcv(struct sk_buff *skb, struct net_device *dev,
>  	if (pn_sockaddr_get_addr(&sa) == 0)
>  		goto out; /* currently, we cannot be device 0 */
>  
> -	/* TODO: put packets to sockets backlog */
> +	sk = pn_find_sock_by_sa(&sa);
> +	if (sk == NULL)
> +		goto out;
> +
> +	/* Push data to the socket (or other sockets connected to it). */
> +	err = pn_sk(sk)->handler(sk, skb);

wouldn't be nice to use sk_backlog_rcv() and sk_receive_skb()?

> +	sock_put(sk);
> +
> +	return err ? NET_RX_DROP : NET_RX_SUCCESS;
>  
>  out:
>  	kfree_skb(skb);
> @@ -196,6 +206,7 @@ static int __init phonet_init(void)
>  {
>  	int err;
>  
> +	phonet_socket_init();
>  	err = sock_register(&phonet_proto_family);
>  	if (err) {
>  		printk(KERN_ALERT
> -- 
> 1.5.4.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2008-09-16 17:00 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-16 14:57 [PATCH 00/14] [RFC] Phonet protocol stack Rémi Denis-Courmont
2008-09-16 15:08 ` [PATCH 01/14] Phonet global definitions Rémi Denis-Courmont
2008-09-17  4:31   ` Simon Horman
2008-09-17 11:05     ` Rémi Denis-Courmont
2008-09-16 15:08 ` [PATCH 02/14] Phonet: add CONFIG_PHONET Rémi Denis-Courmont
2008-09-16 16:06   ` Arnaldo Carvalho de Melo
2008-09-16 15:08 ` [PATCH 03/14] Phonet: build the net/phonet/ directory Rémi Denis-Courmont
2008-09-16 16:06   ` Arnaldo Carvalho de Melo
2008-09-17  4:52     ` Simon Horman
2008-09-17  8:44       ` Rémi Denis-Courmont
2008-09-16 15:08 ` [PATCH 04/14] Phonet: PF_PHONET protocol family support Rémi Denis-Courmont
2008-09-16 16:17   ` Arnaldo Carvalho de Melo
2008-09-17 10:48     ` Rémi Denis-Courmont
2008-09-16 15:08 ` [PATCH 05/14] Phonet: network device and address handling Rémi Denis-Courmont
2008-09-16 16:41   ` Arnaldo Carvalho de Melo
2008-09-16 15:08 ` [PATCH 06/14] Phonet: Netlink interface Rémi Denis-Courmont
2008-09-16 15:08 ` [PATCH 07/14] Phonet: common socket glue Rémi Denis-Courmont
2008-09-16 16:50   ` Arnaldo Carvalho de Melo
2008-09-16 15:08 ` [PATCH 08/14] Phonet: receive path socket lookup Rémi Denis-Courmont
2008-09-16 16:52   ` Arnaldo Carvalho de Melo [this message]
2008-09-19  6:20     ` Rémi Denis-Courmont
2008-09-16 15:08 ` [PATCH 09/14] Phonet: allocate and initialize new sockets Rémi Denis-Courmont
2008-09-16 16:53   ` Arnaldo Carvalho de Melo
2008-09-16 18:42   ` Pavel Emelyanov
2008-09-17  8:30     ` Rémi Denis-Courmont
2008-09-19 10:14       ` Pavel Emelyanov
2008-09-16 15:08 ` [PATCH 10/14] Phonet: Phonet datagram transport protocol Rémi Denis-Courmont
2008-09-16 17:06   ` Arnaldo Carvalho de Melo
2008-09-19  6:33     ` Rémi Denis-Courmont
2008-09-19 15:24       ` [PATCH]: net: Use hton[sl]() was " Arnaldo Carvalho de Melo
2008-09-21  5:21         ` David Miller
2008-11-14  8:32         ` Piet Delaney
2008-09-16 15:08 ` [PATCH 11/14] Phonet: provide MAC header operations Rémi Denis-Courmont
2008-09-16 15:08 ` [PATCH 12/14] Phonet: proc interface for port range Rémi Denis-Courmont
2008-09-16 15:08 ` [PATCH 13/14] Phonet: emit errors when a packet cannot be delivered locally Rémi Denis-Courmont
2008-09-16 17:11   ` Arnaldo Carvalho de Melo
2008-09-16 15:08 ` [PATCH 14/14] Phonet: kernel documentation Rémi Denis-Courmont
2008-09-16 20:09 ` [PATCH 00/14] [RFC] Phonet protocol stack Marcel Holtmann
2008-09-17 13:52   ` Rémi Denis-Courmont
2008-09-17  4:15 ` Dan Williams
2008-09-19  7:25   ` Rémi Denis-Courmont

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=20080916165205.GK8702@ghostprotocols.net \
    --to=acme@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=remi.denis-courmont@nokia.com \
    /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).