e1000 드라이버 커널 패닉 문제

ihkwon23의 이미지

심심해서 커널 2.4에서 e1000 네트웍 드라이버에서 ip filtering 기능을 첨가하는 테스트 코드를 짜고 있는데.. 커널 패닉이 나는군요..

드라이버 코드를 보면 skb->protocol = eth_type_trans(skb, netdev);에서
ethernet header는 쉽게 까서 보는데..

ip hdr을 까면.. oops가 나는 이유를 모르겟네요.. 물론 ip 패킷만 날리고 이것을 받습니다.

간단히 넣은 코드는 다음과 같습니다.(e1000_main.c -> e1000_clean_rx_irq 함수)
skb->protocol = eth_type_trans(skb, netdev);

==> 여기서 부터..
if (sizeof(struct iphdr) > skb->len) {
dev_kfree_skb_irq(skb);
goto next_desc;
}

iph = skb->nh.iph;

if (iph->ihl < 5 || iph->version != 4) {
dev_kfree_skb_irq(skb);
goto next_desc;
}

if (iph->ihl*4 > skb->len) {
dev_kfree_skb_irq(skb);
goto next_desc;
}

if (iph->daddr != XXX) {
dev_kfree_skb_irq(skb);
goto next_desc;
}
==> 여기 까지 추가했습니다.

위 코드를 추가해서 테스트를 한 경우 패닉이 났고
skb_push, skb_pull, pskb_may_pull 등을 이용해도(ip_rcv함수 참고)..패닉이 나네요

oops 메시지도 콘솔에 일부만 나와서 다 확인 할 수도 없네요 ㅠ.ㅠ
드라이버 intr 함수에서 ip header를 못 볼 이유는 없을 듯한데..
답답하네요.. ^^

초보에게 힌트라도 하나 던져 주심 감사하겠습니다..끄응
그럼 미리 감솨 ..

merely_c의 이미지

ihkwon23 wrote:

iph = skb->nh.iph;

ip 인지 icmp 인지 arp 인지 구분하는게 필요할것 같습니다.
젤먼저 arp 날라 올테닌깐요..

정보공유는 자신감의 표현입니다

flyduck의 이미지

제 홈페이지에 같은 질문을 올리셨는데... 같은 대답을 :-)

우선 packet filtering이 목적이라면 netfilter를 이용하는게 더 바람직하다고 생각합니다.

ethernet driver에서 패킷을 분석하려고 한다면, RX시에 호출하는 eth_type_trans()는 ethernet header만 해석합니다. 즉 sk_buff에서 mac field만 유효하고, nh, h field은 유효하지 않습니다. 따라서 이를 접근하는 것은 잘못된 것입니다. 그리고 위의 분 말대로 패킷 헤더를 제대로 분석하지 않고 있습니다. 수신한 패킷이 IP 패킷인지 확인하려면 :

struct ethhdr *pethhdr = pskb->mac.ethernet;

if (pethhdr->h_proto == __constant_htons(ETH_P_IP)) {
   /* IP packet */
   struct iphdr *piphdr = (struct iphdr *) ((char *) pethhdr + sizeof(struct ethhdr));
}

Freedom is another word for nothing left to lose,
Nothing doesn't mean nothing if it ain't free.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.