diff options
author | Rémi Denis-Courmont <remi.denis-courmont@nokia.com> | 2009-10-13 20:48:30 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-10-14 18:04:17 -0400 |
commit | aa6c45f32f7db292f8f6a76d7b39c19007d6a456 (patch) | |
tree | d1a061698678103144a67e3a57919f4b34a2ba5a /net/phonet/af_phonet.c | |
parent | f062f41d06575744b9eaf725eef8a5d3b5f5b7ca (diff) |
Phonet: route outgoing packets
Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/phonet/af_phonet.c')
-rw-r--r-- | net/phonet/af_phonet.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c index b113fe00c154..cc2eef169a8b 100644 --- a/net/phonet/af_phonet.c +++ b/net/phonet/af_phonet.c | |||
@@ -190,9 +190,8 @@ static int pn_send(struct sk_buff *skb, struct net_device *dev, | |||
190 | skb->priority = 0; | 190 | skb->priority = 0; |
191 | skb->dev = dev; | 191 | skb->dev = dev; |
192 | 192 | ||
193 | if (pn_addr(src) == pn_addr(dst)) { | 193 | if (skb->pkt_type == PACKET_LOOPBACK) { |
194 | skb_reset_mac_header(skb); | 194 | skb_reset_mac_header(skb); |
195 | skb->pkt_type = PACKET_LOOPBACK; | ||
196 | skb_orphan(skb); | 195 | skb_orphan(skb); |
197 | if (irq) | 196 | if (irq) |
198 | netif_rx(skb); | 197 | netif_rx(skb); |
@@ -222,6 +221,9 @@ static int pn_raw_send(const void *data, int len, struct net_device *dev, | |||
222 | if (skb == NULL) | 221 | if (skb == NULL) |
223 | return -ENOMEM; | 222 | return -ENOMEM; |
224 | 223 | ||
224 | if (phonet_address_lookup(dev_net(dev), pn_addr(dst)) == 0) | ||
225 | skb->pkt_type = PACKET_LOOPBACK; | ||
226 | |||
225 | skb_reserve(skb, MAX_PHONET_HEADER); | 227 | skb_reserve(skb, MAX_PHONET_HEADER); |
226 | __skb_put(skb, len); | 228 | __skb_put(skb, len); |
227 | skb_copy_to_linear_data(skb, data, len); | 229 | skb_copy_to_linear_data(skb, data, len); |
@@ -235,6 +237,7 @@ static int pn_raw_send(const void *data, int len, struct net_device *dev, | |||
235 | int pn_skb_send(struct sock *sk, struct sk_buff *skb, | 237 | int pn_skb_send(struct sock *sk, struct sk_buff *skb, |
236 | const struct sockaddr_pn *target) | 238 | const struct sockaddr_pn *target) |
237 | { | 239 | { |
240 | struct net *net = sock_net(sk); | ||
238 | struct net_device *dev; | 241 | struct net_device *dev; |
239 | struct pn_sock *pn = pn_sk(sk); | 242 | struct pn_sock *pn = pn_sk(sk); |
240 | int err; | 243 | int err; |
@@ -243,9 +246,13 @@ int pn_skb_send(struct sock *sk, struct sk_buff *skb, | |||
243 | 246 | ||
244 | err = -EHOSTUNREACH; | 247 | err = -EHOSTUNREACH; |
245 | if (sk->sk_bound_dev_if) | 248 | if (sk->sk_bound_dev_if) |
246 | dev = dev_get_by_index(sock_net(sk), sk->sk_bound_dev_if); | 249 | dev = dev_get_by_index(net, sk->sk_bound_dev_if); |
247 | else | 250 | else if (phonet_address_lookup(net, daddr) == 0) { |
248 | dev = phonet_device_get(sock_net(sk)); | 251 | dev = phonet_device_get(net); |
252 | skb->pkt_type = PACKET_LOOPBACK; | ||
253 | } else | ||
254 | dev = phonet_route_output(net, daddr); | ||
255 | |||
249 | if (!dev || !(dev->flags & IFF_UP)) | 256 | if (!dev || !(dev->flags & IFF_UP)) |
250 | goto drop; | 257 | goto drop; |
251 | 258 | ||