Stop inserting and paying attention to 'interface <if>;'
authorkrw <krw@openbsd.org>
Mon, 18 Dec 2017 14:17:58 +0000 (14:17 +0000)
committerkrw <krw@openbsd.org>
Mon, 18 Dec 2017 14:17:58 +0000 (14:17 +0000)
inside 'lease {}' declarations. We don't keep leases from
multiple interfaces in dhclient.leases.<if> files.

One less thing to parse and keep in memory. More rope for
those wanting to do unspeakable things with their lease files.

sbin/dhclient/clparse.c
sbin/dhclient/dhclient.c
sbin/dhclient/dhclient.leases.5
sbin/dhclient/dhcpd.h

index db82ae7..722b7ae 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: clparse.c,v 1.158 2017/12/17 14:24:04 krw Exp $       */
+/*     $OpenBSD: clparse.c,v 1.159 2017/12/18 14:17:58 krw Exp $       */
 
 /* Parser for dhclient config and lease files. */
 
@@ -543,13 +543,7 @@ parse_lease(FILE *cfile, char *name,
                }
                if (token == '}') {
                        token = next_token(NULL, cfile);
-                       if (lease->interface != NULL &&
-                           strcmp(name, lease->interface) == 0)
-                               *lp = lease;
-                       else {
-                               *lp = NULL;
-                               free_client_lease(lease);
-                       }
+                       *lp = lease;
                        return 1;
                }
                parse_lease_declaration(cfile, lease, name);
@@ -607,11 +601,9 @@ parse_lease_declaration(FILE *cfile, struct client_lease *lease,
                        return;
                break;
        case TOK_INTERFACE:
-               if (parse_string(cfile, NULL, &val) == 0)
-                       return;
-               free(lease->interface);
-               lease->interface = val;
-               break;
+               /* 'interface' is just a comment. */
+               skip_to_semi(cfile);
+               return;
        case TOK_NEXT_SERVER:
                if (parse_ip_addr(cfile, &lease->next_server) == 0)
                        return;
index fce081c..d193457 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: dhclient.c,v 1.541 2017/12/16 20:47:53 krw Exp $      */
+/*     $OpenBSD: dhclient.c,v 1.542 2017/12/18 14:17:58 krw Exp $      */
 
 /*
  * Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -1683,7 +1683,6 @@ free_client_lease(struct client_lease *lease)
        if (lease == NULL)
                return;
 
-       free(lease->interface);
        free(lease->server_name);
        free(lease->filename);
        for (i = 0; i < DHO_COUNT; i++)
@@ -1883,11 +1882,6 @@ lease_as_string(char *ifname, char *type, struct client_lease *lease)
        strlcat(string, " {\n", sizeof(string));
        strlcat(string, BOOTP_LEASE(lease) ? "  bootp;\n" : "", sizeof(string));
 
-       buf = pretty_print_string(ifname, strlen(ifname), 1);
-       if (buf == NULL)
-               return NULL;
-       append_statement(string, sizeof(string), "  interface ", buf);
-
        append_statement(string, sizeof(string), "  fixed-address ",
            inet_ntoa(lease->address));
        append_statement(string, sizeof(string), "  next-server ",
index 430b393..782f71f 100644 (file)
@@ -1,4 +1,4 @@
-.\"    $OpenBSD: dhclient.leases.5,v 1.13 2017/11/09 17:30:22 jmc Exp $
+.\"    $OpenBSD: dhclient.leases.5,v 1.14 2017/12/18 14:17:58 krw Exp $
 .\"
 .\" Copyright (c) 1997 The Internet Software Consortium.
 .\" All rights reserved.
@@ -36,7 +36,7 @@
 .\" see ``http://www.isc.org/isc''.  To learn more about Vixie
 .\" Enterprises, see ``http://www.vix.com''.
 .\"
-.Dd $Mdocdate: November 9 2017 $
+.Dd $Mdocdate: December 18 2017 $
 .Dt DHCLIENT.LEASES 5
 .Os
 .Sh NAME
@@ -140,12 +140,6 @@ The IPv4 address of the lease.
 This is required for all lease statements.
 The IPv4 address is specified as a dotted quad (e.g. 12.34.56.78).
 .Pp
-.It Ic interface Qq Ar string
-The interface on which the lease is valid.
-Every lease must contain an
-.Ic interface
-declaration.
-.Pp
 .It Ic next-server Ar ip-address
 The IPv4 address of the boot server.
 The IPv4 address is specified as a dotted quad (e.g. 12.34.56.78).
index 2cd04e1..19782e5 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: dhcpd.h,v 1.242 2017/12/16 20:47:53 krw Exp $ */
+/*     $OpenBSD: dhcpd.h,v 1.243 2017/12/18 14:17:58 krw Exp $ */
 
 /*
  * Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -56,7 +56,6 @@ struct reject_elem {
 
 struct client_lease {
        TAILQ_ENTRY(client_lease) next;
-       char                    *interface;
        time_t                   epoch;
        struct in_addr           address;
        struct in_addr           next_server;