File 0015-Expose-next-server-DHCPv4-option-to-dhclient-script.patch of Package dhcp

From 5fd4d0595760acd3e4c2524c9747dc5c0042e173 Mon Sep 17 00:00:00 2001
From: Tomas Hozza <thozza@redhat.com>
Date: Fri, 29 May 2015 13:56:58 +0200
Subject: Expose next-server DHCPv4 option to dhclient script

Currently dhclient does not exposes next-server option
to the dhclient script. this patch fixes this.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
References: bsc#928390

Index: dhcp-4.4.3-P1/client/dhclient.c
===================================================================
--- dhcp-4.4.3-P1.orig/client/dhclient.c
+++ dhcp-4.4.3-P1/client/dhclient.c
@@ -1487,7 +1487,7 @@ void state_selecting (cpp)
 		client -> state = S_REQUESTING;
 
 		/* Bind to the address we received. */
-		bind_lease (client);
+		bind_lease (client, NULL);
 		return;
 	}
 
@@ -1690,11 +1690,12 @@ void dhcpack (packet)
 	if (client -> new -> rebind < cur_time)
 		client -> new -> rebind = TIME_MAX;
 
-	bind_lease (client);
+	bind_lease (client, &packet -> raw -> siaddr);
 }
 
-void bind_lease (client)
+void bind_lease (client, siaddr)
 	struct client_state *client;
+	struct in_addr *siaddr;
 {
 	struct timeval tv;
 
@@ -1714,6 +1715,13 @@ void bind_lease (client)
 	if (client->alias)
 		script_write_params(client, "alias_", client->alias);
 
+	if (siaddr) {
+		char buf[INET_ADDRSTRLEN];
+
+		if (inet_ntop (AF_INET, (void *) siaddr, buf, sizeof (buf)))
+			client_envadd (client, "new_", "next_server", "%s", buf);
+	}
+
 	/* If the BOUND/RENEW code detects another machine using the
 	   offered address, then per our man page it should exit with
        a non-zero status, to which we send a DHCPDECLINE and toss
Index: dhcp-4.4.3-P1/includes/dhcpd.h
===================================================================
--- dhcp-4.4.3-P1.orig/includes/dhcpd.h
+++ dhcp-4.4.3-P1/includes/dhcpd.h
@@ -3012,7 +3012,7 @@ uint32_t check_v6only (struct packet *,
 void start_v6only (struct client_state *, uint32_t);
 void finish_v6only (void *);
 
-void bind_lease (struct client_state *);
+void bind_lease (struct client_state *, struct in_addr *);
 
 void make_client_options (struct client_state *,
 			  struct client_lease *, u_int8_t *,
openSUSE Build Service is sponsored by