2016-11-16 103 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