I’m surprised by ISSET() macro.

ok mvs@

> On 4 Aug 2022, at 20:06, Alexander Bluhm <[email protected]> wrote:
> 
> On Thu, Jul 28, 2022 at 04:41:54PM +0200, Alexander Bluhm wrote:
>> -            mff = (ip->ip_off & htons(IP_MF)) != 0;
>> +            mff = ISSET(ip->ip_off, htons(IP_MF));
> 
> This part breaks big endian machines.
> New mff is 0x0020 on little and 0x2000 on big endian.
> Later it is assigned to u_int8_t ipqe_mff.  This strips higher bits.
> 
> I think the best way is to have 16 bit variables everywhere.
> 
> ok?
> 
> bluhm
> 
> Index: netinet/ip_input.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_input.c,v
> retrieving revision 1.375
> diff -u -p -r1.375 ip_input.c
> --- netinet/ip_input.c        28 Jul 2022 22:05:39 -0000      1.375
> +++ netinet/ip_input.c        4 Aug 2022 17:01:55 -0000
> @@ -577,7 +577,8 @@ ip_fragcheck(struct mbuf **mp, int *offp
>       struct ip *ip;
>       struct ipq *fp;
>       struct ipqent *ipqe;
> -     int mff, hlen;
> +     int hlen;
> +     uint16_t mff;
> 
>       ip = mtod(*mp, struct ip *);
>       hlen = ip->ip_hl << 2;
> Index: netinet/ip_var.h
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_var.h,v
> retrieving revision 1.94
> diff -u -p -r1.94 ip_var.h
> --- netinet/ip_var.h  25 Jul 2022 23:19:34 -0000      1.94
> +++ netinet/ip_var.h  4 Aug 2022 17:01:55 -0000
> @@ -174,7 +174,7 @@ struct ipqent {
>       LIST_ENTRY(ipqent) ipqe_q;
>       struct ip       *ipqe_ip;
>       struct mbuf     *ipqe_m;        /* mbuf contains packet */
> -     u_int8_t        ipqe_mff;       /* for IP fragmentation */
> +     uint16_t         ipqe_mff;      /* for IP fragmentation */
> };
> 
> /*
> 

Reply via email to