summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2013-08-08 14:29:30 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2013-08-08 14:29:30 +0000
commita2efdf8beacd8bd10b7c44a3567fde6a9ac9e138 (patch)
tree2d604480c4e38cae989650724fb692db1e9412a3
parent3a8ba4bf67a9d74fe25e2fd192dde8bbf0e46de7 (diff)
Change MTU discovery functions to not abuse the global icmpsrc variable
to pass the destination address of the route to clone. ok markus@, mikeb@
-rw-r--r--sys/netinet/ip_icmp.c21
-rw-r--r--sys/netinet/ip_icmp.h4
-rw-r--r--sys/netinet/ip_output.c7
-rw-r--r--sys/netinet/tcp_timer.c19
4 files changed, 27 insertions, 24 deletions
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c
index 62bec749f6e..68018a65ece 100644
--- a/sys/netinet/ip_icmp.c
+++ b/sys/netinet/ip_icmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_icmp.c,v 1.102 2013/06/17 02:31:37 lteo Exp $ */
+/* $OpenBSD: ip_icmp.c,v 1.103 2013/08/08 14:29:28 mpi Exp $ */
/* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */
/*
@@ -907,13 +907,21 @@ icmp_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
struct rtentry *
-icmp_mtudisc_clone(struct sockaddr *dst, u_int rtableid)
+icmp_mtudisc_clone(struct in_addr dst, u_int rtableid)
{
+ struct sockaddr_in *sin;
+ struct route ro;
struct rtentry *rt;
int error;
- rt = rtalloc1(dst, RT_REPORT, rtableid);
- if (rt == 0)
+ bzero(&ro, sizeof(ro));
+ sin = satosin(&ro.ro_dst);
+ sin->sin_family = AF_INET;
+ sin->sin_len = sizeof(*sin);
+ sin->sin_addr = dst;
+
+ rt = rtalloc1(&ro.ro_dst, RT_REPORT, rtableid);
+ if (rt == NULL)
return (NULL);
/* Check if the route is actually usable */
@@ -928,7 +936,7 @@ icmp_mtudisc_clone(struct sockaddr *dst, u_int rtableid)
struct rt_addrinfo info;
bzero(&info, sizeof(info));
- info.rti_info[RTAX_DST] = dst;
+ info.rti_info[RTAX_DST] = sintosa(sin);
info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
info.rti_flags = RTF_GATEWAY | RTF_HOST | RTF_DYNAMIC;
@@ -955,7 +963,6 @@ void
icmp_mtudisc(struct icmp *icp, u_int rtableid)
{
struct rtentry *rt;
- struct sockaddr *dst = sintosa(&icmpsrc);
u_long mtu = ntohs(icp->icmp_nextmtu); /* Why a long? IPv6 */
/* Table of common MTUs: */
@@ -965,7 +972,7 @@ icmp_mtudisc(struct icmp *icp, u_int rtableid)
4352, 2002, 1492, 1006, 508, 296, 68, 0
};
- rt = icmp_mtudisc_clone(dst, rtableid);
+ rt = icmp_mtudisc_clone(icp->icmp_ip.ip_dst, rtableid);
if (rt == 0)
return;
diff --git a/sys/netinet/ip_icmp.h b/sys/netinet/ip_icmp.h
index d694bc646d9..04c54458b3a 100644
--- a/sys/netinet/ip_icmp.h
+++ b/sys/netinet/ip_icmp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_icmp.h,v 1.24 2010/09/13 09:59:32 claudio Exp $ */
+/* $OpenBSD: ip_icmp.h,v 1.25 2013/08/08 14:29:29 mpi Exp $ */
/* $NetBSD: ip_icmp.h,v 1.10 1996/02/13 23:42:28 christos Exp $ */
/*
@@ -238,7 +238,7 @@ int icmp_reflect(struct mbuf *, struct mbuf **, struct in_ifaddr *);
void icmp_send(struct mbuf *, struct mbuf *);
int icmp_sysctl(int *, u_int, void *, size_t *, void *, size_t);
struct rtentry *
- icmp_mtudisc_clone(struct sockaddr *, u_int);
+ icmp_mtudisc_clone(struct in_addr, u_int);
void icmp_mtudisc(struct icmp *, u_int);
int icmp_do_exthdr(struct mbuf *, u_int16_t, u_int8_t, void *, size_t);
#endif /* _KERNEL */
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index 182f0591ec0..d031c08a760 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_output.c,v 1.245 2013/08/08 07:28:08 mpi Exp $ */
+/* $OpenBSD: ip_output.c,v 1.246 2013/08/08 14:29:29 mpi Exp $ */
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
/*
@@ -615,10 +615,7 @@ sendit:
if (transportmode)
rt = NULL;
else if (rt == NULL || (rt->rt_flags & RTF_HOST) == 0) {
- struct sockaddr_in dst = {
- sizeof(struct sockaddr_in), AF_INET};
- dst.sin_addr = ip->ip_dst;
- rt = icmp_mtudisc_clone((struct sockaddr *)&dst,
+ rt = icmp_mtudisc_clone(ip->ip_dst,
m->m_pkthdr.rdomain);
rt_mtucloned = 1;
}
diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c
index 7f2511d751a..94841434bc0 100644
--- a/sys/netinet/tcp_timer.c
+++ b/sys/netinet/tcp_timer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_timer.c,v 1.46 2011/07/06 23:44:20 sthen Exp $ */
+/* $OpenBSD: tcp_timer.c,v 1.47 2013/08/08 14:29:29 mpi Exp $ */
/* $NetBSD: tcp_timer.c,v 1.14 1996/02/13 23:44:09 christos Exp $ */
/*
@@ -204,7 +204,7 @@ tcp_timer_rexmt(void *arg)
if ((tp->t_flags & TF_PMTUD_PEND) && tp->t_inpcb &&
SEQ_GEQ(tp->t_pmtud_th_seq, tp->snd_una) &&
SEQ_LT(tp->t_pmtud_th_seq, (int)(tp->snd_una + tp->t_maxseg))) {
- extern struct sockaddr_in icmpsrc;
+ struct sockaddr_in sin;
struct icmp icmp;
tp->t_flags &= ~TF_PMTUD_PEND;
@@ -213,14 +213,18 @@ tcp_timer_rexmt(void *arg)
icmp.icmp_nextmtu = tp->t_pmtud_nextmtu;
icmp.icmp_ip.ip_len = tp->t_pmtud_ip_len;
icmp.icmp_ip.ip_hl = tp->t_pmtud_ip_hl;
- icmpsrc.sin_addr = tp->t_inpcb->inp_faddr;
+ icmp.icmp_ip.ip_dst = tp->t_inpcb->inp_faddr;
icmp_mtudisc(&icmp, tp->t_inpcb->inp_rtableid);
/*
* Notify all connections to the same peer about
* new mss and trigger retransmit.
*/
- in_pcbnotifyall(&tcbtable, sintosa(&icmpsrc),
+ bzero(&sin, sizeof(sin));
+ sin.sin_len = sizeof(sin);
+ sin.sin_family = AF_INET;
+ sin.sin_addr = tp->t_inpcb->inp_faddr;
+ in_pcbnotifyall(&tcbtable, sintosa(&sin),
tp->t_inpcb->inp_rtableid, EMSGSIZE, tcp_mtudisc);
splx(s);
return;
@@ -258,7 +262,6 @@ tcp_timer_rexmt(void *arg)
tp->t_rxtshift > TCP_MAXRXTSHIFT / 6) {
struct inpcb *inp = tp->t_inpcb;
struct rtentry *rt = NULL;
- struct sockaddr_in sin;
/* No data to send means path mtu is not a problem */
if (!inp->inp_socket->so_snd.sb_cc)
@@ -282,11 +285,7 @@ tcp_timer_rexmt(void *arg)
break;
#endif
case PF_INET:
- bzero(&sin, sizeof(struct sockaddr_in));
- sin.sin_family = AF_INET;
- sin.sin_len = sizeof(struct sockaddr_in);
- sin.sin_addr = inp->inp_faddr;
- rt = icmp_mtudisc_clone(sintosa(&sin),
+ rt = icmp_mtudisc_clone(inp->inp_faddr,
inp->inp_rtableid);
break;
}