netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rémi Denis-Courmont" <remi@remlab.net>
To: netdev@vger.kernel.org
Cc: "Rémi Denis-Courmont" <remi.denis-courmont@nokia.com>
Subject: [PATCH 5/5] Phonet: forward incoming packets
Date: Tue, 15 Sep 2009 14:32:23 +0300	[thread overview]
Message-ID: <1253014343-20326-5-git-send-email-remi@remlab.net> (raw)
In-Reply-To: <1253014343-20326-4-git-send-email-remi@remlab.net>

From: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>

From: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>

Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
---
 net/phonet/af_phonet.c |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
index f0ef6f8..e69c915 100644
--- a/net/phonet/af_phonet.c
+++ b/net/phonet/af_phonet.c
@@ -394,8 +394,40 @@ static int phonet_rcv(struct sk_buff *skb, struct net_device *dev,
 			send_obj_unreachable(skb);
 			send_reset_indications(skb);
 		}
+	} else if (unlikely(skb->pkt_type == PACKET_LOOPBACK))
+		goto out; /* Race between address deletion and loopback */
+	else {
+		/* Phonet packet routing */
+		struct net_device *out_dev;
+
+		out_dev = phonet_route_output(net, pn_sockaddr_get_addr(&sa));
+		if (!out_dev) {
+			LIMIT_NETDEBUG(KERN_WARNING"No Phonet route to %02X\n",
+					pn_sockaddr_get_addr(&sa));
+			goto out;
+		}
+
+		__skb_push(skb, sizeof(struct phonethdr));
+		skb->dev = out_dev;
+		if (out_dev == dev) {
+			LIMIT_NETDEBUG(KERN_ERR"Phonet loop to %02X on %s\n",
+					pn_sockaddr_get_addr(&sa), dev->name);
+			goto out_dev;
+		}
+		/* Some drivers (e.g. TUN) do not allocate HW header space */
+		if (skb_cow_head(skb, out_dev->hard_header_len))
+			goto out_dev;
+
+		if (dev_hard_header(skb, out_dev, ETH_P_PHONET, NULL, NULL,
+					skb->len) < 0)
+			goto out_dev;
+		dev_queue_xmit(skb);
+		dev_put(out_dev);
+		return NET_RX_SUCCESS;
 	}
 
+out_dev:
+	dev_put(skb->dev);
 out:
 	kfree_skb(skb);
 	return NET_RX_DROP;
-- 
1.6.0.4


  reply	other threads:[~2009-09-15 11:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-15 11:30 [PATCH 0/5] Phonet: basic routing support Rémi Denis-Courmont
2009-09-15 11:32 ` [PATCH 1/5] Phonet: error on broadcast sending (unimplemented) Rémi Denis-Courmont
2009-09-15 11:32   ` [PATCH 2/5] Phonet: routing table backend Rémi Denis-Courmont
2009-09-15 11:32     ` [PATCH 3/5] Phonet: routing table Netlink interface Rémi Denis-Courmont
2009-09-15 11:32       ` [PATCH 4/5] Phonet: route outgoing packets Rémi Denis-Courmont
2009-09-15 11:32         ` Rémi Denis-Courmont [this message]
2009-09-15 21:22 ` [PATCH 0/5] Phonet: basic routing support David Miller
  -- strict thread matches above, loose matches on Subject: below --
2009-10-14 10:47 [PATCH net-next " Rémi Denis-Courmont
2009-10-14 10:48 ` [PATCH 1/5] Phonet: deliver broadcast packets to broadcast sockets Rémi Denis-Courmont
2009-10-14 10:48   ` [PATCH 2/5] Phonet: routing table backend Rémi Denis-Courmont
2009-10-14 10:48     ` [PATCH 3/5] Phonet: routing table Netlink interface Rémi Denis-Courmont
2009-10-14 10:48       ` [PATCH 4/5] Phonet: route outgoing packets Rémi Denis-Courmont
2009-10-14 10:48         ` [PATCH 5/5] Phonet: forward incoming packets 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=1253014343-20326-5-git-send-email-remi@remlab.net \
    --to=remi@remlab.net \
    --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).