af-xdp: make WriteLinuxTunables resolve real netdev name in case of altname used in suricata config

WriteLinuxTunables built the sysfs path from the configured interface
name. When an altname is used in the config, sysfs only exposes the
real netdev name and writing gro_flush_timeout/napi_defer_hard_irqs
failed. Resolve the real name via if_indextoname before building the
path.

Ticket: #8780
pull/16208/head
amir.boussejra 3 months ago committed by Amir Boussejra
parent 928ac01215
commit cc033f1960

@ -354,9 +354,17 @@ static TmEcode InitFillRing(AFXDPThreadVars *ptv, const uint32_t cnt)
static TmEcode WriteLinuxTunables(AFXDPThreadVars *ptv)
{
char fname[SYSFS_MAX_FILENAME_SIZE];
char ifname[IF_NAMESIZE];
if (snprintf(fname, SYSFS_MAX_FILENAME_SIZE, "class/net/%s/gro_flush_timeout", ptv->iface) <
0) {
/* The configured interface may be an alternative name (e.g. "mon0"), but
* sysfs only exposes a directory for the real netdev name. */
if (if_indextoname(ptv->ifindex, ifname) == NULL) {
SCLogError("Could not resolve interface name for %s (ifindex %u): %s", ptv->iface,
ptv->ifindex, strerror(errno));
SCReturnInt(TM_ECODE_FAILED);
}
if (snprintf(fname, SYSFS_MAX_FILENAME_SIZE, "class/net/%s/gro_flush_timeout", ifname) < 0) {
SCReturnInt(TM_ECODE_FAILED);
}
@ -364,8 +372,7 @@ static TmEcode WriteLinuxTunables(AFXDPThreadVars *ptv)
SCReturnInt(TM_ECODE_FAILED);
}
if (snprintf(fname, SYSFS_MAX_FILENAME_SIZE, "class/net/%s/napi_defer_hard_irqs", ptv->iface) <
0) {
if (snprintf(fname, SYSFS_MAX_FILENAME_SIZE, "class/net/%s/napi_defer_hard_irqs", ifname) < 0) {
SCReturnInt(TM_ECODE_FAILED);
}

Loading…
Cancel
Save