Page 1 of 1

Some Linux Kernel codes

Posted: Tue Oct 07, 2014 3:02 am
by lilzz
1)

Code: Select all

	rtnl_link_register(&batadv_link_ops);
what does rtnl_link_register really does? what does rtnl stands for?

2)

Code: Select all

INIT_HLIST_HEAD(&bat_priv->gw.list);
    INIT_LIST_HEAD(&bat_priv->tt.changes_list);
Also what are differences between INIT_LIST_HEAD and INIT_HLIST_HEAD?

3)

Code: Select all

free_percpu(bat_priv->bat_counters);
what does free_percpu does?

4) list_for_each_entry_safe verus list_for_each_entry
what's safe means in this case?

5)

Code: Select all

seqno_event = malloc(sizeof(struct seqno_event));
	INIT_LIST_HEAD(&seqno_event->list);
	list_add_tail(&seqno_event->list, &orig_event->event_list);
can someone describe in word of what's happening above?

Re: Some Linux Kernel codes

Posted: Tue Oct 07, 2014 6:38 am
by elatllat
First hit on Google for rtnl_link_register is
http://lxr.free-electrons.com/source/ne ... ink.c#L321

Code: Select all

/**
* rtnl_link_register - Register rtnl_link_ops with rtnetlink.
* @ops: struct rtnl_link_ops * to register
*
* Returns 0 on success or a negative error code.
*/
so rtnl_link_register is rtnetlink_link_register, first hit on Google for rtnetlink is
http://man7.org/linux/man-pages/man7/rtnetlink.7.html

Code: Select all

rtnetlink - Linux IPv4 routing socket
so rtnetlink_link_register is "Linux IPv4 routing socket link register"

now you try using Google it's fun.

Re: Some Linux Kernel codes

Posted: Tue Oct 07, 2014 8:20 am
by ShiftPlusOne
The linux kernel is well documented and will usually have a in-source description of such functions.

Look up linux kernel linked lists to help understand the last snippet.