Skip to content

Commit

Permalink
Icmp ttl expire to be answered with gw ip
Browse files Browse the repository at this point in the history
For traceroute requests from vm, when ttl expires for them, Agent diag
module should respond with gateway address of network. Currently,
agent is responding with its underlay Ip address. This is modified
by responding with gateway address for traceroute requests.

Change-Id: Iee194c4f46b38f5acc1b7618a7ce770a3cd058a4
Closes-Bug: #1616430
(cherry picked from commit e6883b0)
  • Loading branch information
ravi-bk authored and haripk committed Apr 7, 2017
1 parent 422fc6b commit 3d17545
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/vnsw/agent/diag/diag_pkt_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,30 @@ void DiagPktHandler::SendTimeExceededPacket() {
// Retain the agent-header before ethernet header
uint16_t len = (char *)pkt_info_->eth - (char *)pkt_info_->pkt;

Ip4Address src_ip(0);
VmInterface *vm_itf = dynamic_cast<VmInterface *>
(agent()->interface_table()->FindInterface(GetInterfaceIndex()));
if (vm_itf == NULL) {
src_ip = agent()->router_id();
} else {
if (vm_itf->vn() == NULL) {
return;
}
const VnIpam *ipam = vm_itf->vn()->GetIpam(pkt_info_->ip_saddr.to_v4());
if (ipam == NULL) {
return;
}
src_ip = ipam->default_gw.to_v4();
}

// Form ICMP Packet with EthHdr - IP Header - ICMP Header
len += EthHdr(ptr + len, buf_len - len, agent()->vhost_interface()->mac(),
MacAddress(pkt_info_->eth->ether_shost), ETHERTYPE_IP,
VmInterface::kInvalidVlanId);

uint16_t ip_len = sizeof(iphdr) + 8 + icmp_len;
len += IpHdr(ptr + len, buf_len - len, ip_len,
htonl(agent()->router_id().to_ulong()),
htonl(src_ip.to_ulong()),
htonl(pkt_info_->ip_saddr.to_v4().to_ulong()),
IPPROTO_ICMP, DEFAULT_IP_ID, DEFAULT_IP_TTL);

Expand Down

0 comments on commit 3d17545

Please sign in to comment.