lkl / linux

Linux kernel source tree

Home Page:https://lkl.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tap interface on FreeBSD

jjpprrrr opened this issue · comments

I was trying to run the code mentioned in #355 . On Ubuntu 18.04, the server works very well with the following configuration: a host tap0 interface on 10.0.0.3/24, LKL tap0 interface on 10.0.0.2/24, and LKL gateway set to 10.0.0.1.

I then built the same server and client code on FreeBSD 11.1. I first created a host tap interface:

$ ifconfig tap0 create
$ ifconfig tap0 10.0.0.3/24
$ ifconfig tap0 up
tap0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=80000<LINKSTATE>
        ether 00:bd:ae:44:16:00
        hwaddr 00:bd:ae:44:16:00
        inet 10.0.0.3 netmask 0xffffff00 broadcast 10.0.0.255
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        media: Ethernet autoselect
        status: no carrier
        groups: tap

The LKL interface address and gateway stays the same with my Ubuntu setup. The server program, however, is stuck at lkl_sys_bind():

while (1) {
       if (lkl_sys_bind(listenfd, (struct lkl_sockaddr*)&serv_addr, sizeof(serv_addr)) != 0 ) {
           printf("BIND: Failed to bind to port. Waiting....\n");
           sleep(10);
       } else {
           printf("BIND: Successful --- Serving Port:%d.\n", serv_addr.sin_port);
           break;
       }
 }

I also find that every time after I run the server program and close it, the address of the host tap0 interface will disappear, and the interface is no longer UP.

What is the proper way of using tap interface with LKL on FreeBSD? Thanks!