On 1/14/25 4:27 PM, Song Yoong Siang wrote: [...]
+ /* Add mqprio qdisc with TC and hardware queue one-to-one mapping */ + char map[256] = {0}; + char queues[256] = {0}; + + for (i = 0; i < rxq; i++) { + char buf[8]; + + snprintf(buf, sizeof(buf), "%d ", i); + strcat(map, buf); + + snprintf(buf, sizeof(buf), "1@%d ", i); + strcat(queues, buf); + } + run_command("sudo tc qdisc add dev %s handle 8001: parent root mqprio num_tc %d map %s queues %s hw 0", + ifname, rxq, map, queues);
Fyi, above triggers selftest build errors: xdp_hw_metadata.c: In function ‘main’: xdp_hw_metadata.c:763:45: error: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size 8 [-Werror=format-truncation=] 763 | snprintf(buf, sizeof(buf), "%d ", i); | ^~ TEST-OBJ [test_progs] arg_parsing.test.o xdp_hw_metadata.c:763:44: note: directive argument in the range [0, 2147483646] 763 | snprintf(buf, sizeof(buf), "%d ", i); | ^~~~~ xdp_hw_metadata.c:763:17: note: ‘snprintf’ output between 3 and 12 bytes into a destination of size 8 763 | snprintf(buf, sizeof(buf), "%d ", i); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ xdp_hw_metadata.c:766:47: error: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size 6 [-Werror=format-truncation=] 766 | snprintf(buf, sizeof(buf), "1@%d ", i); | ^~ xdp_hw_metadata.c:766:44: note: directive argument in the range [0, 2147483646] 766 | snprintf(buf, sizeof(buf), "1@%d ", i); | ^~~~~~~ xdp_hw_metadata.c:766:17: note: ‘snprintf’ output between 5 and 14 bytes into a destination of size 8 766 | snprintf(buf, sizeof(buf), "1@%d ", i); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~