TGTGInsighttelegram intelligenceLIVE / telegram public index
← Welcome to the Black Parade
Welcome to the Black Parade avatar

TGINSIGHT POST

Post #116

@TheB1ackParade

Welcome to the Black Parade

Views106Post view count
PostedJun 1006/10/2022, 05:48 PM
Post content

Post content

其实不太明白 __be16 是啥意思. 抛开 sparse 不管, 难道它的意思不应该是 "这个字段用已经转成大端序" 吗? 比如 struct sk_buff 的 protocol 是 __be16 类型, 但是在 tc-bpf 里读这个字段, ipv4 的时候值是 8, 这根本不是大端序的 ETH_P_IP 喂! 大端序的 ETH_P_IP 是 0x0800 啊... 在尝试用更地道的方式写 bpf, 使用 __builtin_x 而不是 libc 函数, 使用 __u32 而不是 u32, 使用 bpf_ntohs 而不是 ntohs, 等等, 很细很催眠...