mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
switch to LwIP 2.0.0 with dual-stack support (IPv4+IPv6)
This commit is contained in:
parent
2c7fdee666
commit
285e38822f
10 changed files with 42 additions and 92 deletions
|
@ -3,7 +3,7 @@ TOPDIR := $(shell pwd)
|
|||
ARCH = x86
|
||||
NAME = libhermit.a
|
||||
DRIVERDIRS = drivers/net
|
||||
LWIPDIRS = lwip/src/arch lwip/src/api lwip/src/core lwip/src/core/ipv4 lwip/src/netif
|
||||
LWIPDIRS = lwip/src/arch lwip/src/api lwip/src/core lwip/src/core/ipv4 lwip/src/core/ipv6 lwip/src/netif
|
||||
KERNDIRS = kernel mm libkern arch/$(ARCH)/kernel arch/$(ARCH)/mm $(LWIPDIRS) $(DRIVERDIRS)
|
||||
SUBDIRS = $(KERNDIRS)
|
||||
GIT_VERSION := $(shell git describe --abbrev=6 --dirty --always --tags)
|
||||
|
@ -35,7 +35,7 @@ MAKE = make
|
|||
NASM = nasm
|
||||
NASMFLAGS = -felf64 -g -i$(TOPDIR)/include/hermit/
|
||||
|
||||
INCLUDE = -I$(TOPDIR)/include -I$(TOPDIR)/arch/$(ARCH)/include -I$(TOPDIR)/lwip/src/include -I$(TOPDIR)/lwip/src/include/ipv4 -I$(TOPDIR)/drivers
|
||||
INCLUDE = -I$(TOPDIR)/include -I$(TOPDIR)/arch/$(ARCH)/include -I$(TOPDIR)/lwip/src/include -I$(TOPDIR)/drivers
|
||||
CFLAGS = -DVERSION=\"$(GIT_VERSION)\" -g -m64 -Wall -O2 -mno-red-zone -fno-var-tracking-assignments -fstrength-reduce -fomit-frame-pointer -finline-functions -ffreestanding -nostdinc -fno-stack-protector -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fno-delete-null-pointer-checks -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mskip-rax-setup -fno-common -Wframe-larger-than=1024 -fno-strict-aliasing -fno-asynchronous-unwind-tables -fno-strict-overflow -maccumulate-outgoing-args $(INCLUDE)
|
||||
AR = ar
|
||||
ARFLAGS = rsv
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
#include <lwip/stats.h>
|
||||
#include <lwip/netif.h>
|
||||
#include <lwip/tcpip.h>
|
||||
#include <lwip/snmp.h>
|
||||
#include <lwip/ethip6.h>
|
||||
#include <netif/etharp.h>
|
||||
#include <net/e1000.h>
|
||||
|
||||
|
@ -562,10 +564,16 @@ err_t e1000if_init(struct netif* netif)
|
|||
/* maximum transfer unit */
|
||||
netif->mtu = 1500;
|
||||
/* broadcast capability */
|
||||
netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_IGMP;
|
||||
netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_IGMP | NETIF_FLAG_LINK_UP | NETIF_FLAG_MLD6;
|
||||
|
||||
e1000if->ethaddr = (struct eth_addr *)netif->hwaddr;
|
||||
|
||||
#if LWIP_IPV6
|
||||
netif->output_ip6 = ethip6_output;
|
||||
netif_create_ip6_linklocal_address(netif, 1);
|
||||
netif->ip6_autoconfig_enabled = 1;
|
||||
#endif
|
||||
|
||||
return ERR_OK;
|
||||
|
||||
oom:
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include <hermit/logging.h>
|
||||
|
||||
#include <lwip/netif.h> /* lwip netif */
|
||||
#include <lwip/netifapi.h>
|
||||
#include <lwip/stats.h> /* inteface stats */
|
||||
#include <netif/etharp.h> /* ethernet arp packets */
|
||||
#include <lwip/ip.h> /* struct iphdr */
|
||||
|
@ -302,7 +303,7 @@ void mmnif_print_driver_status(void)
|
|||
static uint8_t mmnif_get_destination(struct netif *netif, struct pbuf *p)
|
||||
{
|
||||
struct ip_hdr *iphdr;
|
||||
ip_addr_p_t ip;
|
||||
ip4_addr_p_t ip;
|
||||
|
||||
/* grab the destination ip address out of the ip header
|
||||
* for internal routing the last ocet is interpreted as core ID.
|
||||
|
@ -687,6 +688,8 @@ err_t mmnif_init(struct netif *netif)
|
|||
|
||||
/* broadcast capability, keep all default flags */
|
||||
//netif->flags |= NETIF_FLAG_BROADCAST;
|
||||
/* set link up */
|
||||
netif->flags |= NETIF_FLAG_LINK_UP;
|
||||
|
||||
/* hardware address length */
|
||||
netif->hwaddr_len = 0;
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
#include <lwip/stats.h>
|
||||
#include <lwip/netif.h>
|
||||
#include <lwip/tcpip.h>
|
||||
#include <lwip/snmp.h>
|
||||
#include <lwip/ethip6.h>
|
||||
#include <netif/etharp.h>
|
||||
#include <net/rtl8139.h>
|
||||
|
||||
|
@ -481,7 +483,12 @@ err_t rtl8139if_init(struct netif* netif)
|
|||
/* maximum transfer unit */
|
||||
netif->mtu = 1500;
|
||||
/* broadcast capability */
|
||||
netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_IGMP;
|
||||
netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_IGMP | NETIF_FLAG_LINK_UP | NETIF_FLAG_MLD6;
|
||||
#if LWIP_IPV6
|
||||
netif->output_ip6 = ethip6_output;
|
||||
netif_create_ip6_linklocal_address(netif, 1);
|
||||
netif->ip6_autoconfig_enabled = 1;
|
||||
#endif
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
{
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015, Stefan Lankes, RWTH Aachen University
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __SYS_MMAN_H__
|
||||
#define __SYS_MMAN_H__
|
||||
|
||||
/**
|
||||
* @author Stefan Lankes
|
||||
* @file include/hermit/uio.h
|
||||
* @brief Definition of struct iovec
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Structure for scatter/gather I/O. */
|
||||
struct iovec
|
||||
{
|
||||
void *iov_base; /* Pointer to data. */
|
||||
size_t iov_len; /* Length of data. */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -44,12 +44,13 @@
|
|||
#include <lwip/init.h>
|
||||
#include <lwip/sys.h>
|
||||
#include <lwip/stats.h>
|
||||
#include <lwip/ip_addr.h>
|
||||
#include <lwip/udp.h>
|
||||
#include <lwip/tcp.h>
|
||||
#include <lwip/tcpip.h>
|
||||
#include <lwip/dhcp.h>
|
||||
#include <lwip/netifapi.h>
|
||||
#include <lwip/timers.h>
|
||||
#include <lwip/ip_addr.h>
|
||||
#include <lwip/sockets.h>
|
||||
#include <lwip/err.h>
|
||||
#include <lwip/stats.h>
|
||||
|
@ -61,9 +62,6 @@
|
|||
#define HERMIT_PORT 0x494E
|
||||
#define HERMIT_MAGIC 0x7E317
|
||||
|
||||
// set to one if the single-kernel version should use a DHCP server
|
||||
#define USE_DHCP 1
|
||||
|
||||
static struct netif default_netif;
|
||||
static const int sobufsize = 131072;
|
||||
|
||||
|
@ -162,9 +160,9 @@ static void tcpip_init_done(void* arg)
|
|||
|
||||
static int init_netifs(void)
|
||||
{
|
||||
struct ip_addr ipaddr;
|
||||
struct ip_addr netmask;
|
||||
struct ip_addr gw;
|
||||
ip_addr_t ipaddr;
|
||||
ip_addr_t netmask;
|
||||
ip_addr_t gw;
|
||||
sys_sem_t sem;
|
||||
err_t err;
|
||||
|
||||
|
@ -182,9 +180,9 @@ static int init_netifs(void)
|
|||
if (!is_single_kernel())
|
||||
{
|
||||
/* Set network address variables */
|
||||
IP4_ADDR(&gw, 192,168,28,1);
|
||||
IP4_ADDR(&ipaddr, 192,168,28,isle+2);
|
||||
IP4_ADDR(&netmask, 255,255,255,0);
|
||||
IP_ADDR4(&gw, 192,168,28,1);
|
||||
IP_ADDR4(&ipaddr, 192,168,28,isle+2);
|
||||
IP_ADDR4(&netmask, 255,255,255,0);
|
||||
|
||||
/* register our Memory Mapped Virtual IP interface in the lwip stack
|
||||
* and tell him how to use the interface:
|
||||
|
@ -195,13 +193,13 @@ static int init_netifs(void)
|
|||
* - ip_input : tells him that he should use ip_input
|
||||
*/
|
||||
#if LWIP_TCPIP_CORE_LOCKING_INPUT
|
||||
if ((err = netifapi_netif_add(&default_netif, &ipaddr, &netmask, &gw, NULL, mmnif_init, ip_input)) != ERR_OK)
|
||||
if ((err = netifapi_netif_add(&default_netif, ip_2_ip4(&ipaddr), ip_2_ip4(&netmask), ip_2_ip4(&gw), NULL, mmnif_init, ip_input)) != ERR_OK)
|
||||
#else
|
||||
/*
|
||||
* Note: Our drivers guarantee that the input function will be called in the context of the tcpip thread.
|
||||
* => Therefore, we are able to use ip_input instead of tcpip_input
|
||||
*/
|
||||
if ((err = netifapi_netif_add(&default_netif, &ipaddr, &netmask, &gw, NULL, mmnif_init, ip_input)) != ERR_OK)
|
||||
if ((err = netifapi_netif_add(&default_netif, ip_2_ip4(&ipaddr), ip_2_ip4(&netmask), ip_2_ip4(&gw), NULL, mmnif_init, ip_input)) != ERR_OK)
|
||||
#endif
|
||||
{
|
||||
LOG_ERROR("Unable to add the intra network interface: err = %d\n", err);
|
||||
|
@ -212,22 +210,16 @@ static int init_netifs(void)
|
|||
netifapi_netif_set_default(&default_netif);
|
||||
netifapi_netif_set_up(&default_netif);
|
||||
} else {
|
||||
#if USE_DHCP
|
||||
/* Clear network address because we use DHCP to get an ip address */
|
||||
IP4_ADDR(&gw, 0,0,0,0);
|
||||
IP4_ADDR(&ipaddr, 0,0,0,0);
|
||||
IP4_ADDR(&netmask, 0,0,0,0);
|
||||
#else
|
||||
IP4_ADDR(&gw, 10,0,2,2);
|
||||
IP4_ADDR(&ipaddr, 10,0,2,15);
|
||||
IP4_ADDR(&netmask, 255,255,255,0);
|
||||
#endif
|
||||
IP_ADDR4(&gw, 0,0,0,0);
|
||||
IP_ADDR4(&ipaddr, 0,0,0,0);
|
||||
IP_ADDR4(&netmask, 0,0,0,0);
|
||||
|
||||
/* Note: Our drivers guarantee that the input function will be called in the context of the tcpip thread.
|
||||
* => Therefore, we are able to use ethernet_input instead of tcpip_input */
|
||||
if ((err = netifapi_netif_add(&default_netif, &ipaddr, &netmask, &gw, NULL, rtl8139if_init, ethernet_input)) == ERR_OK)
|
||||
if ((err = netifapi_netif_add(&default_netif, ip_2_ip4(&ipaddr), ip_2_ip4(&netmask), ip_2_ip4(&gw), NULL, rtl8139if_init, ethernet_input)) == ERR_OK)
|
||||
goto success;
|
||||
if ((err = netifapi_netif_add(&default_netif, &ipaddr, &netmask, &gw, NULL, e1000if_init, ethernet_input)) == ERR_OK)
|
||||
if ((err = netifapi_netif_add(&default_netif, ip_2_ip4(&ipaddr), ip_2_ip4(&netmask), ip_2_ip4(&gw), NULL, e1000if_init, ethernet_input)) == ERR_OK)
|
||||
goto success;
|
||||
|
||||
LOG_ERROR("Unable to add the network interface: err = %d\n", err);
|
||||
|
@ -236,19 +228,19 @@ static int init_netifs(void)
|
|||
|
||||
success:
|
||||
netifapi_netif_set_default(&default_netif);
|
||||
netifapi_netif_set_up(&default_netif);
|
||||
|
||||
#if USE_DHCP
|
||||
LOG_INFO("Starting DHCPD...\n");
|
||||
netifapi_dhcp_start(&default_netif);
|
||||
|
||||
int mscnt = 0;
|
||||
/* wait for ip address */
|
||||
while(!default_netif.ip_addr.addr) {
|
||||
while(!ip_2_ip4(&default_netif.ip_addr)->addr) {
|
||||
uint64_t end_tsc, start_tsc = rdtsc();
|
||||
|
||||
#if 1
|
||||
do {
|
||||
if (default_netif.ip_addr.addr)
|
||||
if (ip_2_ip4(&default_netif.ip_addr)->addr)
|
||||
return 0;
|
||||
check_workqueues();
|
||||
end_tsc = rdtsc();
|
||||
|
@ -264,9 +256,6 @@ success:
|
|||
mscnt = 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
netifapi_netif_set_up(&default_netif);
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include <hermit/memory.h>
|
||||
#include <hermit/signal.h>
|
||||
#include <hermit/logging.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/poll.h>
|
||||
|
||||
#include <lwip/sockets.h>
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit b20b9a2c2532c0713122053ce57f2970c538ca1a
|
||||
Subproject commit 6d1ec9cc709892e9a30461b85df2161f556e4af6
|
|
@ -81,7 +81,6 @@ headers:
|
|||
$Q$(CP) -R ../lwip/src/include/posix/* $(TOPDIR)/$(ARCH)/$(CROSSCOMPREFIX)/include/
|
||||
$Q$(CP) -R ../lwip/src/include/arch $(TOPDIR)/$(ARCH)/$(CROSSCOMPREFIX)/include/
|
||||
$Q$(CP) -R ../lwip/src/include/lwip* $(TOPDIR)/$(ARCH)/$(CROSSCOMPREFIX)/include/
|
||||
$Q$(CP) -R ../lwip/src/include/ipv4/lwip/* $(TOPDIR)/$(ARCH)/$(CROSSCOMPREFIX)/include/lwip/
|
||||
$Q$(CP) -R ../include/neti* $(TOPDIR)/$(ARCH)/$(CROSSCOMPREFIX)/include/
|
||||
$Q$(CP) -R ../include/sys $(TOPDIR)/$(ARCH)/$(CROSSCOMPREFIX)/include/
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue