【发布时间】:2017-03-13 15:23:54
【问题描述】:
我在 Linux 内核中观察到以下代码模式,例如 net/sched/act_api.c 或许多其他地方:
rtnl_lock();
rtnetlink_rcv_msg(skb, ...);
replay:
ret = process_msg(skb);
...
/* try to obtain symbol which is in module. */
/* if fail, try to load the module, otherwise use the symbol */
a = get_symbol();
if (a == NULL) {
rtnl_unlock();
request_module();
rtnl_lock();
/* now verify that we can obtain symbols from requested module and return EAGAIN.*/
a = get_symbol();
module_put();
return -EAGAIN;
}
...
if (ret == -EAGAIN)
goto replay;
...
rtnl_unlock();
request_module 成功后,我们感兴趣的符号在内核内存空间中可用,我们可以使用它。但是我不明白为什么要返回 EAGAIN 并重新读取符号,为什么不能在 request_module() 之后继续?
【问题讨论】:
-
您正在查看哪个版本的内核源代码?上面的代码似乎在持有锁时返回
-EAGAIN。
标签: linux networking linux-kernel network-programming