Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 7065
b: refs/heads/master
c: 12a49ff
h: refs/heads/master
i:
  7063: 0cb91a9
v: v3
  • Loading branch information
Patrick Caulfield authored and David S. Miller committed Sep 2, 2005
1 parent 3be58da commit 82df8a1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 71 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: eb6f1160ddb2fdadf50f350da79d0796c37f17e2
refs/heads/master: 12a49ffd842bf5b07c62eaabf178703ce4fe09d7
40 changes: 33 additions & 7 deletions trunk/net/decnet/af_decnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1876,8 +1876,27 @@ static inline unsigned int dn_current_mss(struct sock *sk, int flags)
return mss_now;
}

/*
* N.B. We get the timeout wrong here, but then we always did get it
* wrong before and this is another step along the road to correcting
* it. It ought to get updated each time we pass through the routine,
* but in practise it probably doesn't matter too much for now.
*/
static inline struct sk_buff *dn_alloc_send_pskb(struct sock *sk,
unsigned long datalen, int noblock,
int *errcode)
{
struct sk_buff *skb = sock_alloc_send_skb(sk, datalen,
noblock, errcode);
if (skb) {
skb->protocol = __constant_htons(ETH_P_DNA_RT);
skb->pkt_type = PACKET_OUTGOING;
}
return skb;
}

static int dn_sendmsg(struct kiocb *iocb, struct socket *sock,
struct msghdr *msg, size_t size)
struct msghdr *msg, size_t size)
{
struct sock *sk = sock->sk;
struct dn_scp *scp = DN_SK(sk);
Expand All @@ -1892,26 +1911,29 @@ static int dn_sendmsg(struct kiocb *iocb, struct socket *sock,
struct dn_skb_cb *cb;
size_t len;
unsigned char fctype;
long timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT);
long timeo;

if (flags & ~(MSG_TRYHARD|MSG_OOB|MSG_DONTWAIT|MSG_EOR|MSG_NOSIGNAL|MSG_MORE|MSG_CMSG_COMPAT))
return -EOPNOTSUPP;

if (addr_len && (addr_len != sizeof(struct sockaddr_dn)))
return -EINVAL;

lock_sock(sk);
timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT);
/*
* The only difference between stream sockets and sequenced packet
* sockets is that the stream sockets always behave as if MSG_EOR
* has been set.
*/
if (sock->type == SOCK_STREAM) {
if (flags & MSG_EOR)
return -EINVAL;
if (flags & MSG_EOR) {
err = -EINVAL;
goto out;
}
flags |= MSG_EOR;
}

lock_sock(sk);

err = dn_check_state(sk, addr, addr_len, &timeo, flags);
if (err)
Expand Down Expand Up @@ -1980,8 +2002,12 @@ static int dn_sendmsg(struct kiocb *iocb, struct socket *sock,

/*
* Get a suitably sized skb.
* 64 is a bit of a hack really, but its larger than any
* link-layer headers and has served us well as a good
* guess as to their real length.
*/
skb = dn_alloc_send_skb(sk, &len, flags & MSG_DONTWAIT, timeo, &err);
skb = dn_alloc_send_pskb(sk, len + 64 + DN_MAX_NSP_DATA_HEADER,
flags & MSG_DONTWAIT, &err);

if (err)
break;
Expand All @@ -1991,7 +2017,7 @@ static int dn_sendmsg(struct kiocb *iocb, struct socket *sock,

cb = DN_SKB_CB(skb);

skb_reserve(skb, DN_MAX_NSP_DATA_HEADER);
skb_reserve(skb, 64 + DN_MAX_NSP_DATA_HEADER);

if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) {
err = -EFAULT;
Expand Down
63 changes: 0 additions & 63 deletions trunk/net/decnet/dn_nsp_out.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,69 +136,6 @@ struct sk_buff *dn_alloc_skb(struct sock *sk, int size, int pri)
return skb;
}

/*
* Wrapper for the above, for allocs of data skbs. We try and get the
* whole size thats been asked for (plus 11 bytes of header). If this
* fails, then we try for any size over 16 bytes for SOCK_STREAMS.
*/
struct sk_buff *dn_alloc_send_skb(struct sock *sk, size_t *size, int noblock, long timeo, int *err)
{
int space;
int len;
struct sk_buff *skb = NULL;

*err = 0;

while(skb == NULL) {
if (signal_pending(current)) {
*err = sock_intr_errno(timeo);
break;
}

if (sk->sk_shutdown & SEND_SHUTDOWN) {
*err = EINVAL;
break;
}

if (sk->sk_err)
break;

len = *size + 11;
space = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc);

if (space < len) {
if ((sk->sk_socket->type == SOCK_STREAM) &&
(space >= (16 + 11)))
len = space;
}

if (space < len) {
set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags);
if (noblock) {
*err = EWOULDBLOCK;
break;
}

clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags);
SOCK_SLEEP_PRE(sk)

if ((sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc)) <
len)
schedule();

SOCK_SLEEP_POST(sk)
continue;
}

if ((skb = dn_alloc_skb(sk, len, sk->sk_allocation)) == NULL)
continue;

*size = len - 11;
}

return skb;
}

/*
* Calculate persist timer based upon the smoothed round
* trip time and the variance. Backoff according to the
Expand Down

0 comments on commit 82df8a1

Please sign in to comment.