Skip to contentSkip to conversation

Need some help to understand the code

B.A.T.M.A.N. Philipp Psurek 4 participants 6 messages Apr 1, 2016 – Apr 5, 2016

lore
Share & tools
lore
#0 lore raw

Hi all,

I'm 1st term IT student and a candidate for Freifunk's GSoC. I can imagine to look inside batman-adv. Therefore I've to learn much more beyond the „Write in C 101“ I took part last year.

If you have some spare time please recommend me some literature that has helped you on your way to write batman-adv code. I've two, three weeks to prepare myself and evaluate if I understand the code (or some parts of it) or participate in fixing some other Freifunk related issues.

Thank you in advance and thank you for batman-adv

best regards,
   Philipp

#1 lore raw

On Friday 01 April 2016 14:27:31 Philipp Psurek wrote:
[...]

Quoted 5 lines

If you have some spare time please recommend me some literature that has helped you on your way to write batman-adv code. I've two, three weeks to prepare myself and evaluate if I understand the code (or some parts of it) or participate in fixing some other Freifunk related issues.

Hm, I cannot speak for the other people but I would not know of any book which would prepare you perfectly for writing kernel code. The best resource is the kernel code itself (LXR is your friend to find things quickly) and the kernel documentation (e.g. in Documentation/*). Also the Linux Kernel Newbies [1] has some nice overviews and links to more information.

There are also some books which are well known and can help you to understand parts better [2,3,4,5]. But I think none of these are must-reads. Having some of them to find out more about a special topic can be helpful. But don't wonder when the example codes don't work anymore because the API in the kernel changed since the book was published :)

I don't know what tasks are currently open in the Freifunk GSoC. But if it is multicast related then you may better ask Linus about some more literature.

Kind regards,
Sven

[1] http://kernelnewbies.org/
[2] http://www.kroah.com/lkn/
[3] http://www.oreilly.com/openbook/linuxdrive3/book/
[4] http://www.oreilly.com/catalog/understandlni/
[5]
https://www.kernel.org/pub/linux/kernel/people/paulmck/perfbook/perfbook.html

#2 lore raw

Thank you very much Sven,

I already tried [3] and yes, the API has changed ;-) Some of the examples has been ported ... I hope to understand this soon.

Am Samstag, den 02.04.2016, 08:15 +0200 schrieb Sven Eckelmann:

Quoted 2 lines · On Friday 01 April 2016 14:27:31 Philipp Psurek wrote:

[...]

[...]

Quoted 4 lines

I don't know what tasks are currently open in the Freifunk GSoC. But if it is multicast related then you may better ask Linus about some more literature.

OK

[...]

Quoted 1 line

[3] http://www.oreilly.com/openbook/linuxdrive3/book/

thanx again and

best regards,
Philipp

#3 lore raw
In reply to Philipp Psurek
Quoted 5 lines · Philipp Psurek

If you have some spare time please recommend me some literature that has helped you on your way to write batman-adv code. I've two, three weeks to prepare myself and evaluate if I understand the code (or some parts of it) or participate in fixing some other Freifunk related issues.

Hi Philipp,

A few of the basics would be lists and locking as they are used everywhere in the code and would be something you would need to use and understand for batman-adv coding.

For lists, for instance:
http://www.makelinux.net/ldd3/chp-11-sect-5
http://kernelnewbies.org/FAQ/LinkedLists

Or the kerneldoc for lists themselves :) :
http://lxr.free-electrons.com/source/include/linux/list.h

For locking, two kinds of locks are mostly used in batman-adv. The easy ones are spin-locks:
http://lxr.free-electrons.com/source/Documentation/locking/spinlocks.txt

And then there is the fancy but super awesome RCU locking :) :
https://lwn.net/Articles/262464/

Finally, knowing how SKBs work is something you should look into for Linux network coding:
http://vger.kernel.org/~davem/skb.html

A friend of mine had written a small (< 300 lines) but fun kernel module:
https://github.com/Gnoxter/devcat

Maybe you could set up a KVM instance and play a little with its code in there? Try out lists and spinlocks etc. in there without crashing the VM instance :).

Cheers, Linus

PS: If you need any help, feel free to query me in #batman on Freenode (nick: T_X).

#4 lore raw
Quoted 3 lines · On Tuesday 05 April 2016 01:15:58 Linus Lüssing wrote:

Maybe you could set up a KVM instance and play a little with its code in there? Try out lists and spinlocks etc. in there without crashing the VM instance :).

There is also an easy example how to build an amd64 [1] VM image with many debug helpers enabled.

Kind regards,
Sven

[1] https://www.open-mesh.org/projects/open-mesh/wiki/Emulation_Debug

#5 lore raw

Hi,

Am 2016-04-05 09:11, schrieb Sven Eckelmann:

Quoted 7 lines · On Tuesday 05 April 2016 01:15:58 Linus Lüssing wrote:
Quoted 3 lines

Maybe you could set up a KVM instance and play a little with its code in there? Try out lists and spinlocks etc. in there without crashing the VM instance :).

There is also an easy example how to build an amd64 [1] VM image with many debug helpers enabled.

And my 2ct: user mode linux still exists - despite making no new headlines in the news - in current kernels. It might not be fit for developing PCI device drivers, but for networking code, it's quite nice. And you can just use gdb on it. It's all just a "make ARCH=um" away! You want 100 kernel instances communicating using batman-adv? No problem! Want a conditional breakpoint at some point in the code you don't yet have a grip on? Inspect stack when things went wrong? Just go ahead :-)

-hwh
(who actually did run 100 UML instances, using batman-adv, just for the fun of it - and to measure resulting "baseline" traffic)