在 Linux 内核模块中,我需要以某种方式禁用 rp_filter。这通常可以通过几个简单的 sysctl 调用从用户空间实现:
sysctl net.ipv4.conf.all.rp_filter=0
sysctl net.ipv4.conf.[ifname].rp_filter=0
Run Code Online (Sandbox Code Playgroud)
如何从内核空间获得相同的结果?我的第一个想法是我可能需要写入相关的 proc 文件。如果是这样,正确的方法是什么?
考虑以下C++示例main.cpp
文件:
class FooIf
{
public:
virtual int handle(char *req, char *res) = 0;
};
class BarIf
{
public:
virtual void handle(char *msg) = 0;
};
class Bar : private BarIf
{
private:
void handle(char * msg){}
};
class Zoo : public FooIf, public Bar
{
public:
using FooIf::handle;
public:
int handle(char *req, char *res){ return (0); }
};
int main(){
Zoo zoo;
return (0);
}
Run Code Online (Sandbox Code Playgroud)
我收到这个警告:
$ clang++ -ggdb -c main.cpp -Wall
main.cpp:23:6: warning: 'Zoo::handle' hides overloaded virtual …
Run Code Online (Sandbox Code Playgroud)