Vincent Tech Blog

Friday, February 22, 2013

A c code I borrowed and modified to eat up cpu usage
it is cool to automate F5 BIGIP software installation and configuration, here are a few scripts I wrote
wow, three years past. time to update my tech blog again, here is some of my kernel code patches relate to my work

Tuesday, January 19, 2010

My home OpenBSD interVLAN routing and Cisco 2900 vlan trunking


# cat /etc/hostname.sis1 /etc/hostname.vlan3 /etc/hostname.vlan4

vlan 3 vlandev sis1
description "DMZ"

vlan 4 vlandev sis1
description "VOIP"

On Cisco 2900

Switch#show vlan brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/5, Fa0/6, Fa0/7, Fa0/9,
Fa0/10, Fa0/11, Fa0/12, Fa0/13,
Fa0/14, Fa0/15, Fa0/16, Fa0/17,
Fa0/18, Fa0/19, Fa0/20, Fa0/21,
Fa0/22, Fa0/23, Fa0/24
2 VLAN0002 active Fa0/2
3 DMZ active Fa0/3, Fa0/4
4 VOIP active Fa0/8
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active

Friday, January 15, 2010

Kernel UTS Release version mismatch problem

I could always build custom mainline git kernel from ubuntu following the wiki link, but since kernel 2.6.33 release, it always complains with error like:

exec debian/rules DEBIAN_REVISION=2.6.33-rc3-test-10.00.Custom APPEND_TO_VERSION=-test kernel_image
/usr/bin/make -f ./debian/rules debian/stamp/binary/pre-linux-image-2.6.33-rc3-test
make[1]: Entering directory `/home/vincent/linux-2.6.git'
====== making target debian/stamp/install/linux-image-2.6.33-rc3-test [new prereqs: ]======
This is kernel package version 11.015.
echo "The UTS Release version in include/linux/version.h"; echo " \"\" "; echo "does not match current version:"; echo " \"2.6.33-rc3-test\" "; echo "Please correct this."; exit 2
The UTS Release version in include/linux/version.h
does not match current version:
Please correct this.
make[1]: *** [debian/stamp/install/linux-image-2.6.33-rc3-test] Error 2
make[1]: Leaving directory `/home/vincent/linux-2.6.git'
make: *** [kernel_image] Error 2

I asked this packaging error on ubuntu-kernel irc channel, someone pointed out that it is a bug of kernel-package and paste a sample working file which should be located in /usr/share/kernel-package/ruleset/misc/, I tried that modified file, it worked, so what is the problem, let's what is patched with

root@kernalhack:/home/vincent# diff -u /usr/share/kernel-package/ruleset/misc/
--- 2010-01-12 11:08:24.000000000 -0800
+++ /usr/share/kernel-package/ruleset/misc/ 2010-01-15 21:37:44.000000000 -0800
@@ -138,11 +138,13 @@

-UTS_RELEASE_HEADER=$(call doit,if [ -f include/linux/utsrelease.h ]; then \
- echo include/linux/utsrelease.h; \
- else \
- echo include/linux/version.h ; \
- fi)
+UTS_RELEASE_HEADER=$(call doit, if [ -f include/generated/utsrelease.h ]; then \
+ echo include/generate/utsrelease.h; \
+ elif [ -f include/linux/utsrelease.h ]; then \
+ echo include/linux/utsrelease.h; \
+ else \
+ echo include/linux/version.h ; \
+ fi)
UTS_RELEASE_VERSION=$(call doit,if [ -f $(UTS_RELEASE_HEADER) ]; then \
perl -nle 'm/^\s*\#define\s+UTS_RELEASE\s+("?)(\S+)\1/g && print $$2;';\

Simply adding the include/generated/utsrelease.h file test solved the problem, where this include/generated directory come from then? here I found the kernel Kbuild patch series which added include/generated:

I am still not sure how kernel kbuild works, need to dig more.

Saturday, December 5, 2009

My asterisk patch got accepted

This is mostly for my kernel blog, but I feel occasionally some non-kernel work are good to be here too :-). After long-waiting, finally My first Asterisk patch got accepted:

lmadsen (administrator)
2009-04-09 10:44
License accepted! This looks like it could be useful :)

lmadsen (administrator)
2009-04-09 10:46

Don't forget to update the documentation either. If it is not already in XML format, that would also be an ideal change, but for now, you will need to update the docs in the code so that people at least know you can either pass it a file, or a playlist filename.


macli (reporter)
2009-04-09 15:58

I added some documentation in XML format, second patch app_mp3.diff uploaded
I will add note here describing how to play m3u playlist file :-)

dialplan will look like this:
exten => 1234,1,Answer()
exten => 1234,n,MP3Player(/var/lib/asterisk/mp3/playlist.m3u)

and the playlist.m3u will be like this:


It is easy to generate mp3 playlist file with .m3u, do the following:

find /path/to/your-mp3-file -type file *.mp3 > playlist.m3u
macli (reporter)
2009-04-09 16:11

the second patch seems have one single long line, I uploaded third patch app_mp3.diff1 to comform to code guide line :-)
lmadsen (administrator)
2009-06-16 14:01

This is a new feature, so it can only go into trunk, but I'm marking this as targeted for in the hopes we can get it merged in sooner rather than later. I will also set the status to Ready for Testing in the hopes we can get some other testers. Thanks!

dvossel (administrator)
2009-12-04 12:20

macli, I don't understand some of your changes. I uploaded a patch that strips out some some of the stuff that didn't seem necessary to me. Let me know what you think. The main thing I didn't understand was why you used the argument parser for a single argument and modified the http mpg321 code. It's still your work of coarse and will be documented as such when it is committed.

macli (reporter)
2009-12-04 13:40
Hi dvossel, I added the argument parser only for learning purpose, I do not remember exactly why I modifed mpg321 code, maybe it is related to some problem while playing some live online music list. Please go ahead using your simple solution, thanks!
svnbot (reporter)
2009-12-04 14:27

Repository: asterisk
Revision: 233234

U trunk/apps/app_mp3.c

r233234 | dvossel | 2009-12-04 14:27:38 -0600 (Fri, 04 Dec 2009) | 9 lines

.m3u support for Mp3Player app

(closes issue 0014823)
Reported by: macli
app_mp3.diff1 uploaded by macli (license )
Tested by: macli, dvossel

Friday, August 14, 2009

My patch to pagemap clear_refs

I posted one trivial patch to fix the user input and got accepted in Andrew Morton's mm test tree, Oh yeah, This is my first kernel patch and it got accepted, that is encouraging and making me feel contributing more :-)

fs/proc/task_mmu.c v1: fix clear_refs_write() input sanity check

v1 fix the compiling errors and keep the type variable name.

Andrew Morton pointed out similar string hacking and obfuscated check for zero-length input
at the end of the function, David Rientjes suggested to use strict_strtol to replace
simple_strtol, this patch cover above suggestions, add removing of leading and trailing
whitespace from user input. It does not change function behavious.

This patch is rebased on mmotm-2009-08-04-14-22.

Signed-off-by: Vincent Li

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index f884ad4..2a1bef9 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -492,21 +492,20 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
struct task_struct *task;
- char buffer[PROC_NUMBUF], *end;
+ char buffer[PROC_NUMBUF];
struct mm_struct *mm;
struct vm_area_struct *vma;
- int type;
+ long type;

memset(buffer, 0, sizeof(buffer));
if (count > sizeof(buffer) - 1)
count = sizeof(buffer) - 1;
if (copy_from_user(buffer, buf, count))
return -EFAULT;
- type = simple_strtol(buffer, &end, 0);
+ if (strict_strtol(strstrip(buffer), 10, &type))
+ return -EINVAL;
if (type < CLEAR_REFS_ALL || type > CLEAR_REFS_MAPPED)
return -EINVAL;
- if (*end == '\n')
- end++;
task = get_proc_task(file->f_path.dentry->d_inode);
if (!task)
return -ESRCH;
@@ -542,9 +541,8 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
- if (end - buffer == 0)
- return -EIO;
- return end - buffer;
+ return count;

const struct file_operations proc_clear_refs_operations = {