Subject: Re: [iproute] rdma broken on 32 bit

From: Stephen Hemminger <[email-masked]>
Date: Thu, 13 Dec 2018 13:15:02 -0800

On Tue, 11 Dec 2018 17:33:19 +0000
Leon Romanovsky <[email-masked]> wrote:

> On Mon, Dec 10, 2018 at 02:10:20PM -0800, Stephen Hemminger wrote:
> > It appears that RDMA is broken on 32 bit platforms.
> > Sure you don't run on 32bit, but iproute2 needs to build everywhere.
> >
> > The issue is that  you are assuming a C enum can hold 64 bits.
> > The standard says enum only has to hold "int" values.
> > So it breaks on 32bit.
> >
> > The issue is deeper than just a trivial fix. Please either change iproute
> > config script to not build RDMA if sizeof(enum) < 64 or fix the code to
> > use a safe value like uint64_t.
> >
> > rdma
> >     CC       rdma.o
> >     CC       utils.o
> >     CC       dev.o
> >     CC       link.o
> > In file included from rdma.h:26:0,
> >                  from dev.c:12:
> > dev.c: In function ‘dev_caps_to_str’:
> > ../include/utils.h:269:38: warning: left shift count >= width of type [-Wshift-count-overflow]
> >  #define BIT(nr)                 (1UL << (nr))
> >                                       ^
> > rdma.h:32:61: note: in expansion of macro ‘BIT’
> >  #define RDMA_BITMAP_ENUM(name, bit_no) RDMA_BITMAP_##name = BIT(bit_no),
> >                                                              ^~~
> > If you wade through the macro swamp:
> > dev.c
> > #define RDMA_DEV_FLAGS(x) \
> >
> > 	x(SG_GAPS_REG, 32) \
> >
> > 	enum { RDMA_DEV_FLAGS(RDMA_BITMAP_ENUM) };
> >
> > Expands to:
> > 	enum {
> > 		RDMA_BITMAP_SG_GAPS_REG = (1UL << (32)),
> > 	};
> >  
> 
> Thanks for the report, I reproduced and will do my best to send patches tomorrow.

Thanks for fixing it so fast. Applied your fix