diff options
author | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 2001-08-23 23:11:03 +0000 |
---|---|---|
committer | Angelos D. Keromytis <angelos@cvs.openbsd.org> | 2001-08-23 23:11:03 +0000 |
commit | 609abece174c8f84050581cc4d1e6f64a6fd3542 (patch) | |
tree | 9551f089442c2a25c54855eb794e6e484e182b15 /sbin | |
parent | e601ba7a689f45e7c735cb0c5e77c95742c922ed (diff) |
Reinitialize transports on SIGUP.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/isakmpd/isakmpd.c | 7 | ||||
-rw-r--r-- | sbin/isakmpd/transport.c | 13 | ||||
-rw-r--r-- | sbin/isakmpd/transport.h | 7 | ||||
-rw-r--r-- | sbin/isakmpd/udp.c | 90 |
4 files changed, 70 insertions, 47 deletions
diff --git a/sbin/isakmpd/isakmpd.c b/sbin/isakmpd/isakmpd.c index ab6f32f895d..6dc3054a3e2 100644 --- a/sbin/isakmpd/isakmpd.c +++ b/sbin/isakmpd/isakmpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: isakmpd.c,v 1.34 2001/08/23 14:17:08 aaron Exp $ */ +/* $OpenBSD: isakmpd.c,v 1.35 2001/08/23 23:11:02 angelos Exp $ */ /* $EOM: isakmpd.c,v 1.54 2000/10/05 09:28:22 niklas Exp $ */ /* @@ -245,10 +245,9 @@ reinit (void) connection_reinit (); /* - * XXX Rescan interfaces. - * transport_reinit (); - * udp_reinit (); + * Rescan interfaces. */ + transport_reinit (); /* * XXX "These" (non-existant) reinitializations should not be done. diff --git a/sbin/isakmpd/transport.c b/sbin/isakmpd/transport.c index ca325361d93..0c29597bfd4 100644 --- a/sbin/isakmpd/transport.c +++ b/sbin/isakmpd/transport.c @@ -1,4 +1,4 @@ -/* $OpenBSD: transport.c,v 1.13 2001/04/09 22:09:53 ho Exp $ */ +/* $OpenBSD: transport.c,v 1.14 2001/08/23 23:11:02 angelos Exp $ */ /* $EOM: transport.c,v 1.43 2000/10/10 12:36:39 provos Exp $ */ /* @@ -53,6 +53,17 @@ LIST_HEAD (transport_list, transport) transport_list; LIST_HEAD (transport_method_list, transport_vtbl) transport_method_list; +/* Call the reinit function of the various transports. */ +void +transport_reinit (void) +{ + struct transport_vtbl *method; + + for (method = LIST_FIRST (&transport_method_list); method; + method = LIST_NEXT (method, link)) + method->reinit (); +} + /* Initialize the transport maintenance module. */ void transport_init (void) diff --git a/sbin/isakmpd/transport.h b/sbin/isakmpd/transport.h index 54a891b9feb..f0e64182539 100644 --- a/sbin/isakmpd/transport.h +++ b/sbin/isakmpd/transport.h @@ -1,4 +1,4 @@ -/* $OpenBSD: transport.h,v 1.9 2001/08/11 05:29:23 angelos Exp $ */ +/* $OpenBSD: transport.h,v 1.10 2001/08/23 23:11:02 angelos Exp $ */ /* $EOM: transport.h,v 1.16 2000/07/17 18:57:59 provos Exp $ */ /* @@ -61,6 +61,9 @@ struct transport_vtbl { /* Create a transport instance of this method. */ struct transport *(*create) (char *); + /* Reinitialize specific transport. */ + void (*reinit) (void); + /* Remove a transport instance of this method. */ void (*remove) (struct transport *); @@ -134,5 +137,5 @@ extern void transport_reference (struct transport *); extern void transport_release (struct transport *); extern void transport_report (void); extern void transport_send_messages (fd_set *); - +extern void transport_reinit (void); #endif /* _TRANSPORT_H_ */ diff --git a/sbin/isakmpd/udp.c b/sbin/isakmpd/udp.c index 960e9254692..7f45859f8f7 100644 --- a/sbin/isakmpd/udp.c +++ b/sbin/isakmpd/udp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp.c,v 1.48 2001/08/13 14:33:35 itojun Exp $ */ +/* $OpenBSD: udp.c,v 1.49 2001/08/23 23:11:02 angelos Exp $ */ /* $EOM: udp.c,v 1.57 2001/01/26 10:09:57 niklas Exp $ */ /* @@ -81,6 +81,7 @@ struct udp_transport { static struct transport *udp_clone (struct udp_transport *, struct sockaddr *); static struct transport *udp_create (char *); +static void udp_reinit (void); static void udp_remove (struct transport *); static void udp_report (struct transport *); static int udp_fd_set (struct transport *, fd_set *, int); @@ -98,6 +99,7 @@ static in_port_t udp_decode_port (char *); static struct transport_vtbl udp_transport_vtbl = { { 0 }, "udp", udp_create, + udp_reinit, udp_remove, udp_report, udp_fd_set, @@ -561,6 +563,49 @@ udp_report (struct transport *t) } /* + * Probe the interface list and determine what new interfaces have + * appeared. + * + * At the same time, we try to determine whether existing interfaces have + * been rendered invalid; we do this by marking all UDP transports before + * we call udp_bind_if () through if_map (), and then releasing those + * transports that have not been unmarked. + */ +static void +udp_reinit (void) +{ + struct udp_transport *u, *u2; + + /* Mark all UDP transports, except the default ones. */ + for (u = LIST_FIRST (&udp_listen_list); u; u = LIST_NEXT (u, link)) + if (&u->transport != default_transport && + &u->transport != default_transport6) + u->transport.flags |= TRANSPORT_MARK; + + /* Re-probe interface list. */ + /* XXX need to check errors */ + if_map (udp_bind_if, udp_default_port ? udp_default_port : "500"); + + /* + * Release listening transports for local addresses that no + * longer exist. udp_bind_if () will have left those still marked. + */ + u = LIST_FIRST (&udp_listen_list); + while (u) + { + u2 = LIST_NEXT (u, link); + + if (u->transport.flags & TRANSPORT_MARK) + { + LIST_REMOVE (u, link); + transport_release (&u->transport); + } + + u = u2; + } +} + +/* * Find out the magic numbers for the UDP protocol as well as the UDP port * to use. Setup an UDP server for each address of this machine, and one * for the generic case when we are the initiator. @@ -667,7 +712,7 @@ udp_fd_isset (struct transport *t, fd_set *fds) static void udp_handle_message (struct transport *t) { - struct udp_transport *u = (struct udp_transport *)t, *u2; + struct udp_transport *u = (struct udp_transport *)t; u_int8_t buf[UDP_SIZE]; struct sockaddr_storage from; int len = sizeof from; @@ -683,47 +728,12 @@ udp_handle_message (struct transport *t) } /* - * If we received a packet over the default transports, then: - * - if we use the Listen-on directive in the configuration, just ignore - * the packet - * - otherwise, re-probe the interface list - * At the same time, we try to determine whether existing transports have - * been rendered invalid; we do this by marking all UDP transports before - * we call udp_bind_if () through if_map (), and then releasing those - * transports that have not been unmarked. + * If we received the packet over the default transports, reprobe the + * interfaces. */ if (t == default_transport || t == default_transport6) { - if (conf_get_str ("General", "Listen-on")) - return; - - /* Mark all UDP transports, except the default ones. */ - for (u = LIST_FIRST (&udp_listen_list); u; u = LIST_NEXT (u, link)) - if (&u->transport != default_transport && - &u->transport != default_transport6) - u->transport.flags |= TRANSPORT_MARK; - - /* Re-probe interface list. */ - /* XXX need to check errors */ - if_map (udp_bind_if, udp_default_port ? udp_default_port : "500"); - - /* - * Release listening transports for local addresses that no - * longer exist. - */ - u = LIST_FIRST (&udp_listen_list); - while (u) - { - u2 = LIST_NEXT (u, link); - - if (u->transport.flags & TRANSPORT_MARK) - { - LIST_REMOVE (u, link); - transport_release (&u->transport); - } - - u = u2; - } + udp_reinit (); /* * As we don't know the actual destination address of the packet, |