Skip to content

Commit 4f5bacb

Browse files
authored
Merge pull request #197 from AkihiroSuda/libslirp430-04
v0.4.5 (libslirp v4.3.0)
2 parents eb14626 + 7a65f67 commit 4f5bacb

File tree

10 files changed

+36
-18
lines changed

10 files changed

+36
-18
lines changed

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AC_PREREQ([2.69])
2-
AC_INIT([slirp4netns], [0.4.4+dev], [https://github.com/rootless-containers/slirp4netns/issues])
2+
AC_INIT([slirp4netns], [0.4.5+dev], [https://github.com/rootless-containers/slirp4netns/issues])
33
AC_CONFIG_SRCDIR([main.c])
44
AC_CONFIG_HEADERS([config.h])
55

vendor.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -eux -o pipefail
3-
# Mar 17, 2020 (v4.2.0)
4-
LIBSLIRP_COMMIT=daba14c3416fa9641ab4453a9a11e7f8bde08875
3+
# Apr 22, 2020 (v4.3.0)
4+
LIBSLIRP_COMMIT=3b478b0028d210518b5cc16ec9f208192ad31caa
55
LIBSLIRP_REPO=https://gitlab.freedesktop.org/slirp/libslirp.git
66

77
# Feb 21, 2020

vendor/README.md

Lines changed: 1 addition & 1 deletion
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 (`daba14c3416fa9641ab4453a9a11e7f8bde08875`)
4+
* libslirp: https://gitlab.freedesktop.org/slirp/libslirp.git (`3b478b0028d210518b5cc16ec9f208192ad31caa`)
55
* parson: https://github.com/kgabis/parson.git (`70dc239f8f54c80bf58477b25435fd3dd3102804`)
66

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

vendor/libslirp/src/ip_input.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,7 @@ static struct ip *ip_reass(Slirp *slirp, struct ip *ip, struct ipq *fp)
327327
*/
328328
q = fp->frag_link.next;
329329
m = dtom(slirp, q);
330-
331-
int was_ext = m->m_flags & M_EXT;
330+
int delta = (char *)q - (m->m_flags & M_EXT ? m->m_ext : m->m_dat);
332331

333332
q = (struct ipasfrag *)q->ipf_next;
334333
while (q != (struct ipasfrag *)&fp->frag_link) {
@@ -351,8 +350,7 @@ static struct ip *ip_reass(Slirp *slirp, struct ip *ip, struct ipq *fp)
351350
* then an m_ext buffer was alloced. But fp->ipq_next points to the old
352351
* buffer (in the mbuf), so we must point ip into the new buffer.
353352
*/
354-
if (!was_ext && m->m_flags & M_EXT) {
355-
int delta = (char *)q - m->m_dat;
353+
if (m->m_flags & M_EXT) {
356354
q = (struct ipasfrag *)(m->m_ext + delta);
357355
}
358356

vendor/libslirp/src/libslirp-version.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ extern "C" {
77
#endif
88

99
#define SLIRP_MAJOR_VERSION 4
10-
#define SLIRP_MINOR_VERSION 2
10+
#define SLIRP_MINOR_VERSION 3
1111
#define SLIRP_MICRO_VERSION 0
12+
#define SLIRP_VERSION_STRING "4.3.0-git"
1213

1314
#define SLIRP_CHECK_VERSION(major,minor,micro) \
1415
(SLIRP_MAJOR_VERSION > (major) || \

vendor/libslirp/src/libslirp.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ typedef struct SlirpCb {
6767
} SlirpCb;
6868

6969
#define SLIRP_CONFIG_VERSION_MIN 1
70-
#define SLIRP_CONFIG_VERSION_MAX 2
70+
#define SLIRP_CONFIG_VERSION_MAX 3
7171

7272
typedef struct SlirpConfig {
7373
/* Version must be provided */
@@ -109,6 +109,10 @@ typedef struct SlirpConfig {
109109
*/
110110
struct sockaddr_in *outbound_addr;
111111
struct sockaddr_in6 *outbound_addr6;
112+
/*
113+
* Fields introduced in SlirpConfig version 3 begin
114+
*/
115+
bool disable_dns; /* slirp will not redirect/serve any DNS packet */
112116
} SlirpConfig;
113117

114118
Slirp *slirp_new(const SlirpConfig *cfg, const SlirpCb *callbacks,

vendor/libslirp/src/slirp.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
#include <net/if.h>
3030
#endif
3131

32+
/* https://gitlab.freedesktop.org/slirp/libslirp/issues/18 */
33+
#if defined(__NetBSD__) && defined(if_mtu)
34+
#undef if_mtu
35+
#endif
36+
3237
int slirp_debug;
3338

3439
/* Define to 1 if you want KEEPALIVE timers */
@@ -333,6 +338,13 @@ Slirp *slirp_new(const SlirpConfig *cfg, const SlirpCb *callbacks, void *opaque)
333338
slirp->outbound_addr = NULL;
334339
slirp->outbound_addr6 = NULL;
335340
}
341+
342+
if (cfg->version >= 3) {
343+
slirp->disable_dns = cfg->disable_dns;
344+
} else {
345+
slirp->disable_dns = false;
346+
}
347+
336348
return slirp;
337349
}
338350

vendor/libslirp/src/slirp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ struct Slirp {
202202

203203
struct sockaddr_in *outbound_addr;
204204
struct sockaddr_in6 *outbound_addr6;
205+
bool disable_dns; /* slirp will not redirect/serve any DNS packet */
205206
};
206207

207208
void if_start(Slirp *);

vendor/libslirp/src/socket.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -821,8 +821,8 @@ void sofwdrain(struct socket *so)
821821

822822
static bool sotranslate_out4(Slirp *s, struct socket *so, struct sockaddr_in *sin)
823823
{
824-
if (so->so_faddr.s_addr == s->vnameserver_addr.s_addr) {
825-
return get_dns_addr(&sin->sin_addr) >= 0;
824+
if (!s->disable_dns && so->so_faddr.s_addr == s->vnameserver_addr.s_addr) {
825+
return so->so_fport == htons(53) && get_dns_addr(&sin->sin_addr) >= 0;
826826
}
827827

828828
if (so->so_faddr.s_addr == s->vhost_addr.s_addr ||
@@ -839,8 +839,13 @@ static bool sotranslate_out4(Slirp *s, struct socket *so, struct sockaddr_in *si
839839

840840
static bool sotranslate_out6(Slirp *s, struct socket *so, struct sockaddr_in6 *sin)
841841
{
842-
if (in6_equal(&so->so_faddr6, &s->vnameserver_addr6)) {
843-
return get_dns6_addr(&sin->sin6_addr, &sin->sin6_scope_id) >= 0;
842+
if (!s->disable_dns && in6_equal(&so->so_faddr6, &s->vnameserver_addr6)) {
843+
uint32_t scope_id;
844+
if (so->so_fport == htons(53) && get_dns6_addr(&sin->sin6_addr, &scope_id) >= 0) {
845+
sin->sin6_scope_id = scope_id;
846+
return true;
847+
}
848+
return false;
844849
}
845850

846851
if (in6_equal_net(&so->so_faddr6, &s->vprefix_addr6, s->vprefix_len) ||

vendor/libslirp/src/version.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
/* SPDX-License-Identifier: BSD-3-Clause */
22
#include "libslirp.h"
3-
#include "util.h"
43

54
const char *
65
slirp_version_string(void)
76
{
8-
return stringify(SLIRP_MAJOR_VERSION) "."
9-
stringify(SLIRP_MINOR_VERSION) "."
10-
stringify(SLIRP_MICRO_VERSION);
7+
return SLIRP_VERSION_STRING;
118
}

0 commit comments

Comments
 (0)