libslirp.git
8 weeks agoMerge branch 'master' into 'master' master
Samuel Thibault [Sat, 3 Dec 2022 23:39:03 +0000 (23:39 +0000)] 
Merge branch 'master' into 'master'

slirp: use localhost as dns when /etc/resolv.conf empty

Closes #25

See merge request slirp/libslirp!130

8 weeks agoslirp: use localhost as dns when /etc/resolv.conf empty
Jiri Slaby [Sat, 3 Dec 2022 23:39:03 +0000 (23:39 +0000)] 
slirp: use localhost as dns when /etc/resolv.conf empty

2 months agomissing semicolon
pgajdos on gitlab.freedesktop.org [Fri, 11 Nov 2022 11:42:05 +0000 (12:42 +0100)] 
missing semicolon

Fixes #64

5 months agoDrop unused UDP_UDPDATALEN macro
Samuel Thibault [Sun, 28 Aug 2022 23:33:50 +0000 (01:33 +0200)] 
Drop unused UDP_UDPDATALEN macro

5 months agoReject domain-search when any entry ends with ".."
Samuel Thibault [Sun, 28 Aug 2022 22:52:28 +0000 (00:52 +0200)] 
Reject domain-search when any entry ends with ".."

rather than rejecting only when all of them are bogus.

Reported-by: Michael T <michael.gr220@gmail.com>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
5 months agoMerge branch 'icmp6-na-use-target' into 'master'
Samuel Thibault [Sun, 7 Aug 2022 19:22:49 +0000 (19:22 +0000)] 
Merge branch 'icmp6-na-use-target' into 'master'

Use target address from Neighbor Advertisement

See merge request slirp/libslirp!129

5 months agoUse target address from Neighbor Advertisement
Bastian Blank [Sun, 7 Aug 2022 10:44:19 +0000 (12:44 +0200)] 
Use target address from Neighbor Advertisement

The IPv6 support in libslirp fails to work with any NDP proxy.  The code
used to interpret the NA packets uses the wrong address to insert into
it's neighbor table, the address of the source of the packet, aka the
proxy itself.

However the NA packet got the real target address readily available.
Just use it directly instead.

Signed-off-by: Bastian Blank <waldi@debian.org>
7 months agoMerge branch 'vmstate' into 'master'
Samuel Thibault [Wed, 22 Jun 2022 16:02:39 +0000 (16:02 +0000)] 
Merge branch 'vmstate' into 'master'

Fix vmstate regression

See merge request slirp/libslirp!127

7 months agoFix vmstate regression
Marc-André Lureau [Wed, 22 Jun 2022 15:10:47 +0000 (19:10 +0400)] 
Fix vmstate regression

Commit e7362700b ("msvc: enable vmstate code on !gnuc") forgot to remove
HAVE_VMSTATE condition...

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
7 months agomsvc: use char* for pointer arithmetic
Marc-André Lureau [Wed, 22 Jun 2022 15:16:59 +0000 (19:16 +0400)] 
msvc: use char* for pointer arithmetic

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
7 months agoAlign outgoing packets
Samuel Thibault [Fri, 17 Jun 2022 23:22:20 +0000 (01:22 +0200)] 
Align outgoing packets

Fixes #62

7 months agoBump incoming packet alignment to 8 bytes
Samuel Thibault [Fri, 17 Jun 2022 23:21:25 +0000 (01:21 +0200)] 
Bump incoming packet alignment to 8 bytes

Fixes #63

8 months agoMerge branch 'msvc' into 'master'
Samuel Thibault [Mon, 30 May 2022 09:03:15 +0000 (09:03 +0000)] 
Merge branch 'msvc' into 'master'

msvc: enable vmstate code on !gnuc

See merge request slirp/libslirp!126

8 months agomsvc: fix some gcc-specific pragma warnings
Marc-André Lureau [Mon, 30 May 2022 08:47:56 +0000 (10:47 +0200)] 
msvc: fix some gcc-specific pragma warnings

8 months agomsvc: enable vmstate code on !gnuc
Marc-André Lureau [Mon, 30 May 2022 08:44:38 +0000 (10:44 +0200)] 
msvc: enable vmstate code on !gnuc

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
8 months agoMerge branch 'msvc' into 'master'
Marc-André Lureau [Mon, 30 May 2022 07:51:17 +0000 (07:51 +0000)] 
Merge branch 'msvc' into 'master'

msvc fixes

Closes #60

See merge request slirp/libslirp!124

8 months agovmstate: only enable when building under GNU C
Samuel Thibault [Fri, 13 May 2022 14:23:10 +0000 (16:23 +0200)] 
vmstate: only enable when building under GNU C

To be able to use typeof.

Fixes #60

8 months agoncsitest: Fix build with msvc
Samuel Thibault [Sun, 29 May 2022 22:41:00 +0000 (00:41 +0200)] 
ncsitest: Fix build with msvc

8 months agoAvoid running git-version-gen when building with MS VC
Samuel Thibault [Tue, 17 May 2022 16:10:12 +0000 (18:10 +0200)] 
Avoid running git-version-gen when building with MS VC

The toolchain usually used there would typically completely fail to run
it.

8 months agowindows: export symbols
Samuel Thibault [Mon, 16 May 2022 22:44:56 +0000 (00:44 +0200)] 
windows: export symbols

8 months agowin32: replace strcasecmp with g_ascii_strcasecmp
Samuel Thibault [Sat, 14 May 2022 19:01:57 +0000 (21:01 +0200)] 
win32: replace strcasecmp with g_ascii_strcasecmp

8 months agoDrop spurious inline
Samuel Thibault [Sat, 14 May 2022 18:58:35 +0000 (20:58 +0200)] 
Drop spurious inline

8 months agoAvoid returning void
Samuel Thibault [Sat, 14 May 2022 18:48:44 +0000 (20:48 +0200)] 
Avoid returning void

8 months agoFix arithmetic on void *
Samuel Thibault [Sat, 14 May 2022 18:47:08 +0000 (20:47 +0200)] 
Fix arithmetic on void *

8 months agoAvoid using ##__VA_ARGS__ gcc extension
Samuel Thibault [Sat, 14 May 2022 18:09:49 +0000 (20:09 +0200)] 
Avoid using ##__VA_ARGS__ gcc extension

8 months agoFix bitfields order for MSVC
Samuel Thibault [Sat, 14 May 2022 14:36:28 +0000 (16:36 +0200)] 
Fix bitfields order for MSVC

It uses a saner strictly "from low to high bit" rule.

8 months agoSeparate out SLIRP_PACKED to SLIRP_PACKED_BEGIN/END
Samuel Thibault [Sat, 14 May 2022 14:16:00 +0000 (16:16 +0200)] 
Separate out SLIRP_PACKED to SLIRP_PACKED_BEGIN/END

Since msvc provides the support through push/pop pragmas.

8 months agoDo not use ssize_t on Windows
Samuel Thibault [Sat, 14 May 2022 13:40:02 +0000 (15:40 +0200)] 
Do not use ssize_t on Windows

It doesn't have it.

8 months agoDo not include unistd.h on windows, it does not have it
Samuel Thibault [Sat, 14 May 2022 12:00:52 +0000 (14:00 +0200)] 
Do not include unistd.h on windows, it does not have it

8 months agoAccept build-aux/git-version-gen failing to run
Samuel Thibault [Fri, 13 May 2022 19:29:59 +0000 (21:29 +0200)] 
Accept build-aux/git-version-gen failing to run

and just revert to meson.project_version()

8 months agocontainer_of: avoid using __extension__
Samuel Thibault [Fri, 13 May 2022 14:33:01 +0000 (16:33 +0200)] 
container_of: avoid using __extension__

We can just write the macro on one line.

8 months agoMerge branch 'master' into 'master'
Samuel Thibault [Sat, 28 May 2022 20:08:30 +0000 (20:08 +0000)] 
Merge branch 'master' into 'master'

ncsi: Add Mellanox Get MAC Address handler

See merge request slirp/libslirp!125

8 months agoncsi: Add Mellanox Get Mac Address handler
Peter Delevoryas [Mon, 16 May 2022 22:49:48 +0000 (15:49 -0700)] 
ncsi: Add Mellanox Get Mac Address handler

Attempted to mirror the upstream Linux driver[1] as closely as reasonably
possible.

[1] https://github.com/torvalds/linux/blob/42226c989789d8da4af1de0c31070c96726d990c/net/ncsi/ncsi-rsp.c#L614-L638

Signed-off-by: Peter Delevoryas <pdel@fb.com>
8 months agoslirp: Add out-of-band ethernet address
Peter Delevoryas [Mon, 16 May 2022 23:05:35 +0000 (16:05 -0700)] 
slirp: Add out-of-band ethernet address

If a network card supports NC-SI, then it redirects all traffic with the
out-of-band (OOB) management controller's (MC) ethernet address to the
out-of-band management controller, usually over some sideband RMII
interface, not like the PCIe connection to the main host.

It's also pretty common for the network card to provision the out-of-band
management controller's ethernet address. At startup, the OOB MC asks the
network card what its MAC address is through OEM NC-SI commands. This
protocol is so common that it's going to be standardized soon in NC-SI 1.2.0
[1] as "Get MC MAC Address".

Note: At some point, the network card may provision *multiple* OOB ethernet
addresses, but right now everything just uses one.

[1] https://www.dmtf.org/sites/default/files/standards/documents/DSP0222_1.2.0WIP80.pdf

Signed-off-by: Peter Delevoryas <pdel@fb.com>
8 months agoncsi: Add OEM command handler
Peter Delevoryas [Sat, 14 May 2022 22:33:16 +0000 (15:33 -0700)] 
ncsi: Add OEM command handler

This commit just sets up the OEM command handler to respond with
"unsupported" for now, as verified in the test.

Signed-off-by: Peter Delevoryas <pdel@fb.com>
8 months agoncsi: Add basic test for Get Version ID response
Peter Delevoryas [Sat, 14 May 2022 22:32:13 +0000 (15:32 -0700)] 
ncsi: Add basic test for Get Version ID response

Signed-off-by: Peter Delevoryas <pdel@fb.com>
8 months agoncsi: Use response header for payload length
Peter Delevoryas [Sat, 14 May 2022 03:12:35 +0000 (20:12 -0700)] 
ncsi: Use response header for payload length

In the Linux NC-SI driver[1], each response's length is validated with a
statically declared payload length, _unless_ it's an OEM command or some
more complicated NC-SI packet that you can't determine the length of just
from the "type" field, in which case it just uses the length provided by the
response's header.

To support OEM response handlers without requiring too many modifications we
can make the default payload length use the value specified in the handler
table, and then allow OEM handlers to override the length by modifying the
"length" in the response header within the handler implementation.

[1] https://github.com/torvalds/linux/blob/ec7f49619d8ee13e108740c82f942cd401b989e9/net/ncsi/ncsi-rsp.c#L1215-L1220

Signed-off-by: Peter Delevoryas <pdel@fb.com>
8 months agoncsi: Pass command header to response handlers
Peter Delevoryas [Sat, 14 May 2022 02:56:45 +0000 (19:56 -0700)] 
ncsi: Pass command header to response handlers

This change passes the command header as an additional read-only parameter
to each response handler so that they can make more response handling
descisions based on the command header fields. This is especially useful for
handling OEM NC-SI commands, or any protocol that's encapsulated in an NC-SI
header.

Signed-off-by: Peter Delevoryas <pdel@fb.com>
8 months agosrc/slirp.h: Bump the minimum Windows version to Windows 7
Thomas Huth [Mon, 16 May 2022 09:04:10 +0000 (11:04 +0200)] 
src/slirp.h: Bump the minimum Windows version to Windows 7

Windows Vista is not supported by its vendor anymore. Additionally,
glib uses 0x0601 as setting for _WIN32_WINNT since version 2.53.6
already, so unless libslirp is used with a very old version of glib,
we are depending on Windows 7 anyway.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Message-Id: <20220516090410.39727-1-thuth@redhat.com>

8 months agoMerge branch 'iana' into 'master'
Samuel Thibault [Wed, 11 May 2022 23:26:32 +0000 (23:26 +0000)] 
Merge branch 'iana' into 'master'

ncsi: Add basic Get Version ID response

See merge request slirp/libslirp!122

8 months agoncsi: Add Get Version ID command
Peter Delevoryas [Fri, 3 Dec 2021 05:20:56 +0000 (21:20 -0800)] 
ncsi: Add Get Version ID command

Get Version ID is one of the first commands used in NC-SI, because BMC's
use a lot of OEM NC-SI extensions, and you need to query the device's
manufacturer through Get Version ID before you can decide which OEM
NC-SI extensions to use.

The response format is documented in the NC-SI spec[1]. We're just
setting the NC-SI version supported to 1.0.0 (BCD-encoded[2]) and
returning the manufacturer's ID in network byte-order.

[1] https://www.dmtf.org/sites/default/files/standards/documents/DSP0222_1.0.0.pdf
[2] https://en.wikipedia.org/wiki/Binary-coded_decimal

Signed-off-by: Peter Delevoryas <pdel@fb.com>
8 months agoncsi: Pass Slirp structure to response handlers
Peter Delevoryas [Fri, 3 Dec 2021 05:13:39 +0000 (21:13 -0800)] 
ncsi: Pass Slirp structure to response handlers

This will let us use Slirp fields to generate more interesting NC-SI
responses.

Signed-off-by: Peter Delevoryas <pdel@fb.com>
8 months agoslirp: Add manufacturer's ID
Peter Delevoryas [Thu, 2 Dec 2021 07:54:04 +0000 (23:54 -0800)] 
slirp: Add manufacturer's ID

The manufacturer's ID is used in NC-SI commands such as "Get Version ID"
[1]. It is also essential to providing a path towards adding OEM
(non-standardized) NC-SI commands.

This field should be derived from the IANA Private Enterprise Numbers list,
per the NC-SI specification. It may be useful for things besides NC-SI, but
NC-SI responses for BMC's in QEMU are the main use case I have in mind.

Note: I did not add this attribute to slirp_init, since it is deprecated.

[1] https://www.dmtf.org/sites/default/files/standards/documents/DSP0222_1.0.0.pdf
[2] https://www.iana.org/assignments/enterprise-numbers/enterprise-numbers

Signed-off-by: Peter Delevoryas <pdel@fb.com>
8 months agoMerge branch 'haiku' into 'master'
Samuel Thibault [Sun, 8 May 2022 16:21:32 +0000 (16:21 +0000)] 
Merge branch 'haiku' into 'master'

Add support for Haiku to meson.build

See merge request slirp/libslirp!123

8 months agoAdd support for Haiku to meson.build
Ivan Holmes [Sun, 8 May 2022 16:14:29 +0000 (17:14 +0100)] 
Add support for Haiku to meson.build

8 months agoMerge branch 'warnings' into 'master'
Samuel Thibault [Wed, 4 May 2022 22:12:29 +0000 (22:12 +0000)] 
Merge branch 'warnings' into 'master'

win32: declare some local functions as static

See merge request slirp/libslirp!121

8 months agomeson: add extra warnings
Paolo Bonzini [Wed, 4 May 2022 21:53:55 +0000 (23:53 +0200)] 
meson: add extra warnings

Enable extra warnings based no what QEMU uses.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
8 months agowin32: declare some local functions as static
Paolo Bonzini [Wed, 4 May 2022 21:54:29 +0000 (23:54 +0200)] 
win32: declare some local functions as static

These functions do not have a prototype and are not meant to be public.
Declare them as static.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
9 months agoMerge branch 'inet6_bsd' into 'master'
Samuel Thibault [Mon, 2 May 2022 06:41:17 +0000 (06:41 +0000)] 
Merge branch 'inet6_bsd' into 'master'

Include <sys/socket.h> and <arpa/inet.h> for AF_INET6 and inet_pton

Closes #58

See merge request slirp/libslirp!120

9 months agoInclude <sys/socket.h> and <arpa/inet.h> for AF_INET6 and inet_pton
Samuel Thibault [Sun, 1 May 2022 18:36:15 +0000 (20:36 +0200)] 
Include <sys/socket.h> and <arpa/inet.h> for AF_INET6 and inet_pton

Fixes #58

9 months agoMerge branch '4.7' into 'master'
Marc-André Lureau [Wed, 27 Apr 2022 07:04:21 +0000 (07:04 +0000)] 
Merge branch '4.7' into 'master'

Release v4.7.0

See merge request slirp/libslirp!119

9 months agoRelease v4.7.0 v4.7.0
Marc-André Lureau [Tue, 26 Apr 2022 09:50:57 +0000 (13:50 +0400)] 
Release v4.7.0

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
9 months agoMerge branch 'opaque-timer' into 'master'
Marc-André Lureau [Mon, 25 Apr 2022 08:36:12 +0000 (08:36 +0000)] 
Merge branch 'opaque-timer' into 'master'

Support for CFI

See merge request slirp/libslirp!117

9 months agobump ABI version and age
Paolo Bonzini [Mon, 11 Apr 2022 07:18:54 +0000 (09:18 +0200)] 
bump ABI version and age

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
9 months agoslirp: invoke client callback before creating timers
Paolo Bonzini [Mon, 11 Apr 2022 10:24:58 +0000 (12:24 +0200)] 
slirp: invoke client callback before creating timers

The introduction of .timer_new_opaque adds an interesting conundrum.
The Slirp* needs to be stored in .timer_new_opaque so that it can be
passed back to slirp_handle_timer, but it is not returned by slirp_new
and slirp_init until after the first call to .timer_new_opaque (which
is in ip6_init).  This is a problem for programs that, like QEMU, use
more than one Slirp*.

Fix them by passing the Slirp* to a callback before slirp_new returns,
and initializing the timer afterwards.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
9 months agopingtest: port to timer_new_opaque
Paolo Bonzini [Sun, 10 Apr 2022 13:53:43 +0000 (15:53 +0200)] 
pingtest: port to timer_new_opaque

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
9 months agointroduce timer_new_opaque callback
Paolo Bonzini [Wed, 28 Jul 2021 15:16:06 +0000 (17:16 +0200)] 
introduce timer_new_opaque callback

Add a new callback that supports CFI better by avoiding having function pointers
in the external libslirp API.  Instead, the new API passes an opaque integer
and requests the application to call a new libslirp function when the timer
expires.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
9 months agointroduce slirp_timer_new wrapper
Paolo Bonzini [Wed, 28 Jul 2021 15:09:19 +0000 (17:09 +0200)] 
introduce slirp_timer_new wrapper

In order to support CFI, we would like to avoid passing function pointers out of
libslirp, and instead use opaque integers for the timer callbacks.  This patch
introduces an internal API for creating a timer that is based on such a timer
callback.

For now, it receives the id (SLIRP_TIMER_RA is the only one) and calls
slirp->cb->timer_new.  The prototype of ra_timer_handler is changed slightly
to fit better with the next patch which introduces a new libslirp function,
to be called on timer expiration.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
9 months agoicmp6: make ndp_send_ra static
Paolo Bonzini [Wed, 28 Jul 2021 15:03:33 +0000 (17:03 +0200)] 
icmp6: make ndp_send_ra static

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
10 months agoAdd sanitizers CI runs
Samuel Thibault [Sun, 20 Mar 2022 21:02:23 +0000 (22:02 +0100)] 
Add sanitizers CI runs

10 months agoMerge branch 'handle-econnaborted' into 'master'
Samuel Thibault [Fri, 4 Mar 2022 18:27:14 +0000 (18:27 +0000)] 
Merge branch 'handle-econnaborted' into 'master'

Handle ECONNABORTED from recv

See merge request slirp/libslirp!116

10 months agosocket: Handle ECONNABORTED from recv
Rich [Fri, 4 Mar 2022 18:17:35 +0000 (18:17 +0000)] 
socket: Handle ECONNABORTED from recv

recv can return ECONNABORTED due to a time-out on the socket. The socket is no longer useable once it enters this state.

11 months agoMerge branch 'bootp-has-prefix' into 'master'
Samuel Thibault [Thu, 17 Feb 2022 12:00:28 +0000 (12:00 +0000)] 
Merge branch 'bootp-has-prefix' into 'master'

bootp: fix g_str_has_prefix warning/critical

See merge request slirp/libslirp!115

11 months agobootp: fix g_str_has_prefix warning/critical
Marc-André Lureau [Thu, 17 Feb 2022 08:07:43 +0000 (12:07 +0400)] 
bootp: fix g_str_has_prefix warning/critical

Fixes: commit 60535013c3e ("bootp: add support for UEFI HTTP boot")
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
11 months agoslirp: Don't duplicate packet in tcp_reass
Brett Nash [Thu, 10 Feb 2022 19:02:22 +0000 (11:02 -0800)] 
slirp: Don't duplicate packet in tcp_reass

When debug is enabled, we duplicate the packet in tcp_reass, but ti is still
pointing to the old buffer, resulting in a use after free.

This makes valgrind debugging a little trickier, but makes it
crash a lot less.

Signed-off-by: Brett Nash <nash@fb.com>
11 months agoRename insque/remque -> slirp_[ins|rem]que
Brett Nash [Thu, 10 Feb 2022 19:14:13 +0000 (11:14 -0800)] 
Rename insque/remque -> slirp_[ins|rem]que

Avoid a macro translation when not needed, and potentially doing really
weird things to headers.

11 months agoMerge branch 'debug-fix' into 'master'
Marc-André Lureau [Thu, 10 Feb 2022 22:25:37 +0000 (22:25 +0000)] 
Merge branch 'debug-fix' into 'master'

mbuf: Use SLIRP_DEBUG to enable mbuf debugging instead of DEBUG

See merge request slirp/libslirp!114

11 months agombuf: Use SLIRP_DEBUG to enable mbuf debugging instead of DEBUG
Brett Nash [Thu, 10 Feb 2022 21:46:04 +0000 (21:46 +0000)] 
mbuf: Use SLIRP_DEBUG to enable mbuf debugging instead of DEBUG

DEBUG is set by a number of IDEs and development environments (*cough*
xcode *cough*).  This means we use mbuf duplication when we don't need
(or expect) it.  Change the name to SLIRP_DEBUG to enable this feature.

Signed-off-by: Pablo Fiori <pablofiori@fb.com>
Signed-off-by: Brett Nash <nash@fb.com>
11 months agoReplace inet_ntoa() with safer inet_ntop()
Marc-André Lureau [Wed, 9 Feb 2022 18:15:08 +0000 (22:15 +0400)] 
Replace inet_ntoa() with safer inet_ntop()

inet_ntoa() returns a static pointer which is subject to safety issues.
Use the recommended alternative.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
11 months agoMerge branch 'libslirp-vmsend' into 'master'
Samuel Thibault [Wed, 2 Feb 2022 11:58:14 +0000 (11:58 +0000)] 
Merge branch 'libslirp-vmsend' into 'master'

Add VMS_END marker

See merge request slirp/libslirp!112

11 months agoAdd VMS_END marker
Dr. David Alan Gilbert [Wed, 2 Feb 2022 10:59:10 +0000 (10:59 +0000)] 
Add VMS_END marker

The migration VMSTATE_END_OF_LIST marker relies on a NULL field
to mark th eend of a list;  that's a bit delicate when the marker is
forgotten and the code hits a NULL by luck.

Use an explicit flag to mark the end as well.

See: https://lists.gnu.org/archive/html/qemu-devel/2022-01/msg03025.html

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
12 months agoMerge branch 'vendor-class-id' into 'master'
Samuel Thibault [Tue, 25 Jan 2022 23:41:06 +0000 (23:41 +0000)] 
Merge branch 'vendor-class-id' into 'master'

bootp: add support for UEFI HTTP boot

See merge request slirp/libslirp!111

12 months agobootp: add support for UEFI HTTP boot
Ignat Korchagin [Tue, 25 Jan 2022 23:10:08 +0000 (23:10 +0000)] 
bootp: add support for UEFI HTTP boot

Current bootp implementation is only one step away from supporting UEFI HTTP
boot in QEMU. The only missing bit is that the UEFI specification [1] requires
a vendor class identifier option (num 60) set to "HTTPClient" string present
in the DHCP response.

OVMF [2] indeed ignores the DHCP response and considers UEFI HTTP boot as
failed, if this option is not present.

With this change one would be able to configure QEMU user networking like
below:

$ qemu ... -nic user,tftp=tftp-root,bootfile=http://10.0.2.2/ipxe.efi

and boot the VM using UEFI HTTP boot instead of TFTP.

[1]: https://uefi.org/sites/default/files/resources/UEFI_Spec_2_9_2021_03_18.pdf
[2]: https://github.com/tianocore/edk2/tree/5302bd81d9ba0c9e7f2371a81c438ec919ec8e1e/OvmfPkg

Signed-off-by: Ignat Korchagin <ignat@cloudflare.com>
12 months agoMerge branch 'dns6' into 'master'
Samuel Thibault [Mon, 24 Jan 2022 21:28:19 +0000 (21:28 +0000)] 
Merge branch 'dns6' into 'master'

IPv6 DNS proxying support

Closes #55

See merge request slirp/libslirp!110

12 months agoIPv6 DNS proxying support
Noah [Mon, 24 Jan 2022 21:28:19 +0000 (21:28 +0000)] 
IPv6 DNS proxying support

12 months agoAdd missing scope_id in caching
Samuel Thibault [Sun, 23 Jan 2022 21:34:41 +0000 (22:34 +0100)] 
Add missing scope_id in caching

13 months agoDrop fixed TODO
Samuel Thibault [Sun, 12 Dec 2021 01:04:04 +0000 (02:04 +0100)] 
Drop fixed TODO

13 months agoMerge branch 'hostfwd-unix' into 'master'
Samuel Thibault [Sun, 12 Dec 2021 01:03:37 +0000 (01:03 +0000)] 
Merge branch 'hostfwd-unix' into 'master'

Support Unix sockets in hostfwd

See merge request slirp/libslirp!103

14 months agosocket: Move closesocket(so->s_aux) to sofree
Nicholas Ngai [Tue, 30 Nov 2021 16:48:46 +0000 (08:48 -0800)] 
socket: Move closesocket(so->s_aux) to sofree

Signed-off-by: Nicholas Ngai <nicholas@ngai.me>
14 months agosocket: Check so_type instead of so_tcpcb for Unix-to-inet translation
Nicholas Ngai [Tue, 30 Nov 2021 00:30:33 +0000 (16:30 -0800)] 
socket: Check so_type instead of so_tcpcb for Unix-to-inet translation

Signed-off-by: Nicholas Ngai <nicholas@ngai.me>
14 months agoMerge branch 'master' into hostfwd-unix
Nicholas Ngai [Tue, 30 Nov 2021 00:22:00 +0000 (16:22 -0800)] 
Merge branch 'master' into hostfwd-unix

Signed-off-by: Nicholas Ngai <nicholas@ngai.me>
14 months agosocket: Add s_aux field to struct socket for storing auxilliary socket
Nicholas Ngai [Tue, 30 Nov 2021 00:21:17 +0000 (16:21 -0800)] 
socket: Add s_aux field to struct socket for storing auxilliary socket

Signed-off-by: Nicholas Ngai <nicholas@ngai.me>
14 months agoMerge branch 'init-so-type' into 'master'
Samuel Thibault [Tue, 30 Nov 2021 00:00:45 +0000 (00:00 +0000)] 
Merge branch 'init-so-type' into 'master'

socket: Initialize so_type in socreate

See merge request slirp/libslirp!109

14 months agosocket: Initialize so_type in socreate
Nicholas Ngai [Mon, 29 Nov 2021 23:54:20 +0000 (15:54 -0800)] 
socket: Initialize so_type in socreate

Signed-off-by: Nicholas Ngai <nicholas@ngai.me>
14 months agosocket: Allocate Unix-to-TCP hostfwd port from OS by binding to port 0
Nicholas Ngai [Sat, 27 Nov 2021 22:22:42 +0000 (14:22 -0800)] 
socket: Allocate Unix-to-TCP hostfwd port from OS by binding to port 0

Signed-off-by: Nicholas Ngai <nicholas@ngai.me>
14 months agoMerge branch 'disable-dhcp' into 'master'
Samuel Thibault [Sat, 20 Nov 2021 10:20:14 +0000 (10:20 +0000)] 
Merge branch 'disable-dhcp' into 'master'

Allow to disable internal DHCP server

See merge request slirp/libslirp!22

14 months agoAllow to disable internal DHCP server
Rafael Gieschke [Thu, 18 Nov 2021 21:43:12 +0000 (22:43 +0100)] 
Allow to disable internal DHCP server

Setting `cfg->disable_dhcp` to `true` will disable the internal DHCP server.

Signed-off-by: Rafael Gieschke <rafael@gieschke.de>
14 months agoMerge branch 'pingtest' into 'master'
Samuel Thibault [Thu, 11 Nov 2021 23:48:41 +0000 (23:48 +0000)] 
Merge branch 'pingtest' into 'master'

pingtest: Add a trivial ping test

See merge request slirp/libslirp!91

14 months agoMerge branch 'icmp_raw' into 'master'
Samuel Thibault [Thu, 11 Nov 2021 23:48:06 +0000 (23:48 +0000)] 
Merge branch 'icmp_raw' into 'master'

icmp: Support falling back on trying a SOCK_RAW socket

See merge request slirp/libslirp!92

14 months agoslirp_pollfds_fill: Explain why dividing so_snd.sb_datalen by two
Samuel Thibault [Thu, 11 Nov 2021 23:29:51 +0000 (00:29 +0100)] 
slirp_pollfds_fill: Explain why dividing so_snd.sb_datalen by two

14 months agoMerge branch 'ci-slirp4netns' into 'master'
Samuel Thibault [Mon, 8 Nov 2021 19:49:58 +0000 (19:49 +0000)] 
Merge branch 'ci-slirp4netns' into 'master'

CI: run integration tests with slirp4netns

Closes #50

See merge request slirp/libslirp!107

14 months agoCI: run integration tests with slirp4netns
Akihiro Suda [Mon, 8 Nov 2021 08:28:20 +0000 (17:28 +0900)] 
CI: run integration tests with slirp4netns

Fix issue 50

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
15 months agosocket: Check address family for Unix-to-inet accept translation
Nicholas Ngai [Wed, 13 Oct 2021 00:55:30 +0000 (17:55 -0700)] 
socket: Check address family for Unix-to-inet accept translation

Signed-off-by: Nicholas Ngai <nicholas@ngai.me>
15 months agosocket: Add debug args for tcpx_listen (inet and Unix sockets)
Nicholas Ngai [Wed, 13 Oct 2021 00:47:39 +0000 (17:47 -0700)] 
socket: Add debug args for tcpx_listen (inet and Unix sockets)

Signed-off-by: Nicholas Ngai <nicholas@ngai.me>
15 months agosocket: Restore original definition of fhost
Nicholas Ngai [Tue, 12 Oct 2021 23:57:27 +0000 (16:57 -0700)] 
socket: Restore original definition of fhost

Signed-off-by: Nicholas Ngai <nicholas@ngai.me>
15 months agosocket: Move <sys/un.h> include to socket.h
Nicholas Ngai [Tue, 12 Oct 2021 23:57:03 +0000 (16:57 -0700)] 
socket: Move <sys/un.h> include to socket.h

Signed-off-by: Nicholas Ngai <nicholas@ngai.me>
15 months agoMerge branch 'master' into 'master'
Samuel Thibault [Thu, 7 Oct 2021 19:56:15 +0000 (19:56 +0000)] 
Merge branch 'master' into 'master'

resolv: fix IPv6 resolution on Darwin

See merge request slirp/libslirp!104

16 months agoSupport Unix sockets in hostfwd
Nicholas Ngai [Mon, 27 Sep 2021 21:21:45 +0000 (14:21 -0700)] 
Support Unix sockets in hostfwd

QEMU has an issue open
(https://gitlab.com/qemu-project/qemu/-/issues/347) to forward a Unix
domain socket to guest TCP port. Both of these protocols support stream
modes of operation (and user-mode networking can only access the stream
anyway), so this patch enables Unix-to-TCP hostfwds.

Like with localhost hostfwds, the sotranslate_accept function will
translate a Unix domain socket connection to a TCP connection
originating from vhost_addr and a randomized ephemeral port.

Signed-off-by: Nicholas Ngai <nicholas@ngai.me>
16 months agoresolv: fix IPv6 resolution on Darwin
osy [Sun, 26 Sep 2021 22:36:00 +0000 (15:36 -0700)] 
resolv: fix IPv6 resolution on Darwin

res_sockaddr_union() has a field for IPv4 and a field for IPv6. When we
used `&servers[i].sin.sin_addr`, it does not return the right address
for IPv6.

16 months agoUse the exact sockaddr size in getnameinfo call
Samuel Thibault [Sat, 18 Sep 2021 19:11:01 +0000 (21:11 +0200)] 
Use the exact sockaddr size in getnameinfo call

On NetBSD, the sockaddr size passed to getnameinfo must match the
family.

(reworked from the patch suggestion from Yorick Hardy)

Fixes #52