Hello,

On Thu, Aug 11, 2022 at 11:59:55AM +0200, Alexander Bluhm wrote:
> Hi,
> 
> ip_fragment() and ip6_fragment() do nearly the same thing, but they
> are implemented differently.
> 
> The idea of this diff is to move things around.  Then only differences
> from the IP standards but not in coding style remain.  This allows
> to compare both functions easily.

    don't mind at all if things will be more consistent.
> 
> In IPv4 assume that m_pkthdr is correct and take the length from
> the, like in IPv6.
> 

    would it make sense to put asssert there at least for a while
    just to discover any surprises? something like this:

> -ip_fragment(struct mbuf *m, struct mbuf_list *fml, struct ifnet *ifp,
> +ip_fragment(struct mbuf *m0, struct mbuf_list *fml, struct ifnet *ifp,
>      u_long mtu)
>  {
> -     struct ip *ip, *mhip;
> -     struct mbuf *m0;
> -     int len, hlen, off;
> -     int mhlen, firstlen;
> +     struct mbuf *m;
> +     struct ip *ip;
> +     int firstlen, hlen, tlen, len, off;
>       int error;
>  
>       ml_init(fml);
> -     ml_enqueue(fml, m);
> +     ml_enqueue(fml, m0);
>  
> -     ip = mtod(m, struct ip *);
> +     ip = mtod(m0, struct ip *);
>       hlen = ip->ip_hl << 2;
> +     tlen = m0->m_pkthdr.len;
        KASSERT(tlen == ntohs(ip->ip_len));


diff looks good to me (with or without assert).

OK sashan

Reply via email to