Recent Posts
-
June 29, 2020
Linux查看丢包原因之dropwatch
dropwatchyum install dropwatchdropwatch -l kasdropwatch> startstap --poison-cache -vvv -L 'kernel.trace("*")'stap /usr/share/systemtap/examples/network/dropwatch.stp -c "sleep 100"perf top -e skb:kfree_skb
-
June 29, 2020
Centos 8多网卡时非主网卡路由不通的reverse path filtering(rp_filter)问题
CentOS的虚拟机设置使用了多个网卡,发现只有一个网卡的外部网络通讯是正常的用ping命令测试排查,结合tcpdump抓包排查,发现网络包是可以出去,icmp reply也回到本机了但被本机丢掉了,用dropwatch命令可以但在本机的ip_rcv_finish函数里面被丢包了ping 163.com -I enp0s3ping 163.com -I enp0s8检查路由没有问题, 发现只有 metric值最小的网卡通讯是可以正常的# ip routedefault via 172.31...
-
June 12, 2020
Golang的http反向代理
https比http的特殊,用的connect tunnel的技术。设置dns服务器地址的只有在linux下面才会用golang 的resolver才会有效果,windows下面不使用这个设置。package mainimport ( "context" "flag" "io" "log" "net" "net/http" "net/http/httputil" "strings" "time")var verbose boolvar dnsServer stringvar localIp...
-
June 11, 2020
Linux的抓包socket的过滤bpf指令怎么写
在内核源码的 https://elixir.bootlin.com/linux/latest/source/Documentation/networking/filter.txt 文件列出了怎么在程序里面写bpf代码https://docs.cilium.io/en/latest/bpf/ 对bpf的实现架构也有点说明“tcpdump ether multicast -dd” 这个也可以用tcpdump直接生成指定bfp表达式的code,然后在程序里面使用这个code数组```text...
-
May 14, 2020
Linux系统启动时的getrandom随机数系统调用阻塞问题
4.1x版本的内核,很多人都观察到系统启动时会有个卡顿现象。 比如这篇文章: “快杰云主机 SSH 登录缓慢的排查和解决” http://blog.ucloud.cn/archives/4310这个老版本内核是没有这个现象的,大概是某版本里面引入的吧,就是之前有人报告内核的随机数生成器(cryptographically-secure pseudo-random number generator (CSPRNG) )不够“随机”(entropy熵不够),所以改进的内核在开机初始化阶段,...
-
May 12, 2020
Bash打印有颜色的字符
bash有个针对终端的颜色表的,,调用方法是这样的printf "\e[91minactive\e[0m"printf "\e[92mactive\e[0m"perl里面也有专门的一个库吧。
-
May 12, 2020
Linux用debugfs查看ext4文件创建时间
ls -i filename debugfs -R 'stat <inode-number>' /dev/sdxxxx
-
May 07, 2020
Ccache的编译速度加速
c++的编译真的是太慢了,ccache说是能提高编译速度,安装ccache会在/usr/lib64/ccache目录创建工具的链接[root@localhost]# ls -lh /usr/lib64/ccache/total 0lrwxrwxrwx. 1 root root 16 Apr 9 15:12 c++ -> ../../bin/ccachelrwxrwxrwx. 1 root root 16 Apr 9 15:12 cc -> ../../bin/ccache...
-
April 30, 2020
Linux内核的关机按钮事件和acpid还有systemd的关机按键处理
发现有的虚拟机系统不能接收“正常关机”的菜单命令,就来找一下资料用户按下物理按键,会发送一个ACPI按键信号, 内核里面的acpi驱动这个event.c button.c进行处理的。这个事件看上去netlink和/dev/input/event里面都能收到KEY_POWER按键事件https://elixir.bootlin.com/linux/latest/source/drivers/acpi/event.c#L148https://elixir.bootlin.com/linux/l...
-
April 27, 2020
Linux的flowtable offiload特性加速网络包转发
https://elixir.bootlin.com/linux/latest/source/Documentation/networking/nf_flowtable.rsthttp://blog.ucloud.cn/archives/4541https://www.netfilter.org/projects/nftables/manpage.html