Commit 4b8f704b authored by remi.denis-courmont@nokia's avatar remi.denis-courmont@nokia Committed by David S. Miller

Phonet: check destination before delivering packets locally

Signed-off-by: default avatarRémi Denis-Courmont <remi.denis-courmont@nokia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5075138d
...@@ -275,8 +275,6 @@ static inline int can_respond(struct sk_buff *skb) ...@@ -275,8 +275,6 @@ static inline int can_respond(struct sk_buff *skb)
return 0; return 0;
ph = pn_hdr(skb); ph = pn_hdr(skb);
if (phonet_address_get(skb->dev, ph->pn_rdev) != ph->pn_rdev)
return 0; /* we are not the destination */
if (ph->pn_res == PN_PREFIX && !pskb_may_pull(skb, 5)) if (ph->pn_res == PN_PREFIX && !pskb_may_pull(skb, 5))
return 0; return 0;
if (ph->pn_res == PN_COMMGR) /* indications */ if (ph->pn_res == PN_COMMGR) /* indications */
...@@ -344,8 +342,8 @@ static int phonet_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -344,8 +342,8 @@ static int phonet_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pkttype, struct packet_type *pkttype,
struct net_device *orig_dev) struct net_device *orig_dev)
{ {
struct net *net = dev_net(dev);
struct phonethdr *ph; struct phonethdr *ph;
struct sock *sk;
struct sockaddr_pn sa; struct sockaddr_pn sa;
u16 len; u16 len;
...@@ -364,21 +362,21 @@ static int phonet_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -364,21 +362,21 @@ static int phonet_rcv(struct sk_buff *skb, struct net_device *dev,
skb_reset_transport_header(skb); skb_reset_transport_header(skb);
pn_skb_get_dst_sockaddr(skb, &sa); pn_skb_get_dst_sockaddr(skb, &sa);
if (pn_sockaddr_get_addr(&sa) == 0)
goto out; /* currently, we cannot be device 0 */
sk = pn_find_sock_by_sa(dev_net(dev), &sa); /* check if we are the destination */
if (sk == NULL) { if (phonet_address_lookup(net, pn_sockaddr_get_addr(&sa)) == 0) {
/* Phonet packet input */
struct sock *sk = pn_find_sock_by_sa(net, &sa);
if (sk)
return sk_receive_skb(sk, skb, 0);
if (can_respond(skb)) { if (can_respond(skb)) {
send_obj_unreachable(skb); send_obj_unreachable(skb);
send_reset_indications(skb); send_reset_indications(skb);
} }
goto out;
} }
/* Push data to the socket (or other sockets connected to it). */
return sk_receive_skb(sk, skb, 0);
out: out:
kfree_skb(skb); kfree_skb(skb);
return NET_RX_DROP; return NET_RX_DROP;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment