기본 콘텐츠로 건너뛰기

Using netfilter in a multi-threaded program


This was very helpful.

However I think I'm not quite to the end of this path yet.

I have the following rules in the mangle section of my iptables:

iptables -t mangle -A PREROUTING -p tcp --dport 9999 -j NFQUEUE
--queue-balance 0:1
iptables -t mangle -A PREROUTING -p tcp --sport 9999 -j NFQUEUE
--queue-balance 0:1

I create 2 threads.Each thread does a nfq_open.  So far so good.
Thread 1 has his nfq_handle and thread 2 has his nfq_handle. Thread 1
does a nfq_create_queue on queue 0, and Thread 2 does a
nfq_create_queue on queue 1.

Each thread then opens a netlink handle.  Each thread does this
independently with the handle returned from nfq_open. Each thread gets
an independent fd.

When I run, only one thread receives traffic (queue 0 on thread #1).
I am using iperf -P 8 for example (8 simultaneous
threads/connections).

Frankly I must be missing something since I don't see any relationship
between the result of nfq_create_queue (which presumably binds to the
queue number given in the second argument), and the file descriptor we
get from nfnl_fd (unless there is a side-effect of this routine to
bind the queue ID to the nfq_handle!).  I can sort of see how
nfq_handle_packet will make that association (presumably the queue #
is squirreled away in some piece of state and that finds the right
callback, etc.).

I think I've misunderstood the basic structure, especially with
respect to what should be in a thread.  Or perhaps my complete naivete
on iptables means I've screwed up that configuration.

So either I've set my stuff up wrong (you can see the code below), or
the iptables stuff isn't really distributing the requests across
queues, or some of both

자세한 사항 (소스 포함)

http://www.spinics.net/lists/netfilter/msg54528.html

댓글

이 블로그의 인기 게시물

톰캣 세션 타임 아웃 설정

web.xml 파일이 있습니다. 이 파일을 열어서 session이라고 검색해 보십시오. <session-config>   <session-timeout>360</session-timeout> </session-config> 위 단락을 찾을 수 있습니다. session-timeout 시간 360이 바로 자동로그아웃 세션 시간입니다.  단위는 분이고요. 30분으로 하고 싶으시면 30으로 바꿔서 저장해주시면 되는 것이죠~ Tomcat 내에서 Session Timeout 를 설정하는 우선 순위가 존재 한다. session.setMaxInactiveInterval() 프로그램내에서 time out 를 설정했을 경우 Web application 내의 WEB-INF/web.xml Tomcat 내의 conf/web.xml 실제로 Tomcat(conf/web.xml)내에 Default 로 설정되어 있는 것은 다음과 같다. < HttpSession 메서드 > getCreationTime() - 세션 생성 시간 getLastAccessedTime() - 마지막 요청 시간 setMaxInactiveInterval() - 최대허용시간 설정 (초) getMaxInactiveInterval() - 최대허용시간 invalidate() - 세션 제거 < 타임아웃 설정하기 > - 일정 시간 동안 요청이 없으면 세션을 제거한다  1. DD에서 전체 세션 타임아웃 설정       web.xml 1. DD에서 전체 세션 타임아웃 설정       web.xml <web-app ... >     <servlet>          ...     </servlet>     <session-config>         <session-timeout>30</session-timeout>

dmesg 메시지 실시간으로 보기

참조사이트 http://imitator.kr/Linux/556 # tail -f /var/log/messages # tail -f |dmesg //기본 2초 단위로 갱신 된다. # watch "dmesg | tail -f" //1초 단위로 갱신하면서 보여준다. # watch -n 1 "dmesg | tail -f" // 보여주는 줄을 20으로 늘린다. (기본 10줄) # watch -n 1 "dmesg | tail -f -n 20"

kernel Hello World

리눅스 커널 모듈 프로그래밍 가이드 참조:http://www.tldp.org/LDP/lkmpg/2.6/html/lkmpg.html 커널 모듈 가이드 아래 테스트는 우분투 14.04에서 테스트 되었습니다. 모듈 유틸리티 insmod:모듈을 커널에 적재한다. rmmod:커널에서 모듈을 제거한다. lsmod:커널에서 적재된 모듈 목록을 보여준다. depmod: 모듈간 의존성 정보를 생성한다. modprobe:모듈을 커널에 적재하거나 제거한다. modinfo rdma_ucm 모듈 정보 보기: #lsmod #cat /etc/modprobe.conf #modinfo ib_core 커널에서 제공하는 심볼 테이블 :커널 내부의 함수나 변수 중 외부에서 참조할 수 있는 함수의 심볼과 주소를 담은 테이블 #cat /proc/kallsyms 커널 모듈 제작해 보기 kernel ver 3.16 hello.c /*  *  hello.c - The simplest kernel module.  */ # #include <linux/module.h> #include <linux/kernel.h> int init_module(void) { printk("<1>Hello World 1.\n"); return 0; } void cleanup_module(void) { printk(KERN_ALERT "Goodbye world 1.\n"); } Makefile obj-m += hello.o all:         make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules clean:         make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean #make make -C /lib/modules/3