diff options
author | Rémi Denis-Courmont <remi.denis-courmont@nokia.com> | 2009-10-13 20:48:27 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-10-14 18:04:15 -0400 |
commit | f14001fcd7bd03983c872810a3b11af4148bae72 (patch) | |
tree | 11b283fe73d751f584d34b684fbfcb077c37f096 | |
parent | 67ca0e5fa884f483d655ef19f22ad8509138dd3e (diff) |
Phonet: deliver broadcast packets to broadcast sockets
Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/phonet/phonet.h | 1 | ||||
-rw-r--r-- | net/phonet/af_phonet.c | 6 | ||||
-rw-r--r-- | 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 d43f71b5ec00..fdb05fa0346f 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) | |||
47 | extern const struct proto_ops phonet_dgram_ops; | 47 | extern const struct proto_ops phonet_dgram_ops; |
48 | 48 | ||
49 | struct sock *pn_find_sock_by_sa(struct net *net, const struct sockaddr_pn *sa); | 49 | struct sock *pn_find_sock_by_sa(struct net *net, const struct sockaddr_pn *sa); |
50 | void pn_deliver_sock_broadcast(struct net *net, struct sk_buff *skb); | ||
50 | void phonet_get_local_port_range(int *min, int *max); | 51 | void phonet_get_local_port_range(int *min, int *max); |
51 | void pn_sock_hash(struct sock *sk); | 52 | void pn_sock_hash(struct sock *sk); |
52 | void pn_sock_unhash(struct sock *sk); | 53 | void pn_sock_unhash(struct sock *sk); |
diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c index c711d58b4bb5..b113fe00c154 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, | |||
369 | 369 | ||
370 | pn_skb_get_dst_sockaddr(skb, &sa); | 370 | pn_skb_get_dst_sockaddr(skb, &sa); |
371 | 371 | ||
372 | /* check if this is broadcasted */ | ||
373 | if (pn_sockaddr_get_addr(&sa) == PNADDR_BROADCAST) { | ||
374 | pn_deliver_sock_broadcast(net, skb); | ||
375 | goto out; | ||
376 | } | ||
377 | |||
372 | /* check if we are the destination */ | 378 | /* check if we are the destination */ |
373 | if (phonet_address_lookup(net, pn_sockaddr_get_addr(&sa)) == 0) { | 379 | if (phonet_address_lookup(net, pn_sockaddr_get_addr(&sa)) == 0) { |
374 | /* Phonet packet input */ | 380 | /* Phonet packet input */ |
diff --git a/net/phonet/socket.c b/net/phonet/socket.c index aa5b5a972bff..8c84190f22de 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) | |||
94 | spin_unlock_bh(&pnsocks.lock); | 94 | spin_unlock_bh(&pnsocks.lock); |
95 | 95 | ||
96 | return rval; | 96 | return rval; |
97 | } | ||
98 | |||
99 | /* Deliver a broadcast packet (only in bottom-half) */ | ||
100 | void pn_deliver_sock_broadcast(struct net *net, struct sk_buff *skb) | ||
101 | { | ||
102 | struct hlist_node *node; | ||
103 | struct sock *sknode; | ||
104 | |||
105 | spin_lock(&pnsocks.lock); | ||
106 | sk_for_each(sknode, node, &pnsocks.hlist) { | ||
107 | struct sk_buff *clone; | ||
108 | |||
109 | if (!net_eq(sock_net(sknode), net)) | ||
110 | continue; | ||
111 | if (!sock_flag(sknode, SOCK_BROADCAST)) | ||
112 | continue; | ||
97 | 113 | ||
114 | clone = skb_clone(skb, GFP_ATOMIC); | ||
115 | if (clone) | ||
116 | sk_receive_skb(sknode, clone, 0); | ||
117 | } | ||
118 | spin_unlock(&pnsocks.lock); | ||
98 | } | 119 | } |
99 | 120 | ||
100 | void pn_sock_hash(struct sock *sk) | 121 | void pn_sock_hash(struct sock *sk) |