Migrating particular TCP Connection using CRIU tools - c

Is it possible to migrate a single and particular TCP connection inside a running process in one machine to another machine using CRIU tools in Linux?
What I want is to dump a particular TCP Connection information in a memory and transfer this information to a peer machine. Inside this machine, I will use the dumped information to recreate the the migrated TCP connection. Does anyone have an example or tutorial in c language?
I am aware about different solutions like SockMi which provides Kernel Module + User Space APIs to migrate a certain TCP Socket. However, I want to use CRIU tools since it is part of Linux Mainline.

Right now we only have the TCP migration functionality integrated into CRIU tool. It sits in the sk-tcp.c file, the whole TCP-repair code is there, though it's bound to the rest of CRIU.
On the other hand, we've been asked for TCP-only migration for quite a while, it's possible to pull this code into smth like libcriutcp.so, but it will require patching. You're welcome to participate to the https://github.com/xemul/criu/issues/72

Related

Client/Server communication using TCP/IP under TLS 1.3

I want to write a client and server in C preferably, simple C++ if necessary.
The server will run on some flavor of Linux, the client is for testing the server.
I want to ensure messages are received and error free; therefore I will use TCP.
I want them to communicate securely; thus I will use the latest version of TLS (v1.3).
I intend to use the GnuTLS library for reasons:
Actively updated by reputable open source project
License permits selling product
Given the above, if implemented and tested, I could claim that the client/server communication is secure, reliable (a.k.a. assured), and error-checked. Yes?
Am I missing something? Is anything patently false?
Edit: certificates... i think i'm missing something about certificates to protect against man in the middle attacks...
TLS is a complex topic. Depending on your specific code the TLS connection might succeed even if you fail to properly validate the certificate. Thus, just based on what you state so far in your question it cannot be assured that the data are transferred with proper end-to-end protection and that no man in the middle can manipulate the data.

Implementing a 9p server

I am looking to develop a C implementation of a 9p file server on a Linux machine. There isn't enough documentation in the internet about 9p and I am not very experienced with implementing servers. My general design is as follows:
Use UNIX sockets to listen to incoming 9p messages.
Decode the 9p message and spawn a new thread to perform the required task.
Reply to the client with the appropriate 9p reply message.
The server would just live in the user space and it will translate the 9p messages into a UNIX call.
Do you see any problems or have any recommendations regarding the proposed design? Are there any documentations that you can refer me to that will help me? How do you think I should debug my server and make sure it is working correctly.
Consider libixp (MIT license).
I've played around with wmii and use it in everyday work. libixp was part of wmii (in the earliest releases) and now it is an independent project. Check wmii's early versions to get a good starting point or dive directly into libixp.
To debug your server just mount it with 9PFUSE(4) with parameter −D to print each FUSE and 9P message.

How to create a BACnet client in C

I am trying to create a client in C that will talk with a BACnet server. This BACnet server is stored on an industrial device (CAN2GO) and I am not sure how I could talk with this device.
I spent quite some time reading documentation for BACnet and I never found a clear example for a BACnet client. I already did some server and clients using TCP and UDP but I don't know how to start this BACnet client and I must say I am getting quite desperate.
I found a library which seems to correspond to what I want which is called BACnet protocol stack but when I tried the whois exemple no device was found (I expected to found the bacnet server but maybe I shouldn't ?).
So my question is : could you give me an exemple in C, or another language but C would be better, that would communicate with a BACnet server (nothing complicated just a question and analysing response). This example could be using the library I just wrote about or if you prefer another library I am of course open to everything.
Thank you very much for your time and answers.
I have used that stack and it is the best open source one you are going to find. If you cannot see anything using the demo\whois\bacwi example from that library, then there is something wrong with your setup. In particular, are you using IP? Are your BACnet client and BACnet server on different machines (they cannot be on the same without some serious tweaking)? Are the two machines on the same IP subnet? (They must be, once again, unless you do some serious tweaking (in this case, setting up BBMDs (BACnet Broadcast Management Devices))).
You will also want to try the "Read Property" example (demo\readprop\bacrp.exe) to actually read a value from the server.
If you are still stuck, then post your detailed problem at the link on Sourceforge, Steve, the author, is very responsive to questions.
I am currently using the stack - just started. I had a little trouble at first, not sure if my problem is the same but.. I basically am using some BAC components made from Schneider Electric (UNC-500) and an old un-supported platform (Niagara R2). On my laptop I created a host server and addressed it to a private LAN network between it and the UNC. My laptop was also using wifi, which was utilizing DHCP, so I had two separate interfaces going. This was my problem. I couldn't read or get 'I-AM' responses back from the UNC. As soon as I turned the WIFI off, I got the 'I-AM' broadcasts. Make sure that you are on the same network as your device, and that there are not other interfaces active. Maybe there is a way to assign the interface to use, IDK. I just started using it.

Save Data using Dynamic C

I am using Rabbit single board computer. I would like to save the data I/O which is connected to another Rabbit single board computer through a wireless connection. Is it able to save the data inside the PC in a .txt file for example?
If you can establish a connection to a PC, and the PC is running some server to log data, yes, you could save to a PC. For example, the PC could run a TFTP server or FTP server on the same wireless network, and you could connect to it from the rabbit SBC and save whatever data you need to.
Yes, this is possible.
There are two parts to this scenario. Your embedded app needs to know how to connect to a server application running on the PC or network, and you must, of course, have said server application running on the target machine.
If you're sending entire files, FTP, as bdonlan suggested, is a good way to go. The protocol is well-understood and you can probably find a library to wrap it for you.
If you need to log data real-time, you'll need to have some sort of application which can receive messages or accept a socket connection, and a protocol to get the text across the wire(less). A web server may be a good way to do this, because you can POST chunks of data to the server with a simple HTTP request, and the server app can decide how to organize and store the information. Once you have a web server running, you may find it beneficial to build some pages that provide basic reporting functionality, so you can see the logged data from any web browser.
This could be less restrictive than FTP, but will require some web development expertise on your part.
Any reasonable solution is going to require that you already have a connection to the wireless network with a correctly-configured and functioning IP stack. Without that, you're probably out of luck connecting to any networked resources.

DCHP with database backend

Here my first question :P.
I am developing some little projectes. I want to change dhcp server rules of IP/MAC without rebooting the server (In a dinamic infrastructure).
I think that the best solution is to use a dhcp server with a database backend, in order to change the SQL information (With an easy JDBC client).
But I want to know some suggestion about open Source Projects, or howto's that explain how to implement it.
Thank you very much
Usually on Unix, long running daemons listen for the HUP signal. On receiving that signal, they re-read their configuration files. This allows daemons to have no down time, but get updated configuration options.
The guys at ISC (authors of BIND and the ISC DHCP server) are working on KEA, a new DHCP server implementation that -- among other nice features -- has SQL support. The source code has had support for SQLite and MySQL for years, and PostgreSQL support was added recently.
There's no proper release yet, and very little activity on their dev/users mailing lists. Hopefully that will change as the code matures, releases are made, distros start packaging it, and it gains traction with users.
SpliFF
On Unix.
No, restart the DHCP server, no the machine :). Sorry.
Because when you change the dhcp.conf you need to restart the dhcp (dhcpd)

Resources