{"id":18978,"date":"2024-10-17T10:56:17","date_gmt":"2024-10-17T02:56:17","guid":{"rendered":"https:\/\/www.yunshan.net\/blog\/?p=18978"},"modified":"2024-10-17T10:56:17","modified_gmt":"2024-10-17T02:56:17","slug":"%e5%89%96%e6%9e%90ebpf%e6%9e%b6%e6%9e%84%ef%bc%9a%e5%ae%9e%e7%8e%b0%e9%ab%98%e6%95%88%e7%bd%91%e7%bb%9c%e6%b5%81%e9%87%8f%e6%8e%a7%e5%88%b6%e7%9a%84%e5%88%a9%e5%99%a8","status":"publish","type":"post","link":"https:\/\/www.yunshan.net\/blog\/archives\/18978.html","title":{"rendered":"\u5256\u6790eBPF\u67b6\u6784\uff1a\u5b9e\u73b0\u9ad8\u6548\u7f51\u7edc\u6d41\u91cf\u63a7\u5236\u7684\u5229\u5668"},"content":{"rendered":"<p>\t\t\t\t<![CDATA[\n\n<p>\u5256\u6790<a href=\"https:\/\/www.yunshan.net\" target=\"_blank\" style=\"color:blue\" rel=\"noopener noreferrer\">eBPF<\/a>\u67b6\u6784\uff1a\u5b9e\u73b0\u9ad8\u6548\u7f51\u7edc\u6d41\u91cf\u63a7\u5236\u7684\u5229\u5668<\/p>\n\n\n\n\n<p>\u5728\u5f53\u4eca\u6570\u5b57\u5316\u65f6\u4ee3\uff0c\u7f51\u7edc\u6d41\u91cf\u5448\u7206\u70b8\u5f0f\u589e\u957f\uff0c\u4f01\u4e1a\u548c\u7ec4\u7ec7\u5bf9\u4e8e\u7f51\u7edc\u6027\u80fd\u4f18\u5316\u3001\u5b89\u5168\u76d1\u63a7\u4ee5\u53ca\u5e94\u7528\u670d\u52a1\u8d28\u91cf\u4fdd\u969c\u7684\u9700\u6c42\u65e5\u76ca\u8feb\u5207\u3002\u5728\u8fd9\u6837\u7684\u80cc\u666f\u4e0b\uff0c<a href=\"https:\/\/www.yunshan.net\" target=\"_blank\" style=\"color:blue\" rel=\"noopener noreferrer\">\u7f51\u7edc\u6d41\u91cf\u91c7\u96c6<\/a>\u5206\u53d1\u6280\u672f\u6210\u4e3a\u4e86\u5173\u952e\u3002\u800c\u4e91\u6749\u7f51\u7edc\u4f5c\u4e3a\u5728\u8fd9\u4e00\u9886\u57df\u7684\u521b\u65b0\u8005\uff0c\u901a\u8fc7\u5f15\u5165\u5148\u8fdb\u7684<a href=\"https:\/\/www.yunshan.net\" target=\"_blank\" style=\"color:blue\" rel=\"noopener noreferrer\">eBPF<\/a>\u67b6\u6784\uff0c\u4e3a\u5b9e\u73b0\u9ad8\u6548\u7684\u7f51\u7edc\u6d41\u91cf\u63a7\u5236\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n\n\n\n<p align=center><img decoding=\"async\" src=\"https:\/\/www.yunshan.net\/blog\/wp-content\/uploads\/2024\/10\/7NHzXQhAEK.jpg\" \/><\/p>\n\n\n\n\n<p>\u4e00\u3001eBPF\u67b6\u6784\u7684\u57fa\u672c\u539f\u7406<\/p>\n\n\n\n\n<p>eBPF\uff08ExtendedBerkeleyPacketFilter\uff09\u662f\u4e00\u79cd\u9769\u547d\u6027\u7684\u5185\u6838\u6280\u672f\uff0c\u5b83\u5141\u8bb8\u5728\u64cd\u4f5c\u7cfb\u7edf\u5185\u6838\u4e2d\u8fd0\u884c\u7528\u6237\u5b9a\u4e49\u7684\u7a0b\u5e8f\u3002\u4f20\u7edf\u7684\u7f51\u7edc\u76d1\u63a7\u548c\u6d41\u91cf\u63a7\u5236\u901a\u5e38\u4f9d\u8d56\u4e8e\u5185\u6838\u6a21\u5757\u6216\u7528\u6237\u7a7a\u95f4\u7684\u4ee3\u7406\u7a0b\u5e8f\uff0c\u4f46\u8fd9\u4e9b\u65b9\u6cd5\u5b58\u5728\u6027\u80fd\u74f6\u9888\u3001\u53ef\u6269\u5c55\u6027\u5dee\u4ee5\u53ca\u4fb5\u5165\u6027\u5f3a\u7b49\u95ee\u9898\u3002<\/p>\n\n\n\n\n<p>eBPF\u67b6\u6784\u7684\u6838\u5fc3\u4f18\u52bf\u5728\u4e8e\u5176\u80fd\u591f\u5728\u5185\u6838\u4e2d\u52a8\u6001\u52a0\u8f7d\u548c\u6267\u884c\u5c0f\u578b\u7684\u3001\u5b89\u5168\u7684\u7a0b\u5e8f\u3002\u8fd9\u4e9b\u7a0b\u5e8f\u53ef\u4ee5\u76f4\u63a5\u8bbf\u95ee\u5185\u6838\u7684\u6570\u636e\u7ed3\u6784\u548c\u7f51\u7edc\u6570\u636e\u5305\uff0c\u4ece\u800c\u5b9e\u73b0\u9ad8\u6548\u7684\u6570\u636e\u5305\u8fc7\u6ee4\u3001\u5904\u7406\u548c\u4e8b\u4ef6\u76d1\u6d4b\u3002\u901a\u8fc7\u4f7f\u7528JIT\uff08Just-In-Time\uff09\u7f16\u8bd1\u5668\uff0ceBPF\u7a0b\u5e8f\u80fd\u591f\u5728\u8fd0\u884c\u65f6\u88ab\u4f18\u5316\u4e3a\u9ad8\u6548\u7684\u673a\u5668\u7801\uff0c\u6781\u5927\u5730\u63d0\u9ad8\u4e86\u6267\u884c\u6548\u7387\u3002<\/p>\n\n\n\n\n<p>\u4e8c\u3001\u4e91\u6749\u7f51\u7edc\u7684\u6d41\u91cf\u91c7\u96c6\u5206\u53d1\u89e3\u51b3\u65b9\u6848<\/p>\n\n\n\n\n<p>\u4e91\u6749\u7f51\u7edc\u5145\u5206\u5229\u7528eBPF\u67b6\u6784\u7684\u4f18\u52bf\uff0c\u6253\u9020\u4e86\u4e00\u5957\u5168\u9762\u800c\u9ad8\u6548\u7684<a href=\"https:\/\/www.yunshan.net\" target=\"_blank\" style=\"color:blue\" rel=\"noopener noreferrer\">\u7f51\u7edc\u6d41\u91cf\u91c7\u96c6<\/a>\u5206\u53d1\u7cfb\u7edf\u3002\u5176\u5de5\u4f5c\u6d41\u7a0b\u5927\u81f4\u5982\u4e0b\uff1a<\/p>\n\n\n\n\n<p>\u9996\u5148\uff0c\u901a\u8fc7eBPF\u7a0b\u5e8f\u5728\u7f51\u7edc\u63a5\u53e3\u5904\u8fdb\u884c\u6570\u636e\u5305\u6355\u83b7\u3002\u8fd9\u4e9b\u7a0b\u5e8f\u80fd\u591f\u6839\u636e\u9884\u8bbe\u7684\u89c4\u5219\u548c\u7b56\u7565\uff0c\u5bf9\u6570\u636e\u5305\u8fdb\u884c\u5feb\u901f\u7b5b\u9009\u548c\u5206\u7c7b\uff0c\u53ea\u91c7\u96c6\u611f\u5174\u8da3\u7684\u6d41\u91cf\uff0c\u4ece\u800c\u5927\u5927\u51cf\u5c11\u4e86\u6570\u636e\u91cf\u548c\u5904\u7406\u5f00\u9500\u3002<\/p>\n\n\n\n\n<p>\u63a5\u7740\uff0c\u91c7\u96c6\u5230\u7684\u6d41\u91cf\u6570\u636e\u88ab\u9ad8\u6548\u5730\u5206\u53d1\u5230\u540e\u7aef\u7684\u5904\u7406\u6a21\u5757\u3002\u4e91\u6749\u7f51\u7edc\u91c7\u7528\u4e86\u4f18\u5316\u7684\u4f20\u8f93\u673a\u5236\uff0c\u786e\u4fdd\u6570\u636e\u80fd\u591f\u5feb\u901f\u3001\u51c6\u786e\u5730\u9001\u8fbe\uff0c\u540c\u65f6\u964d\u4f4e\u4e86\u6570\u636e\u4e22\u5931\u548c\u5ef6\u8fdf\u7684\u98ce\u9669\u3002<\/p>\n\n\n\n\n<p>\u5728\u540e\u7aef\uff0c\u5f3a\u5927\u7684\u6570\u636e\u5206\u6790\u548c\u5904\u7406\u5f15\u64ce\u5bf9\u6d41\u91cf\u6570\u636e\u8fdb\u884c\u6df1\u5165\u6316\u6398\u548c\u5206\u6790\u3002\u901a\u8fc7\u8fd0\u7528\u673a\u5668\u5b66\u4e60\u3001\u6570\u636e\u6316\u6398\u7b49\u6280\u672f\uff0c\u63d0\u53d6\u51fa\u6709\u4ef7\u503c\u7684\u4fe1\u606f\uff0c\u5982\u5e94\u7528\u6d41\u91cf\u6a21\u5f0f\u3001\u7528\u6237\u884c\u4e3a\u3001\u5f02\u5e38\u68c0\u6d4b\u7b49\u3002<\/p>\n\n\n\n\n<p>\u4e09\u3001eBPF\u67b6\u6784\u5e26\u6765\u7684\u663e\u8457\u4f18\u52bf<\/p>\n\n\n\n\n<p>1.\u9ad8\u6027\u80fd<\/p>\n\n\n\n\n<p>eBPF\u76f4\u63a5\u5728\u5185\u6838\u4e2d\u8fd0\u884c\uff0c\u907f\u514d\u4e86\u9891\u7e41\u7684\u5185\u6838\u6001\u4e0e\u7528\u6237\u6001\u5207\u6362\uff0c\u51cf\u5c11\u4e86\u4e0a\u4e0b\u6587\u5207\u6362\u7684\u5f00\u9500\uff0c\u4ece\u800c\u663e\u8457\u63d0\u9ad8\u4e86\u6d41\u91cf\u91c7\u96c6\u548c\u5904\u7406\u7684\u6027\u80fd\u3002<\/p>\n\n\n\n\n<p>2.\u7075\u6d3b\u6027<\/p>\n\n\n\n\n<p>\u7528\u6237\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u7684\u9700\u6c42\u7f16\u5199\u81ea\u5b9a\u4e49\u7684eBPF\u7a0b\u5e8f\uff0c\u5b9e\u73b0\u4e2a\u6027\u5316\u7684\u6d41\u91cf\u63a7\u5236\u548c\u5206\u6790\u903b\u8f91\uff0c\u80fd\u591f\u5feb\u901f\u9002\u5e94\u4e0d\u65ad\u53d8\u5316\u7684\u7f51\u7edc\u73af\u5883\u548c\u4e1a\u52a1\u9700\u6c42\u3002<\/p>\n\n\n\n\n<p>3.\u5b89\u5168\u6027<\/p>\n\n\n\n\n<p>eBPF\u7a0b\u5e8f\u5728\u6267\u884c\u524d\u7ecf\u8fc7\u4e25\u683c\u7684\u5b89\u5168\u68c0\u67e5\u548c\u9a8c\u8bc1\uff0c\u786e\u4fdd\u5176\u4e0d\u4f1a\u5bf9\u7cfb\u7edf\u7684\u7a33\u5b9a\u6027\u548c\u5b89\u5168\u6027\u9020\u6210\u5a01\u80c1\u3002<\/p>\n\n\n\n\n<p>4.\u4f4e\u4fb5\u5165\u6027<\/p>\n\n\n\n\n<p>\u4e0e\u4f20\u7edf\u7684\u5185\u6838\u6a21\u5757\u76f8\u6bd4\uff0ceBPF\u67b6\u6784\u5bf9\u5185\u6838\u7684\u4fee\u6539\u548c\u5f71\u54cd\u6781\u5c0f\uff0c\u964d\u4f4e\u4e86\u56e0\u7cfb\u7edf\u66f4\u65b0\u6216\u5185\u6838\u7248\u672c\u53d8\u5316\u5bfc\u81f4\u7684\u4e0d\u517c\u5bb9\u6027\u95ee\u9898\u3002<\/p>\n\n\n\n\n<p>\u56db\u3001\u5e94\u7528\u573a\u666f\u4e3e\u4f8b<\/p>\n\n\n\n\n<p>1.\u5fae\u670d\u52a1\u67b6\u6784\u4e2d\u7684\u6027\u80fd\u76d1\u63a7<\/p>\n\n\n\n\n<p>\u5728\u590d\u6742\u7684\u5fae\u670d\u52a1\u73af\u5883\u4e2d\uff0c\u901a\u8fc7eBPF\u53ef\u4ee5\u5b9e\u65f6\u91c7\u96c6\u5404\u670d\u52a1\u4e4b\u95f4\u7684\u7f51\u7edc\u6d41\u91cf\uff0c\u7cbe\u786e\u5206\u6790\u670d\u52a1\u95f4\u7684\u8c03\u7528\u5173\u7cfb\u3001\u5ef6\u8fdf\u548c\u9519\u8bef\u7387\uff0c\u5e2e\u52a9\u5feb\u901f\u5b9a\u4f4d\u6027\u80fd\u74f6\u9888\u3002<\/p>\n\n\n\n\n<p>2.\u7f51\u7edc\u5b89\u5168\u68c0\u6d4b<\/p>\n\n\n\n\n<p>\u5b9e\u65f6\u76d1\u6d4b\u7f51\u7edc\u4e2d\u7684\u5f02\u5e38\u6d41\u91cf\uff0c\u5982DDoS\u653b\u51fb\u3001\u6076\u610f\u8f6f\u4ef6\u4f20\u64ad\u7b49\uff0c\u53ca\u65f6\u53d1\u51fa\u8b66\u62a5\u5e76\u91c7\u53d6\u76f8\u5e94\u7684\u9632\u62a4\u63aa\u65bd\u3002<\/p>\n\n\n\n\n<p>3.\u5e94\u7528\u6d41\u91cf\u4f18\u5316<\/p>\n\n\n\n\n<p>\u6839\u636e\u5e94\u7528\u7684\u91cd\u8981\u6027\u548c\u4f18\u5148\u7ea7\uff0c\u5408\u7406\u5206\u914d\u7f51\u7edc\u5e26\u5bbd\u8d44\u6e90\uff0c\u786e\u4fdd\u5173\u952e\u4e1a\u52a1\u7684\u6d41\u7545\u8fd0\u884c\u3002<\/p>\n\n\n\n\n<p>\u4e94\u3001\u9762\u4e34\u7684\u6311\u6218\u4e0e\u672a\u6765\u5c55\u671b<\/p>\n\n\n\n\n<p>\u5c3d\u7ba1eBPF\u67b6\u6784\u5728\u7f51\u7edc\u6d41\u91cf\u63a7\u5236\u65b9\u9762\u5177\u6709\u5de8\u5927\u7684\u6f5c\u529b\uff0c\u4f46\u4e5f\u9762\u4e34\u4e00\u4e9b\u6311\u6218\u3002\u4f8b\u5982\uff0ceBPF\u7f16\u7a0b\u7684\u590d\u6742\u6027\u5bf9\u4e8e\u5f00\u53d1\u8005\u6765\u8bf4\u662f\u4e00\u4e2a\u95e8\u69db\uff0c\u9700\u8981\u5177\u5907\u6df1\u5165\u7684\u5185\u6838\u77e5\u8bc6\u548c\u7f16\u7a0b\u6280\u80fd\u3002\u6b64\u5916\uff0c\u968f\u7740\u7f51\u7edc\u6280\u672f\u7684\u4e0d\u65ad\u53d1\u5c55\uff0c\u5982\u4f55\u786e\u4fddeBPF\u67b6\u6784\u80fd\u591f\u9002\u5e94\u65b0\u7684\u7f51\u7edc\u534f\u8bae\u548c\u786c\u4ef6\u67b6\u6784\u4e5f\u662f\u4e00\u4e2a\u9700\u8981\u6301\u7eed\u5173\u6ce8\u7684\u95ee\u9898\u3002<\/p>\n\n\n\n\n<p>\u7136\u800c\uff0c\u5c55\u671b\u672a\u6765\uff0c\u968f\u7740\u6280\u672f\u7684\u4e0d\u65ad\u8fdb\u6b65\u548c\u521b\u65b0\uff0ceBPF\u67b6\u6784\u6709\u671b\u5728\u7f51\u7edc\u6d41\u91cf\u63a7\u5236\u9886\u57df\u53d1\u6325\u66f4\u52a0\u91cd\u8981\u7684\u4f5c\u7528\u3002\u901a\u8fc7\u4e0e\u4eba\u5de5\u667a\u80fd\u3001\u5927\u6570\u636e\u7b49\u6280\u672f\u7684\u6df1\u5ea6\u878d\u5408\uff0c\u5c06\u5b9e\u73b0\u66f4\u52a0\u667a\u80fd\u5316\u3001\u81ea\u52a8\u5316\u7684\u7f51\u7edc\u6d41\u91cf\u7ba1\u7406\uff0c\u4e3a\u4f01\u4e1a\u548c\u7ec4\u7ec7\u63d0\u4f9b\u66f4\u52a0\u9ad8\u6548\u3001\u5b89\u5168\u3001\u53ef\u9760\u7684\u7f51\u7edc\u670d\u52a1\u3002<\/p>\n\n\n\n\n<p>\u603b\u4e4b\uff0c\u4e91\u6749\u7f51\u7edc\u57fa\u4e8eeBPF\u67b6\u6784\u7684\u7f51\u7edc\u6d41\u91cf\u91c7\u96c6\u5206\u53d1\u89e3\u51b3\u65b9\u6848\u4e3a\u5b9e\u73b0\u9ad8\u6548\u7684\u7f51\u7edc\u6d41\u91cf\u63a7\u5236\u5f00\u8f9f\u4e86\u65b0\u7684\u9053\u8def\u3002\u5728\u6570\u5b57\u5316\u8f6c\u578b\u7684\u6d6a\u6f6e\u4e2d\uff0c\u8fd9\u4e00\u6280\u672f\u5c06\u6210\u4e3a\u4f01\u4e1a\u63d0\u5347\u7f51\u7edc\u6027\u80fd\u3001\u4fdd\u969c\u7f51\u7edc\u5b89\u5168\u3001\u4f18\u5316\u4e1a\u52a1\u4f53\u9a8c\u7684\u91cd\u8981\u5229\u5668\u3002\u968f\u7740\u6280\u672f\u7684\u4e0d\u65ad\u6f14\u8fdb\u548c\u5b8c\u5584\uff0c\u6211\u4eec\u6709\u7406\u7531\u76f8\u4fe1\uff0ceBPF\u67b6\u6784\u5c06\u4e3a\u7f51\u7edc\u4e16\u754c\u5e26\u6765\u66f4\u591a\u7684\u521b\u65b0\u548c\u7a81\u7834\u3002<\/p>\n\n]]>\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\t\t\t\t<![CDATA[]]>\t\t<\/p>\n","protected":false},"author":5,"featured_media":18979,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-18978","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-discussion"],"_links":{"self":[{"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/posts\/18978","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/comments?post=18978"}],"version-history":[{"count":0,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/posts\/18978\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/media?parent=18978"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/categories?post=18978"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yunshan.net\/blog\/wp-json\/wp\/v2\/tags?post=18978"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}