On Sat, Oct 24, 2015 at 02:54:00PM +0200, Martin Pieuchot wrote:
> ok?

Some parts have been commited in a differnet way.
So I will comment individually.

> Index: netinet/if_ether.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/if_ether.c,v
> retrieving revision 1.176
> diff -u -p -r1.176 if_ether.c
> --- netinet/if_ether.c        22 Oct 2015 18:14:53 -0000      1.176
> +++ netinet/if_ether.c        24 Oct 2015 12:39:24 -0000
> @@ -141,7 +141,7 @@ arp_rtrequest(int req, struct rtentry *r
>  {
>       struct sockaddr *gate = rt->rt_gateway;
>       struct llinfo_arp *la = (struct llinfo_arp *)rt->rt_llinfo;
> -     struct ifnet *ifp = rt->rt_ifp;
> +     struct ifnet *ifp;
>       struct ifaddr *ifa;
>       struct mbuf *m;
>  
> @@ -166,8 +166,9 @@ arp_rtrequest(int req, struct rtentry *r
>       if (rt->rt_flags & (RTF_GATEWAY|RTF_BROADCAST))
>               return;
>  
> -     switch (req) {
> +     ifp = if_get(rt->rt_ifidx);
>  
> +     switch (req) {
>       case RTM_ADD:
>               /*
>                * XXX: If this is a manually added route to interface
> @@ -251,6 +252,8 @@ arp_rtrequest(int req, struct rtentry *r
>               }
>               pool_put(&arp_pool, la);
>       }
> +
> +     if_put(ifp);
>  }
>  
>  /*

Fixed differently.  arp_rtrequest() gets an ifp.

> Index: netinet/in_pcb.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/in_pcb.c,v
> retrieving revision 1.186
> diff -u -p -r1.186 in_pcb.c
> --- netinet/in_pcb.c  23 Oct 2015 13:26:07 -0000      1.186
> +++ netinet/in_pcb.c  24 Oct 2015 12:41:54 -0000
> @@ -624,19 +624,22 @@ in_pcbnotifyall(struct inpcbtable *table
>  void
>  in_losing(struct inpcb *inp)
>  {
> +     struct ifnet *ifp;
>       struct rtentry *rt;
>       struct rt_addrinfo info;
>  
>       if ((rt = inp->inp_route.ro_rt)) {
> -             inp->inp_route.ro_rt = 0;
> +             inp->inp_route.ro_rt = NULL;

OK bluhm@

>  
>               memset(&info, 0, sizeof(info));
>               info.rti_flags = rt->rt_flags;
>               info.rti_info[RTAX_DST] = &inp->inp_route.ro_dst;
>               info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
>               info.rti_info[RTAX_NETMASK] = rt_mask(rt);
> -             rt_missmsg(RTM_LOSING, &info, rt->rt_flags, rt->rt_ifp, 0,
> +             ifp = if_get(rt->rt_ifidx);
> +             rt_missmsg(RTM_LOSING, &info, rt->rt_flags, ifp, 0,
>                   inp->inp_rtableid);
> +             if_put(ifp);
>               if (rt->rt_flags & RTF_DYNAMIC)
>                       (void)rtrequest1(RTM_DELETE, &info, rt->rt_priority,
>                           NULL, inp->inp_rtableid);

Fixed differently.  rt_missmsg() gets an interface index.

> Index: netinet/ip_input.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/ip_input.c,v
> retrieving revision 1.258
> diff -u -p -r1.258 ip_input.c
> --- netinet/ip_input.c        19 Oct 2015 11:59:26 -0000      1.258
> +++ netinet/ip_input.c        24 Oct 2015 12:52:35 -0000
> @@ -1452,7 +1452,7 @@ ip_forward(struct mbuf *m, struct ifnet 
>        * Don't send redirect if we advertise destination's arp address
>        * as ours (proxy arp).
>        */
> -     if (rt->rt_ifp == ifp &&
> +     if ((rt->rt_ifidx == ifp->if_index) &&
>           (rt->rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) == 0 &&
>           satosin(rt_key(rt))->sin_addr.s_addr != 0 &&
>           ipsendredirects && !srcrt &&

OK bluhm@

> Index: netinet/tcp_input.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/tcp_input.c,v
> retrieving revision 1.305
> diff -u -p -r1.305 tcp_input.c
> --- netinet/tcp_input.c       11 Sep 2015 08:17:06 -0000      1.305
> +++ netinet/tcp_input.c       24 Oct 2015 12:26:49 -0000
> @@ -2989,7 +2989,7 @@ tcp_mss(struct tcpcb *tp, int offer)
>       if (rt == NULL)
>               goto out;
>  
> -     ifp = rt->rt_ifp;
> +     ifp = if_get(rt->rt_ifidx);
>  
>       switch (tp->pf) {
>  #ifdef INET6
> @@ -3065,6 +3065,7 @@ tcp_mss(struct tcpcb *tp, int offer)
>       }
>  
>   out:
> +     if_put(ifp);
>       /*
>        * The current mss, t_maxseg, is initialized to the default value.
>        * If we compute a smaller value, reduce the current mss.

This is wrong.  If the "goto out" above if_get() is taken, you
if_put() an uninitialized ifp.  Initialize ifp with NULL.

Maybe you can move the if_get() down, so you gab it only when you
need it.
        } else if ((ifp = if_get(rt->rt_ifidx) != NULL) {

In the "if (offer != -1)" block, ifp is accessed without NULL check.
mssopt = ifp->if_mtu - iphlen - sizeof(struct tcphdr);

bluhm

Reply via email to