Phonet: correct pipe backlog callback return values
In some cases, the Phonet pipe backlog callbacks returned negative errno instead of NET_RX_* values. In other cases, NET_RX_DROP was returned for invalid packets, even though it seems only intended for buffering problems (not for deliberately discarded packets). Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
b765e84f96
commit
0ebbf31863
|
@ -522,7 +522,8 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
|
||||||
if (!pn_flow_safe(pn->rx_fc)) {
|
if (!pn_flow_safe(pn->rx_fc)) {
|
||||||
err = sock_queue_rcv_skb(sk, skb);
|
err = sock_queue_rcv_skb(sk, skb);
|
||||||
if (!err)
|
if (!err)
|
||||||
return 0;
|
return NET_RX_SUCCESS;
|
||||||
|
err = -ENOBUFS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,7 +576,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
kfree_skb(skb);
|
kfree_skb(skb);
|
||||||
return err;
|
return (err == -ENOBUFS) ? NET_RX_DROP : NET_RX_SUCCESS;
|
||||||
|
|
||||||
queue:
|
queue:
|
||||||
skb->dev = NULL;
|
skb->dev = NULL;
|
||||||
|
@ -584,7 +585,7 @@ queue:
|
||||||
skb_queue_tail(queue, skb);
|
skb_queue_tail(queue, skb);
|
||||||
if (!sock_flag(sk, SOCK_DEAD))
|
if (!sock_flag(sk, SOCK_DEAD))
|
||||||
sk->sk_data_ready(sk, err);
|
sk->sk_data_ready(sk, err);
|
||||||
return 0;
|
return NET_RX_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Destroy connected sock. */
|
/* Destroy connected sock. */
|
||||||
|
@ -686,11 +687,6 @@ static int pep_connreq_rcv(struct sock *sk, struct sk_buff *skb)
|
||||||
}
|
}
|
||||||
peer_type = hdr->other_pep_type << 8;
|
peer_type = hdr->other_pep_type << 8;
|
||||||
|
|
||||||
if (unlikely(sk->sk_state != TCP_LISTEN) || sk_acceptq_is_full(sk)) {
|
|
||||||
pep_reject_conn(sk, skb, PN_PIPE_ERR_PEP_IN_USE);
|
|
||||||
return -ENOBUFS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Parse sub-blocks (options) */
|
/* Parse sub-blocks (options) */
|
||||||
n_sb = hdr->data[4];
|
n_sb = hdr->data[4];
|
||||||
while (n_sb > 0) {
|
while (n_sb > 0) {
|
||||||
|
@ -790,7 +786,6 @@ static int pep_do_rcv(struct sock *sk, struct sk_buff *skb)
|
||||||
struct sock *sknode;
|
struct sock *sknode;
|
||||||
struct pnpipehdr *hdr;
|
struct pnpipehdr *hdr;
|
||||||
struct sockaddr_pn dst;
|
struct sockaddr_pn dst;
|
||||||
int err = NET_RX_SUCCESS;
|
|
||||||
u8 pipe_handle;
|
u8 pipe_handle;
|
||||||
|
|
||||||
if (!pskb_may_pull(skb, sizeof(*hdr)))
|
if (!pskb_may_pull(skb, sizeof(*hdr)))
|
||||||
|
@ -814,18 +809,20 @@ static int pep_do_rcv(struct sock *sk, struct sk_buff *skb)
|
||||||
sock_put(sknode);
|
sock_put(sknode);
|
||||||
if (net_ratelimit())
|
if (net_ratelimit())
|
||||||
printk(KERN_WARNING"Phonet unconnected PEP ignored");
|
printk(KERN_WARNING"Phonet unconnected PEP ignored");
|
||||||
err = NET_RX_DROP;
|
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (hdr->message_id) {
|
switch (hdr->message_id) {
|
||||||
case PNS_PEP_CONNECT_REQ:
|
case PNS_PEP_CONNECT_REQ:
|
||||||
err = pep_connreq_rcv(sk, skb);
|
if (sk->sk_state == TCP_LISTEN && !sk_acceptq_is_full(sk))
|
||||||
|
pep_connreq_rcv(sk, skb);
|
||||||
|
else
|
||||||
|
pep_reject_conn(sk, skb, PN_PIPE_ERR_PEP_IN_USE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef CONFIG_PHONET_PIPECTRLR
|
#ifdef CONFIG_PHONET_PIPECTRLR
|
||||||
case PNS_PEP_CONNECT_RESP:
|
case PNS_PEP_CONNECT_RESP:
|
||||||
err = pep_connresp_rcv(sk, skb);
|
pep_connresp_rcv(sk, skb);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -842,11 +839,11 @@ static int pep_do_rcv(struct sock *sk, struct sk_buff *skb)
|
||||||
case PNS_PEP_DISABLE_REQ:
|
case PNS_PEP_DISABLE_REQ:
|
||||||
/* invalid handle is not even allowed here! */
|
/* invalid handle is not even allowed here! */
|
||||||
default:
|
default:
|
||||||
err = NET_RX_DROP;
|
break;
|
||||||
}
|
}
|
||||||
drop:
|
drop:
|
||||||
kfree_skb(skb);
|
kfree_skb(skb);
|
||||||
return err;
|
return NET_RX_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef CONFIG_PHONET_PIPECTRLR
|
#ifndef CONFIG_PHONET_PIPECTRLR
|
||||||
|
|
Reference in New Issue