2005-04-21 16:53:53 +02:00
|
|
|
/* this file contains the interface of the network software with rest of
|
|
|
|
minix. Furthermore it contains the main loop of the network task.
|
|
|
|
|
|
|
|
Copyright 1995 Philip Homburg
|
|
|
|
|
|
|
|
The valid messages and their parameters are:
|
|
|
|
|
|
|
|
from FS:
|
|
|
|
__________________________________________________________________
|
|
|
|
| | | | | | |
|
|
|
|
| m_type | DEVICE | PROC_NR | COUNT | POSITION | ADDRESS |
|
|
|
|
|_______________|___________|_________|_______|__________|_________|
|
|
|
|
| | | | | | |
|
|
|
|
| NW_OPEN | minor dev | proc nr | mode | | |
|
|
|
|
|_______________|___________|_________|_______|__________|_________|
|
|
|
|
| | | | | | |
|
|
|
|
| NW_CLOSE | minor dev | proc nr | | | |
|
|
|
|
|_______________|___________|_________|_______|__________|_________|
|
|
|
|
| | | | | | |
|
|
|
|
| NW_IOCTL | minor dev | proc nr | | NWIO.. | address |
|
|
|
|
|_______________|___________|_________|_______|__________|_________|
|
|
|
|
| | | | | | |
|
|
|
|
| NW_READ | minor dev | proc nr | count | | address |
|
|
|
|
|_______________|___________|_________|_______|__________|_________|
|
|
|
|
| | | | | | |
|
|
|
|
| NW_WRITE | minor dev | proc nr | count | | address |
|
|
|
|
|_______________|___________|_________|_______|__________|_________|
|
|
|
|
| | | | | | |
|
|
|
|
| NW_CANCEL | minor dev | proc nr | | | |
|
|
|
|
|_______________|___________|_________|_______|__________|_________|
|
|
|
|
|
2005-06-28 17:19:58 +02:00
|
|
|
from DL_ETH:
|
2005-04-21 16:53:53 +02:00
|
|
|
_______________________________________________________________________
|
|
|
|
| | | | | | |
|
|
|
|
| m_type | DL_PORT | DL_PROC | DL_COUNT | DL_STAT | DL_TIME |
|
|
|
|
|_______________|___________|_________|__________|____________|_________|
|
|
|
|
| | | | | | |
|
2007-04-23 16:49:20 +02:00
|
|
|
| DL_CONF_REPLY | minor dev | proc nr | rd_count | 0 | stat | time |
|
2005-04-21 16:53:53 +02:00
|
|
|
|_______________|___________|_________|__________|____________|_________|
|
|
|
|
| | | | | | |
|
2005-06-28 17:19:58 +02:00
|
|
|
| DL_TASK_REPLY | minor dev | proc nr | rd_count | err | stat | time |
|
2005-04-21 16:53:53 +02:00
|
|
|
|_______________|___________|_________|__________|____________|_________|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "inet.h"
|
|
|
|
|
2005-06-28 17:19:58 +02:00
|
|
|
#define _MINIX_SOURCE 1
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-06-28 17:19:58 +02:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <time.h>
|
2005-04-21 16:53:53 +02:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/svrctl.h>
|
2007-05-02 13:30:16 +02:00
|
|
|
#include <minix/ds.h>
|
2009-09-29 20:47:56 +02:00
|
|
|
#include <minix/endpoint.h>
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
#include "mq.h"
|
2005-06-28 17:19:58 +02:00
|
|
|
#include "qp.h"
|
2005-04-21 16:53:53 +02:00
|
|
|
#include "proto.h"
|
|
|
|
#include "generic/type.h"
|
|
|
|
|
2005-06-28 17:19:58 +02:00
|
|
|
#include "generic/arp.h"
|
2005-04-21 16:53:53 +02:00
|
|
|
#include "generic/assert.h"
|
|
|
|
#include "generic/buf.h"
|
|
|
|
#include "generic/clock.h"
|
|
|
|
#include "generic/eth.h"
|
|
|
|
#include "generic/event.h"
|
|
|
|
#include "generic/ip.h"
|
|
|
|
#include "generic/psip.h"
|
2005-06-28 17:19:58 +02:00
|
|
|
#include "generic/rand256.h"
|
2005-04-21 16:53:53 +02:00
|
|
|
#include "generic/sr.h"
|
|
|
|
#include "generic/tcp.h"
|
|
|
|
#include "generic/udp.h"
|
|
|
|
|
|
|
|
THIS_FILE
|
|
|
|
|
2005-06-28 17:19:58 +02:00
|
|
|
#define RANDOM_DEV_NAME "/dev/random"
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
int this_proc; /* Process number of this server. */
|
|
|
|
|
2005-06-28 17:19:58 +02:00
|
|
|
#ifdef __minix_vmd
|
|
|
|
static int synal_tasknr= ANY;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Killing Solaris */
|
|
|
|
int killer_inet= 0;
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
#ifdef BUF_CONSISTENCY_CHECK
|
|
|
|
extern int inet_buf_debug;
|
|
|
|
#endif
|
|
|
|
|
2008-12-11 15:54:42 +01:00
|
|
|
#if HZ_DYNAMIC
|
|
|
|
u32_t system_hz;
|
|
|
|
#endif
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
_PROTOTYPE( void main, (void) );
|
|
|
|
|
2005-06-28 17:19:58 +02:00
|
|
|
FORWARD _PROTOTYPE( void nw_conf, (void) );
|
2005-04-21 16:53:53 +02:00
|
|
|
FORWARD _PROTOTYPE( void nw_init, (void) );
|
|
|
|
|
Basic System Event Framework (SEF) with ping and live update.
SYSLIB CHANGES:
- SEF must be used by every system process and is thereby part of the system
library.
- The framework provides a receive() interface (sef_receive) for system
processes to automatically catch known system even messages and process them.
- SEF provides a default behavior for each type of system event, but allows
system processes to register callbacks to override the default behavior.
- Custom (local to the process) or predefined (provided by SEF) callback
implementations can be registered to SEF.
- SEF currently includes support for 2 types of system events:
1. SEF Ping. The event occurs every time RS sends a ping to figure out
whether a system process is still alive. The default callback implementation
provided by SEF is to notify RS back to let it know the process is alive
and kicking.
2. SEF Live update. The event occurs every time RS sends a prepare to update
message to let a system process know an update is available and to prepare
for it. The live update support is very basic for now. SEF only deals with
verifying if the prepare state can be supported by the process, dumping the
state for debugging purposes, and providing an event-driven programming
model to the process to react to state changes check-in when ready to update.
- SEF should be extended in the future to integrate support for more types of
system events. Ideally, all the cross-cutting concerns should be integrated into
SEF to avoid duplicating code and ease extensibility. Examples include:
* PM notify messages primarily used at shutdown.
* SYSTEM notify messages primarily used for signals.
* CLOCK notify messages used for system alarms.
* Debug messages. IS could still be in charge of fkey handling but would
forward the debug message to the target process (e.g. PM, if the user
requested debug information about PM). SEF would then catch the message and
do nothing unless the process has registered an appropriate callback to
deal with the event. This simplifies the programming model to print debug
information, avoids duplicating code, and reduces the effort to print
debug information.
SYSTEM PROCESSES CHANGES:
- Every system process registers SEF callbacks it needs to override the default
system behavior and calls sef_startup() right after being started.
- sef_startup() does almost nothing now, but will be extended in the future to
support callbacks of its own to let RS control and synchronize with every
system process at initialization time.
- Every system process calls sef_receive() now rather than receive() directly,
to let SEF handle predefined system events.
RS CHANGES:
- RS supports a basic single-component live update protocol now, as follows:
* When an update command is issued (via "service update *"), RS notifies the
target system process to prepare for a specific update state.
* If the process doesn't respond back in time, the update is aborted.
* When the process responds back, RS kills it and marks it for refreshing.
* The process is then automatically restarted as for a buggy process and can
start running again.
* Live update is currently prototyped as a controlled failure.
2009-12-21 15:12:21 +01:00
|
|
|
/* SEF functions and variables. */
|
|
|
|
FORWARD _PROTOTYPE( void sef_local_startup, (void) );
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
PUBLIC void main()
|
|
|
|
{
|
|
|
|
mq_t *mq;
|
|
|
|
int r;
|
2007-04-23 16:49:20 +02:00
|
|
|
int source, m_type, timerand, fd;
|
2007-05-02 13:30:16 +02:00
|
|
|
u32_t tasknr;
|
2005-06-28 17:19:58 +02:00
|
|
|
struct fssignon device;
|
|
|
|
#ifdef __minix_vmd
|
|
|
|
struct systaskinfo info;
|
|
|
|
#endif
|
|
|
|
u8_t randbits[32];
|
|
|
|
struct timeval tv;
|
|
|
|
|
Basic System Event Framework (SEF) with ping and live update.
SYSLIB CHANGES:
- SEF must be used by every system process and is thereby part of the system
library.
- The framework provides a receive() interface (sef_receive) for system
processes to automatically catch known system even messages and process them.
- SEF provides a default behavior for each type of system event, but allows
system processes to register callbacks to override the default behavior.
- Custom (local to the process) or predefined (provided by SEF) callback
implementations can be registered to SEF.
- SEF currently includes support for 2 types of system events:
1. SEF Ping. The event occurs every time RS sends a ping to figure out
whether a system process is still alive. The default callback implementation
provided by SEF is to notify RS back to let it know the process is alive
and kicking.
2. SEF Live update. The event occurs every time RS sends a prepare to update
message to let a system process know an update is available and to prepare
for it. The live update support is very basic for now. SEF only deals with
verifying if the prepare state can be supported by the process, dumping the
state for debugging purposes, and providing an event-driven programming
model to the process to react to state changes check-in when ready to update.
- SEF should be extended in the future to integrate support for more types of
system events. Ideally, all the cross-cutting concerns should be integrated into
SEF to avoid duplicating code and ease extensibility. Examples include:
* PM notify messages primarily used at shutdown.
* SYSTEM notify messages primarily used for signals.
* CLOCK notify messages used for system alarms.
* Debug messages. IS could still be in charge of fkey handling but would
forward the debug message to the target process (e.g. PM, if the user
requested debug information about PM). SEF would then catch the message and
do nothing unless the process has registered an appropriate callback to
deal with the event. This simplifies the programming model to print debug
information, avoids duplicating code, and reduces the effort to print
debug information.
SYSTEM PROCESSES CHANGES:
- Every system process registers SEF callbacks it needs to override the default
system behavior and calls sef_startup() right after being started.
- sef_startup() does almost nothing now, but will be extended in the future to
support callbacks of its own to let RS control and synchronize with every
system process at initialization time.
- Every system process calls sef_receive() now rather than receive() directly,
to let SEF handle predefined system events.
RS CHANGES:
- RS supports a basic single-component live update protocol now, as follows:
* When an update command is issued (via "service update *"), RS notifies the
target system process to prepare for a specific update state.
* If the process doesn't respond back in time, the update is aborted.
* When the process responds back, RS kills it and marks it for refreshing.
* The process is then automatically restarted as for a buggy process and can
start running again.
* Live update is currently prototyped as a controlled failure.
2009-12-21 15:12:21 +01:00
|
|
|
/* SEF local startup. */
|
|
|
|
sef_local_startup();
|
|
|
|
|
2005-06-28 17:19:58 +02:00
|
|
|
#if DEBUG
|
|
|
|
printf("Starting inet...\n");
|
|
|
|
printf("%s\n", version);
|
|
|
|
#endif
|
|
|
|
|
2008-12-11 15:54:42 +01:00
|
|
|
#if HZ_DYNAMIC
|
|
|
|
system_hz = sys_hz();
|
|
|
|
#endif
|
|
|
|
|
2005-06-28 17:19:58 +02:00
|
|
|
/* Read configuration. */
|
|
|
|
nw_conf();
|
|
|
|
|
|
|
|
/* Get a random number */
|
|
|
|
timerand= 1;
|
|
|
|
fd= open(RANDOM_DEV_NAME, O_RDONLY | O_NONBLOCK);
|
|
|
|
if (fd != -1)
|
|
|
|
{
|
|
|
|
r= read(fd, randbits, sizeof(randbits));
|
|
|
|
if (r == sizeof(randbits))
|
|
|
|
timerand= 0;
|
|
|
|
else
|
|
|
|
{
|
2009-04-02 13:56:50 +02:00
|
|
|
printf("inet: unable to read random data from %s: %s\n",
|
2005-06-28 17:19:58 +02:00
|
|
|
RANDOM_DEV_NAME, r == -1 ? strerror(errno) :
|
|
|
|
r == 0 ? "EOF" : "not enough data");
|
|
|
|
}
|
|
|
|
close(fd);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-04-02 13:56:50 +02:00
|
|
|
printf("inet: unable to open random device %s: %s\n",
|
2005-06-28 17:19:58 +02:00
|
|
|
RANDOM_DEV_NAME, strerror(errno));
|
|
|
|
}
|
|
|
|
if (timerand)
|
|
|
|
{
|
2009-04-02 13:56:50 +02:00
|
|
|
printf("inet: using current time for random-number seed\n");
|
2005-06-28 17:19:58 +02:00
|
|
|
#ifdef __minix_vmd
|
|
|
|
r= sysutime(UTIME_TIMEOFDAY, &tv);
|
|
|
|
#else /* Minix 3 */
|
|
|
|
r= gettimeofday(&tv, NULL);
|
|
|
|
#endif
|
|
|
|
if (r == -1)
|
|
|
|
{
|
|
|
|
printf("sysutime failed: %s\n", strerror(errno));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
memcpy(randbits, &tv, sizeof(tv));
|
|
|
|
}
|
|
|
|
init_rand256(randbits);
|
|
|
|
|
|
|
|
#ifdef __minix_vmd
|
|
|
|
if (svrctl(SYSSIGNON, (void *) &info) == -1) pause();
|
|
|
|
|
|
|
|
/* Our new identity as a server. */
|
|
|
|
this_proc = info.proc_nr;
|
|
|
|
#else /* Minix 3 */
|
|
|
|
|
|
|
|
/* Our new identity as a server. */
|
2007-05-02 13:30:16 +02:00
|
|
|
r= ds_retrieve_u32("inet", &tasknr);
|
|
|
|
if (r != OK)
|
|
|
|
ip_panic(("inet: ds_retrieve_u32 failed for 'inet': %d", r));
|
|
|
|
this_proc= tasknr;
|
2005-06-28 17:19:58 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Register the device group. */
|
|
|
|
device.dev= ip_dev;
|
|
|
|
device.style= STYLE_CLONE;
|
|
|
|
if (svrctl(FSSIGNON, (void *) &device) == -1) {
|
|
|
|
printf("inet: error %d on registering ethernet devices\n",
|
|
|
|
errno);
|
|
|
|
pause();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef BUF_CONSISTENCY_CHECK
|
|
|
|
inet_buf_debug= (getenv("inetbufdebug") &&
|
|
|
|
(strcmp(getenv("inetbufdebug"), "on") == 0));
|
|
|
|
inet_buf_debug= 100;
|
|
|
|
if (inet_buf_debug)
|
|
|
|
{
|
|
|
|
ip_warning(( "buffer consistency check enabled" ));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (getenv("killerinet"))
|
|
|
|
{
|
|
|
|
ip_warning(( "killer inet active" ));
|
|
|
|
killer_inet= 1;
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-06-28 17:19:58 +02:00
|
|
|
#ifdef __minix_vmd
|
|
|
|
r= sys_findproc(SYN_AL_NAME, &synal_tasknr, 0);
|
|
|
|
if (r != OK)
|
|
|
|
ip_panic(( "unable to find synchronous alarm task: %d\n", r ));
|
|
|
|
#endif
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
nw_init();
|
|
|
|
while (TRUE)
|
|
|
|
{
|
|
|
|
#ifdef BUF_CONSISTENCY_CHECK
|
|
|
|
if (inet_buf_debug)
|
|
|
|
{
|
|
|
|
static int buf_debug_count= 0;
|
|
|
|
|
2005-06-28 17:19:58 +02:00
|
|
|
if (++buf_debug_count >= inet_buf_debug)
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
|
|
|
buf_debug_count= 0;
|
|
|
|
if (!bf_consistency_check())
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (ev_head)
|
|
|
|
{
|
|
|
|
ev_process();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (clck_call_expire)
|
|
|
|
{
|
|
|
|
clck_expire_timers();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
mq= mq_get();
|
|
|
|
if (!mq)
|
|
|
|
ip_panic(("out of messages"));
|
|
|
|
|
Basic System Event Framework (SEF) with ping and live update.
SYSLIB CHANGES:
- SEF must be used by every system process and is thereby part of the system
library.
- The framework provides a receive() interface (sef_receive) for system
processes to automatically catch known system even messages and process them.
- SEF provides a default behavior for each type of system event, but allows
system processes to register callbacks to override the default behavior.
- Custom (local to the process) or predefined (provided by SEF) callback
implementations can be registered to SEF.
- SEF currently includes support for 2 types of system events:
1. SEF Ping. The event occurs every time RS sends a ping to figure out
whether a system process is still alive. The default callback implementation
provided by SEF is to notify RS back to let it know the process is alive
and kicking.
2. SEF Live update. The event occurs every time RS sends a prepare to update
message to let a system process know an update is available and to prepare
for it. The live update support is very basic for now. SEF only deals with
verifying if the prepare state can be supported by the process, dumping the
state for debugging purposes, and providing an event-driven programming
model to the process to react to state changes check-in when ready to update.
- SEF should be extended in the future to integrate support for more types of
system events. Ideally, all the cross-cutting concerns should be integrated into
SEF to avoid duplicating code and ease extensibility. Examples include:
* PM notify messages primarily used at shutdown.
* SYSTEM notify messages primarily used for signals.
* CLOCK notify messages used for system alarms.
* Debug messages. IS could still be in charge of fkey handling but would
forward the debug message to the target process (e.g. PM, if the user
requested debug information about PM). SEF would then catch the message and
do nothing unless the process has registered an appropriate callback to
deal with the event. This simplifies the programming model to print debug
information, avoids duplicating code, and reduces the effort to print
debug information.
SYSTEM PROCESSES CHANGES:
- Every system process registers SEF callbacks it needs to override the default
system behavior and calls sef_startup() right after being started.
- sef_startup() does almost nothing now, but will be extended in the future to
support callbacks of its own to let RS control and synchronize with every
system process at initialization time.
- Every system process calls sef_receive() now rather than receive() directly,
to let SEF handle predefined system events.
RS CHANGES:
- RS supports a basic single-component live update protocol now, as follows:
* When an update command is issued (via "service update *"), RS notifies the
target system process to prepare for a specific update state.
* If the process doesn't respond back in time, the update is aborted.
* When the process responds back, RS kills it and marks it for refreshing.
* The process is then automatically restarted as for a buggy process and can
start running again.
* Live update is currently prototyped as a controlled failure.
2009-12-21 15:12:21 +01:00
|
|
|
r= sef_receive(ANY, &mq->mq_mess);
|
2005-06-28 17:19:58 +02:00
|
|
|
if (r<0)
|
|
|
|
{
|
2005-04-21 16:53:53 +02:00
|
|
|
ip_panic(("unable to receive: %d", r));
|
|
|
|
}
|
|
|
|
reset_time();
|
|
|
|
source= mq->mq_mess.m_source;
|
2007-04-23 16:49:20 +02:00
|
|
|
m_type= mq->mq_mess.m_type;
|
2005-06-28 17:19:58 +02:00
|
|
|
if (source == FS_PROC_NR)
|
|
|
|
{
|
2005-04-21 16:53:53 +02:00
|
|
|
sr_rec(mq);
|
2005-06-28 17:19:58 +02:00
|
|
|
}
|
|
|
|
#ifdef __minix_vmd
|
|
|
|
else if (source == synal_tasknr)
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
2005-06-28 17:19:58 +02:00
|
|
|
clck_tick (&mq->mq_mess);
|
|
|
|
mq_free(mq);
|
|
|
|
}
|
|
|
|
#else /* Minix 3 */
|
2009-09-29 20:47:56 +02:00
|
|
|
else if (is_notify(m_type))
|
2005-06-28 17:19:58 +02:00
|
|
|
{
|
2009-09-29 20:47:56 +02:00
|
|
|
if (_ENDPOINT_P(source) == CLOCK)
|
|
|
|
{
|
|
|
|
clck_tick(&mq->mq_mess);
|
|
|
|
mq_free(mq);
|
|
|
|
}
|
|
|
|
else if (_ENDPOINT_P(source) == PM_PROC_NR)
|
|
|
|
{
|
|
|
|
/* signaled */
|
|
|
|
/* probably SIGTERM */
|
|
|
|
mq_free(mq);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* A driver is (re)started. */
|
|
|
|
eth_check_drivers(&mq->mq_mess);
|
|
|
|
mq_free(mq);
|
|
|
|
}
|
2005-10-21 13:51:45 +02:00
|
|
|
}
|
2005-06-28 17:19:58 +02:00
|
|
|
#endif
|
2007-04-23 16:49:20 +02:00
|
|
|
else if (m_type == DL_CONF_REPLY || m_type == DL_TASK_REPLY ||
|
|
|
|
m_type == DL_NAME_REPLY || m_type == DL_STAT_REPLY)
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
|
|
|
eth_rec(&mq->mq_mess);
|
|
|
|
mq_free(mq);
|
|
|
|
}
|
2006-08-28 14:59:36 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("inet: got bad message type 0x%x from %d\n",
|
|
|
|
mq->mq_mess.m_type, mq->mq_mess.m_source);
|
|
|
|
mq_free(mq);
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
ip_panic(("task is not allowed to terminate"));
|
|
|
|
}
|
|
|
|
|
Basic System Event Framework (SEF) with ping and live update.
SYSLIB CHANGES:
- SEF must be used by every system process and is thereby part of the system
library.
- The framework provides a receive() interface (sef_receive) for system
processes to automatically catch known system even messages and process them.
- SEF provides a default behavior for each type of system event, but allows
system processes to register callbacks to override the default behavior.
- Custom (local to the process) or predefined (provided by SEF) callback
implementations can be registered to SEF.
- SEF currently includes support for 2 types of system events:
1. SEF Ping. The event occurs every time RS sends a ping to figure out
whether a system process is still alive. The default callback implementation
provided by SEF is to notify RS back to let it know the process is alive
and kicking.
2. SEF Live update. The event occurs every time RS sends a prepare to update
message to let a system process know an update is available and to prepare
for it. The live update support is very basic for now. SEF only deals with
verifying if the prepare state can be supported by the process, dumping the
state for debugging purposes, and providing an event-driven programming
model to the process to react to state changes check-in when ready to update.
- SEF should be extended in the future to integrate support for more types of
system events. Ideally, all the cross-cutting concerns should be integrated into
SEF to avoid duplicating code and ease extensibility. Examples include:
* PM notify messages primarily used at shutdown.
* SYSTEM notify messages primarily used for signals.
* CLOCK notify messages used for system alarms.
* Debug messages. IS could still be in charge of fkey handling but would
forward the debug message to the target process (e.g. PM, if the user
requested debug information about PM). SEF would then catch the message and
do nothing unless the process has registered an appropriate callback to
deal with the event. This simplifies the programming model to print debug
information, avoids duplicating code, and reduces the effort to print
debug information.
SYSTEM PROCESSES CHANGES:
- Every system process registers SEF callbacks it needs to override the default
system behavior and calls sef_startup() right after being started.
- sef_startup() does almost nothing now, but will be extended in the future to
support callbacks of its own to let RS control and synchronize with every
system process at initialization time.
- Every system process calls sef_receive() now rather than receive() directly,
to let SEF handle predefined system events.
RS CHANGES:
- RS supports a basic single-component live update protocol now, as follows:
* When an update command is issued (via "service update *"), RS notifies the
target system process to prepare for a specific update state.
* If the process doesn't respond back in time, the update is aborted.
* When the process responds back, RS kills it and marks it for refreshing.
* The process is then automatically restarted as for a buggy process and can
start running again.
* Live update is currently prototyped as a controlled failure.
2009-12-21 15:12:21 +01:00
|
|
|
/*===========================================================================*
|
|
|
|
* sef_local_startup *
|
|
|
|
*===========================================================================*/
|
|
|
|
PRIVATE void sef_local_startup()
|
|
|
|
{
|
|
|
|
/* No live update support for now. */
|
|
|
|
|
|
|
|
/* Let SEF perform startup. */
|
|
|
|
sef_startup();
|
|
|
|
}
|
|
|
|
|
2005-06-28 17:19:58 +02:00
|
|
|
PRIVATE void nw_conf()
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
|
|
|
read_conf();
|
|
|
|
eth_prep();
|
|
|
|
arp_prep();
|
|
|
|
psip_prep();
|
|
|
|
ip_prep();
|
|
|
|
tcp_prep();
|
|
|
|
udp_prep();
|
2005-06-28 17:19:58 +02:00
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2005-06-28 17:19:58 +02:00
|
|
|
PRIVATE void nw_init()
|
|
|
|
{
|
2005-04-21 16:53:53 +02:00
|
|
|
mq_init();
|
|
|
|
bf_init();
|
|
|
|
clck_init();
|
|
|
|
sr_init();
|
2006-07-13 15:19:48 +02:00
|
|
|
qp_init();
|
2005-04-21 16:53:53 +02:00
|
|
|
eth_init();
|
|
|
|
arp_init();
|
|
|
|
psip_init();
|
|
|
|
ip_init();
|
|
|
|
tcp_init();
|
|
|
|
udp_init();
|
|
|
|
}
|
|
|
|
|
|
|
|
PUBLIC void panic0(file, line)
|
|
|
|
char *file;
|
|
|
|
int line;
|
|
|
|
{
|
|
|
|
printf("panic at %s, %d: ", file, line);
|
|
|
|
}
|
|
|
|
|
2005-06-01 16:31:00 +02:00
|
|
|
PUBLIC void inet_panic()
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
|
|
|
printf("\ninet stacktrace: ");
|
2008-12-11 15:54:42 +01:00
|
|
|
util_stacktrace();
|
2005-06-28 17:19:58 +02:00
|
|
|
#ifdef __minix_vmd
|
|
|
|
sys_abort(RBT_PANIC);
|
|
|
|
#else /* Minix 3 */
|
|
|
|
(panic)("INET","aborted due to a panic",NO_NUM);
|
2005-04-21 16:53:53 +02:00
|
|
|
#endif
|
2005-06-28 17:19:58 +02:00
|
|
|
for(;;);
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
#if !NDEBUG
|
|
|
|
PUBLIC void bad_assertion(file, line, what)
|
|
|
|
char *file;
|
|
|
|
int line;
|
|
|
|
char *what;
|
|
|
|
{
|
|
|
|
panic0(file, line);
|
|
|
|
printf("assertion \"%s\" failed", what);
|
2005-06-28 17:19:58 +02:00
|
|
|
panic();
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PUBLIC void bad_compare(file, line, lhs, what, rhs)
|
|
|
|
char *file;
|
|
|
|
int line;
|
|
|
|
int lhs;
|
|
|
|
char *what;
|
|
|
|
int rhs;
|
|
|
|
{
|
|
|
|
panic0(file, line);
|
|
|
|
printf("compare (%d) %s (%d) failed", lhs, what, rhs);
|
2005-06-28 17:19:58 +02:00
|
|
|
panic();
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
#endif /* !NDEBUG */
|
|
|
|
|
|
|
|
/*
|
2005-06-28 17:19:58 +02:00
|
|
|
* $PchId: inet.c,v 1.23 2005/06/28 14:27:22 philip Exp $
|
2005-04-21 16:53:53 +02:00
|
|
|
*/
|