envoyproxy/envoy

UDP proxying should track and decrement TTL

开放

#20,379 创建于 2022年3月16日

 (0 条评论) (0 个反应) (0 位负责人)C++ (5,373 个派生)batch import
area/udphelp wanted

仓库指标

星标
 (27,997 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

When UDP proxying from A-B it's really unfortunate when bad or misconfigured hardware ends up routing your packets in a loop. Decrementing TTL means you don't end up with that loop being infinite and destroying your CPU.

useful kernel options:

setsockopt(fd, IPPROTO_IP, IP_RECVTTL, &get_ttl, sizeof(get_ttl));

setsockopt(fd, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &get_ttl, sizeof(get_ttl));

kMinCmsgSpaceForRead += CMSG_SPACE(sizeof(int)) // TTL

if ((cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_TTL) || (cmsg->cmsg_level == IPPROTO_IPV6 && cmsg->cmsg_type == IPV6_HOPLIMIT)) { ttl = reinterpret_cast<int*>(CMSG_DATA(cmsg)))); }

贡献者指南