Skip to content

Commit

Permalink
Netif (Linux): don't use fseek
Browse files Browse the repository at this point in the history
Turns out that `fseek` generates two extra syscalls, which causes unnecessary overhead.
  • Loading branch information
CarterLi committed Oct 13, 2024
1 parent f847a23 commit fbed730
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/common/netif/netif_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ bool ffNetifGetDefaultRouteImpl(char iface[IF_NAMESIZE + 1], uint32_t* ifIndex)
FILE* FF_AUTO_CLOSE_FILE netRoute = fopen("/proc/net/route", "r");
if (!netRoute) return false;

// skip first line #1336
fseek(netRoute, 128, SEEK_SET);
// skip first line
fscanf(netRoute, "%*[^\n]\n");

unsigned long long destination; //, gateway, flags, refCount, use, metric, mask, mtu,
while (fscanf(netRoute, "%" FF_STR(IF_NAMESIZE) "s%llx%*[^\n]", iface, &destination) == 2)
Expand Down

0 comments on commit fbed730

Please sign in to comment.