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 1/5] Phonet: deliver broadcast packets to broadcast sockets
Date: Wed, 14 Oct 2009 13:48:27 +0300 [thread overview]
Message-ID: <1255517311-19527-1-git-send-email-remi@remlab.net> (raw)
In-Reply-To: <06dcdf33b2a0132b2a05c3220735a81e@chewa.net>
From: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
---
include/net/phonet/phonet.h | 1 +
net/phonet/af_phonet.c | 6 ++++++
net/phonet/socket.c | 21 +++++++++++++++++++++
3 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/include/net/phonet/phonet.h b/include/net/phonet/phonet.h
index d43f71b..fdb05fa 100644
--- a/include/net/phonet/phonet.h
+++ b/include/net/phonet/phonet.h
@@ -47,6 +47,7 @@ static inline struct pn_sock *pn_sk(struct sock *sk)
extern const struct proto_ops phonet_dgram_ops;
struct sock *pn_find_sock_by_sa(struct net *net, const struct sockaddr_pn *sa);
+void pn_deliver_sock_broadcast(struct net *net, struct sk_buff *skb);
void phonet_get_local_port_range(int *min, int *max);
void pn_sock_hash(struct sock *sk);
void pn_sock_unhash(struct sock *sk);
diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
index c711d58..b113fe0 100644
--- a/net/phonet/af_phonet.c
+++ b/net/phonet/af_phonet.c
@@ -369,6 +369,12 @@ static int phonet_rcv(struct sk_buff *skb, struct net_device *dev,
pn_skb_get_dst_sockaddr(skb, &sa);
+ /* check if this is broadcasted */
+ if (pn_sockaddr_get_addr(&sa) == PNADDR_BROADCAST) {
+ pn_deliver_sock_broadcast(net, skb);
+ goto out;
+ }
+
/* check if we are the destination */
if (phonet_address_lookup(net, pn_sockaddr_get_addr(&sa)) == 0) {
/* Phonet packet input */
diff --git a/net/phonet/socket.c b/net/phonet/socket.c
index aa5b5a9..8c84190 100644
--- a/net/phonet/socket.c
+++ b/net/phonet/socket.c
@@ -94,7 +94,28 @@ struct sock *pn_find_sock_by_sa(struct net *net, const struct sockaddr_pn *spn)
spin_unlock_bh(&pnsocks.lock);
return rval;
+}
+
+/* Deliver a broadcast packet (only in bottom-half) */
+void pn_deliver_sock_broadcast(struct net *net, struct sk_buff *skb)
+{
+ struct hlist_node *node;
+ struct sock *sknode;
+
+ spin_lock(&pnsocks.lock);
+ sk_for_each(sknode, node, &pnsocks.hlist) {
+ struct sk_buff *clone;
+
+ if (!net_eq(sock_net(sknode), net))
+ continue;
+ if (!sock_flag(sknode, SOCK_BROADCAST))
+ continue;
+ clone = skb_clone(skb, GFP_ATOMIC);
+ if (clone)
+ sk_receive_skb(sknode, clone, 0);
+ }
+ spin_unlock(&pnsocks.lock);
}
void pn_sock_hash(struct sock *sk)
--
1.6.0.4
next prev parent reply other threads:[~2009-10-14 10:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-14 10:47 [PATCH net-next 0/5] Phonet: basic routing support Rémi Denis-Courmont
2009-10-14 10:48 ` Rémi Denis-Courmont [this message]
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
2009-10-14 22:08 ` [PATCH net-next 0/5] Phonet: basic routing support David Miller
2009-10-15 12:58 ` Rémi Denis-Courmont
2009-10-15 13:00 ` [PATCH] Phonet: hold socket before giving it to sk_deliver_skb() Rémi Denis-Courmont
2009-10-15 14:52 ` Eric Dumazet
2009-10-15 19:29 ` David Miller
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=1255517311-19527-1-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).