[置顶] 全是好东西

摘要: Linux 网络栈接收数据(RX):原理及内核实现(2022) : https://arthurchiao.art/blog/linux-net-stack-implementation-rx-zh/ 从 “TCP 速度打不上去” 聊到 “交换机 QoS” https://mp.weixin.qq. 阅读全文
posted @ 2024-05-15 11:34 toong 阅读(55) 评论(0) 推荐(0) 编辑

[置顶] 内容精选

摘要: strongswan/ipsec [ipsec][strongswan]strongswan源码分析--(零)引子 [ipsec][strongswan] strongswan源码分析--(〇)总体架构图 [ipsec][strongswan] strongswan源码分析--(一)SA整体分析 [ 阅读全文
posted @ 2020-05-25 21:02 toong 阅读(4936) 评论(1) 推荐(0) 编辑

tmux调整窗口大小

摘要: 方法一,使用快捷键,但是ssh调整之后有可能因为键被占用等原因,不好使 调整窗格大小: 向上/向下调整:按 Ctrl+b 然后按 Ctrl+上箭头 或 Ctrl+下箭头 可以增加或减少当前窗格的高度。 向左/向右调整:按 Ctrl+b 然后按 Ctrl+左箭头 或 Ctrl+右箭头 可以增加或减少当 阅读全文
posted @ 2025-03-05 14:05 toong 阅读(6) 评论(0) 推荐(0) 编辑

k8s查看镜像内容的方法

摘要: 查看 使用ctr工具在namespace下查看镜像名称 ctr ns list ctr -n k8s.io images ls |grep ingress-nginx 挂载 ctr -n k8s.io images mount registry.k8s.io/ingress-nginx/contro 阅读全文
posted @ 2025-02-27 15:36 toong 阅读(2) 评论(0) 推荐(0) 编辑

k8s安装ingress-nginx/tengine-ingress

摘要: 背景 要先会各种概念,node,pods,service 术语 ingress:指定是k8s的用户业务语境,描述用户的业务流量经过的一个转发环节。是用户视角。 术语 ingress-controller:指定是k8s的实现架构语境,指k8s作为一个基础设施,他的一个组件的名称。 文档 从0到1:k8 阅读全文
posted @ 2025-02-26 19:05 toong 阅读(6) 评论(0) 推荐(0) 编辑

使用iptables把linux配置成nat网关的方法

摘要: 1 开启端口转发 sysctl -w net.ipv4.ip_forward=1 2 允许防火墙端口转发 iptables -A FORWARD -i enp0s3 -o enp0s8 -j ACCEPT iptables -A FORWARD -i enp0s8 -o enp0s3 -j ACCE 阅读全文
posted @ 2025-02-21 14:40 toong 阅读(2) 评论(0) 推荐(0) 编辑

ubuntu网络的配置方法

摘要: 一直用CentOS和archlinux, 主要的配置方式是:network.service,NetworkManger,netctl。 但ubuntu是全新的配置方式,netplan 参考:https://linux.fasionchan.com/zh_CN/latest/administratio 阅读全文
posted @ 2025-02-21 13:27 toong 阅读(6) 评论(0) 推荐(0) 编辑

k8s集群从0到1安装部署

摘要: 文档 两个官方文档, 一个是官方教程:https://kubernetes.io/docs/tutorials/ 另一个是生产环境安装手册:https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/ 教程里建议用学习环 阅读全文
posted @ 2025-02-18 16:15 toong 阅读(5) 评论(0) 推荐(0) 编辑

docker查看镜像内容

摘要: 使用命令: docker run -it --entrypoint sh 251ce211cf31 如图示: 阅读全文
posted @ 2025-02-14 17:53 toong 阅读(1) 评论(0) 推荐(0) 编辑

lb与ingress与service mesh与云原生与k8s

摘要: 总之你可以把服务网格作为 OSI 模型中的会话层。也就是L5。 我们将在云原生应用程序中考虑弹性的两个主要方面:为失败设计和优雅降级。 知道应用程序可能失败的每种方式是不可能的。假设任何事情都可能并且可能会失败,这是一种云原生应用程序的模式。 云原生是关于不需要人类做出决定的自治系统。它仍然使用自动 阅读全文
posted @ 2025-02-10 16:59 toong 阅读(9) 评论(0) 推荐(0) 编辑

linux vrf使用

摘要: 定义 vrf是一个网口设备,绑定了一张路由表。 然后“奴役”另一个网口设备。 A VRF device is created with an associated route table. Network interfaces are then enslaved to a VRF device 参考 阅读全文
posted @ 2025-02-08 17:04 toong 阅读(16) 评论(0) 推荐(0) 编辑

linux 169.254的路由是从哪来的

摘要: CentOS 8 查看路由表,能看见在每个物理口上,有条169.254的路由。 169.254.0.0/16 dev enp0s8 scope link metric 1006 可以看见是network.servcie这个服务加的 使用脚本:/etc/sysconfig/network-script 阅读全文
posted @ 2025-02-06 14:33 toong 阅读(12) 评论(0) 推荐(0) 编辑

linux kernel 学习笔记

摘要: 主要是这书:《linux内核设计与实现》还有几本别的 自下而上子系统: 系统调用 | IPC 内存管理 | 虚拟文件系统 | 网络协议栈 进程调度 | 中断调度 | 同步/timer ## 指令/汇编 | ## 设备驱动 boot: 0x7C00/保护模式 > 分段/分页,物理地址/逻辑地址/虚拟地 阅读全文
posted @ 2025-01-27 18:13 toong 阅读(9) 评论(0) 推荐(0) 编辑

nginx defer_accept 分析

摘要: netstat发现很多TCPDeferAcceptDrop的统计 nignx的listen配置里设置了defered选项。 查看代码发现是设置了listen socket的TCP_DEFER_ACCEPT的选项。 /nginx/src/core/ngx_connection.c::ngx_confi 阅读全文
posted @ 2025-01-23 18:55 toong 阅读(4) 评论(0) 推荐(0) 编辑

TCP状态机

摘要: 留张图备查。随记随忘随忘随记 阅读全文
posted @ 2025-01-23 15:28 toong 阅读(1) 评论(0) 推荐(0) 编辑

linux kernel端口耗尽优化

摘要: bind()源ip之后,分配端口会有端口耗尽问题。 linux kernel 如何bind() VRF端口上的源IP perf看到如下图: 在bind的时候因为还没有目的ip和port,所以可用端口会很少。 socketopt IP_BIND_ADDRESS_NO_PORT 会把分配端口延后至con 阅读全文
posted @ 2025-01-21 17:28 toong 阅读(11) 评论(0) 推荐(0) 编辑

linux kernel tcp丢包分析

摘要: 现象 使用netstat -s 能看见如下丢包统计 1352910 failed connection attempts 1352910 resets received for embryonic SYN_RECV sockets 查看netstat的代码 https://sourceforge.n 阅读全文
posted @ 2025-01-16 19:12 toong 阅读(19) 评论(0) 推荐(0) 编辑

syslog转存nginx日志的简单配法

摘要: 命令 单独启动一个独立的rsyslog进程 rsyslogd -i /root/tong1/rsyslogd/pid -f /root/tong1/rsyslogd/rsyslogd.conf 配置文件 module(load="imuxsock") input(type="imuxsock" So 阅读全文
posted @ 2025-01-14 17:51 toong 阅读(10) 评论(0) 推荐(0) 编辑

linux kernel 如何bind() VRF端口上的源IP

摘要: 前文 linux kernel bind()时发生了什么 讲了bind()的实现机制。 今天,我用bind()绑定一个VRF上的源IP,发生如下报错: bind(11.1.1.64) failed (99: Cannot assign requested address) 经过分析kernel代码, 阅读全文
posted @ 2025-01-10 14:20 toong 阅读(11) 评论(0) 推荐(0) 编辑

emacs cscope linux kernel 找不到符号的一种原因

摘要: 当阅读linux内核代码时,我一般使用emacs + cscope, 但是今天发生了找不到符合的问题。 cscope can not find symbol function sock_setbindtodevice 找了半天原因,重建了很多次索引库,都不行。但是egrep就可以正常找到。 最后发现 阅读全文
posted @ 2025-01-10 12:20 toong 阅读(8) 评论(0) 推荐(0) 编辑

linux内核快速找到系统调用的入口

摘要: 以函数 setsockopt 为例。 查找关键字SYSCALL_DEFINE,再查找函数名setsockopt egrep -R "SYSCALL_DEFINE.\(setsockopt" ./ 就在文件 ./net/socket.c 的 2097 行。 阅读全文
posted @ 2025-01-10 11:54 toong 阅读(10) 评论(0) 推荐(0) 编辑

linux kernel bind()时发生了什么

摘要: 配置 实验一下,我有两个口lo和enp0s3, 两个地址,如下所示。 真实物理口测试 访问同子网的10.0.2.2 如果没有地址,返回:Cannot assign requested address,说明bind失败了。 lo口测试 访问loopback地址127.0.0.1 如果没有地址,返回:C 阅读全文
posted @ 2025-01-09 18:14 toong 阅读(15) 评论(0) 推荐(0) 编辑

[转]使用nginx的proxy_bind选项配置透明的反向代理

摘要: 开了transparent之后,nginx里会走下面的代码: 从而可以bind一个本机不存在的地址。 下文的试验中有三个关键步骤: 1 setsockopt(IP_TRANSPARENT) 作用1: 使socket可以bind本地没有的IP 作用2: 使socket可以接受本地没用IP的报文。 2 阅读全文
posted @ 2025-01-06 14:48 toong 阅读(126) 评论(0) 推荐(0) 编辑

tcpdump过滤非proxy_protocol报文的方法

摘要: 过滤非proxy protocol v2的报文 tcpdump -r 1.pcap -nn "(tcp[tcpflags] & (tcp-push) != 0) and (tcp[20:4] & 0xffffffff != 0x0d0a0d0a) and (tcp[24:4] & 0xfffffff 阅读全文
posted @ 2025-01-02 12:02 toong 阅读(3) 评论(0) 推荐(0) 编辑

特别好看的流量监控工具dstat

摘要: 总也记不住叫啥,忘了很多次,备忘一下,叫: dstat rpm: dstat-0.7.2-12.el7.noarch 阅读全文
posted @ 2024-12-25 17:30 toong 阅读(7) 评论(0) 推荐(0) 编辑

nginx的fastopen是怎么回事

摘要: 介绍 fastopen就是tcp 0rtt发包的方法,在syn里就带上data数据。 见:https://datatracker.ietf.org/doc/html/rfc7413 ngnix nginx有这个选项,如下这样配 配完之后会走一个setsockopt的代码 改option TCP_FA 阅读全文
posted @ 2024-12-16 18:58 toong 阅读(29) 评论(0) 推荐(0) 编辑

nginx reload时对http keepalive连接的处理

摘要: nginx各协议的reload行为 协议 行为 http keepalive server fin http2 server fin tcp 保持shutdown不断 udp 保持shutdown不断 grpc 基于HTTP2与其保持一致,但是没实测 现象 nginx 在reload时,会对http 阅读全文
posted @ 2024-12-13 18:24 toong 阅读(64) 评论(0) 推荐(0) 编辑

socket() failed (24: Too many open files)

摘要: 这个错误因为超出了ulimit nofile 当前bash的这样修改: [root@A06 ~]# ulimit -n 200 [root@A06 ~]# ulimit -n 2000000 [root@A06 ~]# ulimit -n 2000000 systemd 启动的程序这样修改 [roo 阅读全文
posted @ 2024-12-04 15:24 toong 阅读(75) 评论(0) 推荐(1) 编辑

用awk做聚合sum统计

摘要: 示例数据: # cat test.txt name1 1 name2 2 name3 3 name1 4 name2 5 name3 6 name1 7 name2 8 name3 9 脚本 cat test.txt |awk '{bytes[1]+=2} END { for (key in 阅读全文
posted @ 2024-11-07 15:02 toong 阅读(7) 评论(0) 推荐(0) 编辑

systemd oneshot服务配置例子

摘要: 服务这样写: [Unit] Description=nginx - high performance web server After=network-online.target remote-fs.target nss-lookup.target Wants=network-online.targ 阅读全文
posted @ 2024-10-25 14:23 toong 阅读(70) 评论(0) 推荐(0) 编辑

bash列编辑column和colrm

摘要: 除了sed和awk,还可以用column 和colrm 两个命令进行列裁剪。 如下: cat /proc/interrupts |column |colrm 20 1400 cat /proc/interrupts |colrm 20 1400 |less 阅读全文
posted @ 2024-10-09 15:36 toong 阅读(8) 评论(0) 推荐(0) 编辑

讨论jiffies回转的time_after比较函数

摘要: 本文讨论jiffies回转的比较函数: #define time_after(a, b) \ ((long)(b) - (long)(a) < 0)写了个例子如下: #include <stdio.h> #include <stdint.h> #define time_after(a, b) \ ( 阅读全文
posted @ 2024-10-08 15:17 toong 阅读(6) 评论(0) 推荐(0) 编辑

发送proxy protocol报文

摘要: V1 echo -e "PROXY TCP4 192.0.2.1 203.0.113.1 12345 80\r\nGET / HTTP/1.0\r\n\r\n" |nc 10.0.2.15 80 0000 00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 阅读全文
posted @ 2024-09-27 14:46 toong 阅读(24) 评论(0) 推荐(0) 编辑

一句话python启动httpserver

摘要: 使用 Python 3 在终端或命令提示符中,导航到你想要提供文件服务的目录,然后运行以下命令: python -m http.server 8000sudo python3 -m http.server --bind 127.0.0.1 100 使用 Python 2 如果你使用的是 Python 阅读全文
posted @ 2024-09-27 12:09 toong 阅读(54) 评论(0) 推荐(0) 编辑

[转发][内核]内核浮点数运算实现

摘要: 简洁,清晰又硬核 抽丝剥茧 Linux 浮点运算的原理 https://linux.cn/article-13474-1.html 阅读全文
posted @ 2024-09-10 20:28 toong 阅读(8) 评论(0) 推荐(0) 编辑

rpm包解压

摘要: rpm包解压方法如下,生成一个目录树在当前目录。 rpm2cpio xxx.rpm | cpio -div 阅读全文
posted @ 2024-09-10 19:30 toong 阅读(30) 评论(0) 推荐(0) 编辑

ros

摘要: 古月居 https://book.guyuehome.com/ROS2/4.%E8%B5%84%E6%BA%90%E6%B1%87%E6%80%BB/4.%E8%B5%84%E6%BA%90%E6%B1%87%E6%80%BB/ 阅读全文
posted @ 2024-09-03 17:18 toong 阅读(76) 评论(0) 推荐(0) 编辑

用nping发裸包

摘要: 以前都自己写程序,或者用libpcap或者用dpdk很麻烦,现在发现有nping工具了,很方便。 nping工具是nmap包里带的。 示例:nping -e ens8f1 --send-eth --dest-mac 10:70:fd:2e:3f:39 --tcp 9.9.9.9 注意:口ens8f1 阅读全文
posted @ 2024-09-03 11:24 toong 阅读(33) 评论(0) 推荐(0) 编辑

条件运算符?:省略表达式2

摘要: dpvs中的两行代码 https://github.com/iqiyi/dpvs/blob/master/src/sa_pool.c#L209 这是GUN C支持的语法,不是标准C。 见:https://zh.wikipedia.org/wiki/%E6%9D%A1%E4%BB%B6%E8%BF%9 阅读全文
posted @ 2024-06-07 15:17 toong 阅读(16) 评论(0) 推荐(0) 编辑

systemtap打印函数调用和参数取值

摘要: 打印某文件内所有参数和入参 #!/usr/bin/stap probe process("/usr/bin/jmy_app").function("*@my_app.c").call { printf("Function %s called with parameters : %s\n", ppfu 阅读全文
posted @ 2024-06-07 13:41 toong 阅读(187) 评论(0) 推荐(0) 编辑

用mpstat查看中断

摘要: 每次 cat /proc/interrupts 行特别长,列特别多不方便查看。 可以用mpstat工具查看 先查每个CPU上的中断总量 mpstat -I SUM -P ALL 1 1 再查 指定CPU的所有中断 mpstat -I ALL -P 10 1 1 阅读全文
posted @ 2024-05-30 17:21 toong 阅读(29) 评论(0) 推荐(0) 编辑

统计

点击右上角即可分享
微信分享提示