一直在为某些请求在 OVS 中模拟“路由器广告”,因为我构建了一个 ICMPv6 pkt,除了校验和之外所有字段都正确,wireshark 在校验和部分给出错误。
ICMP6 校验和应包括src + dst + icmp_length + next_header
但以下代码计算不正确。我错过了什么吗?感谢帮助家伙。
struct nd_router_advert *ra;
struct ofpbuf *ra_rsp;
struct ovs_16aligned_ip6_hdr *nh;
.
.
.
.
.
ofpbuf_set_l3(ra_rsp, nh);
nh->ip6_vfc = 0x60;
nh->ip6_plen = htons(sizeof(*ra));
nh->ip6_nxt = IPPROTO_ICMPV6;
.
.
ofpbuf_set_l4(ra_rsp, ra);
ra->nd_ra_type = ND_ROUTER_ADVERT;
ra->nd_ra_code = 0;
ra->nd_ra_cksum = htons(0);
ra->nd_ra_curhoplimit = 255;
ra->nd_ra_flags_reserved = 0;
ra->nd_ra_router_lifetime = htons(9000);
ra->nd_ra_reachable = htons(0);
ra->nd_ra_retransmit = htons(0);
packet_set_ipv6(ra_rsp, IPPROTO_ICMPV6, src, dst, 0, 0, 212);
ra->nd_ra_cksum = recalc_csum16(ra->nd_ra_cksum, 0, htons(sizeof(*ra)));
ra->nd_ra_cksum = recalc_csum32(ra->nd_ra_cksum, 0, IPPROTO_ICMPV6);