From 903a2fd56bbd3315b69a3e0b5fd936fd3b35b192 Mon Sep 17 00:00:00 2001 From: Saikrishna Arcot Date: Wed, 17 Jan 2024 18:50:22 -0800 Subject: [PATCH] dhcrelay: Don't look up the ifindex for the fallback interface (#17797) Currently, whenever isc-dhcp-relay forwards a packet upstream, internally, it will try to send it on a "fallback" interface. My understanding is that this isn't meant to be a real interface, but instead is basically saying to use Linux's regular routing stack to route the packet appropriately (rather than having isc-dhcp-relay specify specifically which interface to use). The problem is that on systems with a weak CPU, a large number of interfaces, and many upstream servers specified, this can introduce a noticeable delay in packets getting sent. The delay comes from trying to get the ifindex of the fallback interface. In one test case, it got to the point that only 2 packets could be processed per second. Because of this, dhcrelay will easily get backlogged and likely get to a point where packets get dropped in the kernel. Fix this by adding a check saying if we're using the fallback interface, then don't try to get the ifindex of this interface. We're never going to have an interface named this in SONiC. Signed-off-by: Saikrishna Arcot --- ...n-t-look-up-the-ifindex-for-fallback.patch | 34 +++++++++++++++++++ src/isc-dhcp/patch/series | 1 + 2 files changed, 35 insertions(+) create mode 100644 src/isc-dhcp/patch/0016-Don-t-look-up-the-ifindex-for-fallback.patch diff --git a/src/isc-dhcp/patch/0016-Don-t-look-up-the-ifindex-for-fallback.patch b/src/isc-dhcp/patch/0016-Don-t-look-up-the-ifindex-for-fallback.patch new file mode 100644 index 000000000000..55fde475ff61 --- /dev/null +++ b/src/isc-dhcp/patch/0016-Don-t-look-up-the-ifindex-for-fallback.patch @@ -0,0 +1,34 @@ +From 079ff1bb570dae96c4ca513e210c9856e9cc75b0 Mon Sep 17 00:00:00 2001 +From: Saikrishna Arcot +Date: Wed, 10 Jan 2024 23:30:17 -0800 +Subject: [PATCH] Don't look up the ifindex for fallback + +If sending a packet on the "fallback" interface, then don't try to get the +ifindex for that interface. There will never be an actual interface named +"fallback" in SONiC (at least, not one that we will want to use). + +This might save 0.009-0.012 seconds per upstream server, and when there +are as many as 48 upstream servers, it can save about 0.4-0.5 seconds of +time. This then allows dhcrelay to process more packets. + +Signed-off-by: Saikrishna Arcot + +diff --git a/common/socket.c b/common/socket.c +index da9f501..e707a7f 100644 +--- a/common/socket.c ++++ b/common/socket.c +@@ -767,7 +767,10 @@ ssize_t send_packet (interface, packet, raw, len, from, to, hto) + memcpy(&dst, to, sizeof(dst)); + m.msg_name = &dst; + m.msg_namelen = sizeof(dst); +- ifindex = if_nametoindex(interface->name); ++ if (strcmp(interface->name, "fallback") != 0) ++ ifindex = if_nametoindex(interface->name); ++ else ++ ifindex = 0; + + /* + * Set the data buffer we're sending. (Using this wacky +-- +2.34.1 + diff --git a/src/isc-dhcp/patch/series b/src/isc-dhcp/patch/series index 07f78949ae0b..5a58b41b1552 100644 --- a/src/isc-dhcp/patch/series +++ b/src/isc-dhcp/patch/series @@ -14,3 +14,4 @@ 0013-Fix-dhcrelay-agent-option-buffer-pointer-logic.patch 0014-enable-parallel-build.patch 0015-option-to-set-primary-address-in-interface.patch +0016-Don-t-look-up-the-ifindex-for-fallback.patch