Skip to content

Commit a6f75c2

Browse files
committed
1 parent 1fea75f commit a6f75c2

14 files changed

+40
-84
lines changed

vendor.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -eux -o pipefail
3-
# Nov 21, 2019
4-
LIBSLIRP_COMMIT=d171af3732a0610a25334b06b77fa547bd677918
3+
# Dec 4, 2019 (v4.1.0)
4+
LIBSLIRP_COMMIT=6651ba26c4e94f64d6448a2db4991269ce553bd9
55
LIBSLIRP_REPO=https://gitlab.freedesktop.org/slirp/libslirp.git
66

77
# Jul 12, 2019

vendor/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# DO NOT EDIT MANUALLY
22

33
Vendored components:
4-
* libslirp: https://gitlab.freedesktop.org/slirp/libslirp.git (`d171af3732a0610a25334b06b77fa547bd677918`)
4+
* libslirp: https://gitlab.freedesktop.org/slirp/libslirp.git (`6651ba26c4e94f64d6448a2db4991269ce553bd9`)
55
* parson: https://github.com/kgabis/parson.git (`c5bb9557fe98367aa8e041c65863909f12ee76b2`)
66

77
Please do not edit the contents under this directory manually.

vendor/libslirp/src/arp_table.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ bool arp_table_search(Slirp *slirp, uint32_t ip_addr,
7171
DEBUG_ARG("ip = %s", inet_ntoa((struct in_addr){ .s_addr = ip_addr }));
7272

7373
/* If broadcast address */
74-
if (ip_addr == 0xffffffff || ip_addr == broadcast_addr) {
74+
if (ip_addr == 0 || ip_addr == 0xffffffff || ip_addr == broadcast_addr) {
7575
/* return Ethernet broadcast address */
7676
memset(out_ethaddr, 0xff, ETH_ALEN);
7777
return 1;

vendor/libslirp/src/dnssearch.c

+1-6
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,8 @@ int translate_dnssearch(Slirp *s, const char **names)
238238
size_t i, num_domains, memreq = 0;
239239
uint8_t *result = NULL, *outptr;
240240
CompactDomain *domains = NULL;
241-
const char **nameptr = names;
242241

243-
while (*nameptr != NULL) {
244-
nameptr++;
245-
}
246-
247-
num_domains = nameptr - names;
242+
num_domains = g_strv_length((GStrv)names);
248243
if (num_domains == 0) {
249244
return -2;
250245
}

vendor/libslirp/src/libslirp-version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ extern "C" {
77
#endif
88

99
#define SLIRP_MAJOR_VERSION 4
10-
#define SLIRP_MINOR_VERSION 0
10+
#define SLIRP_MINOR_VERSION 1
1111
#define SLIRP_MICRO_VERSION 0
1212

1313
#define SLIRP_CHECK_VERSION(major,minor,micro) \

vendor/libslirp/src/sbuf.c

+11-32
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,17 @@ static void sbappendsb(struct sbuf *sb, struct mbuf *m);
99

1010
void sbfree(struct sbuf *sb)
1111
{
12-
free(sb->sb_data);
12+
g_free(sb->sb_data);
1313
}
1414

15-
bool sbdrop(struct sbuf *sb, int num)
15+
bool sbdrop(struct sbuf *sb, size_t num)
1616
{
1717
int limit = sb->sb_datalen / 2;
1818

19-
/*
20-
* We can only drop how much we have
21-
* This should never succeed
22-
*/
19+
g_warn_if_fail(num <= sb->sb_cc);
2320
if (num > sb->sb_cc)
2421
num = sb->sb_cc;
22+
2523
sb->sb_cc -= num;
2624
sb->sb_rptr += num;
2725
if (sb->sb_rptr >= sb->sb_data + sb->sb_datalen)
@@ -34,30 +32,11 @@ bool sbdrop(struct sbuf *sb, int num)
3432
return false;
3533
}
3634

37-
void sbreserve(struct sbuf *sb, int size)
35+
void sbreserve(struct sbuf *sb, size_t size)
3836
{
39-
if (sb->sb_data) {
40-
/* Already alloced, realloc if necessary */
41-
if (sb->sb_datalen != size) {
42-
char *new = realloc(sb->sb_data, size);
43-
sb->sb_cc = 0;
44-
if (new) {
45-
sb->sb_data = sb->sb_wptr = sb->sb_rptr = new;
46-
sb->sb_datalen = size;
47-
} else {
48-
free(sb->sb_data);
49-
sb->sb_data = sb->sb_wptr = sb->sb_rptr = NULL;
50-
sb->sb_datalen = 0;
51-
}
52-
}
53-
} else {
54-
sb->sb_wptr = sb->sb_rptr = sb->sb_data = (char *)malloc(size);
55-
sb->sb_cc = 0;
56-
if (sb->sb_wptr)
57-
sb->sb_datalen = size;
58-
else
59-
sb->sb_datalen = 0;
60-
}
37+
sb->sb_wptr = sb->sb_rptr = sb->sb_data = g_realloc(sb->sb_data, size);
38+
sb->sb_cc = 0;
39+
sb->sb_datalen = size;
6140
}
6241

6342
/*
@@ -164,17 +143,17 @@ static void sbappendsb(struct sbuf *sb, struct mbuf *m)
164143
* Don't update the sbuf rptr, this will be
165144
* done in sbdrop when the data is acked
166145
*/
167-
void sbcopy(struct sbuf *sb, int off, int len, char *to)
146+
void sbcopy(struct sbuf *sb, size_t off, size_t len, char *to)
168147
{
169148
char *from;
170149

150+
g_assert(len + off <= sb->sb_cc);
151+
171152
from = sb->sb_rptr + off;
172153
if (from >= sb->sb_data + sb->sb_datalen)
173154
from -= sb->sb_datalen;
174155

175156
if (from < sb->sb_wptr) {
176-
if (len > sb->sb_cc)
177-
len = sb->sb_cc;
178157
memcpy(to, from, len);
179158
} else {
180159
/* re-use off */

vendor/libslirp/src/sbuf.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ struct sbuf {
1818
char *sb_data; /* Actual data */
1919
};
2020

21-
void sbfree(struct sbuf *);
22-
bool sbdrop(struct sbuf *, int);
23-
void sbreserve(struct sbuf *, int);
24-
void sbappend(struct socket *, struct mbuf *);
25-
void sbcopy(struct sbuf *, int, int, char *);
21+
void sbfree(struct sbuf *sb);
22+
bool sbdrop(struct sbuf *sb, size_t len);
23+
void sbreserve(struct sbuf *sb, size_t size);
24+
void sbappend(struct socket *sb, struct mbuf *mb);
25+
void sbcopy(struct sbuf *sb, size_t off, size_t len, char *p);
2626

2727
#endif

vendor/libslirp/src/slirp.c

-5
Original file line numberDiff line numberDiff line change
@@ -845,11 +845,6 @@ static int if_encap4(Slirp *slirp, struct mbuf *ifm, struct ethhdr *eh,
845845
{
846846
const struct ip *iph = (const struct ip *)ifm->m_data;
847847

848-
if (iph->ip_dst.s_addr == 0) {
849-
/* 0.0.0.0 can not be a destination address, something went wrong,
850-
* avoid making it worse */
851-
return 1;
852-
}
853848
if (!arp_table_search(slirp, iph->ip_dst.s_addr, ethaddr)) {
854849
uint8_t arp_req[ETH_HLEN + sizeof(struct slirp_arphdr)];
855850
struct ethhdr *reh = (struct ethhdr *)arp_req;

vendor/libslirp/src/slirp.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ struct tcpcb *tcp_close(register struct tcpcb *);
266266
void tcp_sockclosed(struct tcpcb *);
267267
int tcp_fconnect(struct socket *, unsigned short af);
268268
void tcp_connect(struct socket *);
269-
int tcp_attach(struct socket *);
269+
void tcp_attach(struct socket *);
270270
uint8_t tcp_tos(struct socket *);
271271
int tcp_emu(struct socket *, struct mbuf *);
272272
int tcp_ctl(struct socket *);

vendor/libslirp/src/socket.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void sofree(struct socket *so)
9595
remque(so); /* crashes if so is not in a queue */
9696

9797
if (so->so_tcpcb) {
98-
free(so->so_tcpcb);
98+
g_free(so->so_tcpcb);
9999
}
100100
g_free(so);
101101
}
@@ -846,6 +846,9 @@ int sotranslate_out(struct socket *so, struct sockaddr_storage *addr)
846846
} else {
847847
sin->sin_addr = loopback_addr;
848848
}
849+
} else if (!slirp->disable_host_loopback && so->so_faddr.s_addr == 0xffffffff) {
850+
/* Receive broadcast as well */
851+
sin->sin_addr = loopback_addr;
849852
}
850853
break;
851854
case AF_INET6:
@@ -865,6 +868,9 @@ int sotranslate_out(struct socket *so, struct sockaddr_storage *addr)
865868
} else {
866869
sin6->sin6_addr = in6addr_loopback;
867870
}
871+
} else if (!slirp->disable_host_loopback
872+
&& in6_equal(&so->so_faddr6, &(struct in6_addr) ALLNODES_MULTICAST)) {
873+
sin6->sin6_addr = in6addr_loopback;
868874
}
869875
break;
870876

vendor/libslirp/src/state.c

+2-6
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,6 @@ static int sbuf_tmp_post_load(void *opaque, int version)
107107
/* Allocate the buffer space used by the field after the tmp */
108108
sbreserve(tmp->parent, tmp->parent->sb_datalen);
109109

110-
if (tmp->parent->sb_datalen != requested_len) {
111-
return -ENOMEM;
112-
}
113110
if (tmp->woff >= requested_len || tmp->roff >= requested_len) {
114111
g_critical("invalid sbuf offsets r/w=%u/%u len=%u", tmp->roff,
115112
tmp->woff, requested_len);
@@ -159,9 +156,8 @@ static bool slirp_family_inet(void *opaque, int version_id)
159156
static int slirp_socket_pre_load(void *opaque)
160157
{
161158
struct socket *so = opaque;
162-
if (tcp_attach(so) < 0) {
163-
return -ENOMEM;
164-
}
159+
160+
tcp_attach(so);
165161
/* Older versions don't load these fields */
166162
so->so_ffamily = AF_INET;
167163
so->so_lfamily = AF_INET;

vendor/libslirp/src/tcp_input.c

+1-4
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,7 @@ void tcp_input(struct mbuf *m, int iphlen, struct socket *inso,
408408
goto dropwithreset;
409409

410410
so = socreate(slirp);
411-
if (tcp_attach(so) < 0) {
412-
g_free(so); /* Not sofree (if it failed, it's not insqued) */
413-
goto dropwithreset;
414-
}
411+
tcp_attach(so);
415412

416413
sbreserve(&so->so_snd, TCP_SNDSPACE);
417414
sbreserve(&so->so_rcv, TCP_RCVSPACE);

vendor/libslirp/src/tcp_subr.c

+7-18
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,7 @@ struct tcpcb *tcp_newtcpcb(struct socket *so)
255255
{
256256
register struct tcpcb *tp;
257257

258-
tp = (struct tcpcb *)malloc(sizeof(*tp));
259-
if (tp == NULL)
260-
return ((struct tcpcb *)0);
261-
262-
memset((char *)tp, 0, sizeof(struct tcpcb));
258+
tp = g_new0(struct tcpcb, 1);
263259
tp->seg_next = tp->seg_prev = (struct tcpiphdr *)tp;
264260
/*
265261
* 40: length of IPv4 header (20) + TCP header (20)
@@ -336,7 +332,7 @@ struct tcpcb *tcp_close(struct tcpcb *tp)
336332
remque(tcpiphdr2qlink(tcpiphdr_prev(t)));
337333
m_free(m);
338334
}
339-
free(tp);
335+
g_free(tp);
340336
so->so_tcpcb = NULL;
341337
/* clobber input socket cache if we're closing the cached connection */
342338
if (so == slirp->tcp_last_so)
@@ -377,8 +373,8 @@ void tcp_sockclosed(struct tcpcb *tp)
377373
case TCPS_LISTEN:
378374
case TCPS_SYN_SENT:
379375
tp->t_state = TCPS_CLOSED;
380-
tp = tcp_close(tp);
381-
break;
376+
tcp_close(tp);
377+
return;
382378

383379
case TCPS_SYN_RECEIVED:
384380
case TCPS_ESTABLISHED:
@@ -474,10 +470,7 @@ void tcp_connect(struct socket *inso)
474470
so = inso;
475471
} else {
476472
so = socreate(slirp);
477-
if (tcp_attach(so) < 0) {
478-
g_free(so); /* NOT sofree */
479-
return;
480-
}
473+
tcp_attach(so);
481474
so->lhost = inso->lhost;
482475
so->so_ffamily = inso->so_ffamily;
483476
}
@@ -528,14 +521,10 @@ void tcp_connect(struct socket *inso)
528521
/*
529522
* Attach a TCPCB to a socket.
530523
*/
531-
int tcp_attach(struct socket *so)
524+
void tcp_attach(struct socket *so)
532525
{
533-
if ((so->so_tcpcb = tcp_newtcpcb(so)) == NULL)
534-
return -1;
535-
526+
so->so_tcpcb = tcp_newtcpcb(so);
536527
insque(so, &so->slirp->tcb);
537-
538-
return 0;
539528
}
540529

541530
/*

vendor/libslirp/src/vmstate.c

-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ static int vmstate_save_state_v(SlirpOStream *f, const VMStateDescription *vmsd,
321321
}
322322
for (i = 0; i < n_elems; i++) {
323323
void *curr_elem = first_elem + size * i;
324-
ret = 0;
325324

326325
if (field->flags & VMS_ARRAY_OF_POINTER) {
327326
assert(curr_elem);

0 commit comments

Comments
 (0)