add/remove static route from route table by LINUX KERNEL MODULE - static

I'm working on a project, that I am implementing via kernel-mode module in Linux,
at some callback (inside the kernel) I need to modify routing table, for example
I may need to delete a static route, or add a static route to routing tables.
I know we can do it simply in Linux user mode, but I need do it in kernel mode,
after reading some Linux source code / iproute package I think it should be related to function fn_hash_insert but i failed to find a good documentation for these commands, like MSDN.
Thanks

Related

Capabilities in a shared lib does not work as expected

A maybe stupid question: For an embedded project I want to switch the single processes (currently running as root) to capabilities. Since the project also includes several shared libraries, my approach is to switch parts in the libraries to use capabilities.
But a first test with 'seteuid()' and a system() call did not run successfully. Only when I replaced 'seteuid()' with 'setuid()' I had success.
For your information: The 'system()' call should delete a file in /sbin (rm /sbin/xyz).
When I started the project, I found a page on the internet about caps and shared libs. Unfortunately I can't find it anymore.
Can someone please give me info, or a link, on the topic of caps and shared libs?
Thanks

how to del and add route with c code or object c in macosx

In macosx, an important part if my project is to delete the original route entry , and add the necessary new route to the system. when the project exits, I need to restore the original route table as before.
unlike the linux or windows, the command to delete or add the route is so complex with so many arguments to consider. apart from that, when use the
netstat -nr
to print the route table, the different presentations of gateway and the flags of each table are troubling me.
so if there are apis to delete and add the route in macosx ,c or object-c ,either appreciated.
All I know that in linux We can use the ioctl plus the SIOCADDRT OR SIOCDELRT to accomplish this ,but mac doesn't support that.

apache 2.4 modules one handler calling a function in another handler with same name

I am using apache server 2.4 for the deployment of a web application for which I have created two custom C modules with request handlers Handler1 & Handler2. These are properly added and configured in httpd.conf file for handling specific requests related to my application.
The issue is that I have a function void foo(char*, char*) with the same name and signature in both the custom module .so files which are loaded into the apache server without any problem. But there is a case when the Handler2 is handling a request and i make the call foo() the function from the Handler1 is invoked. And after Handler1::foo() is done the control again comes back to Handler2.
Any idea as to what could be a reason behind this kind of behavior ?
Either the foo() function does not need to be exported, and you can declare it static, or you need to properly manage symbol visibility. See for example (this is for AIX, but the concepts are exactly the same):
http://www.ibm.com/developerworks/aix/library/au-aix-symbol-visibility/

Controlling Name Resolution server (DNS) address per request

Looking for ideas on how to generate a Name Resolution request and specify to which server to dispatch the request.
I'm working on Linux.
Up until now, I found two options:
Use an external library which can be hooked for achieving this.
Anyone knows a reliable DNS library that can be used for a production system?
Use Network Namespaces to virtualize the stack and use mounting to link the name resolution server files per namespace (see iproute2 latest version). Requests issued from each namespace may have different servers.
please share your thoughts...
Linux actually comes with a resolver API. See the man(3) page for 'resolver', and link your application with -lresolv.
The libsres library (dnsval) from the DNSSEC-Tools project definitely lets you send queries to a particular server. I know because I've done just that inside the DNSSEC-Check application, which is also part of the DNSSEC-Tools project.

How to make every page of a process in the page table present?

i compiled a static program using gcc on linux and run it under kvm. I checked every page table entry of this process in guest memory and found that some pages have been mapped and some ones are not. Is this the feature of on-demand paging? My question is whether there is a solution to make all the pte present and mapped in the page table?
E.g. i fork a new process and load a new elf binary, how to make every page mapped in the page table of this new process.
Thanks
Try out the following system call:
#include <sys/mman.h>
int mlockall(int flags);
Set the flags parameter with MCL_FUTURE and it will lock all current and future pages into memory. You can find more info about it here or just type "man mlockall" and you will get a bunch of information.
The linux API for this is mlock().
However, if you're trying to do this in a linux VM running on top of KVM I don't think there's a way for usermode code to make this work. It is possible that a paravirtualized linux kernel might have access to some KVM APIs that it could uses for this sort of thing, but kind of doubt it would do so.

Resources