Giter Club home page Giter Club logo

level-ip's Introduction

Level-IP Build Status

Level-IP is a Linux userspace TCP/IP stack, implemented with TUN/TAP devices.

The main goals are to:

  • Learn TCP/IP
  • Learn Linux systems/network programming
  • Learn Linux Socket API

The results of the learning experience will be accompanied by explanatory blog posts:

See Getting Started.

For development documentation, start with Development.

Reference works

License

See LICENSE.md (MIT)

level-ip's People

Contributors

johnlonganecker avatar robo-bob avatar saminiir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

level-ip's Issues

there may be some problem with tcp checksum!

I spend several weeks read and debug the code, and I had learned a lot, thanks.

And I spend a lot of time in debuging tcp tree-way handshark, I tested a lot, and today I finally got the result I want, and I find the problem:

in tcp.c -->tcp_udp_checksum --> line 95 sum += htons(proto);
should it be sum += proto ?

when checksum is wrong,and the system will discard the package, I send a lot of syn to tap0, and tap0 didn't response to me, and I use wireshark capture the package, and find the checksum was wrong, and today I fixed the checksum bug, and tap0 send ack and syn to me.

my english is poor.hope you can understand the meaning I want to express.

hello there, it's very confused here

int socket_rd_acquire(struct socket *sock)
{
int rc = pthread_rwlock_wrlock(&sock->lock);
sock->refcnt++;
return rc;
}

int socket_wr_acquire(struct socket *sock)
{
int rc = pthread_rwlock_wrlock(&sock->lock);
sock->refcnt++;
return rc;
}

int socket_release(struct socket *sock)
{
int rc = 0;
sock->refcnt--;

if (sock->refcnt == 0) {
    rc = pthread_rwlock_unlock(&sock->lock);
    free(sock);
} else {
    rc = pthread_rwlock_unlock(&sock->lock);
}

return rc;

}

Race condition in tcp_linger

Describe your issue

Running the binary with ASan, there's a recurrent threading error in the socket_free and tcp_linger logic.

==27410==ERROR: AddressSanitizer: heap-use-after-free on address 0x615000228100 at pc 0x0041dbfa75a2 bp 0x7f0dd603ae40 sp 0x7f0dd603ae30
READ of size 8 at 0x615000228100 thread T27389
    #0 0x41dbfa75a1 in tcp_linger src/tcp.c:393
    #1 0x7f435e89a048 in start_thread (/usr/lib/libpthread.so.0+0x7048)
    #2 0x7f435e5daf0e in clone (/usr/lib/libc.so.6+0xedf0e)

0x615000228100 is located 0 bytes inside of 496-byte region [0x615000228100,0x6150002282f0)
freed by thread T27374 here:
    #0 0x7f435eb8f4c8 in __interceptor_free /build/gcc-multilib/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:45
    #1 0x41dbfa2a6d in inet_free src/inet.c:180
    #2 0x41dbf9ec08 in socket_free src/socket.c:44
    #3 0x41dbf9f03b in socket_garbage_collect src/socket.c:67
    #4 0x7f435e89a048 in start_thread (/usr/lib/libpthread.so.0+0x7048)

previously allocated by thread T27009 here:
    #0 0x7f435eb8f860 in __interceptor_malloc /build/gcc-multilib/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:62
    #1 0x41dbfa507f in tcp_alloc_sock src/tcp.c:111
    #2 0x41dbfa9772 in sk_alloc src/sock.c:9
    #3 0x41dbfa20e3 in inet_create src/inet.c:58
    #4 0x41dbf9fb09 in _socket src/socket.c:184
    #5 0x41dbfb1a16 in ipc_socket src/ipc.c:175
    #6 0x41dbfb459c in demux_ipc_socket_call src/ipc.c:405
    #7 0x41dbfb47fc in socket_ipc_open src/ipc.c:446
    #8 0x7f435e89a048 in start_thread (/usr/lib/libpthread.so.0+0x7048)

Thread T27389 created by T2 here:
    #0 0x7f435eae8a3f in __interceptor_pthread_create /build/gcc-multilib/src/gcc/libsanitizer/asan/asan_interceptors.cc:243
    #1 0x41dbfbe794 in timers_tick src/timer.c:74
    #2 0x41dbfbef2e in timers_start src/timer.c:179
    #3 0x7f435e89a048 in start_thread (/usr/lib/libpthread.so.0+0x7048)

Thread T2 created by T0 here:
    #0 0x7f435eae8a3f in __interceptor_pthread_create /build/gcc-multilib/src/gcc/libsanitizer/asan/asan_interceptors.cc:243
    #1 0x41dbfb59af in create_thread src/main.c:30
    #2 0x41dbfb5d0d in run_threads src/main.c:86
    #3 0x41dbfb5efa in main src/main.c:131
    #4 0x7f435e50d4c9 in __libc_start_main (/usr/lib/libc.so.6+0x204c9)

Thread T27374 created by T2 here:
    #0 0x7f435eae8a3f in __interceptor_pthread_create /build/gcc-multilib/src/gcc/libsanitizer/asan/asan_interceptors.cc:243
    #1 0x41dbfbe794 in timers_tick src/timer.c:74
    #2 0x41dbfbef2e in timers_start src/timer.c:179
    #3 0x7f435e89a048 in start_thread (/usr/lib/libpthread.so.0+0x7048)

Thread T27009 created by T3 here:
    #0 0x7f435eae8a3f in __interceptor_pthread_create /build/gcc-multilib/src/gcc/libsanitizer/asan/asan_interceptors.cc:243
    #1 0x41dbfb4bb9 in start_ipc_listener src/ipc.c:517
    #2 0x7f435e89a048 in start_thread (/usr/lib/libpthread.so.0+0x7048)

Thread T3 created by T0 here:
    #0 0x7f435eae8a3f in __interceptor_pthread_create /build/gcc-multilib/src/gcc/libsanitizer/asan/asan_interceptors.cc:243
    #1 0x41dbfb59af in create_thread src/main.c:30
    #2 0x41dbfb5d21 in run_threads src/main.c:87
    #3 0x41dbfb5efa in main src/main.c:131
    #4 0x7f435e50d4c9 in __libc_start_main (/usr/lib/libc.so.6+0x204c9)

SUMMARY: AddressSanitizer: heap-use-after-free src/tcp.c:393 in tcp_linger
Shadow bytes around the buggy address:
  0x0c2a8003cfd0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2a8003cfe0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2a8003cff0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2a8003d000: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2a8003d010: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c2a8003d020:[fd]fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c2a8003d030: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c2a8003d040: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c2a8003d050: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fa fa
  0x0c2a8003d060: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2a8003d070: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==27410==ABORTING

can NOT compile the code successfully

I followed the instructions in readme file.
when executing make all , many error-messages come into screen .
so ...
could you tell me about your environment when compiling code , pls ?

e.g what is the version of your gcc ?
c99 or gnu99 or else ?

thanX!

  • OS (e.g. cat /etc/os-release):
    NAME="CentOS Linux"
    VERSION="7 (Core)"
    ID="centos"
    ID_LIKE="rhel fedora"
    VERSION_ID="7"
    PRETTY_NAME="CentOS Linux 7 (Core)"
    ANSI_COLOR="0;31"
    CPE_NAME="cpe:/o:centos:centos:7"
    HOME_URL="https://www.centos.org/"
    BUG_REPORT_URL="https://bugs.centos.org/"
    CENTOS_MANTISBT_PROJECT="CentOS-7"
    CENTOS_MANTISBT_PROJECT_VERSION="7"
    REDHAT_SUPPORT_PRODUCT="centos"
    REDHAT_SUPPORT_PRODUCT_VERSION="7"
  • Kernel (e.g. uname -a):
    Linux lll 3.10.0-693.21.1.el7.x86_64 #1 SMP Wed Mar 7 19:03:37 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

License

Under which license is this project released?

compile failure: taking address of packed member of may result in an unaligned pointer value

Describe your issue

compile failure on ubuntu: taking address of packed member of may result in an unaligned pointer value

  • Is this a bug report or a feature request?
    bug report
  • Describe the issue
    compile failure
  • What is the expected behaviour?
    compile success
  • How to reproduce the problem?
    under ubuntu 20.04, run command make all will reproduce this issue.

error logs:

❯ make all
cc  -I include -Wall -Werror -pthread -c src/skbuff.c -o build/skbuff.o
cc  -I include -Wall -Werror -pthread -c src/socket.c -o build/socket.o
cc  -I include -Wall -Werror -pthread -c src/ip_input.c -o build/ip_input.o
cc  -I include -Wall -Werror -pthread -c src/tuntap_if.c -o build/tuntap_if.o
cc  -I include -Wall -Werror -pthread -c src/icmpv4.c -o build/icmpv4.o
cc  -I include -Wall -Werror -pthread -c src/netdev.c -o build/netdev.o
cc  -I include -Wall -Werror -pthread -c src/tcp.c -o build/tcp.o
cc  -I include -Wall -Werror -pthread -c src/cli.c -o build/cli.o
cc  -I include -Wall -Werror -pthread -c src/tcp_data.c -o build/tcp_data.o
cc  -I include -Wall -Werror -pthread -c src/sock.c -o build/sock.o
cc  -I include -Wall -Werror -pthread -c src/tcp_output.c -o build/tcp_output.o
cc  -I include -Wall -Werror -pthread -c src/arp.c -o build/arp.o
cc  -I include -Wall -Werror -pthread -c src/route.c -o build/route.o
cc  -I include -Wall -Werror -pthread -c src/ipc.c -o build/ipc.o
src/ipc.c: In function ‘ipc_connect’:
src/ipc.c:164:41: error: taking address of packed member of ‘struct ipc_connect’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
  164 |     rc = _connect(pid, payload->sockfd, &payload->addr, payload->addrlen);
      |                                         ^~~~~~~~~~~~~~
src/ipc.c: In function ‘ipc_getsockopt’:
src/ipc.c:275:79: error: taking address of packed member of ‘struct ipc_sockopt’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
  275 |     rc = _getsockopt(pid, opts->fd, opts->level, opts->optname, opts->optval, &opts->optlen);
      |                                                                               ^~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [Makefile:15: build/ipc.o] Error 1
❯ gcc --version
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Describe your running environment

This is important for troubleshooting. Please attach at least the following info:

Sequence number comparisons need to be done "modulo"

Sequence numbers must not be compared for inequality "naively", since they are designed to wrap around. For example there is an issue here when checking if an incoming segment has a valid sequence number:

if (th->seq < tcb->rcv_nxt ||

Consider the case tcb->rcv_nxt=4294967290, tcb->rcv_wnd=20, th->seq=5. This is an acceptable segment (it is 11 more than tcb->rcv_nxt, so it is within the receive window), but your code will decide it is not acceptable.

One way to fix this specific part of code is like this:

uint32_t seq_relative_to_rcv_nxt = (uint32_t)(th->seq - tcb->rcv_nxt);
if (seq_relative_to_rcv_nxt > tcb->rcv_wnd) {
    // invalid segment
}

Note that the conversion of the result of the subtraction to uint32_t is imperative to ensure modulo reduction.

make failed!

Describe your issue

I just git clone this project, and cd root dir , and make.
I got some error:
$ make

cc  -I include -Wall -Werror -pthread -c src/skbuff.c -o build/skbuff.o
cc  -I include -Wall -Werror -pthread -c src/socket.c -o build/socket.o
cc  -I include -Wall -Werror -pthread -c src/ip_input.c -o build/ip_input.o
cc  -I include -Wall -Werror -pthread -c src/tuntap_if.c -o build/tuntap_if.o
cc  -I include -Wall -Werror -pthread -c src/icmpv4.c -o build/icmpv4.o
cc  -I include -Wall -Werror -pthread -c src/inet.c -o build/inet.o
cc  -I include -Wall -Werror -pthread -c src/tcp.c -o build/tcp.o
cc  -I include -Wall -Werror -pthread -c src/cli.c -o build/cli.o
cc  -I include -Wall -Werror -pthread -c src/sock.c -o build/sock.o
cc  -I include -Wall -Werror -pthread -c src/tcp_output.c -o build/tcp_output.o
cc  -I include -Wall -Werror -pthread -c src/arp.c -o build/arp.o
cc  -I include -Wall -Werror -pthread -c src/netdev.c -o build/netdev.o
cc  -I include -Wall -Werror -pthread -c src/utils.c -o build/utils.o
cc  -I include -Wall -Werror -pthread -c src/ipc.c -o build/ipc.o
cc  -I include -Wall -Werror -pthread -c src/ip_output.c -o build/ip_output.o
cc  -I include -Wall -Werror -pthread -c src/main.c -o build/main.o
cc  -I include -Wall -Werror -pthread -c src/dst.c -o build/dst.o
cc  -I include -Wall -Werror -pthread -c src/tcp_input.c -o build/tcp_input.o
cc  -I include -Wall -Werror -pthread -c src/timer.c -o build/timer.o
cc  -I include -Wall -Werror -pthread -c src/tcp_data.c -o build/tcp_data.o
cc  -I include -Wall -Werror -pthread -c src/route.c -o build/route.o
cc  -I include -Wall -Werror -pthread  build/skbuff.o  build/socket.o  build/ip_input.o  build/tuntap_if.o  build/icmpv4.o  build/inet.o  build/tcp.o  build/cli.o  build/sock.o  build/tcp_output.o  build/arp.o  build/netdev.o  build/utils.o  build/ipc.o  build/ip_output.o  build/main.o  build/dst.o  build/tcp_input.o  build/timer.o  build/tcp_data.o  build/route.o -o lvl-ip

lvl-ip needs CAP_NET_ADMIN:
sudo setcap cap_setpcap,cap_net_admin=ep lvl-ip
Failed to set capabilities on file `lvl-ip' (Invalid argument)
The value of the capability argument is not permitted for a file. Or the file is not a regular (non-symlink) file
Makefile:8: recipe for target 'lvl-ip' failed
make: *** [lvl-ip] Error 1

$ ls

apps  bin  build  Documentation  include  LICENSE.md  lvl-ip  Makefile  README.md  src  tests  tools

Describe your running environment

$ uname -a

Linux ubuntu 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:10:15 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release -a

No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.2 LTS
Release:	16.04
Codename:	xenial

missing capability.h while make all

NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

Linux SCXI-FIXT91 3.10.0-957.5.1.el7.x86_64 #1 SMP Fri Feb 1 14:54:57 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

make all
cc -I include -Wall -Werror -pthread -c src/skbuff.c -o build/skbuff.o
In file included from src/skbuff.c:1:0:
include/syshead.h:27:28: fatal error: sys/capability.h: No such file or directory
#include <sys/capability.h>
^
compilation terminated.
make: *** [build/skbuff.o] Error 1

Nov 14 2017 level-ip-master

Setup refine

There is no need to create manually /dev/net/tap each time. And the 10, 200 is the /dev/net/tun based on device.txt.
So, sudo mknod /dev/net/tap c 10 200 is just creating an alias for tun/tap device.
It's also confused since the kernel using IFF_TUN or IFF_TAP flag to distinguish Tun device or Tap device respectly instead of open /dev/net/tun or open /dev/net/tap.

Unsupported IP header/ ethernet type msgs

Describe your issue

This is the log when running sudo ./lvl-ip

~/level-ip$ sudo ./lvl-ip Unsupported ethertype 86dd ARP was not for us Unknown IP header proto : 2 Unsupported ethertype 86dd Unknown IP header proto : 17 Unknown IP header proto : 17 Unknown IP header proto : 17 Unsupported ethertype 86dd Unknown IP header proto : 2 Unknown IP header proto : 17 Unknown IP header proto : 17 Unsupported ethertype 86dd Unknown IP header proto : 17 ARP was not for us Unsupported ethertype 86dd Unsupported ethertype 86dd Unsupported ethertype 86dd Unknown IP header proto : 17 Unsupported ethertype 86dd Unsupported ethertype 86dd Unknown IP header proto : 17 Unsupported ethertype 86dd Unknown IP header proto : 17 Unsupported ethertype 86dd Unsupported ethertype 86dd Unsupported ethertype 86dd Unknown IP header proto : 17 Unknown IP header proto : 17 Unknown IP header proto : 17 Unsupported ethertype 86dd Unsupported ethertype 86dd Unknown IP header proto : 17 Unknown IP header proto : 17 Unsupported ethertype 86dd Unknown IP header proto : 17 Unsupported ethertype 86dd Unknown IP header proto : 17 Unsupported ethertype 86dd Unsupported ethertype 86dd Unknown IP header proto : 17 Unsupported ethertype 86dd Unsupported ethertype 86dd Unknown IP header proto : 17 Unsupported ethertype 86dd Unknown IP header proto : 17

Describe your running environment

Ubuntu 16.04 LTS

make failed

cc -I include -Wall -Werror -pthread -c src/skbuff.c -o build/skbuff.o
In file included from src/skbuff.c:1:0:
include/syshead.h:27:10: fatal error: sys/capability.h: No such file or directory
#include <sys/capability.h>
^~~~~~~~~~~~~~~~~~
compilation terminated.
Makefile:15: recipe for target 'build/skbuff.o' failed
make: *** [build/skbuff.o] Error 1

how to fix this error?
I just do make all on my Vbox with linux Ubuntu 18.04

more documentation

This is pretty awesome. I was wondering if you can add some more documentation on how to go about reading/modifying the code. (I have read your 5 part series) e.g. ipc.h/.c

Thanks!

checking arp implementation

Hello,

I am playing around with level-ip. I am following the blog posts, and writing the code on my own (copying the code whenever necessary).

I finished the ethernet parsing and arp implementation, and had a question about routing.

My eth0 has ip 10.64.8.54. On doing, arping -I tap0 -s 10.64.8.54 10.0.0.5, I can see the ARP requests reach my arping code, and correctly replies back the ARP request. However, these requests are never received back by the arping utility and hence it never updates the arp cache.

i went through the getting started and noticed the iptables section. I have not done that part. Could this be the reason that my responses are not correctly received by the arping utility?

Thanks. Let me know if there is some more information that I can provide.

Can't compile on gcc 9 and clang 8

Describe your issue

  • Is this a bug report or a feature request?
    bug
  • Describe the issue
    gcc9 and clang4(maybe) open -Waddress-of-packed-member by default, which will cause a build failure as we use packed struct.
➜  level-ip git:(master) ✗ make all
cc  -I include -Wall -Werror -pthread -c src/ipc.c -o build/ipc.o
src/ipc.c: In function ‘ipc_connect’:
src/ipc.c:164:41: error: taking address of packed member of ‘struct ipc_connect’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
  164 |     rc = _connect(pid, payload->sockfd, &payload->addr, payload->addrlen);
      |                                         ^~~~~~~~~~~~~~
src/ipc.c: In function ‘ipc_getsockopt’:
src/ipc.c:275:79: error: taking address of packed member of ‘struct ipc_sockopt’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
  275 |     rc = _getsockopt(pid, opts->fd, opts->level, opts->optname, opts->optval, &opts->optlen);
      |                                                                               ^~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [Makefile:15: build/ipc.o] Error 1
  • What is the expected behaviour?
    Make should successfully pass.
  • How to reproduce the problem?
    With gcc9 or clang8
cd level-ip
make all

Describe your running environment

This is important for troubleshooting. Please attach at least the following info:

  • OS : Manjaro Linux
  • Kernel : 4.19.56-1
  • Arch: x86_64
  • GCC: 9.1.0
  • Clang: 8.0.0

Cannot build on Debian

Hi,

I cannot build this on Debian, any idea how to resolve it?

make
cc  -std=gnu99 -D_XOPEN_SOURCE=700 -I include -Wall -pthread  build/skbuff.o  build/socket.o  build/tcp_timer.o  build/ip_input.o  build/icmpv4.o  build/inet.o  build/tcp.o  build/cli.o  build/sock.o  build/tcp_output.o  build/arp.o  build/ethernet.o  build/netdev.o  build/utils.o  build/tuntap_if.o  build/ip_output.o  build/main.o  build/dst.o  build/tcp_input.o  build/curl.o  build/tcp_data.o  build/route.o -o lvl-ip
build/socket.o: In function `eth_hdr':
socket.c:(.text+0x39): multiple definition of `eth_hdr'
build/skbuff.o:skbuff.c:(.text+0x0): first defined here
build/tcp_timer.o: In function `eth_hdr':
tcp_timer.c:(.text+0x0): multiple definition of `eth_hdr'
build/skbuff.o:skbuff.c:(.text+0x0): first defined here
build/ip_input.o: In function `eth_hdr':
ip_input.c:(.text+0x0): multiple definition of `eth_hdr'
build/skbuff.o:skbuff.c:(.text+0x0): first defined here
build/icmpv4.o: In function `eth_hdr':
icmpv4.c:(.text+0x0): multiple definition of `eth_hdr'
build/skbuff.o:skbuff.c:(.text+0x0): first defined here
build/ethernet.o: In function `eth_hdr':
ethernet.c:(.text+0x0): multiple definition of `eth_hdr'
build/skbuff.o:skbuff.c:(.text+0x0): first defined here
build/utils.o: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
Makefile:8: recipe for target 'lvl-ip' failed
make: *** [lvl-ip] Error 1

No TCP socket for sport 42582 dport 1337

Describe your issue

  • Is this a bug report or a feature request?
    bug report

  • Describe the issue
    tap device doesn't respond

  • What is the expected behaviour?
    should respond..

  • How to reproduce the problem?

Command:
nmap -Pn 10.0.0.4 -p 1337

in level-ip log:
No TCP socket for sport 56996 dport 1337

in tcpdump:
tcpdump -i any host 10.0.0.4 -n

13:00:08.067870 ARP, Request who-has 10.0.0.4 tell 10.0.0.5, length 28
13:00:08.067909 ARP, Reply 10.0.0.4 is-at 00:0c:29:6d:50:25, length 28
13:00:08.219951 IP 10.0.0.5.56996 > 10.0.0.4.1337: Flags [S], seq 4159220327, win 1024, options [mss 1460], length 0
13:00:08.320111 IP 10.0.0.5.56997 > 10.0.0.4.1337: Flags [S], seq 4159285862, win 1024, options [mss 1460], length 0

Same issue happen when I try to use the curl application to request google.com, 10.0.0.4 doesn't respond. It does respond with ping tho:

$ ping -c3 10.0.0.4
PING 10.0.0.4 (10.0.0.4) 56(84) bytes of data.
64 bytes from 10.0.0.4: icmp_seq=1 ttl=64 time=0.054 ms
64 bytes from 10.0.0.4: icmp_seq=2 ttl=64 time=0.071 ms
64 bytes from 10.0.0.4: icmp_seq=3 ttl=64 time=0.065 ms

13:05:11.023961 IP 10.0.0.5 > 10.0.0.4: ICMP echo request, id 5001, seq 1, length 64
13:05:11.024002 IP 10.0.0.4 > 10.0.0.5: ICMP echo reply, id 5001, seq 1, length 64
13:05:12.039468 IP 10.0.0.5 > 10.0.0.4: ICMP echo request, id 5001, seq 2, length 64
13:05:12.039522 IP 10.0.0.4 > 10.0.0.5: ICMP echo reply, id 5001, seq 2, length 64
13:05:13.063461 IP 10.0.0.5 > 10.0.0.4: ICMP echo request, id 5001, seq 3, length 64
13:05:13.063506 IP 10.0.0.4 > 10.0.0.5: ICMP echo reply, id 5001, seq 3, length 64


Describe your running environment

This is important for troubleshooting. Please attach at least the following info:

  • OS (e.g. cat /etc/os-release):
    NAME="Ubuntu"
    VERSION="19.10 (Eoan Ermine)"

  • Kernel (e.g. uname -a):
    Linux pig 5.3.0-51-generic #44-Ubuntu SMP Wed Apr 22 21:09:44 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.