diff options
author | Jan Kiszka <jan.kiszka@siemens.com> | 2011-07-20 12:20:18 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2011-07-23 10:19:50 -0500 |
commit | 68a340053c766490b3c7460e543aebcc4bee4efa (patch) | |
tree | e8a4e80e36569cb2bc6047f048c54a46a6a5f3ed /slirp.c | |
parent | af35375b6d600cf553f0d0748b2a10ff7dbf6142 (diff) | |
download | slirp-68a340053c766490b3c7460e543aebcc4bee4efa.zip slirp-68a340053c766490b3c7460e543aebcc4bee4efa.tar.gz slirp-68a340053c766490b3c7460e543aebcc4bee4efa.tar.bz2 |
slirp: Forward ICMP echo requests via unprivileged socketsv0.15.0-rc0
Linux 3.0 gained support for unprivileged ICMP ping sockets. Use this
feature to forward guest pings to the outer world. The host admin has to
set the ping_group_range in order to grant access to those sockets. To
allow ping for the users group (GID 100):
echo 100 100 > /proc/sys/net/ipv4/ping_group_range
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'slirp.c')
-rw-r--r-- | slirp.c | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -376,6 +376,30 @@ void slirp_select_fill(int *pnfds, fd_set *readfds, fd_set *writefds, UPD_NFDS(so->s); } } + + /* + * ICMP sockets + */ + for (so = slirp->icmp.so_next; so != &slirp->icmp; so = so_next) { + so_next = so->so_next; + + /* + * See if it's timed out + */ + if (so->so_expire) { + if (so->so_expire <= curtime) { + icmp_detach(so); + continue; + } else { + do_slowtimo = 1; /* Let socket expire */ + } + } + + if (so->so_state & SS_ISFCONNECTED) { + FD_SET(so->s, readfds); + UPD_NFDS(so->s); + } + } } *pnfds = nfds; @@ -542,6 +566,17 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds, sorecvfrom(so); } } + + /* + * Check incoming ICMP relies. + */ + for (so = slirp->icmp.so_next; so != &slirp->icmp; so = so_next) { + so_next = so->so_next; + + if (so->s != -1 && FD_ISSET(so->s, readfds)) { + icmp_receive(so); + } + } } /* |