slirp updates

-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEErr90SPq5RTpFUjkOsKUb9YyRecUFAllqCssACgkQsKUb9YyR
 ecVE6hAAlGPrzCgHJ1R6RzT+HHUPGgu99CiiVc6nyAtWBdBhVSt6rhlK90EPiYxL
 dEnM06M+hQ6o+K3SIHfb4MbKwck/L8QYSsp7L4SNF83uhdtJEXYtd7v1dbyznwVh
 WnCb8/gcNip7+dSd9w7LyZcMQt7RPH7M2YLZlq4u7qLpVoN1Nw4/+YKp6gwgG5M9
 ByALG6X2ZR9hI7elYQmxLhb6Vi6oy47SVy1K9pYXi3igiYMTsdced+iE50mg1ML8
 Oni70fDWW3SQVovmDLG0TB5XxwycYhZpf+4Fn8kc2QlhQraWlpFYNXU2J68vyR4w
 YXuKKMbp3aO3QBwcR9H0GtWRHARMRSo5sLDTNF34Oi3EDWqDi05OvfeWBhUKm/Sh
 RkRjBhqch5YTaYUhbRknTgvTxLLHRvffJenw0ATetduvtSJ6XNUDY/A2GDv6i5Be
 cLc9GsWQFKyAcDPUGRfeW586hIigB4DSewdL30r22djPQx3/88U9xjccwHMpFPHy
 wUNddOcUcCeTqEIPJl5j5uk4ehdkAYJljCq+3Ie9ruTPfhr5VS9phLbZLQfzvkYF
 ktBjQm2T9VX9qw4EgcubW43hgFfGOcg4jJJlBmXVRmdYb84V/cwH31eRnwJXhOiV
 iqwc6kaazeybWvHQIrmVfjD3fcTuFDq4+aORqgnRHbP+4+cjAn0=
 =o/qe
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/thibault/tags/samuel-thibault' into staging

slirp updates

# gpg: Signature made Sat 15 Jul 2017 13:30:03 BST
# gpg:                using RSA key 0xB0A51BF58C9179C5
# gpg: Good signature from "Samuel Thibault <samuel.thibault@aquilenet.fr>"
# gpg:                 aka "Samuel Thibault <sthibault@debian.org>"
# gpg:                 aka "Samuel Thibault <samuel.thibault@gnu.org>"
# gpg:                 aka "Samuel Thibault <samuel.thibault@inria.fr>"
# gpg:                 aka "Samuel Thibault <samuel.thibault@labri.fr>"
# gpg:                 aka "Samuel Thibault <samuel.thibault@ens-lyon.org>"
# gpg:                 aka "Samuel Thibault <samuel.thibault@u-bordeaux.fr>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 900C B024 B679 31D4 0F82  304B D017 8C76 7D06 9EE6
#      Subkey fingerprint: AEBF 7448 FAB9 453A 4552  390E B0A5 1BF5 8C91 79C5

* remotes/thibault/tags/samuel-thibault:
  slirp: Handle error returns from sosendoob()
  slirp: Handle error returns from slirp_send() in sosendoob()
  slirp: fork_exec(): Don't close() a negative number in fork_exec()
  slirp: use DIV_ROUND_UP

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2017-07-17 10:02:22 +01:00
commit acbaa0f4fd
4 changed files with 44 additions and 24 deletions

View File

@ -57,9 +57,9 @@ static inline bool in6_equal_mach(const struct in6_addr *a,
const struct in6_addr *b,
int prefix_len)
{
if (memcmp(&(a->s6_addr[(prefix_len + 7) / 8]),
&(b->s6_addr[(prefix_len + 7) / 8]),
16 - (prefix_len + 7) / 8) != 0) {
if (memcmp(&(a->s6_addr[DIV_ROUND_UP(prefix_len, 8)]),
&(b->s6_addr[DIV_ROUND_UP(prefix_len, 8)]),
16 - DIV_ROUND_UP(prefix_len, 8)) != 0) {
return 0;
}

View File

@ -112,7 +112,9 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
bind(s, (struct sockaddr *)&addr, addrlen) < 0 ||
listen(s, 1) < 0) {
error_report("Error: inet socket: %s", strerror(errno));
closesocket(s);
if (s >= 0) {
closesocket(s);
}
return 0;
}

View File

@ -91,7 +91,7 @@ sbappend(struct socket *so, struct mbuf *m)
if (so->so_urgc) {
sbappendsb(&so->so_rcv, m);
m_free(m);
sosendoob(so);
(void)sosendoob(so);
return;
}

View File

@ -345,34 +345,41 @@ sosendoob(struct socket *so)
if (sb->sb_rptr < sb->sb_wptr) {
/* We can send it directly */
n = slirp_send(so, sb->sb_rptr, so->so_urgc, (MSG_OOB)); /* |MSG_DONTWAIT)); */
so->so_urgc -= n;
DEBUG_MISC((dfd, " --- sent %d bytes urgent data, %d urgent bytes left\n", n, so->so_urgc));
} else {
/*
* Since there's no sendv or sendtov like writev,
* we must copy all data to a linear buffer then
* send it all
*/
uint32_t urgc = so->so_urgc;
len = (sb->sb_data + sb->sb_datalen) - sb->sb_rptr;
if (len > so->so_urgc) len = so->so_urgc;
if (len > urgc) {
len = urgc;
}
memcpy(buff, sb->sb_rptr, len);
so->so_urgc -= len;
if (so->so_urgc) {
urgc -= len;
if (urgc) {
n = sb->sb_wptr - sb->sb_data;
if (n > so->so_urgc) n = so->so_urgc;
if (n > urgc) {
n = urgc;
}
memcpy((buff + len), sb->sb_data, n);
so->so_urgc -= n;
len += n;
}
n = slirp_send(so, buff, len, (MSG_OOB)); /* |MSG_DONTWAIT)); */
#ifdef DEBUG
if (n != len)
DEBUG_ERROR((dfd, "Didn't send all data urgently XXXXX\n"));
#endif
DEBUG_MISC((dfd, " ---2 sent %d bytes urgent data, %d urgent bytes left\n", n, so->so_urgc));
}
#ifdef DEBUG
if (n != len) {
DEBUG_ERROR((dfd, "Didn't send all data urgently XXXXX\n"));
}
#endif
if (n < 0) {
return n;
}
so->so_urgc -= n;
DEBUG_MISC((dfd, " ---2 sent %d bytes urgent data, %d urgent bytes left\n", n, so->so_urgc));
sb->sb_cc -= n;
sb->sb_rptr += n;
if (sb->sb_rptr >= (sb->sb_data + sb->sb_datalen))
@ -397,7 +404,15 @@ sowrite(struct socket *so)
DEBUG_ARG("so = %p", so);
if (so->so_urgc) {
sosendoob(so);
uint32_t expected = so->so_urgc;
if (sosendoob(so) < expected) {
/* Treat a short write as a fatal error too,
* rather than continuing on and sending the urgent
* data as if it were non-urgent and leaving the
* so_urgc count wrong.
*/
goto err_disconnected;
}
if (sb->sb_cc == 0)
return 0;
}
@ -441,11 +456,7 @@ sowrite(struct socket *so)
return 0;
if (nn <= 0) {
DEBUG_MISC((dfd, " --- sowrite disconnected, so->so_state = %x, errno = %d\n",
so->so_state, errno));
sofcantsendmore(so);
tcp_sockclosed(sototcpcb(so));
return -1;
goto err_disconnected;
}
#ifndef HAVE_READV
@ -472,6 +483,13 @@ sowrite(struct socket *so)
sofcantsendmore(so);
return nn;
err_disconnected:
DEBUG_MISC((dfd, " --- sowrite disconnected, so->so_state = %x, errno = %d\n",
so->so_state, errno));
sofcantsendmore(so);
tcp_sockclosed(sototcpcb(so));
return -1;
}
/*