Linux Kernel Core Implementation - header

How to Insert a HOP BY HOP OPTION Extension header into a IPv6 frame in the Linux kernel .
Implementing it through IPtables using Netfilter framework (i.e) using mangle chain and Output hook is a better option or should i write a code for including it as a patch into the Linux kernel.
I have been trying to find the implementation of this option in Linux by traversing the code regarding transport and network layer, Couldn't.
IPV6 frame
Generated packets
Kindly suggest me a better way of implementing this.

From a quick glance at the code it should be possible to set hop-to-hop options using setsockopt().
I've not tried to work out how to do it exactly, but net/ipv6/ipv6_sockglue.c handles IPV6_HOPOPT in do_ipv6_setsockopt().
You will need to be root (or have CAP_NET_RAW at least) to do so.

Related

What is the best way to know which protocols are supported by curl in python?

I am building a python application that is used to download remote files. In most cases, we use pycurl to do the actual download but we need to define a class that wraps the pycurl object. The class can handle several protocols (HTTP(S), FTP(S) and SFTP).
We have noticed that on some distributions (for example Ubuntu 18.04), cURL doesn't support the SFTP protocol. So using some SFTP-related options (SSH_KNOWNHOSTS for instance) leads to crashes (the crash occurs when setting the option before the download even if the URL uses another protocol). Therefore we need to know which protocols are available when the class is defined (i.e. when importing the module).
What is the best way to know, in python, which protocols are supported by cURL ? I know that the output of pycurl.version_info() contains the supported protocols (item 8) but is there a better way ?
pycurl does not track or check which protocols are supported by libcurl.

Using salt-cloud with oVirt

I have a small cloud, configured and set up with SaltStack. The instances are running on Xen right now.
I would like to use oVirt instead, with automatic provisioning of virtual machines (via salt-cloud, I guess).
Apparently, there is no formula for this yet. Also, one cannot just use virsh on the command line or something (oVirt uses its own XML files for configuration and has virsh disabled). There is a REST API for oVirt, but I would prefer something already made before I dive into this and try to make it work with salt.
I have searched for oVirt and salt, but have found almost nothing.
Can I use oVirt with salt-cloud to do automatic provisioning? If so, how?
There doesn't appear to be an oVirt salt cloud driver yet. Here's the list of currently supported clouds:
https://docs.saltstack.com/en/latest/topics/cloud/#cloud-provider-specifics

How to figure out port information in mininet

I use python to create a custom mininet topology. To know the topology in detail is not important for the question.
I use ryu as controller. Especially I use the app "ofctl_rest.py". This controller does not install rules in the switch on its own. You have to issue rest - commands to establish rules. In every rest request (rule) you have to specify an outgoing port. To specify this port I need information about the topology of the network.
I need to know which link is connected to a port. I need to know which interface the port runs on. Also helpful would be to know the foreign interface, foreign switch/host, and foraign port of the actual port. How can I retrieve this information???
Please help me. I am really frustrated right now, because I do not know how to figure it out.
Inside the mininet CLI you can use the net command to find out about the topology. The nodes command will show you a list of nodes.
You can also use the dump command to display the interface details.
For information on the 'hosts', such as they are, you can run normal linux commands on each host, e.g.
mn> h1 ifconfig
will run ifconfig on host h1, showing you some of the network configuration for that host.
Given that you seem to be running mininet from a custom script, you could start the CLI at the end of your script (if that's possible) e.g.
net = Mininet(your_topo)
net.start()
CLI(net)
net.stop()
Otherwise, you can use the mininet python APIs to find much of the information.
the dump* functions in mininet.util will print out lots of information.
topo.links() will give you a list of the links in the topology.
topo.linkinfo() might give you some extra info.
For flow information you can either run ovs-dpctl, ovs-ofctl etc. outside of mininet (in a normal shell), or run the equivalents without the ovs- prefix inside the mininet CLI.

Launch webserver with no configuration file

I really like the concept of firing up an HTTP daemon to serve something like the current working directory in the file system without the distraction of configuring modules, directories, permissions etc. (instant gratification for programmers). My example use-cases are:
I may be trying to prototype some RESTful web services with a new UI framework, or
provide a tutorial for users to use some UI framework with a realistic but minimal end-to-end sample code.
experimenting with making an SVN or Git repository available over HTTP (no lectures about security or alternative protocols please)
making my personal files (photos, documents,...) available temporarily over HTTP while I am out of town (particularly abroad where all I would have is a plugin-less browser at an internet cafe)
Here's one I found from another thread:
python -m SimpleHTTPServer 8000
Is there an equivalent, ideally, with Apache httpd? Lighttpd is a candidate too but once you create prerequisites you lose adopters of the technology you are trying to teach (or learn yourself). The best tutorials are one liners you can copy and paste to execute, then figure out how it works after seeing it in action.
I'm guessing the answer is no, not directly BUT you can use a heredoc in place of your httpd.conf file? It would be nicer if the popular binaries had direct command line arguments.
This runs lighttpd in the foreground on port 8080, serving files from /www. Ctrl-C to cause lighttpd to exit:
printf 'server.document-root="/www" \n server.port=8080' | lighttpd -D -f -

Writing a web-scripting language from the ground up?

I'm looking for references stating how to write a web scripting language and interface it with a web-server.
I'm not looking for "how to write the language" or "how to write an interpreter" references rather - I don't know how the basics of a web-script interpreter work? Is it a simply a CGI based interpreter that is passed the HTTP parameters through stdin then interprets the script and pushes the output back to stdout?
What about interfacing and registering with the web-server (IIS, Apache) how is that done? Again, through stdin/stdout?
Any basic examples, references or comments would be appreciated.
Eric Lippert had a series of posts on building your own script engine. They may be of help/interest:
SimpleScript, Part Zero
SimpleScript Part One: DllMain is Boring
SimpleScript Part Two: Class Factories Are Also Boring
SimpleScript Part Three: Engine Skeleton
SimpleScript Part Four: Finite State Machines and Script Engines
SimpleScript Part Five: Named Items and Modules
SimpleScript Part Six: Threading Technicalities
SimpleScript Part Seven: Binder Skeleton
Is it a simply a CGI based interpreter that is passed
the HTTP parameters through stdin then interprets the
script and pushes the output back to stdout?
It could be.
What about interfacing and registering with the
web-server (IIS, Apache) how is that done?
If it is CGI, then you would use their built in CGI modules.
Otherwise, you might use FastCGI (again with built in modules), or the APIs provided by the server: Apache, IIS
This is certainly going to be server-dependent. Apache is very modular and afaik uses own IPC protocol. In any case, the interpreter should be something that is started up once for the server, not once per request. As far as IPC, stdin is one option as you mentioned; others would be shared memory, pipes, or localhost TCP.