Skip to content

Commit

Permalink
Phonet: look up the resource routing table when forwarding
Browse files Browse the repository at this point in the history
Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Rémi Denis-Courmont authored and David S. Miller committed Sep 16, 2010
1 parent 7417fa8 commit b6a563b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions net/phonet/af_phonet.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,16 @@ int pn_skb_send(struct sock *sk, struct sk_buff *skb,
else if (phonet_address_lookup(net, daddr) == 0) {
dev = phonet_device_get(net);
skb->pkt_type = PACKET_LOOPBACK;
} else if (pn_sockaddr_get_object(target) == 0) {
/* Resource routing (small race until phonet_rcv()) */
struct sock *sk = pn_find_sock_by_res(net,
target->spn_resource);
if (sk) {
sock_put(sk);
dev = phonet_device_get(net);
skb->pkt_type = PACKET_LOOPBACK;
} else
dev = phonet_route_output(net, daddr);
} else
dev = phonet_route_output(net, daddr);

Expand Down Expand Up @@ -383,6 +393,13 @@ static int phonet_rcv(struct sk_buff *skb, struct net_device *dev,
goto out;
}

/* resource routing */
if (pn_sockaddr_get_object(&sa) == 0) {
struct sock *sk = pn_find_sock_by_res(net, sa.spn_resource);
if (sk)
return sk_receive_skb(sk, skb, 0);
}

/* check if we are the destination */
if (phonet_address_lookup(net, pn_sockaddr_get_addr(&sa)) == 0) {
/* Phonet packet input */
Expand Down

0 comments on commit b6a563b

Please sign in to comment.