diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2016-03-20 12:29:54 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2016-04-01 17:51:55 +0200 |
commit | 0b11c036620251f8f831ab8f0d9a7280ec1c4813 (patch) | |
tree | c8f390cd7e7cc6986b6a5febcdcaf5c99bc6012f /slirp | |
parent | de1d099a448beb2ec39af4bd9ce4dd6452a18cb5 (diff) |
slirp: Allow disabling IPv4 or IPv6
Add ipv4 and ipv6 boolean options, so the user can setup IPv4-only and
IPv6-only network environments.
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'slirp')
-rw-r--r-- | slirp/ip6_icmp.c | 8 | ||||
-rw-r--r-- | slirp/ip6_input.c | 5 | ||||
-rw-r--r-- | slirp/ip_input.c | 4 | ||||
-rw-r--r-- | slirp/libslirp.h | 3 | ||||
-rw-r--r-- | slirp/slirp.c | 10 | ||||
-rw-r--r-- | slirp/slirp.h | 2 |
6 files changed, 30 insertions, 2 deletions
diff --git a/slirp/ip6_icmp.c b/slirp/ip6_icmp.c index 9d61349c7d..09571bcd6b 100644 --- a/slirp/ip6_icmp.c +++ b/slirp/ip6_icmp.c @@ -24,6 +24,10 @@ static void ra_timer_handler(void *opaque) void icmp6_init(Slirp *slirp) { + if (!slirp->in6_enabled) { + return; + } + slirp->ra_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL, ra_timer_handler, slirp); timer_mod(slirp->ra_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + NDP_Interval); @@ -31,6 +35,10 @@ void icmp6_init(Slirp *slirp) void icmp6_cleanup(Slirp *slirp) { + if (!slirp->in6_enabled) { + return; + } + timer_del(slirp->ra_timer); timer_free(slirp->ra_timer); } diff --git a/slirp/ip6_input.c b/slirp/ip6_input.c index c0b11e73cd..ac2e3ea882 100644 --- a/slirp/ip6_input.c +++ b/slirp/ip6_input.c @@ -24,6 +24,11 @@ void ip6_cleanup(Slirp *slirp) void ip6_input(struct mbuf *m) { struct ip6 *ip6; + Slirp *slirp = m->slirp; + + if (!slirp->in6_enabled) { + goto bad; + } DEBUG_CALL("ip6_input"); DEBUG_ARG("m = %lx", (long)m); diff --git a/slirp/ip_input.c b/slirp/ip_input.c index b464f6baf0..cdd54833a3 100644 --- a/slirp/ip_input.c +++ b/slirp/ip_input.c @@ -80,6 +80,10 @@ ip_input(struct mbuf *m) register struct ip *ip; int hlen; + if (!slirp->in_enabled) { + goto bad; + } + DEBUG_CALL("ip_input"); DEBUG_ARG("m = %p", m); DEBUG_ARG("m_len = %d", m->m_len); diff --git a/slirp/libslirp.h b/slirp/libslirp.h index c4b25c90e6..127aa41d40 100644 --- a/slirp/libslirp.h +++ b/slirp/libslirp.h @@ -8,8 +8,9 @@ typedef struct Slirp Slirp; int get_dns_addr(struct in_addr *pdns_addr); -Slirp *slirp_init(int restricted, struct in_addr vnetwork, +Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork, struct in_addr vnetmask, struct in_addr vhost, + bool in6_enabled, struct in6_addr vprefix_addr6, uint8_t vprefix_len, struct in6_addr vhost6, const char *vhostname, const char *tftp_path, const char *bootfile, diff --git a/slirp/slirp.c b/slirp/slirp.c index 998f27876c..fef526c5ad 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -200,8 +200,9 @@ static void slirp_init_once(void) static void slirp_state_save(QEMUFile *f, void *opaque); static int slirp_state_load(QEMUFile *f, void *opaque, int version_id); -Slirp *slirp_init(int restricted, struct in_addr vnetwork, +Slirp *slirp_init(int restricted, bool in_enabled, struct in_addr vnetwork, struct in_addr vnetmask, struct in_addr vhost, + bool in6_enabled, struct in6_addr vprefix_addr6, uint8_t vprefix_len, struct in6_addr vhost6, const char *vhostname, const char *tftp_path, const char *bootfile, @@ -216,6 +217,9 @@ Slirp *slirp_init(int restricted, struct in_addr vnetwork, slirp->grand = g_rand_new(); slirp->restricted = restricted; + slirp->in_enabled = in_enabled; + slirp->in6_enabled = in6_enabled; + if_init(slirp); ip_init(slirp); ip6_init(slirp); @@ -694,6 +698,10 @@ static void arp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len) int ar_op; struct ex_list *ex_ptr; + if (!slirp->in_enabled) { + return; + } + ar_op = ntohs(ah->ar_op); switch(ar_op) { case ARPOP_REQUEST: diff --git a/slirp/slirp.h b/slirp/slirp.h index 1abbcc6c32..c99ebb9621 100644 --- a/slirp/slirp.h +++ b/slirp/slirp.h @@ -180,6 +180,8 @@ struct Slirp { u_int last_slowtimo; bool do_slowtimo; + bool in_enabled, in6_enabled; + /* virtual network configuration */ struct in_addr vnetwork_addr; struct in_addr vnetwork_mask; |