diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2016-08-23 09:26:03 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2016-08-23 09:26:03 +0000 |
commit | 44d1c95501ff586f3bc7fd53d12a30ee6cd346a6 (patch) | |
tree | 5cc497d2a0e5adcfd2139b19225e132f999382cc /sbin | |
parent | f3ce66b51c5bcc786a446f8b813c59a2790c09d7 (diff) |
Make the 'ifi' global local to dhclient.c and pass it as an argument to
functions needing it.
This is the first step to support multiple interfaces in one dhclient(8)
instance.
ok krw@
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/dhclient/bpf.c | 19 | ||||
-rw-r--r-- | sbin/dhclient/clparse.c | 36 | ||||
-rw-r--r-- | sbin/dhclient/dhclient.c | 38 | ||||
-rw-r--r-- | sbin/dhclient/dhcpd.h | 31 | ||||
-rw-r--r-- | sbin/dhclient/dispatch.c | 24 | ||||
-rw-r--r-- | sbin/dhclient/kroute.c | 34 | ||||
-rw-r--r-- | sbin/dhclient/options.c | 6 | ||||
-rw-r--r-- | sbin/dhclient/packet.c | 4 | ||||
-rw-r--r-- | sbin/dhclient/privsep.c | 14 | ||||
-rw-r--r-- | sbin/dhclient/privsep.h | 18 |
10 files changed, 116 insertions, 108 deletions
diff --git a/sbin/dhclient/bpf.c b/sbin/dhclient/bpf.c index aa2e5c11839..74dc0b1c72e 100644 --- a/sbin/dhclient/bpf.c +++ b/sbin/dhclient/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.42 2016/07/23 15:53:19 stsp Exp $ */ +/* $OpenBSD: bpf.c,v 1.43 2016/08/23 09:26:02 mpi Exp $ */ /* BPF socket interface code, originally contributed by Archie Cobbs. */ @@ -64,7 +64,7 @@ #include "dhcp.h" #include "dhcpd.h" -int if_register_bpf(void); +int if_register_bpf(struct interface_info *ifi); /* * Called by get_interface_list for each interface that's discovered. @@ -72,7 +72,7 @@ int if_register_bpf(void); * mask. */ int -if_register_bpf(void) +if_register_bpf(struct interface_info *ifi) { struct ifreq ifr; int sock; @@ -90,7 +90,7 @@ if_register_bpf(void) } void -if_register_send(void) +if_register_send(struct interface_info *ifi) { int sock, on = 1; @@ -185,14 +185,14 @@ struct bpf_insn dhcp_bpf_wfilter[] = { int dhcp_bpf_wfilter_len = sizeof(dhcp_bpf_wfilter) / sizeof(struct bpf_insn); void -if_register_receive(void) +if_register_receive(struct interface_info *ifi) { struct bpf_version v; struct bpf_program p; int flag = 1, sz; /* Open a BPF device and hang it on this interface. */ - ifi->bfdesc = if_register_bpf(); + ifi->bfdesc = if_register_bpf(ifi); /* Make sure the BPF version is in range. */ if (ioctl(ifi->bfdesc, BIOCVERSION, &v) < 0) @@ -257,7 +257,7 @@ if_register_receive(void) } ssize_t -send_packet(struct in_addr from, struct in_addr to) +send_packet(struct interface_info *ifi, struct in_addr from, struct in_addr to) { struct sockaddr_in dest; struct ether_header eh; @@ -275,7 +275,7 @@ send_packet(struct in_addr from, struct in_addr to) dest.sin_addr.s_addr = to.s_addr; if (to.s_addr == INADDR_BROADCAST) { - assemble_eh_header(&eh); + assemble_eh_header(ifi, &eh); iov[0].iov_base = &eh; iov[0].iov_len = sizeof(eh); iovcnt++; @@ -333,7 +333,8 @@ send_packet(struct in_addr from, struct in_addr to) } ssize_t -receive_packet(struct sockaddr_in *from, struct ether_addr *hfrom) +receive_packet(struct interface_info *ifi, struct sockaddr_in *from, + struct ether_addr *hfrom) { int length = 0, offset = 0; struct bpf_hdr hdr; diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c index ee20a16207f..70728a8a385 100644 --- a/sbin/dhclient/clparse.c +++ b/sbin/dhclient/clparse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clparse.c,v 1.97 2016/08/16 21:57:51 krw Exp $ */ +/* $OpenBSD: clparse.c,v 1.98 2016/08/23 09:26:02 mpi Exp $ */ /* Parser for dhclient config and lease files. */ @@ -59,12 +59,13 @@ #include "dhcpd.h" #include "dhctoken.h" -void parse_client_statement(FILE *); +void parse_client_statement(FILE *, struct interface_info *); int parse_X(FILE *, u_int8_t *, int); int parse_option_list(FILE *, u_int8_t *, size_t); -void parse_interface_declaration(FILE *); -void parse_client_lease_statement(FILE *, int); -void parse_client_lease_declaration(FILE *, struct client_lease *); +void parse_interface_declaration(FILE *, struct interface_info *); +void parse_client_lease_statement(FILE *, int, struct interface_info *); +void parse_client_lease_declaration(FILE *, struct client_lease *, + struct interface_info *); int parse_option_decl(FILE *, struct option_data *); void parse_reject_statement(FILE *); @@ -75,7 +76,7 @@ void parse_reject_statement(FILE *); * | client-declarations client-declaration */ void -read_client_conf(void) +read_client_conf(struct interface_info *ifi) { FILE *cfile; int token; @@ -120,7 +121,7 @@ read_client_conf(void) token = peek_token(NULL, cfile); if (token == EOF) break; - parse_client_statement(cfile); + parse_client_statement(cfile, ifi); } while (1); fclose(cfile); } @@ -132,7 +133,7 @@ read_client_conf(void) * | client-lease-statements LEASE client-lease-statement */ void -read_client_leases(void) +read_client_leases(struct interface_info *ifi) { FILE *cfile; int token; @@ -151,7 +152,7 @@ read_client_leases(void) warning("Corrupt lease file - possible data loss!"); break; } - parse_client_lease_statement(cfile, 0); + parse_client_lease_statement(cfile, 0, ifi); } while (1); fclose(cfile); } @@ -180,7 +181,7 @@ read_client_leases(void) * TOK_REJECT reject-statement */ void -parse_client_statement(FILE *cfile) +parse_client_statement(FILE *cfile, struct interface_info *ifi) { u_int8_t optlist[256]; char *string; @@ -261,10 +262,10 @@ parse_client_statement(FILE *cfile) parse_lease_time(cfile, &config->initial_interval); break; case TOK_INTERFACE: - parse_interface_declaration(cfile); + parse_interface_declaration(cfile, ifi); break; case TOK_LEASE: - parse_client_lease_statement(cfile, 1); + parse_client_lease_statement(cfile, 1, ifi); break; case TOK_ALIAS: case TOK_MEDIA: @@ -411,7 +412,7 @@ syntaxerror: * INTERFACE string LBRACE client-declarations RBRACE */ void -parse_interface_declaration(FILE *cfile) +parse_interface_declaration(FILE *cfile, struct interface_info *ifi) { char *val; int token; @@ -445,7 +446,7 @@ parse_interface_declaration(FILE *cfile) } if (token == '}') break; - parse_client_statement(cfile); + parse_client_statement(cfile, ifi); } while (1); token = next_token(&val, cfile); } @@ -460,7 +461,7 @@ parse_interface_declaration(FILE *cfile) * client-lease-declarations client-lease-declaration */ void -parse_client_lease_statement(FILE *cfile, int is_static) +parse_client_lease_statement(FILE *cfile, int is_static, struct interface_info *ifi) { struct client_lease *lease, *lp, *pl; struct option_data *opt1, *opt2; @@ -487,7 +488,7 @@ parse_client_lease_statement(FILE *cfile, int is_static) } if (token == '}') break; - parse_client_lease_declaration(cfile, lease); + parse_client_lease_declaration(cfile, lease, ifi); } while (1); token = next_token(NULL, cfile); @@ -544,7 +545,8 @@ parse_client_lease_statement(FILE *cfile, int is_static) * EXPIRE time-decl */ void -parse_client_lease_declaration(FILE *cfile, struct client_lease *lease) +parse_client_lease_declaration(FILE *cfile, struct client_lease *lease, + struct interface_info *ifi) { char *val; int token; diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index eb1ee5049ea..499f4a68622 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.380 2016/08/16 21:57:51 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.381 2016/08/23 09:26:02 mpi Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -359,7 +359,7 @@ routehandler(void) if (ifi->flags & IFI_VALID_LLADDR) { memcpy(&hw, &ifi->hw_address, sizeof(hw)); - get_hw_address(); + get_hw_address(ifi); if (memcmp(&hw, &ifi->hw_address, sizeof(hw))) { warning("LLADDR changed; restarting"); ifi->flags |= IFI_NEW_LLADDR; @@ -368,7 +368,7 @@ routehandler(void) } } - linkstat = interface_status(ifi->name); + linkstat = interface_status(ifi); if (linkstat != ifi->linkstat) { #ifdef DEBUG debug("link state %s -> %s", @@ -379,7 +379,7 @@ routehandler(void) if (ifi->linkstat) { if (client->state == S_PREBOOT) { state_preboot(); - get_hw_address(); + get_hw_address(ifi); } else { client->state = S_REBOOTING; state_reboot(); @@ -544,7 +544,7 @@ main(int argc, char *argv[]) TAILQ_INIT(&client->leases); TAILQ_INIT(&client->offered_leases); - read_client_conf(); + read_client_conf(ifi); if ((nullfd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1) error("cannot open %s: %s", _PATH_DEVNULL, strerror(errno)); @@ -591,7 +591,7 @@ main(int argc, char *argv[]) O_RDONLY|O_EXLOCK|O_CREAT|O_NOFOLLOW, 0640)) == -1) error("can't open and lock %s: %s", path_dhclient_db, strerror(errno)); - read_client_leases(); + read_client_leases(ifi); if ((leaseFile = fopen(path_dhclient_db, "w")) == NULL) error("can't open %s: %s", path_dhclient_db, strerror(errno)); rewrite_client_leases(); @@ -603,7 +603,7 @@ main(int argc, char *argv[]) * the routing socket is listening, the RTM_IFINFO message with the * RTF_UP flag reset will cause premature exit. */ - ifi->linkstat = interface_status(ifi->name); + ifi->linkstat = interface_status(ifi); if (ifi->linkstat == 0) interface_link_forceup(ifi->name); @@ -621,8 +621,8 @@ main(int argc, char *argv[]) error("setsockopt(ROUTE_TABLEFILTER): %s", strerror(errno)); /* Register the interface. */ - if_register_receive(); - if_register_send(); + if_register_receive(ifi); + if_register_send(ifi); if (chroot(_PATH_VAREMPTY) == -1) error("chroot"); @@ -657,7 +657,7 @@ main(int argc, char *argv[]) state_preboot(); } - dispatch(); + dispatch(ifi); /* not reached */ return (0); @@ -685,7 +685,7 @@ state_preboot(void) interval = (int)(cur_time - client->startup_time); - ifi->linkstat = interface_status(ifi->name); + ifi->linkstat = interface_status(ifi); if (log_perror && interval > 3) { if (!preamble && !ifi->linkstat) { @@ -729,7 +729,7 @@ state_reboot(void) deleting.s_addr = INADDR_ANY; adding.s_addr = INADDR_ANY; - get_hw_address(); + get_hw_address(ifi); opt = &config->send_options[DHO_DHCP_CLIENT_IDENTIFIER]; /* * Check both len && data so @@ -985,7 +985,7 @@ bind_lease(void) client->new = NULL; /* Deleting the addresses also clears out arp entries. */ - delete_addresses(); + delete_addresses(ifi); flush_routes(); opt = &options[DHO_INTERFACE_MTU]; @@ -1421,7 +1421,7 @@ send_discover(void) note("DHCPDISCOVER on %s - interval %lld", ifi->name, (long long)client->interval); - rslt = send_packet(inaddr_any, inaddr_broadcast); + rslt = send_packet(ifi, inaddr_any, inaddr_broadcast); if (rslt == -1 && errno == EAFNOSUPPORT) { warning("dhclient cannot be used on %s", ifi->name); quit = INTERNALSIG; @@ -1575,7 +1575,7 @@ send_request(void) note("DHCPREQUEST on %s to %s", ifi->name, inet_ntoa(destination.sin_addr)); - send_packet(from, destination.sin_addr); + send_packet(ifi, from, destination.sin_addr); set_timeout_interval(client->interval, send_request); } @@ -1585,7 +1585,7 @@ send_decline(void) { note("DHCPDECLINE on %s", ifi->name); - send_packet(inaddr_any, inaddr_broadcast); + send_packet(ifi, inaddr_any, inaddr_broadcast); } void @@ -2161,7 +2161,7 @@ fork_privchld(int fd, int fd2) continue; } - dispatch_imsg(priv_ibuf); + dispatch_imsg(ifi, priv_ibuf); } imsg_clear(priv_ibuf); @@ -2182,7 +2182,7 @@ fork_privchld(int fd, int fd2) if (quit != SIGTERM) { memset(&imsg, 0, sizeof(imsg)); imsg.addr = active_addr; - priv_cleanup(&imsg); + priv_cleanup(ifi, &imsg); } if (quit == SIGHUP) { @@ -2582,7 +2582,7 @@ priv_write_resolv_conf(struct imsg *imsg) return; } - if (!resolv_conf_priority()) + if (!resolv_conf_priority(ifi)) return; contents = imsg->data; diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h index 38fb8222d56..3472f167a4c 100644 --- a/sbin/dhclient/dhcpd.h +++ b/sbin/dhclient/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.155 2016/08/16 21:57:51 krw Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.156 2016/08/23 09:26:02 mpi Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@openbsd.org> @@ -172,7 +172,6 @@ struct dhcp_timeout { /* External definitions. */ -extern struct interface_info *ifi; extern struct client_state *client; extern struct client_config *config; extern struct imsgbuf *unpriv_ibuf; @@ -189,7 +188,8 @@ int pretty_print_classless_routes(unsigned char *, size_t, unsigned char *, size_t); int pretty_print_domain_search(unsigned char *, size_t, unsigned char *, size_t); -void do_packet(unsigned int, struct in_addr, struct ether_addr *); +void do_packet(struct interface_info *, unsigned int, struct in_addr, + struct ether_addr *); /* errwarn.c */ extern int warnings_occurred; @@ -221,20 +221,21 @@ int parse_hex(FILE *, unsigned char *); time_t parse_date(FILE *); /* bpf.c */ -void if_register_send(void); -void if_register_receive(void); -ssize_t send_packet(struct in_addr, struct in_addr); -ssize_t receive_packet(struct sockaddr_in *, struct ether_addr *); +void if_register_send(struct interface_info *); +void if_register_receive(struct interface_info *); +ssize_t send_packet(struct interface_info *, struct in_addr, struct in_addr); +ssize_t receive_packet(struct interface_info *, struct sockaddr_in *, + struct ether_addr *); /* dispatch.c */ -void dispatch(void); +void dispatch(struct interface_info *); void set_timeout(time_t, void (*)(void)); void set_timeout_interval(time_t, void (*)(void)); void cancel_timeout(void); void interface_link_forceup(char *); -int interface_status(char *); +int interface_status(struct interface_info *); int get_rdomain(char *); -void get_hw_address(void); +void get_hw_address(struct interface_info *); /* tables.c */ extern const struct option dhcp_options[256]; @@ -254,7 +255,7 @@ void free_client_lease(struct client_lease *); void routehandler(void); /* packet.c */ -void assemble_eh_header(struct ether_header *); +void assemble_eh_header(struct interface_info *, struct ether_header *); ssize_t decode_hw_header(unsigned char *, int, struct ether_addr *); ssize_t decode_udp_ip_header(unsigned char *, int, struct sockaddr_in *, int); @@ -262,11 +263,11 @@ u_int32_t checksum(unsigned char *, unsigned, u_int32_t); u_int32_t wrapsum(u_int32_t); /* clparse.c */ -void read_client_conf(void); -void read_client_leases(void); +void read_client_conf(struct interface_info *); +void read_client_leases(struct interface_info *); /* kroute.c */ -void delete_addresses(void); +void delete_addresses(struct interface_info *); void delete_address(struct in_addr); void set_interface_mtu(int); @@ -279,6 +280,6 @@ void add_route(struct in_addr, struct in_addr, struct in_addr, struct in_addr, void sendhup(struct client_lease *); -int resolv_conf_priority(void); +int resolv_conf_priority(struct interface_info *); void flush_unpriv_ibuf(const char *); diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c index f3d8489c58f..ac0ee601016 100644 --- a/sbin/dhclient/dispatch.c +++ b/sbin/dhclient/dispatch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dispatch.c,v 1.106 2016/07/21 09:58:55 krw Exp $ */ +/* $OpenBSD: dispatch.c,v 1.107 2016/08/23 09:26:02 mpi Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -71,10 +71,10 @@ struct dhcp_timeout timeout; -void packethandler(void); +void packethandler(struct interface_info *ifi); void -get_hw_address(void) +get_hw_address(struct interface_info *ifi) { struct ifaddrs *ifap, *ifa; struct sockaddr_dl *sdl; @@ -117,7 +117,7 @@ get_hw_address(void) * Loop waiting for packets, timeouts or routing messages. */ void -dispatch(void) +dispatch(struct interface_info *ifi) { int count, to_msec; struct pollfd fds[3]; @@ -173,7 +173,7 @@ dispatch(void) } if ((fds[0].revents & (POLLIN | POLLHUP))) - packethandler(); + packethandler(ifi); if ((fds[1].revents & (POLLIN | POLLHUP))) routehandler(); if (fds[2].revents & POLLOUT) @@ -196,14 +196,14 @@ dispatch(void) } void -packethandler(void) +packethandler(struct interface_info *ifi) { struct sockaddr_in from; struct ether_addr hfrom; struct in_addr ifrom; ssize_t result; - if ((result = receive_packet(&from, &hfrom)) == -1) { + if ((result = receive_packet(ifi, &from, &hfrom)) == -1) { warning("%s receive_packet failed: %s", ifi->name, strerror(errno)); ifi->errors++; @@ -220,7 +220,7 @@ packethandler(void) ifrom.s_addr = from.sin_addr.s_addr; - do_packet(from.sin_port, ifrom, &hfrom); + do_packet(ifi, from.sin_port, ifrom, &hfrom); } void @@ -262,7 +262,7 @@ interface_link_forceup(char *ifname) } int -interface_status(char *ifname) +interface_status(struct interface_info *ifi) { struct ifreq ifr; struct ifmediareq ifmr; @@ -273,9 +273,9 @@ interface_status(char *ifname) /* Get interface flags. */ memset(&ifr, 0, sizeof(ifr)); - strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); + strlcpy(ifr.ifr_name, ifi->name, sizeof(ifr.ifr_name)); if (ioctl(sock, SIOCGIFFLAGS, &ifr) == -1) { - error("ioctl(SIOCGIFFLAGS) on %s: %s", ifname, + error("ioctl(SIOCGIFFLAGS) on %s: %s", ifi->name, strerror(errno)); } @@ -286,7 +286,7 @@ interface_status(char *ifname) if (ifi->flags & IFI_NOMEDIA) goto active; memset(&ifmr, 0, sizeof(ifmr)); - strlcpy(ifmr.ifm_name, ifname, sizeof(ifmr.ifm_name)); + strlcpy(ifmr.ifm_name, ifi->name, sizeof(ifmr.ifm_name)); if (ioctl(sock, SIOCGIFMEDIA, (caddr_t)&ifmr) == -1) { /* * EINVAL or ENOTTY simply means that the interface does not diff --git a/sbin/dhclient/kroute.c b/sbin/dhclient/kroute.c index 66a5ea00c14..ad93a6cd0e6 100644 --- a/sbin/dhclient/kroute.c +++ b/sbin/dhclient/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.80 2016/07/21 09:58:55 krw Exp $ */ +/* $OpenBSD: kroute.c,v 1.81 2016/08/23 09:26:02 mpi Exp $ */ /* * Copyright 2012 Kenneth R Westerback <krw@openbsd.org> @@ -48,7 +48,7 @@ struct in_addr active_addr; int create_route_label(struct sockaddr_rtlabel *); int check_route_label(struct sockaddr_rtlabel *); void populate_rti_info(struct sockaddr **, struct rt_msghdr *); -void delete_route(int, struct rt_msghdr *); +void delete_route(struct interface_info *, int, struct rt_msghdr *); #define ROUTE_LABEL_NONE 1 #define ROUTE_LABEL_NOT_DHCLIENT 2 @@ -80,7 +80,7 @@ flush_routes(void) } void -priv_flush_routes(struct imsg_flush_routes *imsg) +priv_flush_routes(struct interface_info *ifi, struct imsg_flush_routes *imsg) { char ifname[IF_NAMESIZE]; struct sockaddr *rti_info[RTAX_MAX]; @@ -147,11 +147,11 @@ priv_flush_routes(struct imsg_flush_routes *imsg) switch (check_route_label(sa_rl)) { case ROUTE_LABEL_DHCLIENT_OURS: /* Always delete routes we labeled. */ - delete_route(s, rtm); + delete_route(ifi, s, rtm); break; case ROUTE_LABEL_DHCLIENT_DEAD: if (imsg->zapzombies) - delete_route(s, rtm); + delete_route(ifi, s, rtm); break; case ROUTE_LABEL_DHCLIENT_LIVE: case ROUTE_LABEL_DHCLIENT_UNKNOWN: @@ -165,7 +165,7 @@ priv_flush_routes(struct imsg_flush_routes *imsg) sa_in->sin_addr.s_addr == INADDR_ANY && rtm->rtm_tableid == ifi->rdomain && strcmp(ifi->name, ifname) == 0) - delete_route(s, rtm); + delete_route(ifi, s, rtm); break; default: break; @@ -199,7 +199,7 @@ add_route(struct in_addr dest, struct in_addr netmask, } void -priv_add_route(struct imsg_add_route *imsg) +priv_add_route(struct interface_info *ifi, struct imsg_add_route *imsg) { char destbuf[INET_ADDRSTRLEN], gatewaybuf[INET_ADDRSTRLEN]; char maskbuf[INET_ADDRSTRLEN], ifabuf[INET_ADDRSTRLEN]; @@ -316,7 +316,7 @@ priv_add_route(struct imsg_add_route *imsg) * Delete all existing inet addresses on interface. */ void -delete_addresses(void) +delete_addresses(struct interface_info *ifi) { struct in_addr addr; struct ifaddrs *ifap, *ifa; @@ -366,7 +366,8 @@ delete_address(struct in_addr addr) } void -priv_delete_address(struct imsg_delete_address *imsg) +priv_delete_address(struct interface_info *ifi, + struct imsg_delete_address *imsg) { struct ifaliasreq ifaliasreq; struct sockaddr_in *in; @@ -419,7 +420,8 @@ set_interface_mtu(int mtu) } void -priv_set_interface_mtu(struct imsg_set_interface_mtu *imsg) +priv_set_interface_mtu(struct interface_info *ifi, + struct imsg_set_interface_mtu *imsg) { struct ifreq ifr; int s; @@ -463,7 +465,7 @@ add_address(struct in_addr addr, struct in_addr mask) } void -priv_add_address(struct imsg_add_address *imsg) +priv_add_address(struct interface_info *ifi, struct imsg_add_address *imsg) { struct ifaliasreq ifaliasreq; struct sockaddr_in *in; @@ -535,23 +537,23 @@ sendhup(struct client_lease *active) * priv_cleanup removes dhclient installed routes and address. */ void -priv_cleanup(struct imsg_hup *imsg) +priv_cleanup(struct interface_info *ifi, struct imsg_hup *imsg) { struct imsg_flush_routes fimsg; struct imsg_delete_address dimsg; fimsg.zapzombies = 0; /* Only zapzombies when binding a lease. */ - priv_flush_routes(&fimsg); + priv_flush_routes(ifi, &fimsg); if (imsg->addr.s_addr == INADDR_ANY) return; dimsg.addr = imsg->addr; - priv_delete_address(&dimsg); + priv_delete_address(ifi, &dimsg); } int -resolv_conf_priority(void) +resolv_conf_priority(struct interface_info *ifi) { struct iovec iov[3]; struct { @@ -723,7 +725,7 @@ populate_rti_info(struct sockaddr **rti_info, struct rt_msghdr *rtm) } void -delete_route(int s, struct rt_msghdr *rtm) +delete_route(struct interface_info *ifi, int s, struct rt_msghdr *rtm) { static int seqno; ssize_t rlen; diff --git a/sbin/dhclient/options.c b/sbin/dhclient/options.c index 06b01561b67..95790e5171c 100644 --- a/sbin/dhclient/options.c +++ b/sbin/dhclient/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.75 2016/02/06 19:30:52 krw Exp $ */ +/* $OpenBSD: options.c,v 1.76 2016/08/23 09:26:02 mpi Exp $ */ /* DHCP options parsing and reassembly. */ @@ -645,8 +645,8 @@ toobig: } void -do_packet(unsigned int from_port, struct in_addr from, - struct ether_addr *hfrom) +do_packet(struct interface_info *ifi, unsigned int from_port, + struct in_addr from, struct ether_addr *hfrom) { struct dhcp_packet *packet = &client->packet; struct option_data options[256]; diff --git a/sbin/dhclient/packet.c b/sbin/dhclient/packet.c index 79febbd44eb..418583585fb 100644 --- a/sbin/dhclient/packet.c +++ b/sbin/dhclient/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.30 2016/02/06 19:30:52 krw Exp $ */ +/* $OpenBSD: packet.c,v 1.31 2016/08/23 09:26:02 mpi Exp $ */ /* Packet assembly code, originally contributed by Archie Cobbs. */ @@ -92,7 +92,7 @@ wrapsum(u_int32_t sum) } void -assemble_eh_header(struct ether_header *eh) +assemble_eh_header(struct interface_info *ifi, struct ether_header *eh) { memset(eh->ether_dhost, 0xff, sizeof(eh->ether_dhost)); diff --git a/sbin/dhclient/privsep.c b/sbin/dhclient/privsep.c index 47f876d76da..41ee5dc1707 100644 --- a/sbin/dhclient/privsep.c +++ b/sbin/dhclient/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.40 2016/02/06 19:30:52 krw Exp $ */ +/* $OpenBSD: privsep.c,v 1.41 2016/08/23 09:26:02 mpi Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@openbsd.org> @@ -35,7 +35,7 @@ #include "privsep.h" void -dispatch_imsg(struct imsgbuf *ibuf) +dispatch_imsg(struct interface_info *ifi, struct imsgbuf *ibuf) { struct imsg imsg; ssize_t n; @@ -54,7 +54,7 @@ dispatch_imsg(struct imsgbuf *ibuf) sizeof(struct imsg_delete_address)) warning("bad IMSG_DELETE_ADDRESS"); else - priv_delete_address(imsg.data); + priv_delete_address(ifi, imsg.data); break; case IMSG_ADD_ADDRESS: @@ -62,7 +62,7 @@ dispatch_imsg(struct imsgbuf *ibuf) sizeof(struct imsg_add_address)) warning("bad IMSG_ADD_ADDRESS"); else - priv_add_address(imsg.data); + priv_add_address(ifi, imsg.data); break; case IMSG_FLUSH_ROUTES: @@ -70,7 +70,7 @@ dispatch_imsg(struct imsgbuf *ibuf) sizeof(struct imsg_flush_routes)) warning("bad IMSG_FLUSH_ROUTES"); else - priv_flush_routes(imsg.data); + priv_flush_routes(ifi, imsg.data); break; case IMSG_ADD_ROUTE: @@ -78,7 +78,7 @@ dispatch_imsg(struct imsgbuf *ibuf) sizeof(struct imsg_add_route)) warning("bad IMSG_ADD_ROUTE"); else - priv_add_route(imsg.data); + priv_add_route(ifi, imsg.data); break; case IMSG_SET_INTERFACE_MTU: @@ -86,7 +86,7 @@ dispatch_imsg(struct imsgbuf *ibuf) sizeof(struct imsg_set_interface_mtu)) warning("bad IMSG_SET_INTERFACE_MTU"); else - priv_set_interface_mtu(imsg.data); + priv_set_interface_mtu(ifi, imsg.data); break; case IMSG_HUP: diff --git a/sbin/dhclient/privsep.h b/sbin/dhclient/privsep.h index a7854ff70df..0c51d7ad73c 100644 --- a/sbin/dhclient/privsep.h +++ b/sbin/dhclient/privsep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.h,v 1.30 2016/07/20 19:40:04 deraadt Exp $ */ +/* $OpenBSD: privsep.h,v 1.31 2016/08/23 09:26:02 mpi Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@openbsd.org> @@ -58,13 +58,15 @@ struct imsg_hup { struct in_addr addr; }; -void dispatch_imsg(struct imsgbuf *); -void priv_delete_address(struct imsg_delete_address *); -void priv_add_address(struct imsg_add_address *); -void priv_flush_routes(struct imsg_flush_routes *); -void priv_add_route(struct imsg_add_route *); -void priv_cleanup(struct imsg_hup *); -void priv_set_interface_mtu(struct imsg_set_interface_mtu *); +void dispatch_imsg(struct interface_info *, struct imsgbuf *); +void priv_delete_address(struct interface_info *, + struct imsg_delete_address *); +void priv_add_address(struct interface_info *, struct imsg_add_address *); +void priv_flush_routes(struct interface_info *, struct imsg_flush_routes *); +void priv_add_route(struct interface_info *, struct imsg_add_route *); +void priv_cleanup(struct interface_info *, struct imsg_hup *); +void priv_set_interface_mtu(struct interface_info *, + struct imsg_set_interface_mtu *); void priv_write_resolv_conf(struct imsg *); void priv_write_option_db(struct imsg *); void priv_write_file(char *, int, mode_t, u_int8_t *, size_t); |