Module Name: src Committed By: pooka Date: Thu May 28 00:02:17 UTC 2009
Modified Files: src/sys/rump/librump/rumpnet: rump_net.c rump_net_private.h src/sys/rump/net/lib/liblocal: Makefile src/sys/rump/net/lib/libnet: Makefile src/sys/rump/net/lib/libsockin: Makefile src/sys/rump/net/lib/libvirtif: Makefile Added Files: src/sys/rump/net/lib/liblocal: component.c src/sys/rump/net/lib/libnet: component.c src/sys/rump/net/lib/libnetinet: component.c src/sys/rump/net/lib/libsockin: component.c src/sys/rump/net/lib/libvirtif: component.c Log Message: Use a bunch of weak symbols to determine which network components are present. This works in userspace as opposed relying in link sets, which fail miserably. Later, when the networking stack becomes modularized, we can move to a dynamic scheme like with file systems. Also, this change allows us to do proper autoconfig, namely attach the loopback interface iff it is present. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/rump/librump/rumpnet/rump_net.c cvs rdiff -u -r1.2 -r1.3 src/sys/rump/librump/rumpnet/rump_net_private.h cvs rdiff -u -r1.1 -r1.2 src/sys/rump/net/lib/liblocal/Makefile cvs rdiff -u -r0 -r1.1 src/sys/rump/net/lib/liblocal/component.c cvs rdiff -u -r1.4 -r1.5 src/sys/rump/net/lib/libnet/Makefile cvs rdiff -u -r0 -r1.1 src/sys/rump/net/lib/libnet/component.c cvs rdiff -u -r0 -r1.1 src/sys/rump/net/lib/libnetinet/component.c cvs rdiff -u -r1.2 -r1.3 src/sys/rump/net/lib/libsockin/Makefile cvs rdiff -u -r0 -r1.1 src/sys/rump/net/lib/libsockin/component.c cvs rdiff -u -r1.2 -r1.3 src/sys/rump/net/lib/libvirtif/Makefile cvs rdiff -u -r0 -r1.1 src/sys/rump/net/lib/libvirtif/component.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/rump/librump/rumpnet/rump_net.c diff -u src/sys/rump/librump/rumpnet/rump_net.c:1.7 src/sys/rump/librump/rumpnet/rump_net.c:1.8 --- src/sys/rump/librump/rumpnet/rump_net.c:1.7 Wed Mar 18 10:22:45 2009 +++ src/sys/rump/librump/rumpnet/rump_net.c Thu May 28 00:02:16 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: rump_net.c,v 1.7 2009/03/18 10:22:45 cegger Exp $ */ +/* $NetBSD: rump_net.c,v 1.8 2009/05/28 00:02:16 pooka Exp $ */ /* * Copyright (c) 2008 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rump_net.c,v 1.7 2009/03/18 10:22:45 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rump_net.c,v 1.8 2009/05/28 00:02:16 pooka Exp $"); #include <sys/param.h> @@ -35,17 +35,38 @@ #include <sys/socketvar.h> #include <net/radix.h> +#include <net/route.h> #include "rump_net_private.h" +void nocomponent(void); +void nocomponent() {} +__weak_alias(rump_net_net_init,nocomponent); +__weak_alias(rump_net_inet_init,nocomponent); +__weak_alias(rump_net_local_init,nocomponent); +__weak_alias(rump_net_sockin_init,nocomponent); +__weak_alias(rump_net_virtif_init,nocomponent); + void rump_net_init(void) { mbinit(); - domaininit(); - rn_init(); + + domaininit(false); + /* + * Add rest of the domains we failed to add in domaininit() + * due to linkset lossage. + */ + rump_net_inet_init(); + rump_net_local_init(); + rump_net_sockin_init(); + rump_net_virtif_init(); + /* Note: should be last due to calling of rn_init() */ + rump_net_net_init(); + soinit(); soinit2(); + rump_netisr_init(); } Index: src/sys/rump/librump/rumpnet/rump_net_private.h diff -u src/sys/rump/librump/rumpnet/rump_net_private.h:1.2 src/sys/rump/librump/rumpnet/rump_net_private.h:1.3 --- src/sys/rump/librump/rumpnet/rump_net_private.h:1.2 Wed May 27 23:41:20 2009 +++ src/sys/rump/librump/rumpnet/rump_net_private.h Thu May 28 00:02:16 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: rump_net_private.h,v 1.2 2009/05/27 23:41:20 pooka Exp $ */ +/* $NetBSD: rump_net_private.h,v 1.3 2009/05/28 00:02:16 pooka Exp $ */ /* * Copyright (c) 2008 Antti Kantee. All Rights Reserved. @@ -31,6 +31,19 @@ void rump_net_init(void); void rump_netisr_init(void); +#define DOMAINADD(dom) \ +do { \ + if (!pffinddomain(dom.dom_family)) { \ + domain_attach(&dom); \ + } \ +} while (/*CONSTCOND*/0) + +void rump_net_net_init(void); +void rump_net_inet_init(void); +void rump_net_local_init(void); +void rump_net_sockin_init(void); +void rump_net_virtif_init(void); + void rump_dummyif_create(void); #endif /* _SYS_RUMP_NET_PRIVATE_H_ */ Index: src/sys/rump/net/lib/liblocal/Makefile diff -u src/sys/rump/net/lib/liblocal/Makefile:1.1 src/sys/rump/net/lib/liblocal/Makefile:1.2 --- src/sys/rump/net/lib/liblocal/Makefile:1.1 Sun Feb 8 16:28:35 2009 +++ src/sys/rump/net/lib/liblocal/Makefile Thu May 28 00:02:16 2009 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.1 2009/02/08 16:28:35 pooka Exp $ +# $NetBSD: Makefile,v 1.2 2009/05/28 00:02:16 pooka Exp $ # .PATH: ${.CURDIR}/../../../../kern @@ -6,6 +6,7 @@ LIB= rumpnet_local SRCS= uipc_proto.c uipc_usrreq.c +SRCS+= component.c CFLAGS+= -Wno-pointer-sign Index: src/sys/rump/net/lib/libnet/Makefile diff -u src/sys/rump/net/lib/libnet/Makefile:1.4 src/sys/rump/net/lib/libnet/Makefile:1.5 --- src/sys/rump/net/lib/libnet/Makefile:1.4 Tue Feb 3 00:33:26 2009 +++ src/sys/rump/net/lib/libnet/Makefile Thu May 28 00:02:16 2009 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.4 2009/02/03 00:33:26 pooka Exp $ +# $NetBSD: Makefile,v 1.5 2009/05/28 00:02:16 pooka Exp $ # .PATH: ${.CURDIR}/../../../../net @@ -8,6 +8,7 @@ # iffy stuff SRCS= if.c if_loop.c route.c rtsock.c raw_usrreq.c raw_cb.c \ if_media.c link_proto.c net_stats.c if_ethersubr.c +SRCS+= component.c CPPFLAGS+= -I${.CURDIR}/opt -I${.CURDIR}/../libnetinet/opt Index: src/sys/rump/net/lib/libsockin/Makefile diff -u src/sys/rump/net/lib/libsockin/Makefile:1.2 src/sys/rump/net/lib/libsockin/Makefile:1.3 --- src/sys/rump/net/lib/libsockin/Makefile:1.2 Mon Jan 26 10:43:21 2009 +++ src/sys/rump/net/lib/libsockin/Makefile Thu May 28 00:02:16 2009 @@ -1,9 +1,10 @@ -# $NetBSD: Makefile,v 1.2 2009/01/26 10:43:21 pooka Exp $ +# $NetBSD: Makefile,v 1.3 2009/05/28 00:02:16 pooka Exp $ # LIB= rumpnet_sockin SRCS= sockin.c +SRCS+= component.c CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern Index: src/sys/rump/net/lib/libvirtif/Makefile diff -u src/sys/rump/net/lib/libvirtif/Makefile:1.2 src/sys/rump/net/lib/libvirtif/Makefile:1.3 --- src/sys/rump/net/lib/libvirtif/Makefile:1.2 Thu Oct 16 09:24:51 2008 +++ src/sys/rump/net/lib/libvirtif/Makefile Thu May 28 00:02:17 2009 @@ -1,9 +1,10 @@ -# $NetBSD: Makefile,v 1.2 2008/10/16 09:24:51 pooka Exp $ +# $NetBSD: Makefile,v 1.3 2009/05/28 00:02:17 pooka Exp $ # LIB= rumpnet_virtif SRCS= if_virt.c +SRCS+= component.c CPPFLAGS+= -I${.CURDIR}/../../../librump/rumpkern Added files: Index: src/sys/rump/net/lib/liblocal/component.c diff -u /dev/null src/sys/rump/net/lib/liblocal/component.c:1.1 --- /dev/null Thu May 28 00:02:17 2009 +++ src/sys/rump/net/lib/liblocal/component.c Thu May 28 00:02:16 2009 @@ -0,0 +1,47 @@ +/* $NetBSD: component.c,v 1.1 2009/05/28 00:02:16 pooka Exp $ */ + +/* + * Copyright (c) 2009 Antti Kantee. All Rights Reserved. + * + * Development of this software was supported by The Nokia Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + */ + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.1 2009/05/28 00:02:16 pooka Exp $"); + +#include <sys/param.h> +#include <sys/domain.h> +#include <sys/protosw.h> + +#include <net/route.h> + +#include "rump_net_private.h" + +void +rump_net_local_init() +{ + extern struct domain unixdomain; + + DOMAINADD(unixdomain); +} Index: src/sys/rump/net/lib/libnet/component.c diff -u /dev/null src/sys/rump/net/lib/libnet/component.c:1.1 --- /dev/null Thu May 28 00:02:17 2009 +++ src/sys/rump/net/lib/libnet/component.c Thu May 28 00:02:16 2009 @@ -0,0 +1,49 @@ +/* $NetBSD: component.c,v 1.1 2009/05/28 00:02:16 pooka Exp $ */ + +/* + * Copyright (c) 2009 Antti Kantee. All Rights Reserved. + * + * Development of this software was supported by The Nokia Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + */ + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.1 2009/05/28 00:02:16 pooka Exp $"); + +#include <sys/param.h> +#include <sys/domain.h> +#include <sys/protosw.h> + +#include <net/if.h> +#include <net/route.h> + +#include "rump_net_private.h" + +void +rump_net_net_init() +{ + extern struct domain routedomain; + + loopattach(0); + DOMAINADD(routedomain); +} Index: src/sys/rump/net/lib/libnetinet/component.c diff -u /dev/null src/sys/rump/net/lib/libnetinet/component.c:1.1 --- /dev/null Thu May 28 00:02:17 2009 +++ src/sys/rump/net/lib/libnetinet/component.c Thu May 28 00:02:16 2009 @@ -0,0 +1,49 @@ +/* $NetBSD: component.c,v 1.1 2009/05/28 00:02:16 pooka Exp $ */ + +/* + * Copyright (c) 2009 Antti Kantee. All Rights Reserved. + * + * Development of this software was supported by The Nokia Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + */ + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.1 2009/05/28 00:02:16 pooka Exp $"); + +#include <sys/param.h> +#include <sys/domain.h> +#include <sys/protosw.h> + +#include <net/route.h> + +#include "rump_net_private.h" + +void +rump_net_inet_init() +{ + extern struct domain arpdomain, inetdomain, inet6domain; + + DOMAINADD(arpdomain); + DOMAINADD(inetdomain); + DOMAINADD(inet6domain); +} Index: src/sys/rump/net/lib/libsockin/component.c diff -u /dev/null src/sys/rump/net/lib/libsockin/component.c:1.1 --- /dev/null Thu May 28 00:02:17 2009 +++ src/sys/rump/net/lib/libsockin/component.c Thu May 28 00:02:16 2009 @@ -0,0 +1,47 @@ +/* $NetBSD: component.c,v 1.1 2009/05/28 00:02:16 pooka Exp $ */ + +/* + * Copyright (c) 2009 Antti Kantee. All Rights Reserved. + * + * Development of this software was supported by The Nokia Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + */ + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.1 2009/05/28 00:02:16 pooka Exp $"); + +#include <sys/param.h> +#include <sys/domain.h> +#include <sys/protosw.h> + +#include <net/route.h> + +#include "rump_net_private.h" + +void +rump_net_sockin_init() +{ + extern struct domain sockindomain; + + DOMAINADD(sockindomain); +} Index: src/sys/rump/net/lib/libvirtif/component.c diff -u /dev/null src/sys/rump/net/lib/libvirtif/component.c:1.1 --- /dev/null Thu May 28 00:02:17 2009 +++ src/sys/rump/net/lib/libvirtif/component.c Thu May 28 00:02:17 2009 @@ -0,0 +1,46 @@ +/* $NetBSD: component.c,v 1.1 2009/05/28 00:02:17 pooka Exp $ */ + +/* + * Copyright (c) 2009 Antti Kantee. All Rights Reserved. + * + * Development of this software was supported by The Nokia Foundation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + */ + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.1 2009/05/28 00:02:17 pooka Exp $"); + +#include <sys/param.h> +#include <sys/domain.h> +#include <sys/protosw.h> + +#include <net/route.h> + +#include "rump_net_private.h" + +void +rump_net_virtif_init() +{ + + rump_dummyif_create(); +}