Openvswitch Module

If you’re getting kernel module installation errors, probably the module is not compiled for the current kernel or its dependencies are not loaded.

# insmod datapath/linux/openvswitch.ko

Error:

datapath/linux/openvswitch.ko: Unknown symbol in module

By using the command modinfo, you can take clues about the module, such as its dependencies and kernel version that was used to compile.

If the problem is dependencies, instead of using insmod to install openvswitch.ko module, you can first type the command in the OVS root directory (after compiling):

# make install

This will install all compiled modules in the Linux system. Then, type:

# modprobe openvswitch

The command should automatically load openvswitch module and its dependencies.

NETIF_F_NETNS_LOCAL

Original post here.

NETIF_F_NETNS_LOCAL a flag to indicate
a network device is local to a single network namespace and
should never be moved.  Useful for pseudo devices that we
need an instance in each network namespace (like the loopback
device) and for any device we find that cannot handle multiple
network namespaces so we may trap them in the initial network
namespace.

 

Linux Kernel Network Namespace (NETNS)

Original post here.

“So what are network namespaces? Generally speaking, an installation of Linux shares a single set of network interfaces and routing table entries. You can modify the routing table entries using policy routing (here’s an introduction I wrote and here’s a write-up on a potential use case for policy routing), but that doesn’t fundamentally change the fact that the set of network interfaces and routing tables/entries are shared across the entire OS. Network namespaces change that fundamental assumption. With network namespaces, you can have different and separate instances of network interfaces and routing tables that operate independent of each other.”

 

Callback sock_def_readable()

Text extracted form the original post here.

 

The default ->sk_data_ready() callback is sock_def_readable():

static void sock_def_readable(struct sock *sk, int len)
{                       
        struct socket_wq *wq;

        rcu_read_lock();
        wq = rcu_dereference(sk->sk_wq);
        if (wq_has_sleeper(wq))
                wake_up_interruptible_sync_poll(&wq->wait, POLLIN | POLLPRI |
                                                POLLRDNORM | POLLRDBAND);
        sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN);
        rcu_read_unlock();
}

which basically wakes up the process waiting for these data, for example, recv(), and let them process the data in ->sk_receive_queue.

Some protocol may override this, for example, netlink, see __netlink_kernel_create().

BTW, you can use perf top command to see which kernel function consumes most CPU cycles.

Kernel trace for packet flow

“There exists a device driver for each kind of NIC. Inside it, Linux will ALWAYS call a standard high level routing: “netif_rx [net/core/dev.c]”, which will controls what 3 level protocol the frame belong to, and it will call the right 3 level function (so we’ll use a pointer to the function to determine which is right).”

Link: http://www.tldp.org/HOWTO/KernelAnalysis-HOWTO-8.html