mirror of https://github.com/xqemu/xqemu.git
slirp: Fix ICMP error sending
Disambiguation : icmp_error is renamed into icmp_send_error, since it doesn't manage errors, but only sends ICMP Error messages. Signed-off-by: Yann Bordenave <meow@meowstars.org> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Reviewed-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
parent
0d6ff71ae3
commit
de40abfecf
|
@ -41,7 +41,7 @@ void ip6_input(struct mbuf *m)
|
||||||
|
|
||||||
/* check ip_ttl for a correct ICMP reply */
|
/* check ip_ttl for a correct ICMP reply */
|
||||||
if (ip6->ip_hl == 0) {
|
if (ip6->ip_hl == 0) {
|
||||||
/*icmp_error(m, ICMP_TIMXCEED,ICMP_TIMXCEED_INTRANS, 0,"ttl");*/
|
/*icmp_send_error(m, ICMP_TIMXCEED,ICMP_TIMXCEED_INTRANS, 0,"ttl");*/
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
/* Be nice and tell them it's just a pseudo-ping packet */
|
/* Be nice and tell them it's just a pseudo-ping packet */
|
||||||
static const char icmp_ping_msg[] = "This is a pseudo-PING packet used by Slirp to emulate ICMP ECHO-REQUEST packets.\n";
|
static const char icmp_ping_msg[] = "This is a pseudo-PING packet used by Slirp to emulate ICMP ECHO-REQUEST packets.\n";
|
||||||
|
|
||||||
/* list of actions for icmp_error() on RX of an icmp message */
|
/* list of actions for icmp_send_error() on RX of an icmp message */
|
||||||
static const int icmp_flush[19] = {
|
static const int icmp_flush[19] = {
|
||||||
/* ECHO REPLY (0) */ 0,
|
/* ECHO REPLY (0) */ 0,
|
||||||
1,
|
1,
|
||||||
|
@ -101,7 +101,7 @@ static int icmp_send(struct socket *so, struct mbuf *m, int hlen)
|
||||||
(struct sockaddr *)&addr, sizeof(addr)) == -1) {
|
(struct sockaddr *)&addr, sizeof(addr)) == -1) {
|
||||||
DEBUG_MISC((dfd, "icmp_input icmp sendto tx errno = %d-%s\n",
|
DEBUG_MISC((dfd, "icmp_input icmp sendto tx errno = %d-%s\n",
|
||||||
errno, strerror(errno)));
|
errno, strerror(errno)));
|
||||||
icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_NET, 0, strerror(errno));
|
icmp_send_error(m, ICMP_UNREACH, ICMP_UNREACH_NET, 0, strerror(errno));
|
||||||
icmp_detach(so);
|
icmp_detach(so);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ icmp_input(struct mbuf *m, int hlen)
|
||||||
(struct sockaddr *)&addr, sizeof(addr)) == -1) {
|
(struct sockaddr *)&addr, sizeof(addr)) == -1) {
|
||||||
DEBUG_MISC((dfd,"icmp_input udp sendto tx errno = %d-%s\n",
|
DEBUG_MISC((dfd,"icmp_input udp sendto tx errno = %d-%s\n",
|
||||||
errno,strerror(errno)));
|
errno,strerror(errno)));
|
||||||
icmp_error(m, ICMP_UNREACH,ICMP_UNREACH_NET, 0,strerror(errno));
|
icmp_send_error(m, ICMP_UNREACH, ICMP_UNREACH_NET, 0, strerror(errno));
|
||||||
udp_detach(so);
|
udp_detach(so);
|
||||||
}
|
}
|
||||||
} /* if ip->ip_dst.s_addr == alias_addr.s_addr */
|
} /* if ip->ip_dst.s_addr == alias_addr.s_addr */
|
||||||
|
@ -235,7 +235,7 @@ end_error:
|
||||||
|
|
||||||
#define ICMP_MAXDATALEN (IP_MSS-28)
|
#define ICMP_MAXDATALEN (IP_MSS-28)
|
||||||
void
|
void
|
||||||
icmp_error(struct mbuf *msrc, u_char type, u_char code, int minsize,
|
icmp_send_error(struct mbuf *msrc, u_char type, u_char code, int minsize,
|
||||||
const char *message)
|
const char *message)
|
||||||
{
|
{
|
||||||
unsigned hlen, shlen, s_ip_len;
|
unsigned hlen, shlen, s_ip_len;
|
||||||
|
@ -243,7 +243,7 @@ icmp_error(struct mbuf *msrc, u_char type, u_char code, int minsize,
|
||||||
register struct icmp *icp;
|
register struct icmp *icp;
|
||||||
register struct mbuf *m;
|
register struct mbuf *m;
|
||||||
|
|
||||||
DEBUG_CALL("icmp_error");
|
DEBUG_CALL("icmp_send_error");
|
||||||
DEBUG_ARG("msrc = %p", msrc);
|
DEBUG_ARG("msrc = %p", msrc);
|
||||||
DEBUG_ARG("msrc_len = %d", msrc->m_len);
|
DEBUG_ARG("msrc_len = %d", msrc->m_len);
|
||||||
|
|
||||||
|
@ -433,7 +433,7 @@ void icmp_receive(struct socket *so)
|
||||||
}
|
}
|
||||||
DEBUG_MISC((dfd, " udp icmp rx errno = %d-%s\n", errno,
|
DEBUG_MISC((dfd, " udp icmp rx errno = %d-%s\n", errno,
|
||||||
strerror(errno)));
|
strerror(errno)));
|
||||||
icmp_error(so->so_m, ICMP_UNREACH, error_code, 0, strerror(errno));
|
icmp_send_error(so->so_m, ICMP_UNREACH, error_code, 0, strerror(errno));
|
||||||
} else {
|
} else {
|
||||||
icmp_reflect(so->so_m);
|
icmp_reflect(so->so_m);
|
||||||
so->so_m = NULL; /* Don't m_free() it again! */
|
so->so_m = NULL; /* Don't m_free() it again! */
|
||||||
|
|
|
@ -156,8 +156,8 @@ struct icmp {
|
||||||
void icmp_init(Slirp *slirp);
|
void icmp_init(Slirp *slirp);
|
||||||
void icmp_cleanup(Slirp *slirp);
|
void icmp_cleanup(Slirp *slirp);
|
||||||
void icmp_input(struct mbuf *, int);
|
void icmp_input(struct mbuf *, int);
|
||||||
void icmp_error(struct mbuf *msrc, u_char type, u_char code, int minsize,
|
void icmp_send_error(struct mbuf *msrc, u_char type, u_char code, int minsize,
|
||||||
const char *message);
|
const char *message);
|
||||||
void icmp_reflect(struct mbuf *);
|
void icmp_reflect(struct mbuf *);
|
||||||
void icmp_receive(struct socket *so);
|
void icmp_receive(struct socket *so);
|
||||||
void icmp_detach(struct socket *so);
|
void icmp_detach(struct socket *so);
|
||||||
|
|
|
@ -132,9 +132,9 @@ ip_input(struct mbuf *m)
|
||||||
m_adj(m, ip->ip_len - m->m_len);
|
m_adj(m, ip->ip_len - m->m_len);
|
||||||
|
|
||||||
/* check ip_ttl for a correct ICMP reply */
|
/* check ip_ttl for a correct ICMP reply */
|
||||||
if(ip->ip_ttl==0) {
|
if (ip->ip_ttl == 0) {
|
||||||
icmp_error(m, ICMP_TIMXCEED,ICMP_TIMXCEED_INTRANS, 0,"ttl");
|
icmp_send_error(m, ICMP_TIMXCEED, ICMP_TIMXCEED_INTRANS, 0, "ttl");
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -637,7 +637,7 @@ typedef uint32_t n_time;
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
bad:
|
bad:
|
||||||
icmp_error(m, type, code, 0, 0);
|
icmp_send_error(m, type, code, 0, 0);
|
||||||
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -463,7 +463,7 @@ sorecvfrom(struct socket *so)
|
||||||
|
|
||||||
DEBUG_MISC((dfd," udp icmp rx errno = %d-%s\n",
|
DEBUG_MISC((dfd," udp icmp rx errno = %d-%s\n",
|
||||||
errno,strerror(errno)));
|
errno,strerror(errno)));
|
||||||
icmp_error(so->so_m, ICMP_UNREACH,code, 0,strerror(errno));
|
icmp_send_error(so->so_m, ICMP_UNREACH, code, 0, strerror(errno));
|
||||||
} else {
|
} else {
|
||||||
icmp_reflect(so->so_m);
|
icmp_reflect(so->so_m);
|
||||||
so->so_m = NULL; /* Don't m_free() it again! */
|
so->so_m = NULL; /* Don't m_free() it again! */
|
||||||
|
@ -511,7 +511,7 @@ sorecvfrom(struct socket *so)
|
||||||
else if(errno == ENETUNREACH) code=ICMP_UNREACH_NET;
|
else if(errno == ENETUNREACH) code=ICMP_UNREACH_NET;
|
||||||
|
|
||||||
DEBUG_MISC((dfd," rx error, tx icmp ICMP_UNREACH:%i\n", code));
|
DEBUG_MISC((dfd," rx error, tx icmp ICMP_UNREACH:%i\n", code));
|
||||||
icmp_error(so->so_m, ICMP_UNREACH,code, 0,strerror(errno));
|
icmp_send_error(so->so_m, ICMP_UNREACH, code, 0, strerror(errno));
|
||||||
m_free(m);
|
m_free(m);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -604,7 +604,7 @@ findso:
|
||||||
m->m_data -= sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr);
|
m->m_data -= sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr);
|
||||||
m->m_len += sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr);
|
m->m_len += sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr);
|
||||||
*ip=save_ip;
|
*ip=save_ip;
|
||||||
icmp_error(m, ICMP_UNREACH,code, 0,strerror(errno));
|
icmp_send_error(m, ICMP_UNREACH, code, 0, strerror(errno));
|
||||||
}
|
}
|
||||||
tcp_close(tp);
|
tcp_close(tp);
|
||||||
m_free(m);
|
m_free(m);
|
||||||
|
|
|
@ -209,7 +209,8 @@ udp_input(register struct mbuf *m, int iphlen)
|
||||||
m->m_data -= iphlen;
|
m->m_data -= iphlen;
|
||||||
*ip=save_ip;
|
*ip=save_ip;
|
||||||
DEBUG_MISC((dfd,"udp tx errno = %d-%s\n",errno,strerror(errno)));
|
DEBUG_MISC((dfd,"udp tx errno = %d-%s\n",errno,strerror(errno)));
|
||||||
icmp_error(m, ICMP_UNREACH,ICMP_UNREACH_NET, 0,strerror(errno));
|
icmp_send_error(m, ICMP_UNREACH, ICMP_UNREACH_NET, 0,
|
||||||
|
strerror(errno));
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue