小编Mar*_*ark的帖子

软件定义的网络和OpenFlow

我正在尝试深入研究这些新概念,即SDN和OpenFlow.我不清楚的一件事是传统路由(OSPF,BGP等)如何在SDN中完成,或者它完全消失了,取而代之的是一些轻量级机制?

我会很感激任何提示,链接,以便更好地理解这一点.谢谢!

标记

networking openflow

6
推荐指数
1
解决办法
2316
查看次数

访问超出C和C++限制的数组

int data[8];
data[9] = 1;
Run Code Online (Sandbox Code Playgroud)

c ++标准对此有何评论?这是未定义的行为吗?

至少C编译器(gcc -std = c99 -pedantic -W -Wall)对此没有任何说明.

谢谢.

c c++ arrays undefined-behavior

6
推荐指数
1
解决办法
3720
查看次数

Linux什么时候调用PCI驱动的probe函数?

在注册 PCI 驱动程序之前,我们必须对其进行初始化struct pci_driver并将其传递给 pci_register_driver. 该结构的字段之一是指向驱动程序probe函数的指针。

我的问题是 - 当内核调用驱动程序的探测例程时。是否保证在调用后立即pci_register_driver发生或可能发生在任何其他时间?是什么决定了这种行为?

UPDATE pci_register_driver是一个扩展为 的宏__pci_register_driver,它依次调用driver_registerdriver_register调用bus_add_driver.

中有以下代码bus_add_driver

if (drv->bus->p->drivers_autoprobe) {
        error = driver_attach(drv);
        if (error)
            goto out_unregister;
}
Run Code Online (Sandbox Code Playgroud)

driver_attachbus_for_each_dev使用参数__driver_attach调用,它将调用driver_probe_device

driver_probe_device最终调用really_probe

if (dev->bus->probe) {
    ret = dev->bus->probe(dev);
Run Code Online (Sandbox Code Playgroud)

我不确定的一件事是,是否drivers_autoprobe为 pci_bus 设置了标志。

linux linux-device-driver linux-kernel pci

6
推荐指数
2
解决办法
6820
查看次数

vsnprintf 和 NULL 输入字符串参数

vsnprintf当它有一个输入 NULL 字符串和/或 size=0 时,预期的行为是什么,例如

vsnprintf(NULL, 0, "%d", p);
Run Code Online (Sandbox Code Playgroud)

或者

vsnprintf(NULL, 10, "%d", p);
Run Code Online (Sandbox Code Playgroud)

它是未定义的行为还是有效的场景?它不会在输入字符串 asNULL和它的长度 as 时崩溃0,并返回 -1(对于有效的非空字符串和零长度相同),但是它会以相反的方式崩溃(NULL输入字符串和正长度)。

c string printf variadic-functions

6
推荐指数
1
解决办法
2130
查看次数

函数中的"静态"对象

可能重复:
gcc是否自动将静态变量初始化为零?

函数内的静态声明对象是否保证用0?初始化?

例如:

int func(void)
{
   static int x;
   ...
}
Run Code Online (Sandbox Code Playgroud)

标准是否承诺x = 0在第一次调用时func()

c static

5
推荐指数
2
解决办法
169
查看次数

python和PEP 440 - 这是什么?

我不得不使用devstack基础设施安装OpenStack,用于开放vSwitch的体验,并在日志中找到:

/usr/lib/python2.7/site-packages/setuptools/dist.py:298: UserWarning: The version specified ('2014.2.2.dev5.gb329598') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
Run Code Online (Sandbox Code Playgroud)

我用谷歌搜索,发现PEP代表Python增强提案,而PEP 440显然是一个特别的提案,但我想知道这个警告有多严重,PEP 440定义了什么?

PS.我对python几乎一无所知.

python openstack devstack

5
推荐指数
2
解决办法
5353
查看次数

夹板:要求不要检查系统标题

有没有办法停止splint分析包括 POSIX、libc 等在内的系统头文件?我运行-warnposix -preproc

% splint -warnposix -preproc my.c

/usr/include/unistd.h:220:8: Parse Error: Non-function declaration:
    __BEGIN_DECLS : int. (For help on parse errors, see splint -help
    parseerrors.)
*** Cannot continue.
Run Code Online (Sandbox Code Playgroud)

更新:

% splint +posixlib +unixlib -I/path/to/myheaders -I/usr/include/x86_64-linux-gnu my.c

/usr/include/asm-generic/int-ll64.h:19:24: Parse Error:
    Suspect missing struct or union keyword: __signed__ :
    int. (For help on parse errors, see splint -help parseerrors.)
Run Code Online (Sandbox Code Playgroud)

阅读夹板 FAQ14 后,我试图消除非标准关键字:

% splint +posixlib +unixlib -D__signed__= -I/path/to/myheaders -I/usr/include/x86_64-linux-gnu my.c

/usr/include/x86_64-linux-gnu/sys/syslog.h:200:66: Parse Error:
    Inconsistent function …
Run Code Online (Sandbox Code Playgroud)

c static-analysis splint

5
推荐指数
0
解决办法
1067
查看次数

如何在内核树之外构建BPF程序

内核在中提供了许多示例samples/bpf。我有兴趣在树外构建示例之一,就像我们构建一个内核模块一样,其中Makefile足够简单。bpf是否可以做同样的事情?我尝试通过从中删除不必要的部分samples/bpf/Makefile并保持对libbpf其他对象的依赖来进行尝试,但是事实并非如此简单。

例如,尝试samples/bpf/bpf_tcp_kern.c使用以下命令行在内核树之外进行构建(我窥视了samples / bpf / Makefile以及的输出make samples/bpf V=1):

clang -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/5/include \
        -I/home/mark/work/net-next.git/arch/x86/include -I/home/mark/work/net-next.git/arch/x86/include/generated -I./include -I/home/mark/work/net-next.git/arch/x86/include/uapi -I/home/mark/work/net-next.git/arch/x86/include/generated/uapi -I/home/mark/work/net-next.git/include -I/home/mark/work/net-next.git/generated/uapi  -I./ \
        -D__KERNEL__ -Wno-unused-value -Wno-pointer-sign \
        -D__TARGET_ARCH_x86 -Wno-compare-distinct-pointer-types \
        -Wno-gnu-variable-sized-type-not-at-end \
        -Wno-address-of-packed-member -Wno-tautological-compare \
        -Wno-unknown-warning-option  \
        -O2 -emit-llvm -c bpf_tcp_kern.c -o -| llc -march=bpf -filetype=obj -o bpf_tcp_kern.o
In file included from bpf_tcp_kern.c:15:
In file included from /home/mark/work/net-next.git/include/uapi/linux/bpf.h:11:
In file included from /home/mark/work/net-next.git/include/linux/types.h:6:
In file included from /home/mark/work/net-next.git/include/uapi/linux/types.h:5:
/home/mark/work/net-next.git/arch/x86/include/uapi/asm/types.h:5:10: …
Run Code Online (Sandbox Code Playgroud)

jit linux-kernel llvm-clang bpf

5
推荐指数
1
解决办法
2341
查看次数

AMD:TLB 未命中周期的性能计数器

我正在寻找 AMD 特定的性能计数器,它可以在TLB发生未命中时对页面遍历所消耗的周期进行计数。我知道英特尔有这样的指标。

但是AMD上存在这种情况吗?我查看了http://developer.amd.com/wordpress/media/2013/12/56255_OSRR-1.pdf,但没有找到任何接近我需要的内容。

我还查看了perf源代码https://elixir.bootlin.com/linux/latest/source/arch/x86/events/amd/core.c#L248它似乎也没有。

也许它有不同的名字?有什么建议么?

performance tlb mmu perf amd-processor

5
推荐指数
1
解决办法
944
查看次数

c++ 抱怨 __VA_ARGS__

以下代码已编译,gcc-5.4.0没有任何问题:

\n
% gcc -W -Wall a.c\n...\n\n#include <stdio.h>\n#include <stdarg.h>\n\nstatic int debug_flag;\nstatic void debug(const char *fmt, ...)\n{\n   va_list ap;\n\n   va_start(ap, fmt);\n   vfprintf(stderr, fmt, ap);\n   va_end(ap);\n}\n\n#define DEBUG(...)               \\\n   do {                 \\\n      if (debug_flag) {       \\\n         debug("DEBUG:"__VA_ARGS__);  \\\n      }              \\\n   } while(0)\n\nint main(void)\n{\n   int dummy = 10;\n   debug_flag = 1;\n   DEBUG("debug msg dummy=%d\\n", dummy);\n   return 0;\n}\n
Run Code Online (Sandbox Code Playgroud)\n

然而,编译它g++会产生有趣的效果:

\n
% g++ -W -Wall -std=c++11 a.c\na.c: In function \xe2\x80\x98int main()\xe2\x80\x99:\na.c:18:10: error: unable to find string literal operator \xe2\x80\x98operator""__VA_ARGS__\xe2\x80\x99 with \xe2\x80\x98const …
Run Code Online (Sandbox Code Playgroud)

c++ gcc c++11

5
推荐指数
1
解决办法
337
查看次数