Merge tag 'upstream/0.2.1'
Upstream version 0.2.1
Reinhard Tartler
5 years ago
66 | 66 |
libslirp_a_SOURCES = rd235_libslirp/src/qemu2libslirp.c
|
67 | 67 |
|
68 | 68 |
# define specific commit if git available or it was replaced during git-archive creation
|
69 | |
COMMIT := $(shell V=5e4789b9a21cab3315801e1750670e10a1c86a2a ; \
|
|
69 |
COMMIT := $(shell V=1797e46728440e93f9229d5a34874befe00b4cab ; \
|
70 | 70 |
expr match "$$V" ormat: >/dev/null \
|
71 | 71 |
&& (cd "$$abs_srcdir" && [ -d .git ] && git describe --always --abbrev=0 --dirty --exclude=\* || echo unknown) \
|
72 | 72 |
|| echo "$$V" )
|
41 | 41 |
$ sudo dnf install slirp4netns
|
42 | 42 |
```
|
43 | 43 |
|
44 | |
#### [Arch Linux](https://aur.archlinux.org/packages/slirp4netns-git/):
|
|
44 |
#### [Arch Linux](https://aur.archlinux.org/packages/slirp4netns/):
|
45 | 45 |
|
46 | |
If you're running Arch Linux you can install `slirp4netns-git` from AUR. When you're using an AUR helper ([yay](https://github.com/Jguer/yay), for example) simply use:
|
|
46 |
If you're running Arch Linux you can install `slirp4netns` (or [`slirp4netns-git`](https://aur.archlinux.org/packages/slirp4netns-git/)) from AUR. When you're using an AUR helper ([yay](https://github.com/Jguer/yay), for example) simply use:
|
47 | 47 |
|
48 | |
yay -S slirp4netns-git
|
|
48 |
yay -S slirp4netns
|
49 | 49 |
|
50 | 50 |
Otherwise make sure you have [base-devel](https://www.archlinux.org/groups/x86_64/base-devel/) installed and build a package manually:
|
51 | 51 |
|
52 | 52 |
cd $(mktemp -d)
|
53 | |
curl -Lo PKGBUILD "https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=slirp4netns-git"
|
|
53 |
curl -Lo PKGBUILD "https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=slirp4netns"
|
54 | 54 |
makepkg
|
55 | |
sudo pacman -U slirp4netns-git-*.pkg.tar.*
|
|
55 |
sudo pacman -U slirp4netns-*.pkg.tar.*
|
56 | 56 |
|
57 | 57 |
#### [openSUSE Tumbleweed](https://build.opensuse.org/package/show/openSUSE%3AFactory/slirp4netns)
|
58 | 58 |
|
|
72 | 72 |
```console
|
73 | 73 |
$ sudo zypper addrepo --refresh http://download.opensuse.org/repositories/devel:/kubic/SLE_15/devel:kubic.repo
|
74 | 74 |
$ sudo zypper install slirp4netns
|
|
75 |
```
|
|
76 |
|
|
77 |
#### [Debian GNU/Linux Sid](https://packages.debian.org/sid/slirp4netns)
|
|
78 |
|
|
79 |
```console
|
|
80 |
$ sudo apt install slirp4netns
|
75 | 81 |
```
|
76 | 82 |
|
77 | 83 |
### Usage
|
0 | 0 |
AC_PREREQ([2.69])
|
1 | |
AC_INIT([slirp4netns], [0.1], [https://github.com/rootless-containers/slirp4netns/issues])
|
|
1 |
AC_INIT([slirp4netns], [0.2.1], [https://github.com/rootless-containers/slirp4netns/issues])
|
2 | 2 |
AC_CONFIG_SRCDIR([main.c])
|
3 | 3 |
AC_CONFIG_HEADERS([config.h])
|
4 | 4 |
|
638 | 638 |
struct sockaddr_in addr;
|
639 | 639 |
socklen_t addrlen = sizeof(struct sockaddr_in);
|
640 | 640 |
struct sbuf *so_rcv = &so->so_rcv;
|
|
641 |
|
|
642 |
if (m->m_len > so_rcv->sb_datalen
|
|
643 |
- (so_rcv->sb_wptr - so_rcv->sb_data)) {
|
|
644 |
return 1;
|
|
645 |
}
|
641 | 646 |
|
642 | 647 |
memcpy(so_rcv->sb_wptr, m->m_data, m->m_len);
|
643 | 648 |
so_rcv->sb_wptr += m->m_len;
|
2 | 2 |
function wait_for_network_namespace {
|
3 | 3 |
# Wait that the namespace is ready.
|
4 | 4 |
COUNTER=0
|
5 | |
while [ $COUNTER -lt 10 ]; do
|
|
5 |
while [ $COUNTER -lt 40 ]; do
|
6 | 6 |
if nsenter --preserve-credentials -U -n --target=$1 true; then
|
7 | 7 |
break
|
8 | 8 |
else
|
|
15 | 15 |
function wait_for_network_device {
|
16 | 16 |
# Wait that the device appears.
|
17 | 17 |
COUNTER=0
|
18 | |
while [ $COUNTER -lt 20 ]; do
|
|
18 |
while [ $COUNTER -lt 40 ]; do
|
19 | 19 |
if nsenter --preserve-credentials -U -n --target=$1 ip addr show $2; then
|
20 | 20 |
break
|
21 | 21 |
else
|
|
27 | 27 |
|
28 | 28 |
function wait_process_exits {
|
29 | 29 |
COUNTER=0
|
30 | |
while [ $COUNTER -lt 20 ]; do
|
|
30 |
while [ $COUNTER -lt 40 ]; do
|
31 | 31 |
if kill -0 $1; then
|
32 | 32 |
sleep 0.5
|
33 | 33 |
else
|
|
39 | 39 |
|
40 | 40 |
function wait_for_ping_connectivity {
|
41 | 41 |
COUNTER=0
|
42 | |
while [ $COUNTER -lt 20 ]; do
|
|
42 |
while [ $COUNTER -lt 40 ]; do
|
43 | 43 |
if nsenter --preserve-credentials -U -n --target=$1 ping -c 1 -w 1 $2; then
|
44 | 44 |
break
|
45 | 45 |
else
|
|
48 | 48 |
let COUNTER=COUNTER+1
|
49 | 49 |
done
|
50 | 50 |
}
|
|
51 |
|
|
52 |
function wait_for_file_content {
|
|
53 |
# Wait for a file to get the specified content.
|
|
54 |
COUNTER=0
|
|
55 |
while [ $COUNTER -lt 20 ]; do
|
|
56 |
if grep $1 $2; then
|
|
57 |
break
|
|
58 |
else
|
|
59 |
sleep 0.5
|
|
60 |
fi
|
|
61 |
let COUNTER=COUNTER+1
|
|
62 |
done
|
|
63 |
}
|
21 | 21 |
|
22 | 22 |
wait_for_network_device $child tun11
|
23 | 23 |
|
24 | |
grep 1 configured
|
|
24 |
wait_for_file_content 1 configured
|
25 | 25 |
|
26 | 26 |
exit 0
|