Is there is any easy way to modify tcp socket parameters? For example: Server_program is using eth0 with 10.0.0.1, it can't be restarted and I need to recreate socket on the eth1 with 192.168.0.1. I know there is some other not trival problems but all I'm looking now is possibility to modify socket "on-the-fly" inside the kernel. Thank you for any advices.
-
The program's hardcoded to the 10.x IP? I doubt you could modify a socket in-memory to change its port/ip like that, short of being Linus, but perhaps the iptables stuff can internally do a redirect for you.Marc B– Marc B2011-02-11 14:20:05 +00:00Commented Feb 11, 2011 at 14:20
-
Marc B: But program connects with inode. Right? I need put program "on hold", modify socket informations and run programuser615155– user6151552011-02-13 19:30:01 +00:00Commented Feb 13, 2011 at 19:30
Add a comment
|
1 Answer
Open the new socket, do whatever steps are needed to get it connected and into the same state, and then use dup2() to turn the old file descriptor into a clone of the new one.
1 Comment
caf
...and if you want to do this from outside, you can use
ptrace() to debauch the target process as necessary.