How to make changes to mac80211 source and then rebuild

I am newbie to Linux kernel and its development. I need to know how to make changes to the Linux mac80211 module before generating the OpenWRT firmware for my router. I found the source code under the directory /Linux-version/net/mac80211/ that I need for modification i.e. mesh.c, mesh_hwmp etc.

I can successfully build and generate OpenWRT firmware for my router but unable to find the exact procedure of making changes to the kernel source code before the build.

Could anyone please enlist the steps for making changes to mac80211 source and then quickly recompile and rebuild it in the context of OpenWRT.

You'll have to patch ~/package/kernel/mac80211

Thank you for the reply.

Since the OpenWRT build process download the tarball of Linux kernel source and then uncompressed it in the local ‘build_root/target_arch..’ directory. Is there exist any way of directly modifying the already downloaded source code in the build directly just like we modify normal C files and recompile.

I have one more question regarding kernel source code modification through patches.

What is the common practice used by Linux kernel developers for incorporating new functionality like adding a new MAC layer rate-control algorithm? Is it provided with patches or direct source code modification?

Until your stuff is accepted upstream, you add in patches. OpenWrt's framework is designed to handle patches by default so upstream code can be used and kept up to date easily.

The clean way to do what you want is adding your own modifications to package/kernel/mac80211/patches/. You can edit the source code directly, generate a patch and place it in the path above.