From 649a5e03814af477d2fe216f6f7d9b720face2a6 Mon Sep 17 00:00:00 2001 From: krw Date: Mon, 30 Dec 2013 03:36:17 +0000 Subject: [PATCH] Replace yet another hand-rolled list with a TAILQ. reject_list this time. --- sbin/dhclient/clparse.c | 15 +++++++-------- sbin/dhclient/dhclient.c | 3 ++- sbin/dhclient/dhcpd.h | 6 +++--- sbin/dhclient/options.c | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c index eba497251eb..ca88396a261 100644 --- a/sbin/dhclient/clparse.c +++ b/sbin/dhclient/clparse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clparse.c,v 1.64 2013/12/28 21:48:04 krw Exp $ */ +/* $OpenBSD: clparse.c,v 1.65 2013/12/30 03:36:17 krw Exp $ */ /* Parser for dhclient config and lease files. */ @@ -748,7 +748,7 @@ bad_flag: void parse_reject_statement(FILE *cfile) { - struct reject_elem *list; + struct reject_elem *elem; struct in_addr addr; int token; @@ -759,13 +759,12 @@ parse_reject_statement(FILE *cfile) return; } - list = malloc(sizeof(struct reject_elem)); - if (!list) - error("no memory for reject list!"); + elem = malloc(sizeof(struct reject_elem)); + if (!elem) + error("no memory for reject address!"); - list->addr = addr; - list->next = config->reject_list; - config->reject_list = list; + elem->addr = addr; + TAILQ_INSERT_TAIL(&config->reject_list, elem, next); token = next_token(NULL, cfile); } while (token == ','); diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 9bc527c72ed..0b5768d40ea 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.280 2013/12/21 18:23:10 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.281 2013/12/30 03:36:17 krw Exp $ */ /* * Copyright 2004 Henning Brauer @@ -456,6 +456,7 @@ main(int argc, char *argv[]) config = calloc(1, sizeof(*config)); if (config == NULL) error("config calloc"); + TAILQ_INIT(&config->reject_list); get_ifname(argv[0]); if (path_dhclient_db == NULL && asprintf(&path_dhclient_db, "%s.%s", diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h index 8d6c382b23e..ef7d992f395 100644 --- a/sbin/dhclient/dhcpd.h +++ b/sbin/dhclient/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.127 2013/12/21 18:23:10 krw Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.128 2013/12/30 03:36:17 krw Exp $ */ /* * Copyright (c) 2004 Henning Brauer @@ -89,7 +89,7 @@ struct option_data { }; struct reject_elem { - struct reject_elem *next; + TAILQ_ENTRY(reject_elem) next; struct in_addr addr; }; @@ -142,7 +142,7 @@ struct client_config { time_t backoff_cutoff; enum { IGNORE, ACCEPT, PREFER } bootp_policy; - struct reject_elem *reject_list; + TAILQ_HEAD(, reject_elem) reject_list; char *resolv_tail; }; diff --git a/sbin/dhclient/options.c b/sbin/dhclient/options.c index be8659c4ef5..cb10ee395f0 100644 --- a/sbin/dhclient/options.c +++ b/sbin/dhclient/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.64 2013/12/22 04:47:57 krw Exp $ */ +/* $OpenBSD: options.c,v 1.65 2013/12/30 03:36:17 krw Exp $ */ /* DHCP options parsing and reassembly. */ @@ -488,7 +488,7 @@ do_packet(unsigned int from_port, struct in_addr from, return; } - for (ap = config->reject_list; ap; ap = ap->next) + TAILQ_FOREACH(ap, &config->reject_list, next) if (from.s_addr == ap->addr.s_addr) { #ifdef DEBUG debug("Discarding packet from address on reject list " -- 2.20.1