自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(53)
  • 收藏
  • 关注

原创 TCP cookie代码走读

TCP syncookie

2022-03-06 18:42:24 3313 1

原创 Generic XDP Hook

上一篇文章讲过bpf_prog_run_xdp是XDP 程序的最终调用函数,想要跟踪Generic XDP的代码可以从该函数入手。很显然你不应该从driver/,而是已改在net/目录下检索。jensonqiu@Bing$ grep -rn "bpf_prog_run_xdp" netnet/core/dev.c:4349: act = bpf_prog_run_xdp(xdp_prog, xdp);稍微过滤一下真相就呼之欲出了,函数的调用关系如下:bpf_prog_run_xdpnet

2022-02-23 15:29:32 579

原创 xdp 程序如何挂载

xdp 功能程序挂载分析。

2022-02-22 21:22:18 893

原创 Native xdp hook 点

看到xdp功能的时候,你可能已经猜到了xdp一定有在内核中有hook,你也可能猜到了xdp的hook应该在程序中,但是你可能不知道xdp hook 具体在网卡驱动的那个流程中,今天走读了一遍xdp的代码逻辑,简单记录内容如下。bpf_prog_run_xdpbpf_prog_run_xdp函数是xdp的框架函数,你注册的xdp程序将会在这个函数中别逐一调用。xdp的hook是在内核驱动中 ? 你可以过滤一下这个函数,大概应该和我的差不多:jensonqiu@Bing$ grep

2022-02-22 18:15:38 1690

原创 BPF_PROG_TYPE_SOCKET_FILTER 功能实现

BPF_PROG_TYPE_SOCKET_FILTER,从宏字面意思比较容易想到实现的是socket filter功能,它区别于sockops和tracepoint等功能,需要额外借助setsockopt能力将功能函数和socket绑定,功能才能真正生效。如何定该类型在内核态功能函数中定义SEC("socketxxxx"),则会被解析为BPF_PROG_TYPE_SOCKET_FILTER类型功能。比如内核中实现的三个example程序:samples/bpf/sockex1_kern.c -

2022-02-20 14:07:02 1773

原创 ebpf tracepoint 功能分析

1. 查看系统支持的所有tracepointfind /sys/kernel/debug/tracing/events -type d可以查看到当前系统支持的所有tracepoint函数点,大家在利用tracepoint功能的时候最好先看看对应的子系统在那些地方有hook点,评估是否能满足功能。比如说你想内视TCP协议栈,那么你可以先tcp trace 支持那些功能:[root@xxx tcp]# ls /sys/kernel/debug/tracing/events/tcpenable t..

2022-02-19 22:08:02 1605

原创 ebpf xdp 挂载点分析

1. 查看支持xdp功能的网卡drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c:218: case XDP_SETUP_PROG:drivers/net/ethernet/cavium/thunder/nicvf_main.c:1848: case XDP_SETUP_PROG:drivers/net/ethernet/intel/i40e/i40e_main.c:11845: case XDP_SETUP_PROG:drivers/net/ethern

2022-02-19 22:00:41 1189

原创 ebpf sockops 代码解读

2032 static inline int tcp_call_bpf(struct sock *sk, int op, u32 nargs, u32 *args)2033 {2034 struct bpf_sock_ops_kern sock_ops;2035 int ret;20362037 memset(&sock_ops, 0, offsetof(struct bpf_sock_ops_kern, temp));2038 .

2022-02-19 18:08:54 1661

原创 ebpf sockops 功能分析

ebpf sockops 实现原理大家肯定好奇为什么通过ebpf sockops可以提取我们想要的数据 ?正常来说实现方式有两种,第一种是关键路径上埋钩子函数;第二种是kprobe的粘贴插入。 ebpf sockops 是通过第一种实现的,在关键路径上埋钩子函数了,所以想要扩展功能难哦,一般在内核版本升级时可以提前规划埋好钩子函数。ebpf sockops 支持那些功能ebpf sockops支持那些功能(关键看在什么路径上埋了钩子函数),看 下面代码吧...

2022-02-18 11:34:39 1630 3

原创 BBR 每秒带宽换算逻辑

/* Scale factor for rate in pkt/uSec unit to avoid truncation in bandwidth* estimation. The rate unit ~= (1500 bytes / 1 usec / 2^24) ~= 715 bps.* This handles bandwidths from 0.06pps (715bps) to 256Mpps (3Tbps) in a u32.* Since the minimum window i...

2022-01-19 15:04:59 316

原创 BBR拥塞控制状态机分析

目录BBR 源码文件的描述四个阶段理想状态图STARTUP进入和退出条件DRAIN进入和退出条件PROBE_BW进入和退出条件PROBE_RTT进入和退出条件PROBE_BW内部状态分析PROBE_UP状态进入和退出PROBE_DOWN状态进入和退出PROBE_USE状态进入和退出后续BBR 源码文件的描述* A BBR flow starts in STARTUP, and ramps up its sending rate quic..

2022-01-19 11:47:55 2644

原创 TCP_NODELAY 和 TCP_CORK

TCP nagle 和 cork机制和代码解读

2021-12-27 12:57:39 1695

原创 SYSCALL_DEFINE5 setsockopt 代码流程

SYSCALL_DEFINE5(setsockopt, int, fd, int, level, int, optname,        char __user *, optval, int, optlen){    int err, fput_needed;    struct socket *sock;    if (optlen < 0)        return -...

2018-12-14 14:47:41 625

原创 tso硬件分片是头部拷贝问题

//skb->date指向了二层头部地址,下面是计算 以太网头 + IP头 大小static inline int skb_transport_offset(const struct sk_buff *skb){ return skb_transport_header(skb) - skb->data;}static int e1000_tso(struct e1000_adapter...

2018-06-28 16:40:20 872

转载 Linux Kernel: Deadlocks and how to avoid them

Linux Kernel: Deadlocks and how to avoid themDeadlock Problem:Scenario 1: Self deadlock - "re-acquire lock"Say there's a thread A, it acquires lock X1 and then before relenquishing the lock, it re-acq...

2018-05-21 16:08:55 449

原创 RFC 793 为什么要发送reset,什么情况下发送reset

A variety of other cases are possible, all of which are accounted for by the following rules for RST generation and processing. Reset Generation As a general rule, reset (RST) must be sent w...

2018-05-19 11:02:45 442

原创 什么时候去发送 update windos报文

/* Clean up the receive buffer for full frames taken by the user, * then send an ACK if necessary.  COPIED is the number of bytes * tcp_recvmsg has given to the user so far, it speeds up the * calcula...

2018-05-18 22:35:01 463

原创 Tcpdump抓包内核代码分析

注册pf_packet协议   .create函数是在PF_PACKET类型socket创建时调用,调用时注册了钩子函数具体看packet_create函数的实现。static const struct net_proto_familypacket_family_ops = {         .family=   PF_PACKET,         .create=  packet_creat...

2018-05-08 20:10:41 2040

转载 Debugging Analysis of Kernel panics and Kernel oopses using System Map

内核问题定位

2017-09-25 11:21:13 624

转载 Linux awk正则表达式简介

awk正则匹配

2017-09-12 11:22:58 592

原创 收包函数调用流程

linux  内核数据报文接收流程[70977.808241]  [] ? tcp_ack+0xd8a/0x1390 [70977.887555]  [] ? tcp_rcv_established+0x18a/0x6a0[70977.978619]  [] ? tpacket_rcv+0x50/0x800[70978.044437]  [] ? tcp_v4_do_rcv+0x1

2017-07-31 09:40:03 715

转载 TCP 指定源端口

TCP 指定源端口

2017-06-20 19:51:04 3152

原创 tcp jprobe 利用问题定位

tcp问题定位jprobe

2017-03-20 13:05:08 419

转载 Kernel Debugging Tricks

Kernel Debugging Tricks

2017-02-28 18:50:04 398

转载 Understanding a Kernel Oops!

Understanding a Kernel Oops!

2017-02-28 18:46:18 282

原创 kretprobe 使用

Kretporbe使用

2017-01-15 11:36:21 1736

原创 centos 7 取消LOG输出限制

Add the following to /etc/rsyslog.conf after '$ModLoad imuxsock' and '$ModLoad imjournal':$IMUXSockRateLimitInterval 0$IMJournalRatelimitInterval 0Set the following in /etc/systemd/journald.co

2017-01-11 14:07:26 1371

原创 内核gdb模块调试

内核模块gdb调试

2016-12-31 13:49:09 744 2

原创 tcp_clean_rtx_queue函数

tcp_clean_rtx_queue函数阅读浅记

2016-12-12 09:26:57 1380

转载 wireshark 关键词

wireshark词义

2016-10-17 11:20:38 562

转载 /proc/kallsyms

T   The symbol is in the text(code) sectionD   The symbol is in the initialized data sectionR   The sysbol is in a read only data sectiont   staticd   staticR   constr   static const

2016-08-04 15:46:12 506

原创 mysql bin 安装

mysql 安装

2016-07-16 08:42:36 416

转载 Controlling which congestion control algorithm is used in Linux

set congestion control algorithm per-socket

2016-07-11 21:11:29 382

转载 C 语言 宏的妙用

C语言宏的妙用。

2016-07-07 18:55:55 457

原创 linx x86 汇编

linux x86 汇编

2016-07-04 11:50:01 742

转载 数据包在用户空间的状态

iptable 状态

2016-06-24 18:46:01 1095

原创 校验和计算

buffer校验和计算

2016-06-21 17:29:59 458

原创 判断一个整数是否是n^m次方类型数据,并比较乘法和除法性能差异

求取a = n^m #include #include #include int testnum(int num, int base){ if (num <= 0 || num < base || num % base != 0) return -1; if(num == base) return 1; num = num/base; return nu

2015-04-27 21:17:22 432

转载 Coping with the TCP TIME-WAIT state on busy Linux servers

Coping with the TCP TIME-WAITstate on busy Linux serversVincent BernatFebruary 24, 2014Also available in FrançaisFiled under NetworkTwitter Google+ 

2015-04-06 09:43:37 810

转载 linux kernel 2.6.35中RFS特性详解

本文链接地址: linux kernel 2.6.35中RFS特性详解前面我介绍过google对内核协议栈的patch,RPS,它主要是为了软中断的负载均衡,这次继续来介绍google 的对RPS的增强path RFS(receive flow steering),RPS是把软中断map到对应cpu,而这个时候还会有另外的性能影响,那就是如果应用程序所在的cpu和软中断处理的cpu不是

2015-03-31 15:20:52 615

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除