Skip to content

Commit 5368b2e

Browse files
committed
net: forward-port FreeBSD IPv6 stack with SLAAC + DHCPv6 autoconfig
Merge the upstream ipv6 branch (FreeBSD 9 netinet6 import + OSv glue) and add boot-time IPv6 autoconfiguration: - netinet6 stack (ip6, icmp6, nd6, in6_*, udp6, raw_ip6, mld6) behind conf-INET6 - OSv net-channel fast path, LRO, RCU classifier extended for IPv6/TCP - Linux socket-option compat for 43 IPV6_* options; getifaddrs/netlink v6 - SLAAC: kernel Router Solicitation (nd6_rs_output) + accept-RA per-interface flag fix so a unikernel (no rtsold) autoconfigures from Router Advertisements - DHCPv6 client (RFC 8415 stateful: SOLICIT/ADVERTISE/REQUEST/REPLY, DUID-LLT, IA_NA) triggered when the RA sets the Managed (M) flag, e.g. AWS VPC - loader picks SLAAC vs DHCPv6 from RA flags; --ipv6 for IPv6-only boot - all IPv6 code compile-gated (conf-INET6, conf_networking_dhcp6) - tests: tst-tcp-v6-smoke, tst-ipv6-internet, tst-ifaddr-dump
2 parents 3aba46c + 4f01d83 commit 5368b2e

105 files changed

Lines changed: 43347 additions & 585 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ before_install:
2323
- sudo adduser $USER libvirt
2424
- sudo adduser $USER kvm
2525
- echo "$DOCKER_ACCESS_TOKEN" | docker login --username osvunikernel --password-stdin
26-
- pushd docker && docker build -t osv/builder -f ./Dockerfile.builder --build-arg DIST="ubuntu-20.10" . && popd
26+
- pushd docker && docker build -t osv/builder -f ./Dockerfile.builder --build-arg DIST="ubuntu-20.10" --build-arg GIT_BRANCH="ipv6" . && popd
2727
- docker run -it --privileged -d --name build osv/builder
2828
stages:
2929
- build_and_publish

Makefile

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ COMMON = $(autodepend) -g -Wall -Wno-pointer-arith $(CFLAGS_WERROR) -Wformat=0 -
361361
-fno-omit-frame-pointer $(compiler-specific) \
362362
-include compiler/include/intrinsics.hh \
363363
$(conf_compiler_cflags) $(conf_compiler_opt) $(acpi-defines) $(tracing-flags) $(gcc-sysroot) \
364-
-D__OSV__ -D__XEN_INTERFACE_VERSION__="0x00030207" -DARCH_STRING=$(ARCH_STR) $(EXTRA_FLAGS)
364+
$(configuration) -D__OSV__ -D__XEN_INTERFACE_VERSION__="0x00030207" -DARCH_STRING=$(ARCH_STR) $(EXTRA_FLAGS)
365365
COMMON += $(standard-includes-flag)
366366

367367
tracing-flags-0 =
@@ -398,6 +398,11 @@ $(out)/bsd/%.o: INCLUDES += -isystem bsd/
398398
# for machine/
399399
$(out)/bsd/%.o: INCLUDES += -isystem bsd/$(arch)
400400

401+
configuration-defines = conf-INET6
402+
403+
configuration = $(foreach cf,$(configuration-defines), \
404+
-D$(cf:conf-%=CONF_%)=$($(cf)))
405+
401406
makedir = $(call very-quiet, mkdir -p $(dir $@))
402407
build-so = $(CC) $(CFLAGS) -o $@ $^ $(EXTRA_LIBS)
403408
q-build-so = $(call quiet, $(build-so), LINK $@)
@@ -688,6 +693,41 @@ bsd += bsd/sys/netinet/cc/cc_cubic.o
688693
bsd += bsd/sys/netinet/cc/cc_htcp.o
689694
bsd += bsd/sys/netinet/cc/cc_newreno.o
690695
bsd += bsd/sys/netinet/arpcache.o
696+
ifeq ($(conf-INET6), 1)
697+
ifeq ($(conf_networking_dhcp6),1)
698+
bsd += bsd/porting/dhcp6.o
699+
endif
700+
bsd += bsd/sys/netinet6/dest6.o
701+
bsd += bsd/sys/netinet6/frag6.o
702+
bsd += bsd/sys/netinet6/icmp6.o
703+
$(out)/bsd/sys/netinet6/icmp6.o: COMMON+=-Wno-address-of-packed-member
704+
bsd += bsd/sys/netinet6/in6.o
705+
$(out)/bsd/sys/netinet6/in6.o: COMMON+=-fno-strict-aliasing
706+
bsd += bsd/sys/netinet6/in6_cksum.o
707+
bsd += bsd/sys/netinet6/in6_ifattach.o
708+
bsd += bsd/sys/netinet6/in6_mcast.o
709+
bsd += bsd/sys/netinet6/in6_pcb.o
710+
bsd += bsd/sys/netinet6/in6_proto.o
711+
bsd += bsd/sys/netinet6/in6_rmx.o
712+
$(out)/bsd/sys/netinet6/in6_rmx.o: COMMON+=-fno-strict-aliasing
713+
bsd += bsd/sys/netinet6/in6_src.o
714+
bsd += bsd/sys/netinet6/ip6_forward.o
715+
bsd += bsd/sys/netinet6/ip6_id.o
716+
bsd += bsd/sys/netinet6/ip6_input.o
717+
bsd += bsd/sys/netinet6/ip6_output.o
718+
bsd += bsd/sys/netinet6/mld6.o
719+
$(out)/bsd/sys/netinet6/mld6.o: COMMON+=-Wno-address-of-packed-member
720+
bsd += bsd/sys/netinet6/nd6.o
721+
$(out)/bsd/sys/netinet6/nd6.o: COMMON+=-fno-strict-aliasing
722+
bsd += bsd/sys/netinet6/nd6_nbr.o
723+
bsd += bsd/sys/netinet6/nd6_rtr.o
724+
$(out)/bsd/sys/netinet6/nd6_rtr.o: COMMON+=-fno-strict-aliasing
725+
bsd += bsd/sys/netinet6/raw_ip6.o
726+
$(out)/bsd/sys/netinet6/raw_ip6.o: COMMON+=-Wno-address-of-packed-member
727+
bsd += bsd/sys/netinet6/route6.o
728+
bsd += bsd/sys/netinet6/scope6.o
729+
bsd += bsd/sys/netinet6/udp6_usrreq.o
730+
endif
691731
endif
692732
ifeq ($(conf_drivers_xen),1)
693733
bsd += bsd/sys/xen/evtchn.o
@@ -1156,6 +1196,11 @@ objects += core/percpu-worker.o
11561196
ifeq ($(conf_networking_dhcp),1)
11571197
objects += core/dhcp.o
11581198
endif
1199+
ifeq ($(conf-INET6),1)
1200+
ifeq ($(conf_networking_dhcp6),1)
1201+
# bsd/porting/dhcp6.o is added to the bsd list (needs BSD-internal headers)
1202+
endif
1203+
endif
11591204
objects += core/run.o
11601205
objects += core/shutdown.o
11611206
objects += core/version.o

bsd/net.cc

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,22 @@
2424
#include <bsd/sys/net/ethernet.h>
2525
#include <bsd/sys/net/route.h>
2626
#include <bsd/sys/compat/linux/linux_netlink.h>
27+
#ifdef INET6
28+
#include <bsd/sys/netinet/icmp6.h>
29+
#include <bsd/sys/netinet6/in6.h>
30+
#include <bsd/sys/netinet6/mld6.h>
31+
#endif
2732

2833
/* Generation of ip ids */
2934
void ip_initid(void);
3035

3136
extern "C" {
3237
/* AF_INET */
3338
extern struct domain inetdomain;
39+
#ifdef INET6
40+
/* AF_INET6 */
41+
extern struct domain inet6domain;
42+
#endif
3443
/* AF_ROUTE */
3544
extern struct domain routedomain;
3645
/* AF_NETLINK */
@@ -55,22 +64,34 @@ void net_init(void)
5564
vnet_pfil_init();
5665
domaininit(NULL);
5766
OSV_DOMAIN_SET(inet);
67+
#ifdef INET6
68+
OSV_DOMAIN_SET(inet6);
69+
#endif
5870
OSV_DOMAIN_SET(route);
5971
OSV_DOMAIN_SET(netlink);
6072
rts_init();
6173
route_init();
6274
vnet_route_init();
6375
netlink_init();
76+
#ifdef INET6
77+
ip6_init2(NULL);
78+
mld_init(NULL);
79+
vnet_mld_init(NULL);
80+
#endif
6481
ipport_tick_init(NULL);
6582
arp_init();
6683
domainfinalize(NULL);
6784
cc_init();
6885
if_attachdomain(NULL);
6986
vnet_loif_init();
7087

88+
/* Adding IPv4 address before starting the loopback interface
89+
* cause the interface to be brought up without IPv6 support.
90+
*/
91+
7192
/* Start the loopback device */
72-
osv::start_if("lo0", "127.0.0.1", "255.0.0.0");
7393
osv::ifup("lo0");
94+
osv::start_if("lo0", "127.0.0.1", "255.0.0.0");
7495

7596
debug(" - done\n");
7697
}

0 commit comments

Comments
 (0)