Kernel Patching 6 - Sofware Freedom Day ROC 13
Transcript of Kernel Patching 6 - Sofware Freedom Day ROC 13
-
7/29/2019 Kernel Patching 6 - Sofware Freedom Day ROC 13
1/21
Your First Linux Kernel Patch
-
7/29/2019 Kernel Patching 6 - Sofware Freedom Day ROC 13
2/21
Kernel Programming Is Like SEX
Youre certain other people are doing it morethan you are.
-
7/29/2019 Kernel Patching 6 - Sofware Freedom Day ROC 13
3/21
Kernel Programming Is Like SEX
When you ask people with more experiencethan you, they avoid the conversation or theyquickly try to end the conversation (go away
kid, Im busy).
-
7/29/2019 Kernel Patching 6 - Sofware Freedom Day ROC 13
4/21
Kernel Programming Is Like SEX
Youre left to just figure it out on your ownand youre not sure what youve figured out isright.
-
7/29/2019 Kernel Patching 6 - Sofware Freedom Day ROC 13
5/21
Choose a host
We have 12 virtual machines
Username: sfd2013
Password: softwarefreedomday
suse{1,2,3}.mailicorn.com
rhel{1,2,3).mailicorn.com ubuntu{1,2,3}.mailicorn.com
amazon{1,2,3}.mailicorn.com
-
7/29/2019 Kernel Patching 6 - Sofware Freedom Day ROC 13
6/21
Installing git
See if git is already installed
user@linux:~$ which git
-
7/29/2019 Kernel Patching 6 - Sofware Freedom Day ROC 13
7/21
Installing git
As root, install git if needed.
# Fedora/CentOS/RHEL
user@linux:~# yum install git
# Debian/Ubuntuuser@linux:~# apt-get install git
mailto:user@linuxmailto:user@linux -
7/29/2019 Kernel Patching 6 - Sofware Freedom Day ROC 13
8/21
Configure yourself in git
Create your identity (goes in ~/.gitconfig)
user@linux:~# git config --global \
user.email [email protected]
user@linux:~# git config --global \user.name My Name
mailto:[email protected]:[email protected] -
7/29/2019 Kernel Patching 6 - Sofware Freedom Day ROC 13
9/21
Download net-next with git
Takes about 12 minutes at RIT
Installs into new subdirectory net-next
user@linux:~$ git clone \
git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git
Try git pull to ensure up to date
user@linux:~$ git pull
mailto:user@linuxmailto:user@linuxmailto:user@linuxmailto:user@linux -
7/29/2019 Kernel Patching 6 - Sofware Freedom Day ROC 13
10/21
Create a branch of your code
Declare a code branch your changes willbe recorded under
user@linux:~$ git branch devel
Then actually change to it
user@linux:~$ git checkout devel
Youre ready to make changes!
mailto:user@linuxmailto:user@linuxmailto:user@linuxmailto:user@linux -
7/29/2019 Kernel Patching 6 - Sofware Freedom Day ROC 13
11/21
Edit code and commit it
Do a cd net-next/drivers/net/ethernet
Edit code
When happy, do a git commit -a. Note:
the first line becomes your Subject linein the email, so choose it well.
-
7/29/2019 Kernel Patching 6 - Sofware Freedom Day ROC 13
12/21
One of the possible patches
How a device registers for interrupts can be confusingif there are more than two of them.
root@host:~# egrep "NE2000" /proc/interrupts
5: 1 0 IO-APIC-edge NE2000
7: 0 0 IO-APIC-edge NE2000
root@host:~#
Which one is which?
mailto:root@hostmailto:root@host -
7/29/2019 Kernel Patching 6 - Sofware Freedom Day ROC 13
13/21
The convention
The accepted style now is to register the device name(ie eth0) when requesting an interrupt withrequest_irq().
It would look like this:
root@host:~# egrep "NE2000" /proc/interrupts
5: 1 0 IO-APIC-edge eth0
7: 0 0 IO-APIC-edge eth1
root@host:~#
mailto:root@hostmailto:root@host -
7/29/2019 Kernel Patching 6 - Sofware Freedom Day ROC 13
14/21
Go forth and code
You gotta do some work, Im not gonna do this for you!
Look in the following files under drivers/net/ethernet:
3c515.c
ne.c
ni65.c
lance.c
hp100.c
de4x5.c
-
7/29/2019 Kernel Patching 6 - Sofware Freedom Day ROC 13
15/21
For the netdev mailing list, checkyour progress
The netdev kernel mailing list is one of a fewthat use the patchwork software to trackpatches semi-automatically. It is run by Dave
Miller
http://patchwork.ozlabs.org/project/netdev/list/
-
7/29/2019 Kernel Patching 6 - Sofware Freedom Day ROC 13
16/21
Generate the patch
Do a cd ~/net-next
Generate patch with
git format-patch --subject-prefix \
net-next --signoff master
A file is created starting with 0001-
-
7/29/2019 Kernel Patching 6 - Sofware Freedom Day ROC 13
17/21
Installing git-email
Try git send-email and if it fails, install thepackage as root.
# Fedora/CentOS/RHEL
user@linux:~# yum install git-email
# Debian/Ubuntu
user@linux:~# apt-get install git-email
mailto:user@linuxmailto:user@linux -
7/29/2019 Kernel Patching 6 - Sofware Freedom Day ROC 13
18/21
Configure git-email in ~/.gitconfig
Edit ~/.gitconfig with your email information
[sendemail]
smtpencryption = tls
smtpserver = smtp.gmail.com
smtpuser = [email protected]
smtpserverport = 587
smtppass = PASSWORD
-
7/29/2019 Kernel Patching 6 - Sofware Freedom Day ROC 13
19/21
Send a test email of the patch
Email the patch to an alternate personal emailas a test, because it automatically CCs youraddress in ~/.gitconfig.
user@linux:~$ git send-email [email protected] 0001-patchfile
mailto:user@linuxmailto:user@linux -
7/29/2019 Kernel Patching 6 - Sofware Freedom Day ROC 13
20/21
Submit the patch!
Consult the source tree MAINTAINERS file tofind where you should submit the patch.
user@linux:~$ git send-email [email protected] 0001-patchfile
mailto:user@linuxmailto:user@linux -
7/29/2019 Kernel Patching 6 - Sofware Freedom Day ROC 13
21/21
Questions on what we did?