On Wed, Jun 13, 2018 at 01:20:29PM +0900, YASUOKA Masahiko wrote:
> > The MCLGET() cannot be called anymore.  Can we remove it and add a
> > compile time assert instead?
> > 
> >     CTASSERT(sizeof(struct ip) + sizeof(struct tcphdr) <= MHLEN);
> >     CTASSERT(sizeof(struct ip6_hdr) + sizeof(struct tcphdr) <= MHLEN);
> 
> Yes, it's possible and it seems better.
> 
> ok?

OK bluhm@

> Index: sys/netinet/tcp_subr.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/tcp_subr.c,v
> retrieving revision 1.171
> diff -u -p -r1.171 tcp_subr.c
> --- sys/netinet/tcp_subr.c    8 May 2018 15:10:33 -0000       1.171
> +++ sys/netinet/tcp_subr.c    13 Jun 2018 04:18:25 -0000
> @@ -191,6 +191,9 @@ tcp_template(struct tcpcb *tp)
>       struct mbuf *m;
>       struct tcphdr *th;
>  
> +     CTASSERT(sizeof(struct ip) + sizeof(struct tcphdr) <= MHLEN);
> +     CTASSERT(sizeof(struct ip6_hdr) + sizeof(struct tcphdr) <= MHLEN);
> +
>       if ((m = tp->t_template) == 0) {
>               m = m_get(M_DONTWAIT, MT_HEADER);
>               if (m == NULL)
> @@ -208,19 +211,6 @@ tcp_template(struct tcpcb *tp)
>  #endif /* INET6 */
>               }
>               m->m_len += sizeof (struct tcphdr);
> -
> -             /*
> -              * The link header, network header, TCP header, and TCP options
> -              * all must fit in this mbuf. For now, assume the worst case of
> -              * TCP options size. Eventually, compute this from tp flags.
> -              */
> -             if (m->m_len + MAX_TCPOPTLEN + max_linkhdr >= MHLEN) {
> -                     MCLGET(m, M_DONTWAIT);
> -                     if ((m->m_flags & M_EXT) == 0) {
> -                             m_free(m);
> -                             return (0);
> -                     }
> -             }
>       }
>  
>       switch(tp->pf) {

Reply via email to