On Thu, Apr 24, 2014 at 04:41:06PM +0200, Martin Pieuchot wrote:
> in_localaddr() is used only once in our tree and only if the sysctl
> net.inet.ip.mtudisc is set to 0.
>
> It is used to optimize the size of the MSS if the forward address
> correspond to a host on one of our subnets. Since it's an
> optimization for a special case that's not enabled by default, I'd
> like to kill it to remove one usage of the global list of IPv4
> addresses.
>
> While here get rid of the "#ifdef RTV_MTU", it is here.
>
> ok?
OK bluhm@
>
>
> Index: netinet/in.c
> ===================================================================
> RCS file: /home/ncvs/src/sys/netinet/in.c,v
> retrieving revision 1.95
> diff -u -p -r1.95 in.c
> --- netinet/in.c 10 Apr 2014 13:47:21 -0000 1.95
> +++ netinet/in.c 24 Apr 2014 14:33:43 -0000
> @@ -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
> Index: netinet/in.h
> ===================================================================
> RCS file: /home/ncvs/src/sys/netinet/in.h,v
> retrieving revision 1.107
> diff -u -p -r1.107 in.h
> --- netinet/in.h 21 Apr 2014 10:07:58 -0000 1.107
> +++ netinet/in.h 24 Apr 2014 14:33:43 -0000
> @@ -778,7 +778,6 @@ int in_broadcast(struct in_addr, stru
> 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 *);
> Index: netinet/tcp_input.c
> ===================================================================
> RCS file: /home/ncvs/src/sys/netinet/tcp_input.c,v
> retrieving revision 1.275
> diff -u -p -r1.275 tcp_input.c
> --- netinet/tcp_input.c 21 Apr 2014 12:22:26 -0000 1.275
> +++ netinet/tcp_input.c 24 Apr 2014 14:33:43 -0000
> @@ -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,23 +3057,21 @@ 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