gpt4 book ai didi

c - 什么是有效的 TC (QoS) u32 过滤器句柄 ID

转载 作者:行者123 更新时间:2023-11-30 17:23:01 25 4
gpt4 key购买 nike

我正在尝试找到一种使用某种命名约定在我的应用程序模块之间分配唯一 ID 的方法。
我希望每个 up 都有一系列 id,它可以用来创建 TC 过滤器/类等。
正如它this page状态:

A u32 handle is actually 3 numbers, written like this: 800:0:3. They are all in hex.

Valid filter item handles range from 1 to ffe hex.

但是当我尝试设置handle 1:1:1时它失败。

这里是u32 handle id的解析来自iproute2-3.17.0 module : (不一定是机器上安装的版本)

static int get_u32_handle(__u32 *handle, const char *str)
{
__u32 htid=0, hash=0, nodeid=0;
char *tmp = strchr(str, ':');

if (tmp == NULL) {
if (memcmp("0x", str, 2) == 0)
return get_u32(handle, str, 16);
return -1;
}
htid = strtoul(str, &tmp, 16);
if (tmp == str && *str != ':' && *str != 0)
return -1;
if (htid>=0x1000)
return -1;
if (*tmp) {
str = tmp+1;
hash = strtoul(str, &tmp, 16);
if (tmp == str && *str != ':' && *str != 0)
return -1;
if (hash>=0x100)
return -1;
if (*tmp) {
str = tmp+1;
nodeid = strtoul(str, &tmp, 16);
if (tmp == str && *str != 0)
return -1;
if (nodeid>=0x1000)
return -1;
}
}
*handle = (htid<<20)|(hash<<12)|nodeid;
return 0;
}

看起来应该得到任何 XXX:XXX:XXX只要xxx < 0x1000 ,但它未能这样做。 (我认为第一部分(即hash必须是800),任何其他值都无法解析。

最佳答案

我不知道iproute2库,但是tc filter show dev eth0以“800::123”格式显示它们。 (LibNL 的样本 nl-cls-list 显示与“8000:123”相同的句柄。)此外,tc filter add 接受“0x123”形式的句柄。

尝试将第一个字段设置为 800,第二个字段设置为 0 或空。这有帮助吗?

关于c - 什么是有效的 TC (QoS) u32 过滤器句柄 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27776831/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com