Register netisr's from component constructors instead of via a hardcoded

global list.
This commit is contained in:
pooka 2014-02-14 01:43:13 +00:00
parent c1c33d6851
commit 459f46c52b
6 changed files with 34 additions and 60 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: netisr.c,v 1.6 2013/07/18 15:59:27 kefren Exp $ */
/* $NetBSD: netisr.c,v 1.7 2014/02/14 01:43:13 pooka Exp $ */
/*
* Copyright (c) 2008 Antti Kantee. All Rights Reserved.
@ -26,17 +26,11 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netisr.c,v 1.6 2013/07/18 15:59:27 kefren Exp $");
__KERNEL_RCSID(0, "$NetBSD: netisr.c,v 1.7 2014/02/14 01:43:13 pooka Exp $");
#include <sys/param.h>
#include <sys/intr.h>
#include <netinet/in.h>
#include <netinet/ip_var.h>
#include <netinet/if_inarp.h>
#include <netinet/ip6.h>
#include <netinet6/ip6_var.h>
#include <netmpls/mpls_var.h>
#include <net/netisr.h>
#include <rump/rumpuser.h>
@ -51,48 +45,10 @@ schednetisr(int isr)
softint_schedule(netisrs[isr]);
}
/*
* Aliases are needed only for static linking (dlsym() is not supported).
*/
void __netisr_stub(void);
void
__netisr_stub(void)
rump_netisr_register(int level, void (*handler)(void))
{
panic("netisr called but networking stack missing");
}
__weak_alias(ipintr,__netisr_stub);
__weak_alias(arpintr,__netisr_stub);
__weak_alias(ip6intr,__netisr_stub);
__weak_alias(mplsintr,__netisr_stub);
void
rump_netisr_init(void)
{
void *iphand, *arphand, *ip6hand, *mplshand, *sym;
iphand = ipintr;
if ((sym = rumpuser_dl_globalsym("rumpns_ipintr")) != NULL)
iphand = sym;
arphand = arpintr;
if ((sym = rumpuser_dl_globalsym("rumpns_arpintr")) != NULL)
arphand = sym;
ip6hand = ip6intr;
if ((sym = rumpuser_dl_globalsym("rumpns_ip6intr")) != NULL)
ip6hand = sym;
mplshand = mplsintr;
if ((sym = rumpuser_dl_globalsym("rumpns_mplsintr")) != NULL)
mplshand = sym;
netisrs[NETISR_IP] = softint_establish(SOFTINT_NET | SOFTINT_MPSAFE,
(void (*)(void *))iphand, NULL);
netisrs[NETISR_ARP] = softint_establish(SOFTINT_NET | SOFTINT_MPSAFE,
(void (*)(void *))arphand, NULL);
netisrs[NETISR_IPV6] = softint_establish(SOFTINT_NET | SOFTINT_MPSAFE,
(void (*)(void *))ip6hand, NULL);
netisrs[NETISR_MPLS] = softint_establish(SOFTINT_NET | SOFTINT_MPSAFE,
(void (*)(void *))mplshand, NULL);
netisrs[level] = softint_establish(SOFTINT_NET | SOFTINT_MPSAFE,
(void (*)(void *))handler, NULL);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: rump_net.c,v 1.16 2013/01/14 16:50:54 pooka Exp $ */
/* $NetBSD: rump_net.c,v 1.17 2014/02/14 01:43:13 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.16 2013/01/14 16:50:54 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: rump_net.c,v 1.17 2014/02/14 01:43:13 pooka Exp $");
#include <sys/param.h>
@ -50,7 +50,6 @@ RUMP_COMPONENT(RUMP__FACTION_NET)
soinit();
domaininit(false);
rump_netisr_init();
rump_component_init(RUMP_COMPONENT_NET);
rump_component_init(RUMP_COMPONENT_NET_ROUTE);

View File

@ -1,4 +1,4 @@
/* $NetBSD: rump_net_private.h,v 1.8 2014/02/14 01:27:48 pooka Exp $ */
/* $NetBSD: rump_net_private.h,v 1.9 2014/02/14 01:43:13 pooka Exp $ */
/*
* Copyright (c) 2008 Antti Kantee. All Rights Reserved.
@ -28,7 +28,7 @@
#ifndef _SYS_RUMP_NET_PRIVATE_H_
#define _SYS_RUMP_NET_PRIVATE_H_
void rump_netisr_init(void);
void rump_netisr_register(int, void (*)(void));
#define DOMAINADD(dom) \
do { \

View File

@ -1,4 +1,4 @@
/* $NetBSD: component.c,v 1.9 2014/01/02 18:29:01 pooka Exp $ */
/* $NetBSD: component.c,v 1.10 2014/02/14 01:43:13 pooka Exp $ */
/*
* Copyright (c) 2009 Antti Kantee. All Rights Reserved.
@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.9 2014/01/02 18:29:01 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.10 2014/02/14 01:43:13 pooka Exp $");
#include <sys/param.h>
#include <sys/domain.h>
@ -36,8 +36,11 @@ __KERNEL_RCSID(0, "$NetBSD: component.c,v 1.9 2014/01/02 18:29:01 pooka Exp $");
#include <sys/socketvar.h>
#include <net/if.h>
#include <net/netisr.h>
#include <netinet/in.h>
#include <netinet/in_var.h>
#include <netinet/ip_var.h>
#include <netinet/if_inarp.h>
#include "rump_private.h"
#include "rump_net_private.h"
@ -52,6 +55,9 @@ RUMP_COMPONENT(RUMP_COMPONENT_NET)
DOMAINADD(inetdomain);
carpattach(1);
rump_netisr_register(NETISR_IP, ipintr);
rump_netisr_register(NETISR_ARP, arpintr);
}
RUMP_COMPONENT(RUMP_COMPONENT_NET_IFCFG)

View File

@ -1,4 +1,4 @@
/* $NetBSD: component.c,v 1.3 2014/01/02 18:29:01 pooka Exp $ */
/* $NetBSD: component.c,v 1.4 2014/02/14 01:43:13 pooka Exp $ */
/*
* Copyright (c) 2013 Antti Kantee. All Rights Reserved.
@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.3 2014/01/02 18:29:01 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.4 2014/02/14 01:43:13 pooka Exp $");
#include <sys/param.h>
#include <sys/domain.h>
@ -34,6 +34,12 @@ __KERNEL_RCSID(0, "$NetBSD: component.c,v 1.3 2014/01/02 18:29:01 pooka Exp $");
#include <sys/socketvar.h>
#include <net/if.h>
#include <net/netisr.h>
#include <netinet/in.h>
#include <netinet/ip_var.h>
#include <netinet/ip6.h>
#include <netinet6/ip6_var.h>
#include "rump_private.h"
#include "rump_net_private.h"
@ -43,6 +49,8 @@ RUMP_COMPONENT(RUMP_COMPONENT_NET)
extern struct domain inet6domain;
DOMAINADD(inet6domain);
rump_netisr_register(NETISR_IPV6, ip6intr);
}
RUMP_COMPONENT(RUMP_COMPONENT_NET_IFCFG)

View File

@ -1,4 +1,4 @@
/* $NetBSD: component.c,v 1.1 2013/07/18 15:59:28 kefren Exp $ */
/* $NetBSD: component.c,v 1.2 2014/02/14 01:43:13 pooka Exp $ */
/*
* Copyright (c) 2009 Antti Kantee. All Rights Reserved.
@ -31,15 +31,18 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.1 2013/07/18 15:59:28 kefren Exp $");
__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.2 2014/02/14 01:43:13 pooka Exp $");
#include <sys/param.h>
#include <sys/domain.h>
#include <sys/protosw.h>
#include <net/if.h>
#include <net/netisr.h>
#include <net/route.h>
#include <netmpls/mpls_var.h>
#include "rump_private.h"
#include "rump_net_private.h"
@ -50,6 +53,8 @@ RUMP_COMPONENT(RUMP_COMPONENT_NET)
extern struct domain mplsdomain;
DOMAINADD(mplsdomain);
rump_netisr_register(NETISR_MPLS, mplsintr);
}
RUMP_COMPONENT(RUMP_COMPONENT_NET_IF)