From: mpi Date: Fri, 25 Apr 2014 09:44:38 +0000 (+0000) Subject: Kill in_localaddr(), one less usage of the global list of IPv4 addresses. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=3fcbae1f90c8af35258f9a4c121908755fcdf662;p=openbsd Kill in_localaddr(), one less usage of the global list of IPv4 addresses. This function is used only once in our tree to optimize the size of the MSS if the forward address correspond to a host on one of our subnets, but only if ip.mutdisc is disable, which is not the default! While here get rid of the "#ifdef RTV_MTU", it is here. ok henning@, mikeb@, bluhm@ --- diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 3340bf927d1..23796512c4d 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in.c,v 1.95 2014/04/10 13:47:21 mpi Exp $ */ +/* $OpenBSD: in.c,v 1.96 2014/04/25 09:44:38 mpi Exp $ */ /* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */ /* @@ -99,22 +99,6 @@ int in_scrubprefix(struct in_ifaddr *); int in_addhost(struct in_ifaddr *); int in_scrubhost(struct in_ifaddr *); -/* Return 1 if an internet address is for a directly connected host */ -int -in_localaddr(struct in_addr in, u_int rdomain) -{ - struct in_ifaddr *ia; - - rdomain = rtable_l2(rdomain); - TAILQ_FOREACH(ia, &in_ifaddr, ia_list) { - if (ia->ia_ifp->if_rdomain != rdomain) - continue; - if ((in.s_addr & ia->ia_netmask) == ia->ia_net) - return (1); - } - return (0); -} - /* * Determine whether an IP address is in a reserved set of addresses * that may not be forwarded, or whether datagrams to that destination diff --git a/sys/netinet/in.h b/sys/netinet/in.h index 71cc81fd72c..770905adb1d 100644 --- a/sys/netinet/in.h +++ b/sys/netinet/in.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in.h,v 1.107 2014/04/21 10:07:58 henning Exp $ */ +/* $OpenBSD: in.h,v 1.108 2014/04/25 09:44:38 mpi Exp $ */ /* $NetBSD: in.h,v 1.20 1996/02/13 23:41:47 christos Exp $ */ /* @@ -778,7 +778,6 @@ int in_broadcast(struct in_addr, struct ifnet *, u_int); int in_canforward(struct in_addr); int in_cksum(struct mbuf *, int); int in4_cksum(struct mbuf *, u_int8_t, int, int); -int in_localaddr(struct in_addr, u_int); void in_proto_cksum_out(struct mbuf *, struct ifnet *); void in_ifdetach(struct ifnet *); int in_mask2len(struct in_addr *); diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 14fc254a3d6..259877df1ae 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_input.c,v 1.275 2014/04/21 12:22:26 henning Exp $ */ +/* $OpenBSD: tcp_input.c,v 1.276 2014/04/25 09:44:38 mpi Exp $ */ /* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */ /* @@ -3040,7 +3040,6 @@ tcp_mss(struct tcpcb *tp, int offer) goto out; } -#ifdef RTV_MTU /* * if there's an mtu associated with the route and we support * path MTU discovery for the underlying protocol family, use it. @@ -3058,24 +3057,22 @@ tcp_mss(struct tcpcb *tp, int offer) */ mss = IPV6_MMTU - iphlen - sizeof(struct ip6_frag) - sizeof(struct tcphdr); - } else - mss = rt->rt_rmx.rmx_mtu - iphlen - sizeof(struct tcphdr); - } else -#endif /* RTV_MTU */ - if (!ifp) + } else { + mss = rt->rt_rmx.rmx_mtu - iphlen - + sizeof(struct tcphdr); + } + } else if (!ifp) { /* * ifp may be null and rmx_mtu may be zero in certain * v6 cases (e.g., if ND wasn't able to resolve the * destination host. */ goto out; - else if (ifp->if_flags & IFF_LOOPBACK) + } else if (ifp->if_flags & IFF_LOOPBACK) { mss = ifp->if_mtu - iphlen - sizeof(struct tcphdr); - else if (tp->pf == AF_INET) { + } else if (tp->pf == AF_INET) { if (ip_mtudisc) mss = ifp->if_mtu - iphlen - sizeof(struct tcphdr); - else if (inp && in_localaddr(inp->inp_faddr, inp->inp_rtableid)) - mss = ifp->if_mtu - iphlen - sizeof(struct tcphdr); } #ifdef INET6 else if (tp->pf == AF_INET6) {