Vincent Tech Blog

Friday, February 22, 2013

A c code I borrowed and modified to eat up cpu usage http://www.vcn.bc.ca/~vli/icontrol/schedrtcpu.c.txt
it is cool to automate F5 BIGIP software installation and configuration, here are a few scripts I wrote http://www.vcn.bc.ca/~vli/icontrol/
wow, three years past. time to update my tech blog again, here is some of my kernel code patches relate to my work http://www.vcn.bc.ca/~vli/Vincent_Kernel.patch.txt

Tuesday, January 19, 2010

My home OpenBSD interVLAN routing and Cisco 2900 vlan trunking

On OPenBSD

# cat /etc/hostname.sis1 /etc/hostname.vlan3 /etc/hostname.vlan4
inet 192.168.2.1 255.255.255.0 192.168.2.255

vlan 3 vlandev sis1
description "DMZ"
inet 192.168.3.1 255.255.255.0
up

vlan 4 vlandev sis1
description "VOIP"
inet 192.168.4.1 255.255.255.0
up
#

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
Switch#

Friday, January 15, 2010

Kernel UTS Release version mismatch problem

I could always build custom mainline git kernel from ubuntu following the https://wiki.ubuntu.com/KernelTeam/GitKernelBuild 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:
"2.6.33-rc3-test"
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 versions_var.mk file which should be located in /usr/share/kernel-package/ruleset/misc/, I tried that modified versions_var.mk file, it worked, so what is the problem, let's what is patched with versions_var.mk:

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

-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 \
grep 'define UTS_RELEASE' $(UTS_RELEASE_HEADER) | \
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:

http://patchwork.kernel.org/patch/54595/

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:


https://issues.asterisk.org/file_download.php?file_id=24698&type=bug


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.

Thanks!
(0103048)

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:

/var/lib/asterisk/mp3/1.mp3
/var/lib/asterisk/mp3/2.mp3
/var/lib/asterisk/mp3/3.mp3
..........
/var/lib/asterisk/mp3/n.mp3

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

find /path/to/your-mp3-file -type file *.mp3 > playlist.m3u
#############
(0103049)
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 :-)
(0106495)
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 1.6.3.0 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!
(0114777)

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.
(0114784)

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!
(0114787)
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
Patches:
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 :-)

http://marc.info/?t=125011994400002&r=1&w=2


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,
mmput(mm);
}
put_task_struct(task);
- if (end - buffer == 0)
- return -EIO;
- return end - buffer;
+
+ return count;
}

const struct file_operations proc_clear_refs_operations = {

Followers