summary:
- struct rq is basic data structure.
- there is a realtime process(es) and normal process(es) are stored in
different sub-runqueue*_rqof rq?
1 | 426 struct cfs_rq cfs; |
1 | git send-email --annotate --subject-prefix="PATCH v2 net-next" \ |
promisc is one bit of struct net_device’s flag, which is used to indicate if a device is in promisc status.
1 | 30 /* Standard interface flags (netdevice->flags). */ |
There are two kinds of operataion, could cause a NIC enter/leave promisc status.
on command, just need one off to recover.1 | ip link set dev eth0 promisc on |
1 | /** |
1 | int register_pernet_subsys(struct pernet_operations *ops) |
inet6_init in pernet.
1 | static struct pernet_operations inet6_net_ops = { |
netlink是一种用于内核和用户空间进行数据交互的socket。 关于netlink的具体介绍,google给出更好的解释。
netlink是socket的一种,其的family号是PF_NETLINK, netlink包括很多种proto,并且用户可以根据自己的需要进行扩展。
每个netlinksocket都有一个pid,该pid在所属proto下是唯一的。 在netlink消息
传递是,pid常被用来标识目的地socket。
Every netlink socket is indicated by (net, proto, pid).
对nl_table的操作:
读操作: netlink_lock_table 和 netlink_unlock_table
写操作netlink_table_grab 和 netlink_table_ungrab
原子变量nl_table_users 用来保存对nl_table的读者引用计数。
只要没有进行的写者,即使有n个写者在等待,m个读者也可以同时读。
当没有任何读者时,写着才可以获得权限。
一旦一个写着获得权限,所有的读者和写者都得等待。
有时候我们需要从内核输出大量的消息。 例如,dump interface, xfrm sa,sp(几千甚至几万条)等 这些信息显然无法放到一个skb里。
这是我们需要借助netlinkcallback机制。 原理:
netlink_callback1 | 93 struct netlink_callback { |
netlink_dump_control1 | 117 struct netlink_dump_control { |
和done`1 | dump: 每次输出时调用,接着上次的数据输出。如果全部输出完成返回0. |
1 | 1. 当dump的消息非常多时候,首先创建struct netlink_callback, 并创建这个cb挂到netlink socket(nlk)上。 |
netlink_recvmsg调用netlink_dump形成闭环反馈。闭环反馈过程:
1 | 这样应用程序每次通过系统调用rcv, 在将数据从内核中收上来的 |
1 | nlk->cb = NULL; |
1 | 2359 stati int netlink_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, |