diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2017-06-14 15:39:56 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2017-06-14 15:39:56 +0000 |
commit | 9873a62c1d39a7136c441c32b8c77e28889205d7 (patch) | |
tree | 37ce30345ea62e10fd36d4265d12dae6f00fa76f | |
parent | 1d9f67fefdc77acd0315577313da19f2b8df2487 (diff) |
No need for two 'flags' fields. Consolidate into one, fixing
value of IFI_HUP while passing.
-rw-r--r-- | sbin/dhclient/dhclient.c | 20 | ||||
-rw-r--r-- | sbin/dhclient/dhcpd.h | 43 |
2 files changed, 31 insertions, 32 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 37a1eaa1f31..76e906b9f6d 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.419 2017/06/13 15:49:32 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.420 2017/06/14 15:39:55 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -261,8 +261,8 @@ routehandler(struct interface_info *ifi) goto done; if ((rtm->rtm_flags & RTF_PROTO3) != 0) { if (rtm->rtm_seq == (int32_t)client->xid) { - client->flags |= IN_CHARGE; - } else if ((client->flags & IN_CHARGE) != 0) { + ifi->flags |= IFI_IN_CHARGE; + } else if ((ifi->flags & IFI_IN_CHARGE) != 0) { rslt = asprintf(&errmsg, "yielding " "responsibility for %s", ifi->name); @@ -297,11 +297,11 @@ routehandler(struct interface_info *ifi) inet_ntoa(client->active->address), (long long)(client->active->renewal - time(NULL))); - client->flags |= IS_RESPONSIBLE; + ifi->flags |= IFI_IS_RESPONSIBLE; go_daemon(); break; } - if ((client->flags & IS_RESPONSIBLE) == 0) + if ((ifi->flags & IFI_IS_RESPONSIBLE) == 0) /* We're not responsible yet! */ break; if (adding.s_addr != INADDR_ANY) { @@ -336,7 +336,7 @@ routehandler(struct interface_info *ifi) deleting.s_addr = INADDR_ANY; break; } - if ((client->flags & IS_RESPONSIBLE) == 0) + if ((ifi->flags & IFI_IS_RESPONSIBLE) == 0) /* We're not responsible yet! */ break; if (adding.s_addr == INADDR_ANY && client->active && @@ -347,7 +347,7 @@ routehandler(struct interface_info *ifi) memset(&b, 0, sizeof(b)); add_address(b, b); /* No need to write resolv.conf now. */ - client->flags &= ~IS_RESPONSIBLE; + ifi->flags &= ~IFI_IS_RESPONSIBLE; quit = INTERNALSIG; break; } @@ -423,7 +423,7 @@ routehandler(struct interface_info *ifi) /* Something has happened. Try to write out the resolv.conf. */ if (client->active && client->active->resolv_conf && - client->flags & IS_RESPONSIBLE) + ifi->flags & IFI_IS_RESPONSIBLE) write_resolv_conf(client->active->resolv_conf, strlen(client->active->resolv_conf)); @@ -978,7 +978,7 @@ bind_lease(struct interface_info *ifi) * A duplicate lease once we are responsible & S_RENEWING means we * don't need to change the interface, routing table or resolv.conf. */ - if ((client->flags & IS_RESPONSIBLE) && client->state == S_RENEWING && + if ((ifi->flags & IFI_IS_RESPONSIBLE) && client->state == S_RENEWING && compare_lease(client->active, client->new) == 0) { client->new->resolv_conf = client->active->resolv_conf; client->active->resolv_conf = NULL; @@ -2611,7 +2611,7 @@ take_charge(struct interface_info *ifi) rtm.rtm_flags = RTF_UP | RTF_PROTO3; retries = 0; - while ((ifi->client->flags & IN_CHARGE) == 0) { + while ((ifi->flags & IFI_IN_CHARGE) == 0) { if (write(routefd, &rtm, sizeof(rtm)) == -1) fatal("tried to take charge"); time(&cur_time); diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h index 17714d23af4..b752a646a21 100644 --- a/sbin/dhclient/dhcpd.h +++ b/sbin/dhclient/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.175 2017/06/13 16:02:46 krw Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.176 2017/06/14 15:39:55 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@openbsd.org> @@ -127,9 +127,6 @@ struct client_state { TAILQ_HEAD(_leases, client_lease) leases; enum dhcp_state state; struct in_addr destination; - int flags; -#define IS_RESPONSIBLE 0x1 -#define IN_CHARGE 0x2 u_int32_t xid; u_int16_t secs; time_t first_sending; @@ -142,25 +139,27 @@ struct client_state { }; struct interface_info { - struct ether_addr hw_address; - char name[IFNAMSIZ]; - char ssid[32]; - uint8_t ssid_len; + struct ether_addr hw_address; + char name[IFNAMSIZ]; + char ssid[32]; + uint8_t ssid_len; struct client_state *client; - int bfdesc; /* bpf - reading & broadcast writing*/ - int ufdesc; /* udp - unicast writing */ - unsigned char *rbuf; - size_t rbuf_max; - size_t rbuf_offset; - size_t rbuf_len; - int errors; - u_int16_t index; - int linkstat; - int rdomain; - int flags; -#define IFI_VALID_LLADDR 0x00000001 -#define IFI_NEW_LLADDR 0x00000002 -#define IFI_HUP 0x00000003 + int bfdesc; /* bpf - reading & broadcast writing*/ + int ufdesc; /* udp - unicast writing */ + unsigned char *rbuf; + size_t rbuf_max; + size_t rbuf_offset; + size_t rbuf_len; + int errors; + u_int16_t index; + int linkstat; + int rdomain; + int flags; +#define IFI_VALID_LLADDR 0x01 +#define IFI_NEW_LLADDR 0x02 +#define IFI_HUP 0x04 +#define IFI_IS_RESPONSIBLE 0x08 +#define IFI_IN_CHARGE 0x10 }; struct dhcp_timeout { |