imq / linuximq

Pseudo-driver for the intermediate queue device.
https://imq.github.io/
GNU General Public License v2.0
99 stars 51 forks source link

Fix the hang issue and add the 4.0.x patch #9

Closed gfreewind closed 9 years ago

gfreewind commented 9 years ago

Hi,

There are two problems in the old codes.

  1. The kernel/v3.x/linux-3.18-imq.diff could not be applied successfully after your change. I just fix it. The patch reports "xxx lines is malformed";
  2. Fix the system hang caused by skb_popd enhancement. It is triggered by that the imq rule is configured in localout hook with process context. I did not consider about this case. The 3.18 patch file has the same issue.
gfreewind commented 9 years ago

The fix has passed my tests.

coolex commented 9 years ago

Hi, I try it too and patch on Gentoo kernel 4.0.5 works fine...

update: after qdisc restart kernel crash...

gfreewind commented 9 years ago

Ok. Then please accept the pull request after tests

gfreewind commented 9 years ago

I have fixed the crash issue.

I think you should configure the imq rule in localout hook. It is the process context.

I didn't consider about this case before, and it is not used in my env.

micron10 commented 9 years ago

hi Feng i not find patch for kernel 4.0.0 please post link

----edit----

i found patch and now start build and test

gfreewind commented 9 years ago

Hi micron, you could use my fork link https://github.com/gfreewind/linuximq/blob/master/kernel/v4.x/linux-4.0-imq.diff

gfreewind commented 9 years ago

Hi Micron,

The 4.x patch file is not accepted by imq, so you could use my fork link above firstly

-------------- edit ---------------------------

I am waiting for your tests result:)

coolex commented 9 years ago

Hi gfreewind, now I was testing your last patch on Gentoo kernel 4.0.5.

with this easy script it works fine:

!/bin/bash

ip link set imq0 up ip link set imq1 up tc qdisc add dev imq0 root handle 1: htb default 2 tc qdisc add dev imq1 root handle 1: htb default 2 tc filter add dev imq0 parent 1: protocol ip u32 tc filter add dev imq1 parent 1: protocol ip u32 tc class add dev imq0 parent 1: classid 1:1 htb rate 50Mbit tc class add dev imq1 parent 1: classid 1:1 htb rate 50Mbit tc class add dev imq0 parent 1:1 classid 1:2 htb rate 1Kbit ceil 8Kbit prio 8 quantum 1514 tc class add dev imq1 parent 1:1 classid 1:2 htb rate 1Kbit ceil 8Kbit prio 8 quantum 1514

tc class add dev imq0 parent 1:1 classid 1:5 htb rate 1Kbit ceil 50Mbit prio 5 quantum 1515 tc class add dev imq1 parent 1:1 classid 1:5 htb rate 1Kbit ceil 50Mbit prio 5 quantum 1515 tc class add dev imq0 parent 1:5 classid 1:a htb rate 1Kbit ceil 1Mbit prio 5 quantum 1515 tc class add dev imq1 parent 1:5 classid 1:a htb rate 1Kbit ceil 5Mbit prio 5 quantum 1515

tc filter add dev imq0 parent 1: protocol ip prio 1 handle 2: u32 divisor 256 tc filter add dev imq1 parent 1: protocol ip prio 1 handle 2: u32 divisor 256 tc filter add dev imq0 protocol ip parent 1: prio 1 u32 ht 800:: match ip src 10.17.0.0/16 hashkey mask 0x0000ff00 at 12 link 2: tc filter add dev imq1 protocol ip parent 1: prio 1 u32 ht 800:: match ip dst 10.17.0.0/16 hashkey mask 0x0000ff00 at 16 link 2: tc filter add dev imq0 parent 1: protocol ip prio 1 handle 3: u32 divisor 256 tc filter add dev imq1 parent 1: protocol ip prio 1 handle 3: u32 divisor 256 tc filter add dev imq0 protocol ip parent 1: prio 1 u32 ht 2:fe match ip src 10.17.254.0/24 hashkey mask 0x000000ff at 12 link 3: tc filter add dev imq1 protocol ip parent 1: prio 1 u32 ht 2:fe match ip dst 10.17.254.0/24 hashkey mask 0x000000ff at 16 link 3: iptables -N acl-ipv4-10.17.254-src iptables -A FORWARD -s 10.17.254.0/24 -j acl-ipv4-10.17.254-src iptables -A acl-ipv4-10.17.254-src -j DROP

tc filter add dev imq0 protocol ip parent 1: prio 5 u32 ht 3:1: match ip src 10.17.254.1/32 flowid 1:a tc filter add dev imq1 protocol ip parent 1: prio 5 u32 ht 3:1: match ip dst 10.17.254.1/32 flowid 1:a iptables -I acl-ipv4-10.17.254-src -s 10.17.254.1 -j ACCEPT iptables -t mangle -A PREROUTING -i eth2 -j IMQ --todev 0 iptables -t mangle -A POSTROUTING -o eth2 -j IMQ --todev 1

bud I found situation when kernel crash: 1) interfaces are UP 2) qdiscs, class and filters are ON (the script) 3) and when i try shutdown interfaces before remove qdiscs every time kernel crash with this:

Jun 19 10:38:25 igw /etc/init.d/net.eth2[3871]: net.eth2: caught SIGINT, aborting Jun 19 10:38:40 igw kernel: INFO: rcu_sched self-detected stall on CPU { 3} (t=60000 jiffies g=1491 c=1490 q=0) Jun 19 10:38:40 igw kernel: Task dump for CPU 3: Jun 19 10:38:40 igw kernel: kworker/3:1 R running task 13512 1452 2 0x00080008 Jun 19 10:38:40 igw kernel: Workqueue: ipv6_addrconf addrconf_dad_work Jun 19 10:38:40 igw kernel: ffffffff81c35940 ffff88013fcc3da8 ffffffff810655bc 0000000000000003 Jun 19 10:38:40 igw kernel: ffffffff81c35940 ffff88013fcc3dc8 ffffffff81068158 ffff88013fcc3e08 Jun 19 10:38:40 igw kernel: 0000000000000004 ffff88013fcc3df8 ffffffff81083cb0 ffff88013fcd2d40 Jun 19 10:38:40 igw kernel: Call Trace: Jun 19 10:38:40 igw kernel: [] sched_show_task+0xcc/0x130 Jun 19 10:38:40 igw kernel: [] dump_cpu_task+0x38/0x40 Jun 19 10:38:40 igw kernel: [] rcu_dump_cpu_stacks+0x90/0xd0 Jun 19 10:38:40 igw kernel: [] rcu_check_callbacks+0x413/0x750 Jun 19 10:38:40 igw kernel: [] update_process_times+0x34/0x60 Jun 19 10:38:40 igw kernel: [] tick_sched_handle.isra.19+0x31/0x40 Jun 19 10:38:40 igw kernel: [] tick_sched_timer+0x3c/0x70 Jun 19 10:38:40 igw kernel: [] run_hrtimer.isra.34+0x41/0xf0 Jun 19 10:38:40 igw kernel: [] hrtimer_interrupt+0xc5/0x1e0 Jun 19 10:38:40 igw kernel: [] local_apic_timer_interrupt+0x34/0x60 Jun 19 10:38:40 igw kernel: [] smp_apic_timer_interrupt+0x3c/0x60 Jun 19 10:38:40 igw kernel: [] apic_timer_interrupt+0x6a/0x70 Jun 19 10:38:40 igw kernel: [] ? _raw_spin_lock_bh+0x27/0x30 Jun 19 10:38:40 igw kernel: [] imq_nf_queue+0x1fd/0x600 Jun 19 10:38:40 igw kernel: [] imq_nf_queue+0x1a4/0x370 Jun 19 10:38:40 igw kernel: [] ? ip6table_mangle_hook+0x66/0x150 [ip6table_mangle] Jun 19 10:38:40 igw kernel: [] nf_queue+0x13d/0x180 Jun 19 10:38:40 igw kernel: [] ? netif_device_attach+0x70/0x70 Jun 19 10:38:40 igw kernel: [] nf_hook_slow+0xb6/0x150 Jun 19 10:38:40 igw kernel: [] ? netif_device_attach+0x70/0x70 Jun 19 10:38:40 igw kernel: [] ip6_finish_output2+0x326/0x430 Jun 19 10:38:40 igw kernel: [] ? nf_iterate+0x8a/0xa0 Jun 19 10:38:40 igw kernel: [] ip6_finish_output+0x8f/0xe0 Jun 19 10:38:40 igw kernel: [] nf_reinject+0x61/0x160 Jun 19 10:38:40 igw kernel: [] ? ip6_fragment+0xad0/0xad0 Jun 19 10:38:40 igw kernel: [] imq_dev_xmit+0x8d/0xd0 Jun 19 10:38:40 igw kernel: [] dev_hard_start_xmit+0x8d/0x350 Jun 19 10:38:40 igw kernel: [] __imq_nf_queue+0x1ea/0x600 Jun 19 10:38:40 igw kernel: [] imq_nf_queue+0x1a4/0x370 Jun 19 10:38:40 igw kernel: [] ? ip6table_mangle_hook+0x66/0x150 [ip6table_mangle] Jun 19 10:38:40 igw kernel: [] nf_queue+0x13d/0x180 Jun 19 10:38:40 igw kernel: [] ? ip6_fragment+0xad0/0xad0 Jun 19 10:38:40 igw kernel: [] nf_hook_slow+0xb6/0x150 Jun 19 10:38:40 igw kernel: [] ? ip6_fragment+0xad0/0xad0 Jun 19 10:38:40 igw kernel: [] ? compat_ipv6_setsockopt+0xf0/0xf0 Jun 19 10:38:40 igw kernel: [] ip6_output+0x6e/0xc0 Jun 19 10:38:40 igw kernel: [] ndisc_send_skb+0x216/0x290 Jun 19 10:38:40 igw kernel: [] ndisc_send_ns+0xc3/0x110 Jun 19 10:38:40 igw kernel: [] addrconf_dad_work+0x21f/0x310 Jun 19 10:38:40 igw kernel: [] process_one_work+0x133/0x360 Jun 19 10:38:40 igw kernel: [] worker_thread+0x119/0x440 Jun 19 10:38:40 igw kernel: [] ? rescuer_thread+0x2f0/0x2f0 Jun 19 10:38:40 igw kernel: [] kthread+0xc4/0xe0 Jun 19 10:38:40 igw kernel: [] ? kthread_create_on_node+0x170/0x170 Jun 19 10:38:40 igw kernel: [] ret_from_fork+0x58/0x90 Jun 19 10:38:40 igw kernel: [] ? kthread_create_on_node+0x170/0x170

gfreewind commented 9 years ago

Hi coolex,

"when i try shutdown interfaces before remove qdiscs every time kernel crash with this:"

How do you shutdown the interfaces? Could you paste the command please? Then I could how it works and which interfaces

BTW, is it ok if you shutdown the interfaces before remove imq rule without my enhancement?

coolex commented 9 years ago

1) /opt/shaper.sh start (script above) 2) ifconfig eth2 down 3) ifconfig eth2 up

I try same situation on kernel 3.14.21 + imq and it works fine.

gfreewind commented 9 years ago
  1. Which imq patch are you using based on 3.14 ? The old one or with my enhancement?
  2. You did not shutdown the imq device?
gfreewind commented 9 years ago

Now I made another fix according to your description to avoid it crash when interface is down before rule is removed.

Please try it.

The link https://github.com/gfreewind/linuximq/blob/master/kernel/v4.x/linux-4.0-imq.diff

micron10 commented 9 years ago

Now test new patch with this fix. Other fix work great.

After coolex confirmed fix with interface up/down whether you will be able to do it for kernel 4.1?

m.

gfreewind commented 9 years ago

Hi m,

Thanks your tests.

I will continue working on the imq.

But there are too many commits pending which are not merged now.

So I will do it after accept my pull requests.

micron10 commented 9 years ago

oki i wait no problem

if I can fix it, I will write you and will give you a link.

gfreewind commented 9 years ago

Hi m,

OK. Maybe I will commit to my fork repository https://github.com/gfreewind/linuximq. You could watch it too.

coolex commented 9 years ago

gfreewind, on kernel 3.14.21 i had old one https://github.com/imq/linuximq/blob/master/kernel/v3.x/gentoo/linux-3.13.10_hardened_gentoo.diff

gfreewind commented 9 years ago

Hi coolex,

thank you.

But I did one performance enhancement from 3.14, it could enhance the IMQ performance about 20%

gfreewind commented 9 years ago

Hi m,

The 4.1 is not released now. Are you urgent to get it really?

coolex commented 9 years ago

I know, I will try test all your patches and give you results....

Dne 19/06/15 v 13:27 Feng Gao napsal(a):

Hi coolex,

thank you.

But I did one performance enhancement from 3.14, it could enhance the IMQ performance about 20%

— Reply to this email directly or view it on GitHub https://github.com/imq/linuximq/pull/9#issuecomment-113482937.

gfreewind commented 9 years ago

Thanks coolex:)

gfreewind commented 9 years ago

Hi Coolex & m,

Could you give me a star (my fork repository) please if you like my enhancement?

micron10 commented 9 years ago

Hi Feng i know but next monday is a release date for kernel 4.1 and i start test system with new kernel to test stabel . best regards, m.

IPacct ltd. Micron On Jun 19, 2015 2:28 PM, "Feng Gao" notifications@github.com wrote:

Hi m,

The 4.1 is not released now. Are you urgent to get it really?

— Reply to this email directly or view it on GitHub https://github.com/imq/linuximq/pull/9#issuecomment-113483216.

gfreewind commented 9 years ago

Hi MihaiC,

The 4.0 patch is ok now. Could you accept the pull request?

gfreewind commented 9 years ago

Hi all,

The 4.1 initial patch is ready. Frankly i could not test it because the 4.1 is not released really.

imq commented 9 years ago

Done, I've added the patch. Thanks.

gfreewind commented 9 years ago

Hi imq,

Welcome. I will continue enhancing the imq because i am using it too.