2016-11-16 101 views
0

我正在尝试使用some patches编译内核版本4.1(向GRO添加一些功能)。我来自硬件背景,相对较新的网络堆栈。我想知道如何解决这个问题,或者至少是指出为什么会发生。使用一些新功能编译内核时出错

这是我做过什么

# my temp location 

mdkir kern 
cd kern 

# cloned the juggler and linux 4.1 tree 

git clone https://github.com/gengyl08/juggler.git 
wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.1.tar.gz 
tar -xvf linux-4.1.tar.gz 

# copied just the essential files that were diffferent 

cp juggler/linux-4.1/include/linux/netdevice.h linux-4.1/include/linux/netdevice.h 
cp juggler/linux-4.1/include/linux/skbuff.h linux-4.1/include/linux/skbuff.h 
cp juggler/linux-4.1/net/core/dev.c linux-4.1/net/core/dev.c 
cp juggler/linux-4.1/net/core/net-sysfs.c linux-4.1/net/core/net-sysfs.c 
cp juggler/linux-4.1/net/core/skbuff.c linux-4.1/net/core/skbuff.c 
cp juggler/linux-4.1/net/ipv4/af_inet.c linux-4.1/net/ipv4/af_inet.c 
cp juggler/linux-4.1/net/ipv4/tcp_offload.c linux-4.1/net/ipv4/tcp_offload.c 

cd linux-4.1 
make menuconfig # generated the default .config file 

# building the kernel 

time make 

当我尝试编译它们,我收到以下错误

drivers/net/ethernet/agere/et131x.c: In function ‘nic_send_packet.constprop.43’: 
include/linux/compiler.h:412:20: error: call to ‘__compiletime_assert_2439’ declared with attribute error: BUILD_BUG 
    prefix ## suffix(); \ 
        ^
include/linux/compiler.h:417:2: note: in expansion of macro ‘__compiletime_assert’ 
    __compiletime_assert(condition, msg, prefix, suffix) 
^
include/linux/compiler.h:429:2: note: in expansion of macro ‘_compiletime_assert’ 
    _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) 
^
include/linux/bug.h:50:37: note: in expansion of macro ‘compiletime_assert’ 
#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) 
            ^
include/linux/bug.h:74:2: note: in expansion of macro ‘BUILD_BUG_ON_MSG’ 
    BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition) 
^
drivers/net/ethernet/agere/et131x.c:2439:2: note: in expansion of macro ‘BUILD_BUG_ON’ 
    BUILD_BUG_ON(MAX_SKB_FRAGS + 1 > 23); 
^
make[4]: *** [drivers/net/ethernet/agere/et131x.o] Error 1 
make[3]: *** [drivers/net/ethernet/agere] Error 2 
make[2]: *** [drivers/net/ethernet] Error 2 
make[1]: *** [drivers/net] Error 2 
make: *** [drivers] Error 2 

real 22m3.067s 
user 21m4.028s 
sys  1m6.724s 

回答

1

看起来MAX_SKB_FRAGS太大和以太网驱动程序不喜欢它。

From drivers/net/ethernet/agere/et131x.c

/* Part of the optimizations of this send routine restrict us to 
* sending 24 fragments at a pass. In practice we should never see 
* more than 5 fragments. 
*/ 

/* nr_frags should be no more than 18. */ 
BUILD_BUG_ON(MAX_SKB_FRAGS + 1 > 23); 

从补丁你使用:

linux-3.18.5/include/linux/skbuff.h

#if (65536/PAGE_SIZE + 1) < 16 
#define MAX_SKB_FRAGS 16UL 
#else 
#define MAX_SKB_FRAGS (65536/PAGE_SIZE + 1) 
#endif 

linux-4.1/include/linux/skbuff.h

#if (65536/PAGE_SIZE + 1) < 45 
#define MAX_SKB_FRAGS 45UL 
#else 
#define MAX_SKB_FRAGS (65536/PAGE_SIZE + 1) 
#endif 

请注意区别。

我还没有分析过这段代码,但是从一开始我就看到了一些不一致的地方。

替换返回应该做的伎俩。当然,修补程序作者为什么选择更高的值可能是有原因的。

+0

谢谢Andrejs。将检查它并返回。 – user2532296