{"id":105,"date":"2018-06-03T18:37:59","date_gmt":"2018-06-03T10:37:59","guid":{"rendered":"http:\/\/39.108.77.145\/?p=105"},"modified":"2018-06-27T11:38:27","modified_gmt":"2018-06-27T03:38:27","slug":"2018060301","status":"publish","type":"post","link":"http:\/\/newcontinent.cn\/index.php\/2018\/06\/03\/2018060301\/","title":{"rendered":"\u600e\u6837\u67e5\u770b\/\u66f4\u6539ubuntu\u7684tcp\/ip\u534f\u8bae\u6e90\u7801"},"content":{"rendered":"<p>\u81ea\u5df1\u7855\u58eb\u8bba\u6587\u7684\u7b2c\u4e00\u4e2a\u70b9\u662f\u6570\u636e\u4e2d\u5fc3\u7f51\u7edc\u4f20\u8f93\u63a7\u5236\u65b9\u9762\u7684\u6587\u7ae0\uff0c\u7136\u540e\u9664\u4e86\u5b9e\u9a8c\u4eff\u771f\uff0c\u4e5f\u8003\u8651\u8fc7\u505a\u4e0b\u771f\u5b9e\u5b9e\u9a8c\uff0c\u53ea\u662f\u771f\u5b9e\u5b9e\u9a8c\u9664\u4e86\u8981\u6539Linux\u7684\u6e90\u7801\uff0c\u8fd8\u8981\u7528VHDL\u6216\u8005Verilog\u5bf9NetFPGA\u505a\u4e9b\u4fee\u6539\uff0c\u5de5\u4f5c\u91cf\u4e0a\u611f\u89c9\u535a\u58eb\u751f\u641e\u8fd9\u4e2a\u8fd8\u884c\uff0c\u7855\u58eb\u751f\u7684\u8bdd\u65f6\u95f4\u6709\u4e9b\u4e0d\u591f\u7528\u3002<\/p>\n<p><span>\u4ee5\u524dLinux\u7684\u53d1\u884c\u7248\u7684\u4e5f\u63a5\u89e6\u8fc7Ubuntu\u3001RedHat\u3001Suse\u3001CentOS\u3001Fedora\uff0c\u5e38\u7528\u7684\u64cd\u4f5c\u8fd8\u7b97\u6bd4\u8f83\u719f\u6089\uff0c\u56de\u60f3\u4e0b\u4e5f\u6ca1\u5177\u4f53\u770b\u8fc7linux\u7684\u6e90\u7801\u662f\u600e\u6837\u7684\uff0c\u4e00\u76f4\u770b\u7684ns2\u4e2dtcp\u534f\u8bae\u7684\u4ee3\u7801\uff0c\u51fa\u4e8e\u597d\u5947\uff0c\u4eca\u5929\u8fd8\u662f\u60f3\u770b\u4e0bUbuntu\u4e2dtcp\u534f\u8bae\u662f\u5982\u4f55\u5b9e\u73b0\u7684\uff0c<\/span>\u7136\u540e\u53bb\u7f51\u4e0a\u627e\u67e5\u770btcp\/ip\u534f\u8bae\u7684\u6e90\u7801\uff0c\u627e\u4e86\u5f88\u4e45\u4e5f\u6ca1\u627e\u5230\u76f8\u5173\u7684\u5185\u5bb9\uff0c\u770b\u5230\u6709\u4e9b\u4eba\u7ed9\u51fa\u7684\u8def\u5f84\uff0c\u6211\u4e5f\u7528&#8221;find \/ -iname ipv4&#8243;\u7684\u65b9\u6cd5\u53bb\u627eipv4\u6587\u4ef6\uff0c\u4f46\u662f\u6240\u6709\u7684\u8def\u5f84\u4e0b\u53ea\u6709Kconfig\u548cMakefile\u6587\u4ef6\uff0c\u6700\u540e\u8fd8\u662fgoogle\u9760\u8c31\u4e9b\uff0c\u5728Ubuntu\u7684\u793e\u533a\u627e\u5230\u4e86\u65b9\u6cd5,\u4e0b\u9762\u662f\u4e00\u6bb5\u4ecb\u7ecd\uff1a<\/p>\n<h4 class=\"line874\">This page will describe how to easily build the kernel.<span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><\/h4>\n<p class=\"line874\">\/* The majority of users that are interested in building their own kernel are\u00a0<span class=\"anchor\"><\/span>doing so because they have installed Ubuntu on their system and they wish to\u00a0<span class=\"anchor\"><\/span>make a small change to the kernel for that system. In many cases the user just\u00a0<span class=\"anchor\"><\/span>wants to make a kernel configuration change.<span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><\/p>\n<p class=\"line874\">The purpose of this page is to give that user a minimum amount of information\u00a0<span class=\"anchor\"><\/span>for them to meet the goal of making a simple change to the kernel, building it\u00a0<span class=\"anchor\"><\/span>and installing their kernel. It is not intended to be the definitive guide to\u00a0<span class=\"anchor\"><\/span>doing Ubuntu kernel development.<\/p>\n<h4 class=\"line874\">Obtaining the source for an Ubuntu release<\/h4>\n<p class=\"line874\">There are a number of different ways of getting the kernel sources. The two\u00a0<span class=\"anchor\"><\/span>main ways will be documented here.<span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><\/p>\n<p class=\"line874\">If you have installed a version of Ubuntu and you want to make changes to the\u00a0<span class=\"anchor\"><\/span>kernel that is installed on your system, use the\u00a0<strong>apt-get<\/strong>\u00a0method (described\u00a0<span class=\"anchor\"><\/span>below) to obtain the sources.<span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><\/p>\n<p class=\"line874\">However, if you wish to get the most up to date sources for the Ubuntu release\u00a0<span class=\"anchor\"><\/span>you are running and make changes to that, use the\u00a0<strong>git<\/strong>\u00a0method (described\u00a0<span class=\"anchor\"><\/span>below) to obtain the sources.<\/p>\n<h4 class=\"line874\">apt-get<\/h4>\n<p class=\"line874\">The source code which generated a specific binary package may be obtained using\u00a0<span class=\"anchor\"><\/span>the\u00a0<tt>apt-get\u00a0source\u00a0&lt;package&gt;<\/tt>\u00a0command. For example to obtain the source\u00a0<span class=\"anchor\"><\/span>for the currently running kernel you can use the command:<span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><\/p>\n<ul>\n<li><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span>\n<pre><span class=\"anchor\"><\/span>apt-get source linux-image-$(uname -r)\r\n<span class=\"anchor\"><\/span><\/pre>\n<\/li>\n<\/ul>\n<h4 class=\"line862\">git<\/h4>\n<p class=\"line862\">All of the Ubuntu Kernel source is maintained under\u00a0<tt>git<\/tt>. The source for\u00a0<span class=\"anchor\"><\/span>each release is maintained in its own git repository on\u00a0<tt>kernel.ubuntu.com<\/tt>.\u00a0<span class=\"anchor\"><\/span>To obtain a local copy you can simply git clone the repository for the release\u00a0<span class=\"anchor\"><\/span>you are interested in as shown below.<span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><\/p>\n<ul>\n<li><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span>\n<pre><span class=\"anchor\"><\/span>git clone git:\/\/kernel.ubuntu.com\/ubuntu\/ubuntu-&lt;release codename&gt;.git<\/pre>\n<p><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><\/li>\n<\/ul>\n<p class=\"line874\">For example to obtain the precise tree:<span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><\/p>\n<ul>\n<li><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span>\n<pre><span class=\"anchor\"><\/span>git clone git:\/\/kernel.ubuntu.com\/ubuntu\/ubuntu-precise.git<\/pre>\n<\/li>\n<\/ul>\n<p><span>\u7528\u7b2c\u4e00\u79cd\u65b9\u6cd5\uff0c\u76f4\u63a5apt-get source linux-image-$(uname -r)\u5b89\u88c5\u5b8c\u6210\uff0c\u7136\u540esudo apt-get build-dep linux-image-$(uname -r)\u5b89\u88c5\u4e00\u4e9b\u5fc5\u8981\u7684\u5305\u6765\u914d\u7f6e\u73af\u5883<\/span><\/p>\n<p><span><img decoding=\"async\" src=\"https:\/\/img-blog.csdn.net\/20180603183100130?watermark\/2\/text\/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3Nvbmdmb3Jlc3Qx\/font\/5a6L5L2T\/fontsize\/400\/fill\/I0JBQkFCMA==\/dissolve\/70\" alt=\"\" \/><br \/>\n<\/span><\/p>\n<p>\u5b8c\u6210\u8fd9\u4e00\u6b65\u4ee5\u540e\uff0c\u5df2\u7ecf\u53ef\u4ee5\u5728\u76f8\u5e94\u7684\u76ee\u5f55\u4e0b\u770b\u5230\u6e90\u7801\uff0c\u6bd4\u5982\u539f\u672c\/usr\/src\/linux-headers-4.4.0-92\/net\/ipv4\/\u76ee\u5f55\u4e0b\u53ea\u6709Makefile\u3001Kconfig\u548cnetfilter\u6587\u4ef6\uff0c\u800c\u8fdb\u5165\u65b0\u5b89\u88c5\u7684\u76ee\u5f55\u4e0b<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img-blog.csdn.net\/20180603183134371?watermark\/2\/text\/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3Nvbmdmb3Jlc3Qx\/font\/5a6L5L2T\/fontsize\/400\/fill\/I0JBQkFCMA==\/dissolve\/70\" alt=\"\" \/><\/p>\n<p>\u6240\u6709\u7684\u6e90\u4ee3\u7801\u90fd\u53ef\u4ee5\u770b\u5230\u4e86\uff0c\u7528vim\u6253\u5f00tcp_dctcp.c\uff0c\u67e5\u770bdctcp\u7684\u6e90\u7801<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img-blog.csdn.net\/20180603183244664?watermark\/2\/text\/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3Nvbmdmb3Jlc3Qx\/font\/5a6L5L2T\/fontsize\/400\/fill\/I0JBQkFCMA==\/dissolve\/70\" alt=\"\" \/><\/p>\n<p>\u63a5\u4e0b\u6765\u662f\u5bf9\u5185\u6838\u8fdb\u884c\u66f4\u6539\u5e76\u4e14\u9009\u62e9\u5e94\u7528\u66f4\u6539\u540e\u7684linux\u5185\u6838(\u5982\u4f55\u5207\u6362linux\u5185\u6838\u7684\u6559\u7a0b\u8fd8\u633a\u591a\u7684)\uff0c\u7136\u540e\u6d4b\u8bd5\u81ea\u5df1\u66f4\u6539\u540e\u5185\u6838\u6548\u679c\u5982\u4f55\u3002<\/p>\n<h4>Modifying the configuration<\/h4>\n<p class=\"line874\">This step can be skipped if no configuration changes are wanted. The build process will use a configuration that is put together from various sub-config files. The simplest way to modify anything here is to run:<span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><\/p>\n<ul>\n<li><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span>\n<pre><span class=\"anchor\"><\/span>chmod a+x debian\/rules\r\n<span class=\"anchor\"><\/span>chmod a+x debian\/scripts\/*\r\n<span class=\"anchor\"><\/span>chmod a+x debian\/scripts\/misc\/*\r\n<span class=\"anchor\"><\/span>fakeroot debian\/rules clean\r\n<span class=\"anchor\"><\/span>fakeroot debian\/rules editconfigs # you need to go through each (Y, Exit, Y, Exit..) or get a complaint about config later<\/pre>\n<p><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><\/li>\n<\/ul>\n<p class=\"line874\">This takes the current configuration for each architecture\/flavour supported and calls menuconfig to edit its config file. The chmod is needed because the way the source package is created, it loses the executable bits on the scripts.<span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><\/p>\n<p class=\"line862\">In order to make your kernel &#8220;newer&#8221; than the stock Ubuntu kernel from which you are based you should add a local version modifier. Add something like &#8220;+test1&#8221; to the end of the first version number in the\u00a0<tt>debian.master\/changelog<\/tt>\u00a0file, before building. This will help identify your kernel when running as it also appears in\u00a0<tt>uname\u00a0-a<\/tt>. Note that when a new Ubuntu kernel is released that will be newer than your kernel (which needs regenerating), so care is needed when upgrading. NOTE: do not attempt to use CONFIG_LOCALVERSION as this _will_ break the build.<\/p>\n<h4 class=\"line862\"><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span>Building the kernel<\/h4>\n<p class=\"line874\">Building the kernel is quite easy. Change your working directory to the root\u00a0<span class=\"anchor\"><\/span>of the kernel source tree and then type the following commands:<span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><\/p>\n<ul>\n<li><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span>\n<pre><span class=\"anchor\"><\/span>fakeroot debian\/rules clean\r\n<span class=\"anchor\"><\/span># quicker build:\r\n<span class=\"anchor\"><\/span>fakeroot debian\/rules binary-headers binary-generic binary-perarch\r\n<span class=\"anchor\"><\/span># if you need linux-tools or lowlatency kernel, run instead:\r\n<span class=\"anchor\"><\/span>fakeroot debian\/rules binary<\/pre>\n<p><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><\/li>\n<\/ul>\n<p class=\"line874\">If the build is successful, a set of three .deb binary package files will be produced in the directory above the build root directory. For example after building a kernel with version &#8220;4.8.0-17.19&#8221; on an amd64 system, these three (or four) .deb packages would be produced:<span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><\/p>\n<ul>\n<li><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span>\n<pre><span class=\"anchor\"><\/span>cd ..\r\n<span class=\"anchor\"><\/span>ls *.deb\r\n<span class=\"anchor\"><\/span>    linux-headers-4.8.0-17_4.8.0-17.19_all.deb\r\n<span class=\"anchor\"><\/span>    linux-headers-4.8.0-17-generic_4.8.0-17.19_amd64.deb\r\n<span class=\"anchor\"><\/span>    linux-image-4.8.0-17-generic_4.8.0-17.19_amd64.deb<\/pre>\n<p><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><\/li>\n<\/ul>\n<p class=\"line874\">on later releases you will also find a linux-extra- package which you should also install if present.<\/p>\n<h4 class=\"line874\"><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span>Testing the new kernel<\/h4>\n<p class=\"line874\">Install the three-package set (on your build system, or on a different target system) with dpkg -i and then reboot:<span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><\/p>\n<ul>\n<li><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span><span class=\"anchor\"><\/span>\n<pre><span class=\"anchor\"><\/span>sudo dpkg -i linux*4.8.0-17.19*.deb\r\n<span class=\"anchor\"><\/span>sudo reboot\r\n*\/<\/pre>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u81ea\u5df1\u7855\u58eb\u8bba\u6587\u7684\u7b2c\u4e00\u4e2a\u70b9\u662f\u6570\u636e\u4e2d\u5fc3\u7f51\u7edc\u4f20\u8f93\u63a7\u5236\u65b9\u9762\u7684\u6587\u7ae0\uff0c\u7136\u540e\u9664\u4e86\u5b9e\u9a8c\u4eff\u771f\uff0c\u4e5f\u8003\u8651\u8fc7\u505a\u4e0b\u771f\u5b9e\u5b9e\u9a8c\uff0c\u53ea\u662f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-105","post","type-post","status-publish","format-standard","hentry","category-5"],"views":3461,"_links":{"self":[{"href":"http:\/\/newcontinent.cn\/index.php\/wp-json\/wp\/v2\/posts\/105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/newcontinent.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/newcontinent.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/newcontinent.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/newcontinent.cn\/index.php\/wp-json\/wp\/v2\/comments?post=105"}],"version-history":[{"count":5,"href":"http:\/\/newcontinent.cn\/index.php\/wp-json\/wp\/v2\/posts\/105\/revisions"}],"predecessor-version":[{"id":150,"href":"http:\/\/newcontinent.cn\/index.php\/wp-json\/wp\/v2\/posts\/105\/revisions\/150"}],"wp:attachment":[{"href":"http:\/\/newcontinent.cn\/index.php\/wp-json\/wp\/v2\/media?parent=105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/newcontinent.cn\/index.php\/wp-json\/wp\/v2\/categories?post=105"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/newcontinent.cn\/index.php\/wp-json\/wp\/v2\/tags?post=105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}