{"id":15,"date":"2024-05-11T13:52:42","date_gmt":"2024-05-11T05:52:42","guid":{"rendered":"https:\/\/yaofeng.wang\/?p=15"},"modified":"2024-05-11T13:52:42","modified_gmt":"2024-05-11T05:52:42","slug":"tcp%e7%bb%8f%e5%85%b8%e5%bc%82%e5%b8%b8%e9%97%ae%e9%a2%98%e6%8e%a2%e8%ae%a8%e4%b8%8e%e8%a7%a3%e5%86%b3","status":"publish","type":"post","link":"https:\/\/yaofeng.wang\/index.php\/2024\/05\/11\/tcp%e7%bb%8f%e5%85%b8%e5%bc%82%e5%b8%b8%e9%97%ae%e9%a2%98%e6%8e%a2%e8%ae%a8%e4%b8%8e%e8%a7%a3%e5%86%b3\/","title":{"rendered":"TCP\u7ecf\u5178\u5f02\u5e38\u95ee\u9898\u63a2\u8ba8\u4e0e\u89e3\u51b3"},"content":{"rendered":"<section style=\"margin-bottom: 0px; padding-left: 10px; padding-right: 10px; background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; , arial;font-size: 16px; line-height: 1.5em; letter-spacing: 0em;\" data-tool=\"mdnice\u7f16\u8f91\u5668\" data-website=\"https:\/\/www.mdnice.com\" data-mpa-powered-by=\"yiban.io\">\n<p style=\"text-align: center;\"><img class=\"rich_pages wxw-img\" data-imgfileid=\"502257907\" data-ratio=\"0.1575\" data-src=\"https:\/\/mmbiz.qpic.cn\/mmbiz_gif\/j3gficicyOvasIjZpiaTNIPReJVWEJf7UGpmokI3LL4NbQDb8fO48fYROmYPXUhXFN8IdDqPcI1gA6OfSLsQHxB4w\/640?wx_fmt=gif\" data-type=\"gif\" data-w=\"400\" \/><\/p>\n<p><img class=\"rich_pages wxw-img\" data-imgfileid=\"502296309\" data-ratio=\"0.5592592592592592\" data-s=\"300,640\" data-src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/j3gficicyOvauCTKmIUakdm23FkH2QA8wNyhWQkhLdrEXxOJslKicflGTqKdANHNXOcibGhcJ5fWVic0UbTNNhFJ3Vw\/640?wx_fmt=png\" data-type=\"png\" data-w=\"1080\" \/><\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u4f5c\u8005\uff1akernelxing<\/p>\n<blockquote style=\"margin-top: 20px; margin-bottom: 20px; border-radius: 0px; width: auto; height: auto; overflow: auto; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; line-height: 1.8;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<p style=\"text-indent: 0em; padding-top: 8px; padding-bottom: 8px; font-size: 14px; line-height: 1.8em; letter-spacing: 0em; text-align: left;\">TCP\u7684\u7ecf\u5178\u5f02\u5e38\u95ee\u9898\u65e0\u975e\u5c31\u662f\u4e22\u5305\u548c\u8fde\u63a5\u4e2d\u65ad\uff0c\u5728\u8fd9\u91cc\u6211\u6253\u7b97\u4e0e\u5404\u4f4d\u804a\u4e00\u804aTCP\u7684RST\u5230\u5e95\u662f\u4ec0\u4e48\uff1f\u73b0\u7f51\u4e2d\u7684RST\u95ee\u9898\u6709\u54ea\u4e9b\u6a21\u6837\uff1f\u6211\u4eec\u5982\u4f55\u53bb\u5e94\u5bf9\u3001\u89e3\u51b3\uff1f\u672c\u6587\u5c06\u4eceRST\u539f\u7406\u3001\u6392\u67e5\u624b\u6bb5\u3001\u73b0\u7f51\u75db\u96be\u70b9\u6848\u4f8b\u4e09\u4e2a\u677f\u5757\u81ea\u4e0a\u800c\u4e0b\u5e26\u7ed9\u8bfb\u8005\u4e00\u5957\u5b8c\u6574\u7684\u5206\u6790\u3002<\/p>\n<\/blockquote>\n<h3 style=\"text-align: left; margin-bottom: 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><span style=\"padding-left: 10px; font-size: 20px; line-height: 1.5em; letter-spacing: 0em; font-weight: bold;\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u4e00\u3001\u80cc\u666f<\/strong><\/span><\/h3>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6700\u8fd1\u4e00\u5e74\u7684\u65f6\u95f4\u91cc\uff0c\u73b0\u7f51\u78b0\u5230RST\u95ee\u9898\u5c61\u5c61\u51fa\u73b0\uff0c\u4e00\u65e6TCP\u8fde\u63a5\u4e2d\u6536\u5230\u4e86RST\u5305\uff0c\u5927\u6982\u7387\u4f1a\u5bfc\u81f4\u8fde\u63a5\u4e2d\u6b62\u6216\u7528\u6237\u5f02\u5e38\u3002\u5982\u4f55\u6b63\u786e\u89e3\u51b3RST\u5f02\u5e38\u662f\u8f83\u4e3a\u68d8\u624b\u7684\u95ee\u9898\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u672c\u6587\u5173\u6ce8\u7684\u4e0d\u662f\u7ec6\u8282\uff0c\u800c\u662f\u65b9\u6cd5\u8bba\uff0c\u4e5f\u786e\u5b9e\u65b9\u6cd5\u66f4\u4e3a\u91cd\u8981\u3002\u7b14\u8005\u59cb\u7ec8\u76f8\u4fe1\uff0c\u4e00\u767e\u4e2a\u4eba\u773c\u4e2d\u7684\u54c8\u59c6\u96f7\u7279\u6700\u7ec8\u8fd8\u662f\u4e00\u4e2a\u5177\u4f53\u7684\u4eba\u7269\u5f62\u8c61\uff0c\u4e00\u767e\u4e2aRST\u5f02\u5e38\u6700\u7ec8\u4e5f\u4f1a\u662f\u4e00\u4e2a\u7b80\u77ed\u7684\u5c0f\u95ee\u9898\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<h3 style=\"text-align: left; margin-bottom: 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><span style=\"padding-left: 10px; font-size: 20px; line-height: 1.5em; letter-spacing: 0em; font-weight: bold;\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u4e8c\u3001\u539f\u7406<\/strong><\/span><\/h3>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u786e\u5b9a\u7684RST\u95ee\u9898\u4e00\u5b9a\u5c31\u662f\u95ee\u9898\u5417\uff1f\u5982\u679cRST\u53d1\u751f\u4e86\u4f60\u4f1a\u5982\u4f55\u53bb\u89e3\u51b3\uff1f\u8bfb\u8005\u53ef\u4ee5\u5c1d\u8bd5\u95ee\u4e0b\u81ea\u5df1\u5e76\u89e3\u7b54\u8fd9\u4e2a\u95ee\u9898\uff0c\u8fd9\u91cc\u201d\u505c\u987f\u3001\u505c\u987f\u3001\u505c\u987f\u201c\u6765\u7ed9\u5927\u5bb6\u4e00\u70b9\u65f6\u95f4\u601d\u8003\uff0c\u597d\u4e86\uff0c\u65f6\u95f4\u5230\uff0c\u6211\u4eec\u7ee7\u7eed\u5f80\u4e0b\u770b\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">RST\u5206\u4e3a\u4e24\u79cd\uff0c\u4e00\u79cd\u662factive rst\uff0c\u53e6\u4e00\u79cd\u662fpassive rst\u3002<\/strong>\u524d\u8005\u591a\u534a\u662f\u6307\u7684\u7b26\u5408\u9884\u671f\u7684reset\u884c\u4e3a\uff0c\u6b64\u79cd\u60c5\u51b5\u591a\u534a\u662f\u5c5e\u4e8e\u673a\u5668\u81ea\u5df1\u4e3b\u52a8\u89e6\u53d1\uff0c\u66f4\u5177\u6709\u5148\u524d\u610f\u8bc6\uff0c\u4e14\u548c\u534f\u8bae\u6808\u672c\u8eab\u7684\u7ec6\u8282\u5173\u8054\u6027\u4e0d\u5f3a\uff1b\u540e\u8005\u591a\u534a\u662f\u6307\u7684\u673a\u5668\u4e5f\u4e0d\u6e05\u695a\u540e\u9762\u4f1a\u53d1\u751f\u4ec0\u4e48\uff0c\u8d70\u4e00\u6b65\u770b\u4e00\u6b65\uff0c\u5982\u679c\u4e0d\u7b26\u5408\u534f\u8bae\u6808\u7684if-else\u5b9e\u73b0\u7684RFC\u4e2d\u6761\u6761\u6760\u6760\u7684\u89c4\u5219\u7684\u60c5\u51b5\u4e0b\uff0c\u90a3\u5c31\u53ea\u80fdreset\u91cd\u7f6e\u4e86\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u8fd9\u91cc\u8d34\u4e0a<a style=\"font-weight: bold; border-style: none none solid; border-width: 3px 3px 0px; border-radius: 0px;\" href=\"https:\/\/datatracker.ietf.org\/doc\/html\/rfc793\" data-linktype=\"2\">RFC 793<\/a>\u6700\u7ecf\u5178\u7684\u6700\u521d\u5bf9RST\u5305\u7684\u89e3\u91ca\uff1a<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img class=\"rich_pages wxw-img\" style=\"margin: 10px auto; border-style: none; border-width: 3px; border-radius: 0px; object-fit: fill;\" data-imgfileid=\"502299559\" data-ratio=\"0.7407407407407407\" data-src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/j3gficicyOvat2qfE1UmGBIwP1tfSQBhF0ms6tBgfNc9rUtjg8Wb9JiaYwic4uUMXtWl6EicSMRibJkB79bdFpmclzsg\/640?wx_fmt=png&amp;from=appmsg\" data-type=\"png\" data-w=\"1080\" \/><\/figure>\n<h4 style=\"font-size: 17px; margin-top: 10px; margin-bottom: 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><span style=\"font-size: 18px; line-height: 1.5em; letter-spacing: 0em; text-align: left; font-weight: bold;\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">active rst<\/strong><\/span><\/h4>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u90a3\u5177\u4f53\u4ec0\u4e48\u662factive rst\uff1f\u5982\u679c\u4ecetcpdump\u6293\u5305\u4e0a\u6765\u770b\u8868\u73b0\u5c31\u662f\uff08\u5982\u4e0b\u56fe\uff09RST\u7684\u62a5\u6587\u4e2d\u542b\u6709\u4e86\u4e00\u4e32Ack\u6807\u8bc6\u3002<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img class=\"rich_pages wxw-img\" style=\"margin: 10px auto; border-style: none; border-width: 3px; border-radius: 0px; object-fit: fill;\" data-imgfileid=\"502299560\" data-ratio=\"0.03888888888888889\" data-src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/j3gficicyOvat2qfE1UmGBIwP1tfSQBhF0LicdO7LUSz6KKBGNaSpqD6ziaSSNF165Ic5bn337SQ4eLNwT2gHEpjew\/640?wx_fmt=png&amp;from=appmsg\" data-type=\"png\" data-w=\"1080\" \/><\/figure>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u8fd9\u4e2a\u5bf9\u5e94\u7684\u5185\u6838\u4ee3\u7801\u4e3a\uff08\u5982\u679c\u611f\u5174\u8da3\uff09\uff1a<\/p>\n<pre style=\"border-radius: 5px; text-align: left; margin-top: 10px; margin-bottom: 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 16px; color: #abb2bf; padding-top: 15px; background: #282c34; border-radius: 5px; , consolas, monaco, menlo, monospace;border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; font-size: 12px;\">tcp_send_active_reset()\r\n\u00a0\u00a0\u00a0\u00a0-&gt;\u00a0skb\u00a0=\u00a0alloc_skb(MAX_TCP_HEADER,\u00a0priority);\r\n\u00a0\u00a0\u00a0\u00a0-&gt;\u00a0tcp_init_nondata_skb(skb,\u00a0tcp_acceptable_seq(sk),\u00a0TCPHDR_ACK\u00a0|\u00a0TCPHDR_RST);\r\n\u00a0\u00a0\u00a0\u00a0-&gt;\u00a0tcp_transmit_skb()\r\n<\/code><\/pre>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u901a\u5e38\u53d1\u751factive rst\u7684\u6709\u51e0\u79cd\u60c5\u51b5\uff1a<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">1\uff09\u4e3b\u52a8\u65b9\u8c03\u7528close()\u7684\u65f6\u5019\uff0c\u4e0a\u5c42\u5374\u6ca1\u6709\u53d6\u8d70\u5b8c\u6570\u636e\uff1b\u8fd9\u4e2a\u5c5e\u4e8e\u4e0a\u5c42user\u81ea\u5df1\u72af\u4e0b\u7684\u9519\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">2\uff09\u4e3b\u52a8\u65b9\u8c03\u7528close()\u7684\u65f6\u5019\uff0csetsockopt\u8bbe\u7f6e\u4e86linger\uff1b\u8fd9\u4e2a\u6807\u8bc6\u4ee3\u8868\u6211\u65e2\u7136\u8bbe\u7f6e\u4e86\u8fd9\u4e2a\uff0c\u90a3close\u5c31\u8d76\u5feb\u7ed3\u675f\u5427\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">3\uff09\u4e3b\u52a8\u65b9\u8c03\u7528close()\u7684\u65f6\u5019\uff0c\u53d1\u73b0\u5168\u5c40\u7684tcp\u53ef\u7528\u7684\u5185\u5b58\u4e0d\u591f\u4e86\uff08\u8fd9\u4e2a\u53ef\u4ee5sysctl\u8c03\u6574tcp mem\u7b2c\u4e09\u4e2a\u53c2\u6570\uff09\uff0c\u6216\uff0c\u53d1\u73b0\u5df2\u7ecf\u6709\u592a\u591a\u7684orphans\u4e86\uff0c\u8fd9\u65f6\u5019\u7cfb\u7edf\u5c31\u662f\u6446\u70c2\u7684\u610f\u601d\uff1a\u6211\u4e5f\u6ca1\u8f99\u4e86\u201d\uff0c\u90a3\u5c31\u53ea\u80fd\u5e72\u8106\u70b9\u957f\u75db\u4e0d\u5982\u77ed\u75db\uff0c\u7ed3\u675f\u5427\u3002\u8fd9\u4e2a\u6848\u4f8b\u53ef\u4ee5\u641c\u7d22(dmesg\u65e5\u5fd7\uff09\u201ctoo many orphaned sockets\u201d\u6216\u201cout of memory -- consider tuning tcp_mem\u201d\uff0c\u5339\u914d\u5176\u4e2d\u4e00\u4e2a\u5c31\u5bb9\u6613\u4e2drst\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6ce8\uff1a\u8fd9\u91cc\u7701\u7565\u5176\u4ed6\u4f7f\u7528diag\u76f8\u5173\uff08\u5982ss\u547d\u4ee4\uff09\u7684RST\u95ee\u9898\u3002\u4e0a\u8ff0\u4e09\u7c7b\u662f\u4e3b\u8981\u7684active rst\u95ee\u9898\u7684\u60c5\u51b5\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">passive rst<\/strong><\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u73b0\u5728\u7ee7\u7eed\u8bf4\u8bf4\u53e6\u4e00\u79cdpassive rst\u5427\u3002\u5982\u679c\u4ece\u6293\u5305\u4e0a\u6765\u770b\u8868\u73b0\u5c31\u662f\uff08\u5982\u4e0b\u56fe\uff09rst\u7684\u62a5\u6587\u4e2d\u65e0ack\u6807\u8bc6\uff0c\u800c\u4e14RST\u7684seq\u7b49\u4e8e\u5b83\u5426\u5b9a\u7684\u62a5\u6587\u7684ack\u53f7\uff08\u7ea2\u8272\u6846\u7684rst\u5426\u5b9a\u7684\u9ec4\u8272\u6846\u7684ack\uff09\uff0c\u5f53\u7136\u8fd8\u6709\u53e6\u4e00\u79cd\u6781\u5c0f\u6982\u7387\u51fa\u73b0\u7684\u7279\u6b8a\u60c5\u51b5\u7684\u8868\u73b0\u6211\u8fd9\u91cc\u4e0d\u8d34\u51fa\u6765\u4e86\uff0c\u5b83\u7684\u8868\u73b0\u5f62\u5f0f\u5c31\u662fRST\u7684Ack\u53f7\u4e3a1\u3002<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img class=\"rich_pages wxw-img\" style=\"margin: 10px auto; border-style: none; border-width: 3px; border-radius: 0px; object-fit: fill;\" data-imgfileid=\"502299557\" data-ratio=\"0.07222222222222222\" data-src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/j3gficicyOvat2qfE1UmGBIwP1tfSQBhF0pW6wPcIhzZAakiapbPTqJTnT6kKO4Xib61zYcyFbqrZmVRUZx9hIhPbw\/640?wx_fmt=png&amp;from=appmsg\" data-type=\"png\" data-w=\"1080\" \/><\/figure>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u8fd9\u4e2a\u5bf9\u5e94\u7684\u5185\u6838\u4ee3\u7801\u4e3a\uff08\u5982\u679c\u611f\u5174\u8da3\uff09\uff1a<\/p>\n<pre style=\"border-radius: 5px; text-align: left; margin-top: 10px; margin-bottom: 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 16px; color: #abb2bf; padding-top: 15px; background: #282c34; border-radius: 5px; , consolas, monaco, menlo, monospace;border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; font-size: 12px;\">tcp_v4_send_reset()\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: #c678dd; line-height: 26px;\">if<\/span>\u00a0(th-&gt;ack)\u00a0{\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u00a0\u8fd9\u91cc\u5bf9\u5e94\u7684\u5c31\u662f\u4e0a\u56fe\u4e2d\u4e3a\u4f55\u51fa\u73b0Seq==Ack<\/span>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0rep.th.seq\u00a0=\u00a0th-&gt;ack_seq;\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\u00a0<span style=\"color: #c678dd; line-height: 26px;\">else<\/span>\u00a0{\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">\/\/\u00a0\u6781\u5c0f\u6982\u7387\uff0c\u5982\u679c\u51fa\u73b0\uff0c\u90a3\u4e48RST\u5305\u7684\u5c31\u6ca1\u6709Seq\u5e8f\u5217\u53f7<\/span>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0rep.th.ack\u00a0=\u00a0<span style=\"color: #d19a66; line-height: 26px;\">1<\/span>;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0rep.th.ack_seq\u00a0=\u00a0htonl(ntohl(th-&gt;seq)\u00a0+\u00a0th-&gt;syn\u00a0+\u00a0th-&gt;fin\u00a0+\u00a0\u00a0\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0skb-&gt;len\u00a0-\u00a0(th-&gt;doff\u00a0&lt;&lt;\u00a0<span style=\"color: #d19a66; line-height: 26px;\">2<\/span>));\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\r\n<\/code><\/pre>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u901a\u5e38\u53d1\u751fpassive rst\u7684\u6709\u54ea\u4e9b\u60c5\u51b5\u5462\uff1f\u8fd9\u4e2a\u8fdc\u6bd4active rst\u66f4\u590d\u6742\uff0c\u573a\u666f\u66f4\u591a\u3002\u5177\u4f53\u7684\u9700\u8981\u770bTCP\u7684\u6536\u3001\u53d1\u7684\u534f\u8bae\uff0c\u6587\u5b57\u7684\u63cf\u8ff0\u53ef\u4ee5\u53c2\u8003rfc 793\u5373\u53ef\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<h3 style=\"text-align: left; margin-bottom: 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><span style=\"padding-left: 10px; font-size: 20px; line-height: 1.5em; letter-spacing: 0em; font-weight: bold;\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u4e09\u3001\u5de5\u5177<\/strong><\/span><\/h3>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6211\u4eec\u9488\u5bf9\u7ebf\u4e0a\u8fd9\u4e48\u591a\u7684rst\u5982\u4f55\u53bb\u5206\u6790\u5462\uff1f\u9996\u5148tcpdump\u7684\u6293\u6355\u662f\u4e00\u5b9a\u9700\u8981\u7684\uff0c\u8fd9\u4e2a\u53ef\u4ee5\u5728\u6574\u4f53\u6d41\u7a0b\u4e0a\u7ed9\u6211\u4eec\u7f29\u5c0f\u6392\u67e5\u8303\u56f4\uff0c\u5176\u6b21\u662f\uff0c\u5fc5\u987b\u8981\u624b\u5199\u6293\u6355\u5f02\u5e38\u8c03\u7528rst\u7684\u70b9\uff0c\u6587\u672b\u6211\u4f1a\u5206\u4eab\u4e00\u4e9b\u6e90\u7801\u51fa\u6765\u4f9b\u53c2\u8003\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u90a3\u5982\u4f55\u6293\u8c03\u7528RST\u7684\u70b9\uff1f\u8fd9\u91cc\u53ea\u63d0\u4f9b\u4e0b\u601d\u8def\u3002<\/p>\n<h4 style=\"font-size: 17px; margin-top: 10px; margin-bottom: 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><span style=\"font-size: 18px; line-height: 1.5em; letter-spacing: 0em; text-align: left; font-weight: bold;\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">active rst<\/strong><\/span><\/h4>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u4f7f\u7528bpf*\u76f8\u5173\u7684\u5de5\u5177\u6293\u6355tcp_send_active_reset()\u51fd\u6570\u5e76\u6253\u5370\u5806\u6808\u5373\u53ef\uff0c\u901a\u8fc7crash\u73b0\u573a\u673a\u5668\u5e76\u8f93\u5165\u201cdis -l [addr]\u201d\u53ef\u4ee5\u5f97\u5230\u5177\u4f53\u7684\u51fd\u6570\u4f4d\u7f6e\uff0c\u6bd4\u5bf9\u6e90\u7801\u5c31\u53ef\u4ee5\u5f97\u77e5\u4e86\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u53ef\u4ee5\u4f7f\u7528bpftrace\u8fdb\u884c\u5feb\u901f\u6293\u6355<\/p>\n<pre style=\"border-radius: 5px; text-align: left; margin-top: 10px; margin-bottom: 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 16px; color: #abb2bf; padding-top: 15px; background: #282c34; border-radius: 5px; , consolas, monaco, menlo, monospace;border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; font-size: 12px;\">sudo\u00a0bpftrace\u00a0-e\u00a0<span style=\"color: #98c379; line-height: 26px;\">'k:tcp_send_active_reset\u00a0{\u00a0@[kstack()]\u00a0=\u00a0count();\u00a0}'<\/span>\r\n<\/code><\/pre>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5806\u6808\u7ed3\u679c\u5982\u56fe\uff1a<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img class=\"rich_pages wxw-img\" style=\"margin: 10px auto; border-style: none; border-width: 3px; border-radius: 0px; object-fit: fill;\" data-imgfileid=\"502299558\" data-ratio=\"0.5657894736842105\" data-src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/j3gficicyOvat2qfE1UmGBIwP1tfSQBhF04ofn228ibMAe2f8WxrJwlEEdd606MC6G6AMwszmYu1x9UZ6SkTG1Igw\/640?wx_fmt=png&amp;from=appmsg\" data-type=\"png\" data-w=\"912\" \/><\/figure>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u5806\u6808\u4fe1\u606f\u63a8\u7b97\u4e0a\u4e0b\u6587\u3002<\/p>\n<h4 style=\"font-size: 17px; margin-top: 10px; margin-bottom: 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><span style=\"font-size: 18px; line-height: 1.5em; letter-spacing: 0em; text-align: left; font-weight: bold;\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">passive rst<\/strong><\/span><\/h4>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u4f7f\u7528bpf*\u76f8\u5173\u7684\u5de5\u5177\u6293\u6355\u6293\u6355tcp_v4_send_reset()\u548c\u5176\u4ed6\u82e5\u5e72\u5c0f\u7684\u5730\u65b9\u5373\u53ef\uff0c\u539f\u7406\u540c\u4e0a\u3002<\/p>\n<pre style=\"border-radius: 5px; text-align: left; margin-top: 10px; margin-bottom: 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 16px; color: #abb2bf; padding-top: 15px; background: #282c34; border-radius: 5px; , consolas, monaco, menlo, monospace;border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; font-size: 12px;\">sudo\u00a0bpftrace\u00a0-e\u00a0<span style=\"color: #98c379; line-height: 26px;\">'k:tcp_v4_send_reset\u00a0{\u00a0@[kstack()]\u00a0=\u00a0count();\u00a0}'<\/span>\r\n<\/code><\/pre>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6548\u679c\u5982\u56fe\uff1a<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img class=\"rich_pages wxw-img\" style=\"margin: 10px auto; border-style: none; border-width: 3px; border-radius: 0px; object-fit: fill;\" data-imgfileid=\"502299556\" data-ratio=\"0.7379310344827587\" data-src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/j3gficicyOvat2qfE1UmGBIwP1tfSQBhF0MBibemX9XPkHTNtFb26ibdjQOADWHzDnQGaQoeMKWnV1GqDibq2iaKIGNg\/640?wx_fmt=png&amp;from=appmsg\" data-type=\"png\" data-w=\"580\" \/><\/figure>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5f53\u7136\uff0c\u65e0\u8bba\u90a3\u79cd\uff0c\u6211\u4eec\u6293\u5230\u4e86\u5806\u6808\u540e\u4f9d\u7136\u9700\u8981\u8f93\u51fa\u5f88\u591a\u7684\u5173\u4e8eskb\u548csk\u7684\u4fe1\u606f\uff0c\u8fd9\u4e2a\u8bfb\u8005\u81ea\u884c\u8003\u8651\u5373\u53ef\u3002\u518d\u8865\u5145\u4e00\u4e9b\u6293\u6355\u5c0f\u6280\u5de7\uff0c\u5982\u679c\u73b0\u7f51\u673a\u5668\u7684rst\u6570\u91cf\u8f83\u591a\u65f6\u5019\uff0c\u5c3d\u91cf\u4f7f\u7528\u5339\u914d\u56fa\u5b9a\u7684ip+port\u65b9\u5f0f\u6216\u5176\u5b83\u5173\u952e\u5b57\u6765\u51cf\u5c11\u6253\u5370\u8f93\u51fa\uff0c\u5426\u5219\u4f1a\u6d88\u8017\u8d44\u6e90\u8fc7\u591a\uff01<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6ce8\uff1a\u5207\u8bb0\u4e0d\u80fd\u53bb\u6293\u6355reset tracepoint\uff08\u5177\u4f53\u51fd\u6570\uff1atrace_tcp_send_reset()\uff09\uff0c\u8fd9\u4e2atracepoint\u5b9e\u73b0\u662f\u6709\u95ee\u9898\u7684\uff0c\u8fd9\u4e2a\u95ee\u9898\u5df2\u7ecf\u5728\u793e\u533a\u5185\u6838\u4e2d\u5b58\u5728\u4e867\u5e74\u4e4b\u4e45\uff01\u76ee\u524d\u6211\u6b63\u5728\u4fee\u590d\u4e2d\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<h3 style=\"text-align: left; margin-bottom: 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><span style=\"padding-left: 10px; font-size: 20px; line-height: 1.5em; letter-spacing: 0em; font-weight: bold;\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u56db\u3001\u6848\u4f8b\u5206\u6790<\/strong><\/span><\/h3>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u672c\u7ae0\u8282\u6211\u5c06\u7528\u73b0\u7f51\u5b9e\u9645\u78b0\u5230\u7684\u4e09\u4e2a\u201d\u79bb\u8c31\u201c\u800c\u4e14\u8ba9\u6211\u975e\u5e38\u201d\u54ac\u7259\u5207\u9f7f\u201c\u7684case\u4f5c\u4e3a\u6848\u4f8b\u5206\u6790\uff0c\u5f53\u65f6\u5728\u67e5\u8fd9\u4e9b\u95ee\u9898\u7684\u65f6\u5019\u6211\u63d0\u524d\u544a\u77e5\u4e1a\u52a1\u201d\u4e0d\u4fdd\u8bc1\u6709\u80fd\u529b\u89e3\u51b3 :(\u201c\uff0c\u4e0d\u8fc7\u6700\u7ec8\u8fd8\u662f\u7528\u65f6\u95f4\u78e8\u8d62\u4e86bug\u3002\u90a3\u4e48\uff0c\u8fd9\u91cc\u8ba9\u5404\u4f4d\u8bfb\u8005\u53ef\u4ee5\u770b\u4e0b\u6781\u4e3a\u590d\u6742\u7684RST\u6848\u4f8b\u5230\u5e95\u957f\u6210\u4ec0\u4e48\u6837\uff1f\u5bf9\u5185\u6838\u4e0d\u611f\u5174\u8da3\u7684\u540c\u5b66\u53ef\u4ee5\u4e0d\u7528\u7ea0\u7ed3\u5177\u4f53\u7684\u7ec6\u8282\uff0c\u53ea\u9700\u8981\u77e5\u9053\u4e00\u4e2a\u8fc7\u7a0b\u5373\u53ef\uff1b\u5bf9\u5185\u6838\u611f\u5174\u8da3\u7684\u540c\u5b66\u4e0d\u59a8\u53ef\u4ee5\u4e00\u8d77\u6784\u9020RST\u7136\u540e\u81ea\u5df1\u518d\u6293\u53d6\u7684\u8bd5\u8bd5\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u7b2c\u4e00\u4e2a\u6848\u4f8b\uff1a\u5c0f\u8bd5\u725b\u5200\u2014\u2014 close\u9636\u6bb5RST<\/strong><\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u80cc\u666f\uff1a<\/strong>\u8fd9\u662f\u7ebf\u4e0a\u51fa\u73b0\u6982\u7387\/\u6b21\u6570\u8f83\u591a\u7684\u4e00\u79cd\u7c7b\u578b\u7684RST\uff0c\u4e1a\u52a1\u603b\u662f\u62b1\u6028\u4e3a\u4f55\u6211\u7684\u8fde\u63a5\u83ab\u540d\u5176\u5999\u7684\u53c8\u6ca1\u4e86\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6211\u4eec\u5148\u4f7f\u7528\u7f51\u7edc\u5f02\u5e38\u68c0\u6d4b\u4e2d\u6700\u5e38\u7528\u7684\u5de5\u5177\uff1atcpdump\u3002\u5982\u4e0b\u6293\u5305\u7684\u56fe\u7247\u518d\u7ed3\u5408\u524d\u6587\u5bf9RST\u7684\u4e24\u79cd\u5206\u7c7b\uff08active &amp;&amp; passive\uff09\u53ef\u77e5\uff0c\u8fd9\u662factive rst\u3002<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img class=\"rich_pages wxw-img\" style=\"margin: 10px auto; border-style: none; border-width: 3px; border-radius: 0px; object-fit: fill;\" data-imgfileid=\"502299562\" data-ratio=\"0.025925925925925925\" data-src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/j3gficicyOvat2qfE1UmGBIwP1tfSQBhF04nqCHtPQGN40weFnjYaUgB23mULINdm7rNB15B1GzAzJZc20oEysKg\/640?wx_fmt=png&amp;from=appmsg\" data-type=\"png\" data-w=\"1080\" \/><\/figure>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u597d\uff0c\u65e2\u7136\u77e5\u9053\u4e86\u662factive rst\uff0c\u6211\u4eec\u5c31\u9488\u5bf9\u6027\u7684\u5728\u7ebf\u4e0a\u5bf9\u5173\u952e\u51fd\u6570\u6293\u6355\uff0c\u5982\u4e0b\uff1a<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img class=\"rich_pages wxw-img\" style=\"margin: 10px auto; border-style: none; border-width: 3px; border-radius: 0px; object-fit: fill;\" data-imgfileid=\"502299563\" data-ratio=\"0.42685185185185187\" data-src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/j3gficicyOvat2qfE1UmGBIwP1tfSQBhF0d6COZ26IE7b7o05Iuzg8ibNiawic78LmzESHZHsESXBRZYicOkU3uibBznA\/640?wx_fmt=png&amp;from=appmsg\" data-type=\"png\" data-w=\"1080\" \/><\/figure>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u901a\u8fc7crash\u547d\u4ee4\u627e\u5230\u4e86\u5bf9\u5e94\u7684\u6e90\u7801\uff0c\u5982\u4e0b\uff1a<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img class=\"rich_pages wxw-img\" style=\"margin: 10px auto; border-style: none; border-width: 3px; border-radius: 0px; object-fit: fill;\" data-imgfileid=\"502299564\" data-ratio=\"0.23796296296296296\" data-src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/j3gficicyOvat2qfE1UmGBIwP1tfSQBhF08vicafvoS2feiatNnsVlicRUxYnGUu7KfiaEwZ2SAUAcL4ichzuoFArDtCw\/640?wx_fmt=png&amp;from=appmsg\" data-type=\"png\" data-w=\"1080\" \/><\/figure>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u8fd9\u65f6\u5019\u4fbf\u77e5\u662f\u7528\u6237\u8bbe\u7f6e\u4e86linger\uff0c\u4e3b\u52a8\u9884\u671f\u5185\u7684\u884c\u4e3a\u89e6\u53d1\u7684rst\uff0c\u6240\u4ee5\u672c\u4f8b\u5c31\u89e3\u51b3\u4e86\u3002\u4e0d\u8fc7\u63d2\u66f2\u662f\uff0c\u7528\u6237\u5e76\u4e0d\u8ba4\u4e3a\u4ed6\u8bbe\u7f6e\u4e86linger\uff0c\u8fd9\u4e2a\u600e\u4e48\u529e\uff1f\u90a3\u5c31\u518d\u6293\u4e00\u6b21sk-&gt;sk_lingertime\u503c\u5c31\u597d\u54af\uff0c\u5982\u4e0b\uff1a<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img class=\"rich_pages wxw-img\" style=\"margin: 10px auto; border-style: none; border-width: 3px; border-radius: 0px; object-fit: fill;\" data-imgfileid=\"502299561\" data-ratio=\"0.05648148148148148\" data-src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/j3gficicyOvat2qfE1UmGBIwP1tfSQBhF0ZoqM9AJ8iaZBSgw199XPw8amYzczaKYDu1zN2Wjbtj73NPaB624FFew\/640?wx_fmt=png&amp;from=appmsg\" data-type=\"png\" data-w=\"1080\" \/><\/figure>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u8ba1\u7b97\uff1asocket\u7684flag\u662f784\uff0c\u7b2c5\u4f4d\uff08\u4ece\u53f3\u5f80\u5de6\uff09\u662f1\uff0c\u8fd9\u4e2a\u662fSO_LINGER\u4f4d\u7f6e\u4f4d\u6210\u529f\uff0c\u4f46\u662f\u540c\u65f6linger_time\u4e3a0\u3002\u8fd9\u4e2a\u6761\u4ef6\u9ed8\u8ba4\uff08\u7b26\u5408\u9884\u671f\uff09\u89e6\u53d1\uff1a\u4e0a\u5c42\u7528\u6237\u9000\u51fa\u65f6\u5019\uff0c\u4e0d\u8d70\u56db\u6b21\u6325\u624b\uff0c\u76f4\u63a5RST\u7ed3\u675f\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u7ed3\u8bba\uff1alinger\u7684\u9ed8\u8ba4\u673a\u5236\u89e6\u53d1\u4e86\u52a0\u901f\u7ed3\u675fTCP\u8fde\u63a5\u4ece\u800cRST\u62a5\u6587\u53d1\u51fa\u3002<\/strong><\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u7b2c\u4e8c\u4e2a\u6848\u4f8b\uff1aTCP \u4e24\u4e2abug \u2014\u2014 \u63e1\u624b\u4e0e\u6325\u624b\u7684RS<\/strong><\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u80cc\u666f\uff1a<\/strong>\u67d0\u91cd\u70b9\u4e1a\u52a1\u62a5\u544a\u4ed6\u4eec\u7684\u67d0\u91cd\u70b9\u7528\u6237\u51fa\u73b0\u4e86\u83ab\u540d\u5176\u5999\u7684RST\u95ee\u9898\uff0c\u800c\u4e14\u6bcf\u4e00\u6b21\u90fd\u662f\u51fa\u73b0\u5728\u4e09\u6b21\u63e1\u624b\u9636\u6bb5\uff0c\u590d\u73b0\u6982\u7387\u7ea6\u4e3a\u2014\u2014\u201d\u6309\u8bf7\u6c42\u6570\u6765\u7b97\u7684\u8bdd\u5dee\u4e0d\u591a\u767e\u4e07\u7ea7\u522b\u5206\u4e4b1\u7684\u6982\u7387\uff0c\u6982\u7387\u6781\u4f4e\u201c\uff08\u8fd9\u662f\u6765\u81ea\u4e1a\u52a1\u7684\u539f\u8bdd\uff09\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u8fd9\u91cc\u9700\u8981\u5267\u900f\u4e00\u70b9\u7684\u662f\uff0c\u540e\u6587\u63d0\u5230\u7684\u4e24\u4e2a\u573a\u666f\u4e0b\u7684rst\u7684bug\uff0c\u90fd\u662f\u7531\u4e8e\u76f8\u540c\u7684race condition\u5bfc\u81f4\u7684\u3002rcu\u4fdd\u62a4\u5173\u6ce8\u7684\u662freader&amp;writer\u7684\u5b89\u5168\u6027\uff08\u4e0d\u4f1a\u8e29\u9519\u5730\u5740\uff09\uff0c\u800c\u4e0d\u4fdd\u62a4\u6570\u636e\u7684\u5b9e\u65f6\u6027\uff0c\u8fd9\u4e2a\u5f88\u91cd\u8981\u3002\u6240\u4ee5<strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u5f53rcu\u4e0ehashtable\u7ed3\u5408\u7684\u65f6\u5019\uff0c\u5bf9\u6574\u4e2a\u8868\u7684\u589e\u5220\u548c\u8bfb\u5982\u4f55\u4fdd\u8bc1\u6570\u636e\u7684\u7edd\u5bf9\u7684\u540c\u6b65\u663e\u5f97\u5f88\u91cd\u8981\uff01<\/strong><\/p>\n<h4 style=\"font-size: 17px; margin-top: 10px; margin-bottom: 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><span style=\"font-size: 18px; line-height: 1.5em; letter-spacing: 0em; text-align: left; font-weight: bold;\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u63e1\u624b\u9636\u6bb5\u7684TCP bug<\/strong><\/span><\/h4>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img class=\"rich_pages wxw-img\" style=\"margin: 10px auto; border-style: none; border-width: 3px; border-radius: 0px; object-fit: fill;\" data-imgfileid=\"502299565\" data-ratio=\"0.09444444444444444\" data-src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/j3gficicyOvat2qfE1UmGBIwP1tfSQBhF0Lic0vbvqgWI98LOdcib5ZLZ5zyG6XgwSxzaRRen4l0lAUKTJod5NegcA\/640?wx_fmt=png&amp;from=appmsg\" data-type=\"png\" data-w=\"1080\" \/><\/figure>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u95ee\u9898\u7684\u8868\u8c61\u662f\uff0c\u4e09\u6b21\u63e1\u624b\u5b8c\u6bd5\u540eclient\u7aef\u7ed9server\u7aef\u53d1\u9001\u4e86\u6570\u636e\uff0c\u7ed3\u679cserver\u7aef\u5374\u53d1\u9001\u4e86rst\u62d2\u7edd\u4e86\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u5206\u6790\uff1a<\/strong>\u6ce8\u610f\u770b\u4e0a\u56fe\u6700\u5de6\u8fb9\u7684\u7b2c4\u548c5\u8fd9\u4e24\u884c\u7684\u65f6\u95f4\u95f4\u9694\u975e\u5e38\u77ed\uff0c\u53ea\u670911\u5fae\u5999\uff0c11\u5fae\u5999\u662f\u4ec0\u4e48\u6982\u5ff5\uff1f\u67e5\u4e00\u6b21tcp socket\u7684hash\u8868\u53ef\u80fd\u90fd\u662f\u51e0\u5341\u5fae\u5999\uff0c\u8fd9\u70b9\u65f6\u95f4\u5b8c\u5168\u53ef\u80fd\u4f1a\u505c\u987f\u5728\u4e00\u4e2a\u51fd\u6570\u4e0a\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5f53server\u7aef\u770b\u5230\u7b2c\u4e09\u884c\u7684ack\u7684\u65f6\u5019\u51e0\u4e4e\u540c\u65f6\u4e5f\u770b\u5230\u4e86\u7b2c\u56db\u884c\u7684\u6570\u636e\uff0c\u8be6\u7ec6\u6765\u8bf4\uff0c\u8fd9\u65f6\u5019server\u7aef\u5728\u63e1\u624b\u6700\u540e\u4e00\u4e2a\u73af\u8282\uff0c\u4f1a\u5728socket\u7684hash\u8868\u4e2d\u5220\u9664\u4e00\u4e2a\u8001\u7684socket\uff08\u6211\u4eec\u53ebreq sk\uff09\uff0c\u518d\u63d2\u5165\u4e00\u4e2a\u65b0\u7684socket\uff08\u6211\u4eec\u53ebfull sk\uff09\uff0c\u5728\u5220\u9664\u548c\u63d2\u5165\u4e4b\u95f4\u7684\u8fd9\u77ed\u6682\u7684\u51e0\u5fae\u5999\u53d1\u751f\u7684\u65f6\u5019\uff0cserver\u6536\u7b2c\u884c\u7684\u6570\u636e\u7684\u65f6\u5019\u9700\u8981\u53bb\u5230\u8fd9\u4e2ahash\u8868\u4e2d\u5bfb\u627e\uff08\u6839\u636e\u4e94\u5143\u7ec4\uff09\u5bf9\u5e94\u7684socket\u6765\u63a5\u53d7\u8fd9\u4e2a\u62a5\u6587\uff0c\u7ed3\u679c\u5728\u8fd9\u4e2a\u7a7a\u6863\u671f\u95f4\u6ca1\u6709\u5339\u914d\u5230\u5e94\u8be5\u627e\u5230\u7684socket\uff0c\u8fd9\u65f6\u5019\u6ca1\u529e\u6cd5\u53ea\u80fd\u628a\u5f53\u65f6\u4e0a\u5c42\u6700\u521d\u76d1\u542c\u7684listener\u62ff\u51fa\u6765\u63a5\u6536\uff0c\u8fd9\u6837\u5c31\u51fa\u73b0\u4e86\u9519\u8bef\uff0c\u8fdd\u80cc\u4e86\u534f\u8bae\u6808\u7684\u57fa\u672c\u7684\u8bbe\u8ba1\uff1a\u5bf9\u4e8elistener socket\u63a5\u6536\u5230\u4e86\u6570\u636e\u5305\uff0c\u90a3\u4e48\u8fd9\u4e2a\u6570\u636e\u5305\u662f\u975e\u9884\u671f\u7684\uff0c\u5e94\u8be5\u53d1\u9001RST\uff01<\/p>\n<pre style=\"border-radius: 5px; text-align: left; margin-top: 10px; margin-bottom: 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 16px; color: #abb2bf; padding-top: 15px; background: #282c34; border-radius: 5px; , consolas, monaco, menlo, monospace;border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; font-size: 12px;\">\u00a0\u00a0\u00a0CPU\u00a00\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0CPU\u00a01\r\n\u00a0\u00a0\u00a0-----\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0-----\r\ntcp_v4_rcv()\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0syn_recv_sock()\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0inet_ehash_insert()\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0-&gt;\u00a0sk_nulls_del_node_init_rcu(osk)\r\n__inet_lookup_established()\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0-&gt;\u00a0__sk_nulls_add_node_rcu(sk,\u00a0list)\r\n<\/code><\/pre>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5bf9\u5e94\u4e0a\u56fe\u7684cpu0\u5c31\u662fserver\u7684\u7b2c\u56db\u884c\u7684\u8bfb\u8005\uff0ccpu1\u5c31\u662f\u5199\u8005\uff0c\u5bf9\u4e8ecpu0\u800c\u8a00\uff0c\u8bfb\u5230\u7684\u6570\u636e\u53ef\u80fd\u662f\u4e09\u79cd\u60c5\u51b5\uff1a1\uff09\u8bfb\u5230\u8001\u7684sk\uff0c2\uff09\u8bfb\u5230\u65b0\u7684sk\uff0c3\uff09\u8c01\u4e5f\u8bfb\u4e0d\u5230\uff0c\u524d\u4e24\u4e2a\u90fd\u662f\u53ef\u4ee5\u63a5\u6536\uff0c\u4f46\u662f\u6700\u540e\u4e00\u4e2a\u5c31\u662fbug\u4e86\u2014\u2014\u6211\u4eec\u5fc5\u987b\u8981\u627e\u5230\u4e24\u8005\u4e4b\u4e00\uff01\u5982\u4e0b\u5c31\u662f\u4e00\u79cd\u573a\u666f\uff0c\u65e0\u6cd5\u6b63\u786e\u627e\u5230new\u6216\u8005old\u3002<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img class=\"rich_pages wxw-img\" style=\"margin: 10px auto; border-style: none; border-width: 3px; border-radius: 0px; object-fit: fill;\" data-imgfileid=\"502299569\" data-ratio=\"0.4\" data-src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/j3gficicyOvat2qfE1UmGBIwP1tfSQBhF00hkQZHBGxb7JvKzHyt3iaM544yyXKbpp1qPmqicSpOtYkbcicI5PRNUsA\/640?wx_fmt=png&amp;from=appmsg\" data-type=\"png\" data-w=\"1080\" \/><\/figure>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u90a3\u5982\u4f55\u4fee\u590d\u8fd9\u4e2a\u95ee\u9898\uff1f\u5728\u6392\u67e5\u5b8c\u6574\u4e2a\u63e1\u624b\u89c4\u5219\u540e\uff0c\u53d1\u73b0\u53ea\u9700\u8981\u5148\u63d2\u5165\u65b0\u7684sk\u5230hash\u6876\u7684\u5c3e\u90e8\uff0c\u518d\u5220\u9664\u8001\u7684sk\u5373\u53ef\uff0c\u8fd9\u6837\u5c31\u4f1a\u6709\u51e0\u79cd\u60c5\u51b5\uff1a1\uff09\u4e24\u4e2a\u540c\u65f6\u90fd\u5728\uff0c\u4e00\u5b9a\u80fd\u5339\u914d\u5230\u5176\u4e2d\u4e00\u4e2a\uff0c2\uff09\u5339\u914d\u5230\u65b0\u7684\u3002\u5982\u4e0b\u56fe\uff0c\u65e0\u8bbareader\u5728\u54ea\u91cc\u90fd\u80fd\u4fdd\u8bc1\u53ef\u4ee5\u8bfb\u5230\u4e00\u4e2a\u3002\u5982\u4e0b\u662f\u6b63\u786e\u7684\uff1a<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img class=\"rich_pages wxw-img\" style=\"margin: 10px auto; border-style: none; border-width: 3px; border-radius: 0px; object-fit: fill;\" data-imgfileid=\"502299567\" data-ratio=\"0.42777777777777776\" data-src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/j3gficicyOvat2qfE1UmGBIwP1tfSQBhF0ncdV374lx2U71gzKRX7ia7rtF8nV3zjtbvUFT7aaMczanuKpvzSlddQ\/640?wx_fmt=png&amp;from=appmsg\" data-type=\"png\" data-w=\"1080\" \/><\/figure>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u7ed3\u8bba\uff1a\u7b2c3\u884c\uff08client\u7ed9server\u53d1\u751f\u4e86\u63e1\u624b\u6700\u540e\u4e00\u6b21ack\uff09\u548c\u7b2c4\u884c\uff08client\u7aef\u7ed9server\u53d1\u9001\u4e86\u7b2c\u4e00\u7ec4\u6570\u636e\uff09\u51fa\u73b0\u7684\u5e76\u53d1\u95ee\u9898\u3002<\/strong><\/p>\n<h4 style=\"font-size: 17px; margin-top: 10px; margin-bottom: 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><span style=\"font-size: 18px; line-height: 1.5em; letter-spacing: 0em; text-align: left; font-weight: bold;\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u6325\u624b\u9636\u6bb5\u7684bug<\/strong><\/span><\/h4>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img class=\"rich_pages wxw-img\" style=\"margin: 10px auto; border-style: none; border-width: 3px; border-radius: 0px; object-fit: fill;\" data-imgfileid=\"502299568\" data-ratio=\"0.08796296296296297\" data-src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/j3gficicyOvat2qfE1UmGBIwP1tfSQBhF0D9nKicwBuqR2GGSLvIG8fDMBicO3ia0oL8md1h84yuV1oeq1yhMJEXTSg\/640?wx_fmt=png&amp;from=appmsg\" data-type=\"png\" data-w=\"1080\" \/><\/figure>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u8fd9\u4e2a\u95ee\u9898\u6839\u56e0\u540c\u4e0a\uff1arcu+hash\u8868\u7684\u4f7f\u7528\u95ee\u9898\uff0c\u5728\u6325\u624b\u9636\u6bb5\u53d1\u8d77close()\u7684\u4e00\u65b9\u7ade\u4e89\u7684\u4e71\u5e8f\u7684\u6536\u5230\u4e86\u4e00\u4e2aack\u548c\u4e00\u4e2afin ack\u89e6\u53d1\uff0c\u5bfc\u81f4socket\u5728\u6700\u540e\u63a5\u6536fin ack\u65f6\u5019\u6ca1\u6709\u5339\u914d\u5230\u4efb\u4f55\u4e00\u4e2asocket\uff0c\u53c8\u53ea\u80fd\u62ff\u51fa\u6700\u521d\u76d1\u542c\u7684listener\u6765\u6536\u5305\u7684\u65f6\u5019\uff0c\u8fd9\u65f6\u5019\u51fa\u73b0\u4e86\u9519\u8bef\u3002\u4f46\u662f\u8fd9\u4e2a\u539f\u59cb\u4ee3\u7801\u4e2d\uff0c\u662f\u5148\u63d2\u5165\u65b0\u7684sk\u518d\u5220\u9664\u4e86\u8001\u7684sk\uff0c\u4e4d\u4e00\u542c\u6ca1\u6709\u4efb\u4f55\u95ee\u9898\uff0c\u4f46\u662f\u5b9e\u9645\u4e0a\u63d2\u5165\u65b0\u7684sk\u51fa\u73b0\u4e86\u95ee\u9898\uff0c\u6e90\u7801\u4e2d\u63d2\u5165\u5230\u5934\u90e8\uff0c\u8fd9\u91cc\u9700\u8981\u63d2\u5165\u5230\u5c3e\u90e8\u624d\u884c\uff01\u51fa\u73b0\u95ee\u9898\u7684\u60c5\u666f\u5982\u4e0b\u56fe\u3002<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img class=\"rich_pages wxw-img\" style=\"margin: 10px auto; border-style: none; border-width: 3px; border-radius: 0px; object-fit: fill;\" data-imgfileid=\"502299566\" data-ratio=\"0.4046296296296296\" data-src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/j3gficicyOvat2qfE1UmGBIwP1tfSQBhF0ZYvkg2raFiaDtbCZTnuv6bFjSe2ua8XN4Xr4ib0BO1Y1HV79nKdmlBIA\/640?wx_fmt=png&amp;from=appmsg\" data-type=\"png\" data-w=\"1080\" \/><\/figure>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u7ed3\u8bba\uff1a\u8fd9\u4e2a\u662f\u539f\u751f\u5185\u6838\u957f\u8fbe\u5341\u591a\u5e74\u7684\u4e00\u4e2a\u5b9e\u73b0\u4e0a\u7684BUG\uff0c\u5373\u4e3a\u4e86\u6027\u80fd\u8003\u8651\u4f7f\u7528\u7684RCU\u673a\u5236\uff0c\u7531\u6b64\u5fc5\u7136\u5f15\u5165\u7684\u4e0d\u51c6\u786e\u6027\u5bfc\u81f4\u5e76\u53d1\u7684\u95ee\u9898\uff0c<\/strong>\u6211\u5b9a\u4f4d\u5e76\u5206\u6790\u51fa\u8fd9\u4e2a\u95ee\u9898\u7684\u5e76\u53d1\u7684\u6839\u56e0\uff0c\u7531\u6b64\u63d0\u4ea4\u4e86\u4e00\u4efd<strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">bugfix patch<\/strong>\u5230\u793e\u533a\u88ab\u63a5\u6536\uff0c\u94fe\u63a5\uff1ahttps:\/\/git.kernel.org\/pub\/scm\/linux\/kernel\/git\/netdev\/net.git\/commit\/?id=3f4ca5fafc08881d7a57daa20449d171f2887043<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u7b2c\u4e09\u4e2a\u6848\u4f8b\uff1anetfilter\u4e24\u4e2abug \u2014\u2014 \u6570\u636e\u4f20\u8f93RST<\/strong><\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u80cc\u666f\uff1a<\/strong>\u7528\u6237\u62a5\u544a\u6709\u4e24\u4e2a\u75db\u70b9\u95ee\u9898\uff1a\u5076\u53d1\u6027\u51fa\u73b01\uff09\u6839\u672c\u65e0\u6cd5\u5b8c\u6210\u4e09\u6b21\u63e1\u624b\u8fde\u63a5\uff0c2\uff09\u5728\u4f20\u8f93\u6570\u636e\u7684\u9636\u6bb5\u7a81\u7136\u88abRST\u5f02\u5e38\u4e2d\u6b62\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u5206\u6790\uff1a<\/strong>\u6211\u4eec\u5f88\u5bb9\u6613\u7684\u901a\u8fc7TCP\u7684\u8bbe\u8ba1\u63a8\u6d4b\u5230\u8fd9\u79cd\u60c5\u51b5\u4e00\u5b9a\u4e0d\u662f\u6b63\u5e38\u7684\u3001\u7b26\u5408\u9884\u671f\u7684\u884c\u4e3a\u3002\u6211\u6293\u53d6\u4e86passive rst\u540e\u53d1\u73b0\u539f\u56e0\u662fTCP\u5c42\u65e0\u6cd5\u901a\u8fc7\u6536\u5230\u7684skb\u5305\u5bfb\u627e\u5230\u5bf9\u5e94\u7684socket\uff0c\u8981\u77e5\u9053socket\u662f\u6700\u6838\u5fc3\u7684TCP\u8fde\u63a5\u901a\u4fe1\u7684\u57fa\u7ad9\uff0c\u5b83\u4fdd\u5b58\u4e86TCP\u5e94\u6709\u7684\u4fe1\u606f\uff08wscale\u3001seq\u3001buf\u7b49\u7b49\uff09\uff0c\u5982\u679cskb\u65e0\u6cd5\u627e\u5230socket\uff0c\u90a3\u4e48\u5c31\u50cf\u5c0f\u65f6\u5019\u7684\u6545\u4e8b\u5c0f\u874c\u86aa\u627e\u5988\u5988\u4f46\u662f\u627e\u4e0d\u5230\u56de\u5bb6\u7684\u8def\u4e00\u6837\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u90a3\u4e3a\u4ec0\u4e48\u4f1a\u51fa\u73b0\u627e\u4e0d\u5230socket\uff1f<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u7ecf\u8fc7\u6392\u67e5\u53d1\u73b0\u7ebf\u4e0a\u914d\u7f6e\u4e86DNAT\u89c4\u5219\uff0c\u5982\u4e0b\u4f8b\u5b50\uff0c\u51e1\u662f\u5230\u8fbeserver\u7aef\u76841111\u7aef\u53e3\u62161112\u7aef\u53e3\u7684\u90fd\u88ab\u8f6c\u53d1\u523080\u7aef\u53e3\u63a5\u6536\u3002<\/p>\n<pre style=\"border-radius: 5px; text-align: left; margin-top: 10px; margin-bottom: 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 16px; color: #abb2bf; padding-top: 15px; background: #282c34; border-radius: 5px; , consolas, monaco, menlo, monospace;border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; font-size: 12px;\">\/\/\u00a0iptables\u00a0A\u00a0port\u00a0-&gt;\u00a0B\u00a0port\r\niptables\u00a0...\u00a0-p\u00a0tcp\u00a0--port\u00a01111\u00a0-j\u00a0REDIRECT\u00a0--to-ports\u00a080\r\niptables\u00a0...\u00a0-p\u00a0tcp\u00a0--port\u00a01112\u00a0-j\u00a0REDIRECT\u00a0--to-ports\u00a080\r\n<\/code><\/pre>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">DNAT+netfilter\u7684\u6d41\u7a0b\u662f\u4ec0\u4e48\u6837\uff1f<\/p>\n<figure style=\"margin-top: 10px; margin-bottom: 10px; flex-direction: column; justify-content: center; align-items: center;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><img class=\"rich_pages wxw-img\" style=\"margin: 10px auto; border-style: none; border-width: 3px; border-radius: 0px; object-fit: fill;\" data-imgfileid=\"502299570\" data-ratio=\"0.6805555555555556\" data-src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_png\/j3gficicyOvat2qfE1UmGBIwP1tfSQBhF0EAwpv4LB8SM5Dia0EeXIf6ibicHHgLIzbH3ibqsb3H6l7h6656gDpJHB6w\/640?wx_fmt=png&amp;from=appmsg\" data-type=\"png\" data-w=\"1080\" \/><\/figure>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u90a3\u4e48\uff0c\u6709\u4e86DNAT\u4e4b\u540e\uff0c\u51e1\u662f\u8fdb\u5165\u5230server\u7aef\u7684A port\u4f1a\u88ab\u76f4\u63a5\u8f6c\u53d1\u5230B port\uff0c\u6700\u540eTCP\u5b8c\u6210\u63a5\u6536\u3002\u5b8c\u6574\u7684\u903b\u8f91\u662f\u8fd9\u6837\uff1aDNAT\u7684\u7aef\u53e3\u6620\u5c04\u5728ip\u5c42\u6536\u5305\u65f6\u5019\u5148\u8fdb\u5165prerouting\u6d41\u7a0b\uff0c\u4fee\u6539skb\u7684dst_ip:dst_port\u4e3a\u771f\u6b63\u7684\u6700\u540e\u6620\u5c04\u7684\u4fe1\u606f\uff0c\u800c\u540e\u7531ip early demux\u673a\u5236\u9488\u5bf9skb\u4e2d\u7684\u539f\u59cb\u4fe1\u606fsrc_ip:src_port\uff08\u4e5f\u5c31\u662fA port\uff09\u4fee\u6539\u4e3adst_ip:dst_port\uff08\u4e5f\u5c31\u662f\u4f7f\u7528B port\uff09\uff0c\u7531\u6b644\u5143\u7ec4hash\u9009\u62e9\u4e00\u4e2ask\uff0c\u7ee7\u800c\u6210\u529f\u7531TCP\u63a5\u6536\u624d\u5bf9\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u4e24\u6761\u6d41\u51b2\u7a81\u89e6\u53d1\u7684bug<\/strong><\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5982\u4e0b\uff0c\u5982\u679c\u8fd9\u65f6\u5019\u6709\u4e24\u6761\u6d41\u91cf\u60f3\u8981TCP\u5efa\u8fde\uff0c\u4e8c\u8005\u90fd\u662f\u7531\u540c\u4e00\u4e2aclient\u7aef\u76f8\u540c\u7684ip\u548cport\u53d1\u8d77\u8fde\u63a5\uff0c\u8fd9\u65f6\u5019\u7b2c1\u6761\u8fde\u63a5\u9996\u5148\u53d1\u8d77\u63e1\u624b\u90a3\u4e48\u80af\u5b9a\u53ef\u4ee5\u987a\u5229\u8fdb\u884c\uff0c\u800c\u5f53\u7b2c2\u6761\u8fde\u63a5\u53d1\u8d77\u7684\u65f6\u5019\u62b5\u8fbe\u5230server\u7aef\u76841112\u7aef\u53e3\u6700\u7ec8\u88ab\u8f6c\u5316\u4e3a80\u7aef\u53e3\uff0c\u4f46\u662f\u6839\u636e80\u7aef\u53e3\u53ef\u4ee5\u53d1\u73b0\u6211\u4eec\u5df2\u7ecf\u5efa\u7acb\u4e86\u8fde\u63a5\uff0c\u6240\u4ee5\u7b2c2\u6761\u6d41\u4e09\u6b21\u63e1\u624b\u76f4\u63a5\u5931\u8d25\u3002<\/p>\n<pre style=\"border-radius: 5px; text-align: left; margin-top: 10px; margin-bottom: 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 16px; color: #abb2bf; padding-top: 15px; background: #282c34; border-radius: 5px; , consolas, monaco, menlo, monospace;border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; font-size: 12px;\">1.\u00a0saddr:12345\u00a0-&gt;\u00a0daddr:80\u00a0\/\/\u00a0\u6b63\u5e38\u8fde\u63a5\r\n2.\u00a0saddr:12345\u00a0-&gt;\u00a0daddr:1112\u00a0-&gt;\u00a0daddr:80\u00a0\/\/\u00a0NAT\u53c2\u4e0e\u8f6c\u5316\r\n\uff08\u5bf9\u5185\u6838\u7ec6\u8282\u4e0d\u611f\u5174\u8da3\u7684\u540c\u5b66\u53ef\u4ee5\u8df3\u8fc7\u6b64\u6bb5\uff09\r\n<\/code><\/pre>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6211\u9700\u8981\u8865\u5145\u7684\u4fe1\u606f\u662f\uff1aNAT\u8f6c\u5316port\u5206\u4e3a\u4e24\u6b21\uff0c\u5bf9\u4e8e\u4e0a\u8ff0\u7b2c\u4e8c\u6761\u6d41\uff0c\u7b2c\u4e00\u6b21\u8f6c\u53161112\u4e3a80\uff0c\u7b2c\u4e8c\u6b21\u8f6c\u531612345\u4e3a1112\uff0c\u6700\u7ec8\u6b64\u6d41\u53d8\u4e3a[saddr:1112 -&gt; daddr:80]<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u7b2c\u4e00\u6761\u6d41\uff1a<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">skb\u5bf9\u5e94\u7684sk\u662f[saddr:12345 -&gt; daddr:80]\uff0c\u8fd9\u4e2a\u6ca1\u6709NAT\u53c2\u4e0e\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u7b2c\u4e8c\u6761\u6d41\uff1a<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">skb\u5728ip\u5c42\u8fd9\u65f6\u5019NAT\u521a\u5b8c\u6210\u7b2c\u4e00\u6b21port\uff08\u4fee\u6539dport 1112\u4e3adport 80\uff09\uff0c\u7136\u540e\u8fdb\u5165\u4e86early demux\u673a\u5236\uff0c\u6b64\u65f6\u76844\u5143\u7ec4\u662f[saddr:12345 -&gt; daddr:80]\uff0c\u6240\u4ee5\u8fd9\u65f6\u5019\u5339\u914d\u4e0a\u4e86\u7b2c\u4e00\u6761\u6d41\u7684sk\uff0c\u4f46\u662f\u7cfb\u7edf\u5e76\u4e0d\u77e5\u60c5\u6709\u95ee\u9898\u4e86\uff0c\u7d27\u63a5\u7740NAT\u7b2c\u4e8c\u6b21\u6539\u53d8skb\u7684port\uff0c\u53d8\u4e3a[saddr:1112 -&gt; daddr:80]\uff0c\u8fd9\u4e2a\u4e5f\u662f\u540e\u7eedTCP\u5c42\u5ef6\u7eed\u4f7f\u7528\u7684\uff0c\u867d\u7136\u8fd9\u4e2a4\u5143\u7ec4\u4fe1\u606f\u662f\u5bf9\u7684\uff0c\u4f46\u662f\u5df2\u7ecf\u6ca1\u6709\u7528\u4e86\uff0c\u56e0\u4e3aearly demux\u9636\u6bb5\u5df2\u7ecf\u83b7\u53d6\u3001\u4fdd\u5b58socket\u4e86\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6ce8\uff1a\u5185\u6838\u4fee\u590d\u540e\uff0c\u5bf9\u4e8e\u7b2c\u4e8c\u6761\u6d41\u5c31\u662f\u653e\u5f03early demux\u9636\u6bb5\u9009\u62e9\u76844\u5143\u7ec4\uff0c\u800c\u662f\u5b89\u5fc3\u7b49\u5f85NAT\u5b8c\u6210\u4e24\u8f6eport\u7684\u8f6c\u5316\u4e4b\u540e\uff0c\u4f7f\u7528[saddr:1112 -&gt; daddr:80]\u6765\u5339\u914dsocket\uff0c\u8fd9\u65f6\u5019\u53d1\u73b0\u6ca1\u6709\u5bf9\u5e94\u7684socket\uff0c\u5c31\u627e\u5230\u4e86listener socket\uff0c\u4ece\u800c\u5b8c\u6210\u4e09\u6b21\u8fde\u63a5\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u7ed3\u8bba\uff1a\u8fd9\u4e2a\u662fearly demux+DNAT\u7684bug\uff0c\u5b83\u672a\u80fd\u89e3\u51b3\u51b2\u7a81\u95ee\u9898\uff0c\u5bfc\u81f4\u4e86\u5f02\u5e38RST\u7684\u53d1\u751f\u3002<\/strong><\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u7279\u6b8askb\u89e6\u53d1\u7684bug<\/strong><\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6ce8\uff1a\u5728\u8fd9\u4e2a\u573a\u666f\u91cc\u9762\u591a\u4e86\u4e00\u4e2a\u4e2d\u95f4\u7684gateway\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5728\u672c\u4f8b\u4e2d\uff0c\u6211\u53d1\u73b0\u4f9d\u7136\u662f\u719f\u77e5\u7684\u4e00\u5e55\uff0cskb\u65e0\u6cd5lookup\u5bfb\u627e\u5230\u5bf9\u5e94\u7684socket\uff0c\u6b64\u65f6\u6211\u4eec\u8981\u76f8\u4fe1\u4e00\u5b9a\u4e0d\u4f1alookup\u7b97\u6cd5\u51fa\u9519\uff0c\u56e0\u4e3a\u6b64\u7b97\u6cd5\u4ec5\u4ec5\u662f\u505a\u7b80\u5355\u76844\u5143\u7ec4\u7684hash\u8ba1\u7b97\u4e0e\u5339\u914d\u3002\u6240\u4ee5\u8ffd\u6eaf\u5f02\u5e38\u7684skb\u548csocket\u7684\u56db\u5143\u7ec4\u4fe1\u606f\u662f\u5934\u7b49\u4e8b\u60c5\uff0c\u7ecf\u8fc7\u5bf9\u6bd4\u679c\u7136\u53d1\u73b0skb\u7684\u7aef\u53e3\u4fe1\u606f\u672a\u80fd\u6210\u529f\u88abiptables\u8f6c\u5316\u4e3aB port\uff0c\u6240\u4ee5\u4f7f\u7528\u4e86\u542b\u6709A port\u7684\u56db\u5143\u7ec4\u4fe1\u606f\u53bb\u627esocket\uff0c\u800csocket\u5f53\u521d\u7684\u5efa\u7acb\u662f\u4f7f\u7528\u4e86B port\uff0c\u6240\u4ee5skb\u4e0esk\u7684\u76f8\u9047\u5c31\u8fd9\u4e48\u64e6\u8eab\u800c\u8fc7\u4e86\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\uff08\u5bf9\u5185\u6838\u7ec6\u8282\u4e0d\u611f\u5174\u8da3\u7684\u540c\u5b66\u53ef\u4ee5\u8df3\u8fc7\u540e\u9762\u5927\u6bb5\uff09<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u90a3\u4e48\u4e3a\u4ec0\u4e48\u4f1aDNAT\u65e0\u6cd5\u8f6c\u5316\uff1f<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u6211\u4eec\u5148\u770b\u4e0b\uff0c\u5f02\u5e38\u672a\u88ab\u8f6c\u5316\u7684skb\u548c\u5e94\u5f53\u80fd\u63a5\u6536\u7684socket\u76844\u5143\u7ec4\u4fe1\u606f\uff1a<\/p>\n<pre style=\"border-radius: 5px; text-align: left; margin-top: 10px; margin-bottom: 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 16px; color: #abb2bf; padding-top: 15px; background: #282c34; border-radius: 5px; , consolas, monaco, menlo, monospace;border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; font-size: 12px;\">\/\/\u00a02.2.2.2\u662f\u53bb\u654f\u540e\u7684server\u7aefip\u5730\u5740\uff0c\u53e6\u5916\u4e24\u4e2a\u662fclient\u7684ip\r\nsk\u00a0info:\u00a01.1.1.1:1111\u00a0&lt;-&gt;\u00a02.2.2.2:80\u00a0\/\/\u00a0\u6211\u4eec\u53ef\u4ee5\u77e5\u9053\u771f\u5b9e\u7684socket\u7684\u5efa\u7acb\u662f\u4f7f\u7528\u4e8680\u7aef\u53e3\r\nskb\u00a0info:\u00a01.1.1.2:2222\u00a0&lt;-&gt;\u00a02.2.2.2:1112\u00a0\/\/\u00a0\u5f02\u5e38\u7684skb\u672a\u6210\u529f\u5c061112\u7aef\u53e3\u8f6c\u5316\u4e3a80\u7aef\u53e3\r\n<\/code><\/pre>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">client-&gt;gw-&gt;server\u7684\u6d41\u7a0b\u4e2d\uff0c\u7531\u4e8egw\u4fa7\u53d1\u9001\u4e86\u4e00\u4e9bunknown skb\u518d\u52a0\u4e0aclient\u7aef\u53d1\u9001\u4e86\u4e00\u4e9bout-of-window\u7684\u5305\uff0c\u5bfc\u81f4\u8fdb\u5165\u5230server\u7684netfilter\u9636\u6bb5\u4f1a\u88ab\u8bc6\u522b\u51fa\u6765INVALID\u5f02\u5e38\uff0c\u8fd9\u4e2a\u5f02\u5e38\u88ab\u8bc6\u522b\u540e\u76f4\u63a5\u6e05\u9664netfilter\u4fdd\u6301\u7684\u8be5\u6709\u7684\u6d41\u4fe1\u606f\uff0c\u7ee7\u800c\u5f02\u5e38\u7684skb\u62b5\u8fbeDNAT\u9636\u6bb5\u540e\u65e0\u6cd5\u8f6c\u5316\u7aef\u53e3\uff08\u56e0\u4e3a\u5224\u65ad\u8f6c\u5316\u7684\u6d41\u4fe1\u606f\u6ca1\u6709\u4e86\uff09\uff0c\u6700\u7ec8skb\u65e0\u6cd5\u6210\u529f\u8f6c\u5316port\u7aef\u53e3\u53f7\u3002<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u8fd9\u4e2a\u662fnetfilter+DNAT\u7684\u8bbe\u8ba1\u4e0a\u7684bug\uff0c\u6211\u8ba4\u4e3a\uff1a\u65e0\u8bba\u662f\u5426\u6709netfilter\uff0c\u90fd\u4e0d\u5e94\u5f53\u662fTCP\u7684\u884c\u4e3a\u88ab\u6539\u53d8\uff0c\u6240\u4ee5\u5982\u679cnetfilter\u8bc6\u522b\u5230\u4e86\u95ee\u9898\u6240\u5728\uff0c1\uff09\u8981\u4e48\u5ffd\u89c6\uff0c\u76f4\u63a5\u4f20\u7ed9TCP\uff0c\u4ea4\u7ed9TCP\u5904\u7406\uff0c2\uff09\u8981\u4e48\u4e22\u5f03\uff0c\u8fd9\u6837\u4e5f\u80fd\u907f\u514dRST\u7684\u53d1\u751f\u3002\u4f46\u662f\uff0c\u5c31\u8fd9\u4e48\u4e00\u4e2a\u5c0f\u5c0f\u7684\u7ec6\u8282\u4e0a\uff0c\u6211\u548c\u793e\u533a\u7684\u51e0\u4e2a\u7ef4\u62a4\u8005\u62c9\u952f\u6218\u7684battle\u4e86\u4e09\u767e\u56de\u5408\uff08\u94fe\u63a5\uff1a<a style=\"font-weight: bold; border-style: none none solid; border-width: 3px 3px 0px; border-radius: 0px;\" href=\"https:\/\/lore.kernel.org\/all\/20240311070550.7438-1-kerneljasonxing@gmail.com\/\" data-linktype=\"2\">https:\/\/lore.kernel.org\/all\/20240311070550.7438-1-kerneljasonxing@gmail.com\/<\/a>\uff09\uff0c\u53ef\u60dc\u867d\u7136\u6709\u4e00\u4e2a\u7ef4\u62a4\u8005ACK\u4e86\u6211\u7684\u8865\u4e01\uff0c\u4f46\u662f\u53e6\u5916\u7684\u7ef4\u62a4\u8005\u8003\u8651netfilter\u4e0d\u9002\u5408\u7528\u4e8e\u4e22\u5305\u529f\u80fd\uff0c\u6240\u4ee5\u8ba9\u7528\u6237\u53bb\u4f7f\u7528iptables --log\u529f\u80fd\u3001\u68c0\u6d4b\u51fainvalid\u5f02\u5e38\u5305\u3001\u7ee7\u800c\u7528iptables\u914d\u7f6e\u4e3b\u52a8\u4e22\u5f03\u3002\u5c31\u51ed\u8fd9\u70b9\uff0c\u6211\u8ba4\u4e3a\u4e25\u91cd\u8fdd\u80cc\u4e86user friendly\u7684\u521d\u8877\uff0c\u8fd9\u4e9b\u5e94\u8be5\u662fdefault\u9ed8\u8ba4\u529f\u80fd\u624d\u5bf9\u3002\u6b64\u65f6\u7684\u6211\u867d\u7136\u8868\u9762\u6253\u4e0d\u8fc7\uff0c\u4f46\u662f\u5728\u5185\u5fc3\u4e16\u754c\u91cc\u5f88\u663e\u7136\u6211battle\u8d62\u4e86...<\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u7ed3\u8bba\uff1anetfilter\u8bc6\u522b\u5f02\u5e38\u7684skb\u672a\u80fd\u6210\u529f\u4fdd\u7559DNAT\u4fe1\u606f\uff0c\u5bfc\u81f4\u6700\u540eport\u7aef\u53e3\u4e0d\u80fd\u6210\u529f\u88ab\u8f6c\u5316\uff0c\u4ece\u800c\u89e6\u53d1\u4e86TCP\u7684RST\u884c\u4e3a\u3002<\/strong><\/p>\n<h3 style=\"text-align: left; margin-bottom: 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><span style=\"padding-left: 10px; font-size: 20px; line-height: 1.5em; letter-spacing: 0em; font-weight: bold;\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u4e94\u3001\u5c0f\u7ed3<\/strong><\/span><\/h3>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">RST\u95ee\u9898\u5e76\u4e0d\u53ef\u6015\uff0c\u53ea\u8981\u601d\u8def\u7406\u6e05\u695a\uff0c<strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u5148\u5224\u65ad\u7c7b\u578b\uff0c\u518d\u6293\u53d6\u5bf9\u5e94\u4ee3\u7801\uff0c\u7ee7\u800c\u7ffb\u51faRFC\u534f\u8bae\uff0c\u6700\u540e\u5206\u6790\u6e90\u7801\u5c31\u80fd\u641e\u5b9a\uff0c\u4ec5\u4ec5\u56db\u6b65\u5c31\u53ef\u4ee5\u4e86 \uff1a\uff09<\/strong><\/p>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u5e0c\u671b\u8fd9\u7bc7\u6587\u7ae0\u5bf9\u5927\u5bb6\u6709\u7528\uff01<\/p>\n<h3 style=\"text-align: left; margin-bottom: 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><span style=\"padding-left: 10px; font-size: 20px; line-height: 1.5em; letter-spacing: 0em; font-weight: bold;\"><strong style=\"background-attachment: scroll; background-image: none; background-position: 0% 0%; background-repeat: no-repeat; background-size: auto; width: auto; height: auto; border-style: none; border-width: 3px; border-radius: 0px;\">\u516d\u3001\u9644\u5f55<\/strong><\/span><\/h3>\n<p style=\"line-height: 1.75; text-indent: 0em; padding-top: 8px; padding-bottom: 8px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\">\u8fd9\u91cc\u5217\u4e00\u4e0bbcc\u7684\u5de5\u5177\u6e90\u7801\uff0c\u611f\u5174\u8da3\u7684\u540c\u5b66\u53ef\u4ee5\u81ea\u884c\u67e5\u9605\u3002\u5982\u4e0b\u662f\u9488\u5bf94.14\u5185\u6838\u5199\u7684\uff0c\u5982\u679c\u662f\u66f4\u9ad8\u7248\u672c\u9700\u8981\u8c03\u6574\u4e00\u4e9bpython\u4e0ec\u5bf9\u7167\u7684\u683c\u5f0f\u95ee\u9898\u3002<\/p>\n<pre style=\"border-radius: 5px; text-align: left; margin-top: 10px; margin-bottom: 10px;\" data-tool=\"mdnice\u7f16\u8f91\u5668\"><code style=\"padding: 16px; color: #abb2bf; padding-top: 15px; background: #282c34; border-radius: 5px; , consolas, monaco, menlo, monospace;border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; font-size: 12px;\"><span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#!\/usr\/bin\/env\u00a0python<\/span>\r\n\r\n<span style=\"color: #c678dd; line-height: 26px;\">from<\/span>\u00a0__future__\u00a0<span style=\"color: #c678dd; line-height: 26px;\">import<\/span>\u00a0print_function\r\n<span style=\"color: #c678dd; line-height: 26px;\">from<\/span>\u00a0bcc\u00a0<span style=\"color: #c678dd; line-height: 26px;\">import<\/span>\u00a0BPF\r\n<span style=\"color: #c678dd; line-height: 26px;\">import<\/span>\u00a0argparse\r\n<span style=\"color: #c678dd; line-height: 26px;\">from<\/span>\u00a0time\u00a0<span style=\"color: #c678dd; line-height: 26px;\">import<\/span>\u00a0strftime\r\n<span style=\"color: #c678dd; line-height: 26px;\">from<\/span>\u00a0socket\u00a0<span style=\"color: #c678dd; line-height: 26px;\">import<\/span>\u00a0inet_ntop,\u00a0AF_INET,\u00a0AF_INET6\r\n<span style=\"color: #c678dd; line-height: 26px;\">from<\/span>\u00a0struct\u00a0<span style=\"color: #c678dd; line-height: 26px;\">import<\/span>\u00a0pack\r\n<span style=\"color: #c678dd; line-height: 26px;\">import<\/span>\u00a0ctypes\u00a0<span style=\"color: #c678dd; line-height: 26px;\">as<\/span>\u00a0ct\r\n<span style=\"color: #c678dd; line-height: 26px;\">from<\/span>\u00a0time\u00a0<span style=\"color: #c678dd; line-height: 26px;\">import<\/span>\u00a0sleep\r\n<span style=\"color: #c678dd; line-height: 26px;\">from<\/span>\u00a0bcc\u00a0<span style=\"color: #c678dd; line-height: 26px;\">import<\/span>\u00a0tcp\r\n\r\n<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0arguments<\/span>\r\nexamples\u00a0=\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"\"\"examples:\r\n\u00a0\u00a0\u00a0\u00a0.\/tcpdrop\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0#\u00a0trace\u00a0kernel\u00a0TCP\u00a0drops\r\n\"\"\"<\/span>\r\nparser\u00a0=\u00a0argparse.ArgumentParser(\r\n\u00a0\u00a0\u00a0\u00a0description=<span style=\"color: #98c379; line-height: 26px;\">\"Trace\u00a0TCP\u00a0drops\u00a0by\u00a0the\u00a0kernel\"<\/span>,\r\n\u00a0\u00a0\u00a0\u00a0formatter_class=argparse.RawDescriptionHelpFormatter,\r\n\u00a0\u00a0\u00a0\u00a0epilog=examples)\r\nparser.add_argument(<span style=\"color: #98c379; line-height: 26px;\">\"--ebpf\"<\/span>,\u00a0action=<span style=\"color: #98c379; line-height: 26px;\">\"store_true\"<\/span>,\r\n\u00a0\u00a0\u00a0\u00a0help=argparse.SUPPRESS)\r\nargs\u00a0=\u00a0parser.parse_args()\r\ndebug\u00a0=\u00a0<span style=\"color: #d19a66; line-height: 26px;\">0<\/span>\r\n\r\n<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0define\u00a0BPF\u00a0program<\/span>\r\nbpf_text\u00a0=\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"\"\"\r\n#include\u00a0&lt;uapi\/linux\/ptrace.h&gt;\r\n#include\u00a0&lt;uapi\/linux\/tcp.h&gt;\r\n#include\u00a0&lt;uapi\/linux\/ip.h&gt;\r\n#include\u00a0&lt;net\/sock.h&gt;\r\n#include\u00a0&lt;bcc\/proto.h&gt;\r\n\r\nBPF_STACK_TRACE(stack_traces,\u00a01024);\r\n\r\nstruct\u00a0ipv4_data_t\u00a0{\r\n\u00a0\u00a0\u00a0\u00a0u32\u00a0pid;\r\n\u00a0\u00a0\u00a0\u00a0u64\u00a0is_sknull;\r\n\u00a0\u00a0\u00a0\u00a0u32\u00a0saddr;\r\n\u00a0\u00a0\u00a0\u00a0u32\u00a0daddr;\r\n\u00a0\u00a0\u00a0\u00a0u16\u00a0sport;\r\n\u00a0\u00a0\u00a0\u00a0u16\u00a0dport;\r\n\u00a0\u00a0\u00a0\u00a0u8\u00a0state;\r\n\u00a0\u00a0\u00a0\u00a0u8\u00a0tcpflags;\r\n\u00a0\u00a0\u00a0\u00a0u32\u00a0stack_id;\r\n};\r\nBPF_PERF_OUTPUT(ipv4_events);\r\n\r\nstruct\u00a0active_data_t\u00a0{\r\n\u00a0\u00a0\u00a0\u00a0u32\u00a0pid;\r\n\u00a0\u00a0\u00a0\u00a0u32\u00a0saddr;\r\n\u00a0\u00a0\u00a0\u00a0u32\u00a0daddr;\r\n\u00a0\u00a0\u00a0\u00a0u16\u00a0sport;\r\n\u00a0\u00a0\u00a0\u00a0u16\u00a0dport;\r\n\u00a0\u00a0\u00a0\u00a0u32\u00a0stack_id;\r\n};\r\nBPF_PERF_OUTPUT(active_events);\r\n\r\nstatic\u00a0struct\u00a0tcphdr\u00a0*skb_to_tcphdr(const\u00a0struct\u00a0sk_buff\u00a0*skb)\r\n{\r\n\u00a0\u00a0\u00a0\u00a0\/\/\u00a0unstable\u00a0API.\u00a0verify\u00a0logic\u00a0in\u00a0tcp_hdr()\u00a0-&gt;\u00a0skb_transport_header().\r\n\u00a0\u00a0\u00a0\u00a0return\u00a0(struct\u00a0tcphdr\u00a0*)(skb-&gt;head\u00a0+\u00a0skb-&gt;transport_header);\r\n}\r\n\r\nstatic\u00a0inline\u00a0struct\u00a0iphdr\u00a0*skb_to_iphdr(const\u00a0struct\u00a0sk_buff\u00a0*skb)\r\n{\r\n\u00a0\u00a0\u00a0\u00a0\/\/\u00a0unstable\u00a0API.\u00a0verify\u00a0logic\u00a0in\u00a0ip_hdr()\u00a0-&gt;\u00a0skb_network_header().\r\n\u00a0\u00a0\u00a0\u00a0return\u00a0(struct\u00a0iphdr\u00a0*)(skb-&gt;head\u00a0+\u00a0skb-&gt;network_header);\r\n}\r\n\r\n\/\/\u00a0from\u00a0include\/net\/tcp.h:\r\n#ifndef\u00a0tcp_flag_byte\r\n#define\u00a0tcp_flag_byte(th)\u00a0(((u_int8_t\u00a0*)th)[13])\r\n#endif\r\n\r\nint\u00a0trace_tcp_v4_send_reset(struct\u00a0pt_regs\u00a0*ctx,\u00a0struct\u00a0sock\u00a0*sk,\u00a0struct\u00a0sk_buff\u00a0*skb)\r\n{\r\n\u00a0\u00a0\u00a0\u00a0u8\u00a0is_sk_null\u00a0=\u00a0sk\u00a0?\u00a00\u00a0:\u00a01;\r\n\u00a0\u00a0\u00a0\u00a0u8\u00a0state\u00a0=\u00a0sk\u00a0?\u00a0(u8)sk-&gt;__sk_common.skc_state\u00a0:\u00a01;\r\n\u00a0\u00a0\u00a0\u00a0u32\u00a0pid\u00a0=\u00a0bpf_get_current_pid_tgid();\r\n\u00a0\u00a0\u00a0\u00a0struct\u00a0iphdr\u00a0*ip\u00a0=\u00a0skb_to_iphdr(skb);\r\n\u00a0\u00a0\u00a0\u00a0u32\u00a0daddr\u00a0=\u00a0ip-&gt;daddr;\r\n\u00a0\u00a0\u00a0\u00a0u32\u00a0saddr\u00a0=\u00a0ip-&gt;saddr;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\/\/\u00a0pull\u00a0in\u00a0details\u00a0from\u00a0the\u00a0packet\u00a0headers\u00a0and\u00a0the\u00a0sock\u00a0struct\r\n\u00a0\u00a0\u00a0\u00a0u16\u00a0family\u00a0=\u00a0sk-&gt;__sk_common.skc_family;\r\n\u00a0\u00a0\u00a0\u00a0u16\u00a0sport\u00a0=\u00a00,\u00a0dport\u00a0=\u00a00;\r\n\u00a0\u00a0\u00a0\u00a0struct\u00a0tcphdr\u00a0*tcp\u00a0=\u00a0skb_to_tcphdr(skb);\r\n\u00a0\u00a0\u00a0\u00a0u8\u00a0tcpflags\u00a0=\u00a0((u_int8_t\u00a0*)tcp)[13];\r\n\u00a0\u00a0\u00a0\u00a0sport\u00a0=\u00a0tcp-&gt;source;\r\n\u00a0\u00a0\u00a0\u00a0dport\u00a0=\u00a0tcp-&gt;dest;\r\n\u00a0\u00a0\u00a0\u00a0sport\u00a0=\u00a0ntohs(sport);\r\n\u00a0\u00a0\u00a0\u00a0dport\u00a0=\u00a0ntohs(dport);\r\n\r\n\u00a0\u00a0\u00a0\u00a0if\u00a0(family\u00a0==\u00a0AF_INET\u00a0&amp;&amp;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0(saddr\u00a0==\u00a016777343\u00a0&amp;&amp;\u00a0daddr\u00a0==\u00a016777343)\u00a0&amp;&amp;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0(sport\u00a0==\u00a08004\u00a0||\u00a0dport\u00a0==\u00a08004))\u00a0{\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0struct\u00a0ipv4_data_t\u00a0data4\u00a0=\u00a0{};\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0data4.pid\u00a0=\u00a0pid;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0data4.saddr\u00a0=\u00a0saddr;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0data4.daddr\u00a0=\u00a0daddr;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0data4.dport\u00a0=\u00a0dport;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0data4.sport\u00a0=\u00a0sport;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0data4.state\u00a0=\u00a0state;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0data4.tcpflags\u00a0=\u00a0tcpflags;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0data4.stack_id\u00a0=\u00a0stack_traces.get_stackid(ctx,\u00a00);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ipv4_events.perf_submit(ctx,\u00a0&amp;data4,\u00a0sizeof(data4));\r\n\r\n\u00a0\u00a0\u00a0\u00a0}\r\n\r\n\u00a0\u00a0\u00a0\u00a0return\u00a00;\r\n}\r\n\r\nint\u00a0trace_tcp_send_active_reset(struct\u00a0pt_regs\u00a0*ctx,\u00a0struct\u00a0sock\u00a0*sk,\u00a0unsigned\u00a0int\u00a0priority)\r\n{\r\n\u00a0\u00a0\u00a0\u00a0u32\u00a0pid\u00a0=\u00a0bpf_get_current_pid_tgid()\u00a0&gt;&gt;\u00a032;\r\n\u00a0\u00a0\u00a0\u00a0u32\u00a0saddr\u00a0=\u00a00,\u00a0daddr\u00a0=\u00a00;\r\n\u00a0\u00a0\u00a0\u00a0u16\u00a0family\u00a0=\u00a0AF_INET;\r\n\u00a0\u00a0\u00a0\u00a0u16\u00a0sport\u00a0=\u00a00,\u00a0dport\u00a0=\u00a00;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\/\/\u00a0sport\u00a0is\u00a0not\u00a0right\r\n\u00a0\u00a0\u00a0\u00a0sport\u00a0=\u00a0sk-&gt;__sk_common.skc_num;\r\n\u00a0\u00a0\u00a0\u00a0dport\u00a0=\u00a0sk-&gt;__sk_common.skc_dport;\r\n\u00a0\u00a0\u00a0\u00a0dport\u00a0=\u00a0ntohs(dport);\r\n\r\n\u00a0\u00a0\u00a0\u00a0saddr\u00a0=\u00a0sk-&gt;__sk_common.skc_rcv_saddr;\r\n\u00a0\u00a0\u00a0\u00a0daddr\u00a0=\u00a0sk-&gt;__sk_common.skc_daddr;\r\n\r\n\u00a0\u00a0\u00a0\u00a0if\u00a0(family\u00a0==\u00a0AF_INET\u00a0&amp;&amp;\u00a0(saddr\u00a0==\u00a016777343\u00a0&amp;&amp;\u00a0daddr\u00a0==\u00a016777343))\u00a0{\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0struct\u00a0active_data_t\u00a0data4\u00a0=\u00a0{};\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0data4.pid\u00a0=\u00a0pid;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0data4.saddr\u00a0=\u00a0saddr;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0data4.daddr\u00a0=\u00a0daddr;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0data4.dport\u00a0=\u00a0dport;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0data4.sport\u00a0=\u00a0sport;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0data4.stack_id\u00a0=\u00a0stack_traces.get_stackid(ctx,\u00a00);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0active_events.perf_submit(ctx,\u00a0&amp;data4,\u00a0sizeof(data4));\r\n\u00a0\u00a0\u00a0\u00a0}\r\n\r\n\u00a0\u00a0\u00a0\u00a0return\u00a00;\r\n}\r\n\"\"\"<\/span>\r\n\r\n<span style=\"color: #c678dd; line-height: 26px;\">if<\/span>\u00a0debug\u00a0<span style=\"color: #c678dd; line-height: 26px;\">or<\/span>\u00a0args.ebpf:\r\n\u00a0\u00a0\u00a0\u00a0print(bpf_text)\r\n\u00a0\u00a0\u00a0\u00a0<span style=\"color: #c678dd; line-height: 26px;\">if<\/span>\u00a0args.ebpf:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0exit()\r\n\r\n<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0event\u00a0data<\/span>\r\n<span style=\"line-height: 26px;\"><span style=\"color: #c678dd; line-height: 26px;\">class<\/span>\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">Data_ipv4<\/span><span style=\"line-height: 26px;\">(ct.Structure)<\/span>:<\/span>\r\n\u00a0\u00a0\u00a0\u00a0_fields_\u00a0=\u00a0[\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0(<span style=\"color: #98c379; line-height: 26px;\">\"pid\"<\/span>,\u00a0ct.c_uint),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0(<span style=\"color: #98c379; line-height: 26px;\">\"is_sknull\"<\/span>,\u00a0ct.c_ulonglong),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0(<span style=\"color: #98c379; line-height: 26px;\">\"saddr\"<\/span>,\u00a0ct.c_uint),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0(<span style=\"color: #98c379; line-height: 26px;\">\"daddr\"<\/span>,\u00a0ct.c_uint),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0(<span style=\"color: #98c379; line-height: 26px;\">\"sport\"<\/span>,\u00a0ct.c_ushort),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0(<span style=\"color: #98c379; line-height: 26px;\">\"dport\"<\/span>,\u00a0ct.c_ushort),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0(<span style=\"color: #98c379; line-height: 26px;\">\"state\"<\/span>,\u00a0ct.c_ubyte),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0(<span style=\"color: #98c379; line-height: 26px;\">\"tcpflags\"<\/span>,\u00a0ct.c_ubyte),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0(<span style=\"color: #98c379; line-height: 26px;\">\"stack_id\"<\/span>,\u00a0ct.c_ulong)\r\n\u00a0\u00a0\u00a0\u00a0]\r\n\r\n<span style=\"line-height: 26px;\"><span style=\"color: #c678dd; line-height: 26px;\">class<\/span>\u00a0<span style=\"color: #e6c07b; line-height: 26px;\">Data_active<\/span><span style=\"line-height: 26px;\">(ct.Structure)<\/span>:<\/span>\r\n\u00a0\u00a0\u00a0\u00a0_fields_\u00a0=\u00a0[\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0(<span style=\"color: #98c379; line-height: 26px;\">\"pid\"<\/span>,\u00a0ct.c_uint),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0(<span style=\"color: #98c379; line-height: 26px;\">\"saddr\"<\/span>,\u00a0ct.c_uint),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0(<span style=\"color: #98c379; line-height: 26px;\">\"daddr\"<\/span>,\u00a0ct.c_uint),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0(<span style=\"color: #98c379; line-height: 26px;\">\"sport\"<\/span>,\u00a0ct.c_ushort),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0(<span style=\"color: #98c379; line-height: 26px;\">\"dport\"<\/span>,\u00a0ct.c_ushort),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0(<span style=\"color: #98c379; line-height: 26px;\">\"stack_id\"<\/span>,\u00a0ct.c_ulong)\r\n\u00a0\u00a0\u00a0\u00a0]\r\n\r\n<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0process\u00a0event<\/span>\r\n<span style=\"line-height: 26px;\"><span style=\"color: #c678dd; line-height: 26px;\">def<\/span>\u00a0<span style=\"color: #61aeee; line-height: 26px;\">print_ipv4_event<\/span><span style=\"line-height: 26px;\">(cpu,\u00a0data,\u00a0size)<\/span>:<\/span>\r\n\u00a0\u00a0\u00a0\u00a0event\u00a0=\u00a0ct.cast(data,\u00a0ct.POINTER(Data_ipv4)).contents\r\n\u00a0\u00a0\u00a0\u00a0<span style=\"color: #c678dd; line-height: 26px;\">if<\/span>\u00a0event.is_sknull\u00a0<span style=\"color: #c678dd; line-height: 26px;\">is<\/span>\u00a0<span style=\"color: #d19a66; line-height: 26px;\">1<\/span>:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0print(<span style=\"color: #98c379; line-height: 26px;\">\"%-8s\u00a0%-7d\u00a0%-20s\u00a0&gt;\u00a0%-20s\u00a0%s\u00a0(%s)\"<\/span>\u00a0%\u00a0(\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0strftime(<span style=\"color: #98c379; line-height: 26px;\">\"%H:%M:%S\"<\/span>),\u00a0event.pid,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"%s:%d\"<\/span>\u00a0%\u00a0(inet_ntop(AF_INET,\u00a0pack(<span style=\"color: #98c379; line-height: 26px;\">'I'<\/span>,\u00a0event.saddr)),\u00a0event.sport),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"%s:%s\"<\/span>\u00a0%\u00a0(inet_ntop(AF_INET,\u00a0pack(<span style=\"color: #98c379; line-height: 26px;\">'I'<\/span>,\u00a0event.daddr)),\u00a0event.dport),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"sk-is-null\"<\/span>,\u00a0tcp.flags2str(event.tcpflags)))\r\n\u00a0\u00a0\u00a0\u00a0<span style=\"color: #c678dd; line-height: 26px;\">else<\/span>:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0print(<span style=\"color: #98c379; line-height: 26px;\">\"%-8s\u00a0%-7d\u00a0%-20s\u00a0&gt;\u00a0%-20s\u00a0%s\u00a0(%s)\"<\/span>\u00a0%\u00a0(\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0strftime(<span style=\"color: #98c379; line-height: 26px;\">\"%H:%M:%S\"<\/span>),\u00a0event.pid,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"%s:%d\"<\/span>\u00a0%\u00a0(inet_ntop(AF_INET,\u00a0pack(<span style=\"color: #98c379; line-height: 26px;\">'I'<\/span>,\u00a0event.saddr)),\u00a0event.sport),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"%s:%s\"<\/span>\u00a0%\u00a0(inet_ntop(AF_INET,\u00a0pack(<span style=\"color: #98c379; line-height: 26px;\">'I'<\/span>,\u00a0event.daddr)),\u00a0event.dport),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0tcp.tcpstate[event.state],\u00a0tcp.flags2str(event.tcpflags)))\r\n\u00a0\u00a0\u00a0\u00a0<span style=\"color: #c678dd; line-height: 26px;\">for<\/span>\u00a0addr\u00a0<span style=\"color: #c678dd; line-height: 26px;\">in<\/span>\u00a0stack_traces.walk(event.stack_id):\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0sym\u00a0=\u00a0b.ksym(addr,\u00a0show_offset=<span style=\"color: #56b6c2; line-height: 26px;\">True<\/span>)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0print(<span style=\"color: #98c379; line-height: 26px;\">\"\\t%s\"<\/span>\u00a0%\u00a0sym)\r\n\u00a0\u00a0\u00a0\u00a0print(<span style=\"color: #98c379; line-height: 26px;\">\"\"<\/span>)\r\n\r\n<span style=\"line-height: 26px;\"><span style=\"color: #c678dd; line-height: 26px;\">def<\/span>\u00a0<span style=\"color: #61aeee; line-height: 26px;\">print_active_event<\/span><span style=\"line-height: 26px;\">(cpu,\u00a0data,\u00a0size)<\/span>:<\/span>\r\n\u00a0\u00a0\u00a0\u00a0event\u00a0=\u00a0ct.cast(data,\u00a0ct.POINTER(Data_active)).contents\r\n\u00a0\u00a0\u00a0\u00a0print(<span style=\"color: #98c379; line-height: 26px;\">\"%-8s\u00a0%-7d\u00a0%-20s\u00a0&gt;\u00a0%-20s\"<\/span>\u00a0%\u00a0(\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0strftime(<span style=\"color: #98c379; line-height: 26px;\">\"%H:%M:%S\"<\/span>),\u00a0event.pid,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"%s:%d\"<\/span>\u00a0%\u00a0(inet_ntop(AF_INET,\u00a0pack(<span style=\"color: #98c379; line-height: 26px;\">'I'<\/span>,\u00a0event.saddr)),\u00a0event.sport),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"%s:%d\"<\/span>\u00a0%\u00a0(inet_ntop(AF_INET,\u00a0pack(<span style=\"color: #98c379; line-height: 26px;\">'I'<\/span>,\u00a0event.daddr)),\u00a0event.dport)))\r\n\r\n\u00a0\u00a0\u00a0\u00a0<span style=\"color: #c678dd; line-height: 26px;\">for<\/span>\u00a0addr\u00a0<span style=\"color: #c678dd; line-height: 26px;\">in<\/span>\u00a0stack_traces.walk(event.stack_id):\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0sym\u00a0=\u00a0b.ksym(addr,\u00a0show_offset=<span style=\"color: #56b6c2; line-height: 26px;\">True<\/span>)\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0print(<span style=\"color: #98c379; line-height: 26px;\">\"\\t%s\"<\/span>\u00a0%\u00a0sym)\r\n\u00a0\u00a0\u00a0\u00a0print(<span style=\"color: #98c379; line-height: 26px;\">\"\"<\/span>)\r\n\r\n<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0initialize\u00a0BPF<\/span>\r\nb\u00a0=\u00a0BPF(text=bpf_text)\r\n<span style=\"color: #c678dd; line-height: 26px;\">if<\/span>\u00a0b.get_kprobe_functions(<span style=\"color: #98c379; line-height: 26px;\">b\"tcp_v4_send_reset\"<\/span>):\r\n\u00a0\u00a0\u00a0\u00a0b.attach_kprobe(event=<span style=\"color: #98c379; line-height: 26px;\">\"tcp_v4_send_reset\"<\/span>,\u00a0fn_name=<span style=\"color: #98c379; line-height: 26px;\">\"trace_tcp_v4_send_reset\"<\/span>)\r\n<span style=\"color: #c678dd; line-height: 26px;\">else<\/span>:\r\n\u00a0\u00a0\u00a0\u00a0print(<span style=\"color: #98c379; line-height: 26px;\">\"ERROR:\u00a0tcp_drop()\u00a0kernel\u00a0function\u00a0not\u00a0found\u00a0or\u00a0traceable.\u00a0\"<\/span>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"Older\u00a0kernel\u00a0versions\u00a0not\u00a0supported.\"<\/span>)\r\n\u00a0\u00a0\u00a0\u00a0exit()\r\n\r\n<span style=\"color: #c678dd; line-height: 26px;\">if<\/span>\u00a0b.get_kprobe_functions(<span style=\"color: #98c379; line-height: 26px;\">b\"tcp_send_active_reset\"<\/span>):\r\n\u00a0\u00a0\u00a0\u00a0b.attach_kprobe(event=<span style=\"color: #98c379; line-height: 26px;\">\"tcp_send_active_reset\"<\/span>,\u00a0fn_name=<span style=\"color: #98c379; line-height: 26px;\">\"trace_tcp_send_active_reset\"<\/span>)\r\n<span style=\"color: #c678dd; line-height: 26px;\">else<\/span>:\r\n\u00a0\u00a0\u00a0\u00a0print(<span style=\"color: #98c379; line-height: 26px;\">\"ERROR:\u00a0tcp_v4_send_reset()\u00a0kernel\u00a0function\"<\/span>)\r\n\u00a0\u00a0\u00a0\u00a0exit()\r\n\r\nstack_traces\u00a0=\u00a0b.get_table(<span style=\"color: #98c379; line-height: 26px;\">\"stack_traces\"<\/span>)\r\n\r\n<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0header<\/span>\r\nprint(<span style=\"color: #98c379; line-height: 26px;\">\"%-8s\u00a0%-6s\u00a0%-2s\u00a0%-20s\u00a0&gt;\u00a0%-20s\u00a0%s\u00a0(%s)\"<\/span>\u00a0%\u00a0(<span style=\"color: #98c379; line-height: 26px;\">\"TIME\"<\/span>,\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"PID\"<\/span>,\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"IP\"<\/span>,\r\n\u00a0\u00a0\u00a0\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"SADDR:SPORT\"<\/span>,\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"DADDR:DPORT\"<\/span>,\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"STATE\"<\/span>,\u00a0<span style=\"color: #98c379; line-height: 26px;\">\"FLAGS\"<\/span>))\r\n\r\n<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#\u00a0read\u00a0events<\/span>\r\nb[<span style=\"color: #98c379; line-height: 26px;\">\"ipv4_events\"<\/span>].open_perf_buffer(print_ipv4_event)\r\n<span style=\"color: #5c6370; font-style: italic; line-height: 26px;\">#b[\"active_events\"].open_perf_buffer(print_active_event)<\/span>\r\n<span style=\"color: #c678dd; line-height: 26px;\">while<\/span>\u00a0<span style=\"color: #d19a66; line-height: 26px;\">1<\/span>:\r\n\u00a0\u00a0\u00a0\u00a0<span style=\"color: #c678dd; line-height: 26px;\">try<\/span>:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0b.perf_buffer_poll()\r\n\u00a0\u00a0\u00a0\u00a0<span style=\"color: #c678dd; line-height: 26px;\">except<\/span>\u00a0KeyboardInterrupt:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0exit()\r\n<\/code><\/pre>\n<\/section>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<section class=\"mp_profile_iframe_wrp\"><\/section>\n<p style=\"text-align: center;\"><img class=\"rich_pages wxw-img\" data-galleryid=\"\" data-imgfileid=\"502296367\" data-ratio=\"0.3\" data-src=\"https:\/\/mmbiz.qpic.cn\/sz_mmbiz_gif\/j3gficicyOvasOHYuGEic5USJwXGgWfxiaIXz2uxcnbFsTuYvRdoias1ajkEa7Qd81r31CJCMQ8OK6YfMYjw2OXz3EA\/640?wx_fmt=gif\" data-type=\"gif\" data-w=\"680\" \/><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u8005\uff1akernelxing TCP\u7684\u7ecf\u5178\u5f02\u5e38\u95ee\u9898\u65e0\u975e\u5c31\u662f\u4e22\u5305\u548c\u8fde\u63a5\u4e2d\u65ad\uff0c\u5728\u8fd9\u91cc\u6211\u6253\u7b97\u4e0e\u5404\u4f4d\u804a\u4e00\u804aTCP\u7684RST [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/yaofeng.wang\/index.php\/wp-json\/wp\/v2\/posts\/15"}],"collection":[{"href":"https:\/\/yaofeng.wang\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yaofeng.wang\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yaofeng.wang\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yaofeng.wang\/index.php\/wp-json\/wp\/v2\/comments?post=15"}],"version-history":[{"count":0,"href":"https:\/\/yaofeng.wang\/index.php\/wp-json\/wp\/v2\/posts\/15\/revisions"}],"wp:attachment":[{"href":"https:\/\/yaofeng.wang\/index.php\/wp-json\/wp\/v2\/media?parent=15"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yaofeng.wang\/index.php\/wp-json\/wp\/v2\/categories?post=15"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yaofeng.wang\/index.php\/wp-json\/wp\/v2\/tags?post=15"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}