changeset 3633:cb7afcd33d84

6521957 dhcpagent produces error messages although DHCP is not used on the client
author carlsonj
date Mon, 12 Feb 2007 10:07:54 -0800
parents 42a13dff2693
children f78a304117bb
files usr/src/cmd/cmd-inet/sbin/dhcpagent/dlpi_io.c usr/src/cmd/cmd-inet/sbin/dhcpagent/dlpi_io.h usr/src/cmd/cmd-inet/sbin/dhcpagent/interface.c
diffstat 3 files changed, 31 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/cmd-inet/sbin/dhcpagent/dlpi_io.c	Mon Feb 12 04:43:25 2007 -0800
+++ b/usr/src/cmd/cmd-inet/sbin/dhcpagent/dlpi_io.c	Mon Feb 12 10:07:54 2007 -0800
@@ -49,8 +49,8 @@
 #include "v4_sum_impl.h"
 
 /*
- * dlpi_open(): opens a DLPI stream to the given interface and returns
- *		information purpose about that interface.
+ * dhcp_dlpi_open(): opens a DLPI stream to the given interface and returns
+ *		     information purpose about that interface.
  *
  *   input: const char *: the name of the interface to open
  *	    dl_info_ack_t *: a place to store information about the interface
@@ -60,7 +60,7 @@
  */
 
 int
-dlpi_open(const char *if_name, dl_info_ack_t *dlia, size_t dlia_size,
+dhcp_dlpi_open(const char *if_name, dl_info_ack_t *dlia, size_t dlia_size,
     t_uscalar_t dl_sap)
 {
 	char		device_name[sizeof ("/dev/") + IFNAMSIZ];
@@ -69,13 +69,13 @@
 	int		is_style2 = 0;
 
 	if (!ifparse_ifspec(if_name, &ifsp)) {
-		dhcpmsg(MSG_ERROR, "dlpi_open: invalid interface name");
+		dhcpmsg(MSG_ERROR, "dhcp_dlpi_open: invalid interface name");
 		return (-1);
 	}
 
 	if (ifsp.ifsp_modcnt != 0) {
-		dhcpmsg(MSG_ERROR, "dlpi_open: modules cannot be specified "
-		    "with an interface name");
+		dhcpmsg(MSG_ERROR, "dhcp_dlpi_open: modules cannot be "
+		    "specified with an interface name");
 		return (-1);
 	}
 
@@ -83,7 +83,7 @@
 	(void) snprintf(device_name, sizeof (device_name),
 	    "/dev/%s%d", ifsp.ifsp_devnm, ifsp.ifsp_ppa);
 	if ((fd = open(device_name, O_RDWR)) == -1) {
-		dhcpmsg(MSG_DEBUG, "dlpi_open: open on `%s'", device_name);
+		dhcpmsg(MSG_DEBUG, "dhcp_dlpi_open: open on `%s'", device_name);
 
 		/* try style 2 interface */
 		(void) snprintf(device_name, sizeof (device_name),
@@ -112,7 +112,7 @@
 		}
 
 		if (fd == -1) {
-			dhcpmsg(MSG_ERR, "dlpi_open: open on `%s'",
+			dhcpmsg(MSG_ERR, "dhcp_dlpi_open: open on `%s'",
 			    device_name);
 			return (-1);
 		}
@@ -127,28 +127,29 @@
 	 */
 
 	if (dlinforeq(fd, dlia, dlia_size) != 0) {
-		dhcpmsg(MSG_ERR, "dlpi_open: DL_INFO_REQ on %s", device_name);
+		dhcpmsg(MSG_ERR, "dhcp_dlpi_open: DL_INFO_REQ on %s (1)",
+		    device_name);
 		(void) close(fd);
 		return (-1);
 	}
 
 	if (dlia->dl_version != DL_VERSION_2) {
-		dhcpmsg(MSG_ERROR, "dlpi_open: %s is DLPI version %ld, not 2",
-		    device_name, dlia->dl_version);
+		dhcpmsg(MSG_ERROR, "dhcp_dlpi_open: %s is DLPI version %ld, "
+		    "not 2", device_name, dlia->dl_version);
 		(void) close(fd);
 		return (-1);
 	}
 
 	if (is_style2 && dlia->dl_provider_style != DL_STYLE2) {
 		dhcpmsg(MSG_ERROR,
-		    "dlpi_open: %s is DL_STYLE %lx, not DL_STYLE2",
+		    "dhcp_dlpi_open: %s is DL_STYLE %lx, not DL_STYLE2",
 		    device_name, dlia->dl_provider_style);
 		(void) close(fd);
 		return (-1);
 	}
 
 	if ((dlia->dl_service_mode & DL_CLDLS) == 0) {
-		dhcpmsg(MSG_ERROR, "dlpi_open: %s is %#lx, not DL_CLDLS, "
+		dhcpmsg(MSG_ERROR, "dhcp_dlpi_open: %s is %#lx, not DL_CLDLS, "
 		    "which is not supported", device_name,
 		    dlia->dl_service_mode);
 		(void) close(fd);
@@ -156,13 +157,15 @@
 	}
 
 	if (is_style2 && dlattachreq(fd, ifsp.ifsp_ppa) == -1) {
-		dhcpmsg(MSG_ERR, "dlpi_open: DL_ATTACH_REQ on %s", device_name);
+		dhcpmsg(MSG_ERR, "dhcp_dlpi_open: DL_ATTACH_REQ on %s",
+		    device_name);
 		(void) close(fd);
 		return (-1);
 	}
 
 	if (dlbindreq(fd, dl_sap, 0, DL_CLDLS, 0) == -1) {
-		dhcpmsg(MSG_ERR, "dlpi_open: DL_BIND_REQ on %s", device_name);
+		dhcpmsg(MSG_ERR, "dhcp_dlpi_open: DL_BIND_REQ on %s",
+		    device_name);
 		(void) close(fd);
 		return (-1);
 	}
@@ -175,13 +178,14 @@
 	 */
 
 	if (dlinforeq(fd, dlia, dlia_size) != 0) {
-		dhcpmsg(MSG_ERR, "dlpi_open: DL_INFO_REQ on %s", device_name);
+		dhcpmsg(MSG_ERR, "dhcp_dlpi_open: DL_INFO_REQ on %s (2)",
+		    device_name);
 		(void) close(fd);
 		return (-1);
 	}
 
 	if (ioctl(fd, I_PUSH, "pfmod") == -1) {
-		dhcpmsg(MSG_ERR, "dlpi_open: cannot push pfmod on stream");
+		dhcpmsg(MSG_ERR, "dhcp_dlpi_open: cannot push pfmod on stream");
 		(void) close(fd);
 		return (-1);
 	}
@@ -191,14 +195,14 @@
 }
 
 /*
- * dlpi_close(): closes a previously opened DLPI stream
+ * dhcp_dlpi_close(): closes a previously opened DLPI stream
  *
  *   input: int: the file descriptor of the DLPI stream
  *  output: int: 0 on success, -1 on failure
  */
 
 int
-dlpi_close(int fd)
+dhcp_dlpi_close(int fd)
 {
 	/* don't bother dismantling.  it will happen automatically */
 	return (close(fd));
--- a/usr/src/cmd/cmd-inet/sbin/dhcpagent/dlpi_io.h	Mon Feb 12 04:43:25 2007 -0800
+++ b/usr/src/cmd/cmd-inet/sbin/dhcpagent/dlpi_io.h	Mon Feb 12 10:07:54 2007 -0800
@@ -63,8 +63,9 @@
 filter_func_t	dhcp_filter;
 uchar_t		*build_broadcast_dest(dl_info_ack_t *, uchar_t *);
 void		set_packet_filter(int, filter_func_t *, void *, const char *);
-int		dlpi_open(const char *, dl_info_ack_t *, size_t, t_uscalar_t);
-int		dlpi_close(int);
+int		dhcp_dlpi_open(const char *, dl_info_ack_t *, size_t,
+		    t_uscalar_t);
+int		dhcp_dlpi_close(int);
 ssize_t		dlpi_recvfrom(int, void *, size_t, struct sockaddr_in *,
 		    struct sockaddr_in *);
 ssize_t		dlpi_recv_link(int, void *, size_t, uint32_t);
--- a/usr/src/cmd/cmd-inet/sbin/dhcpagent/interface.c	Mon Feb 12 04:43:25 2007 -0800
+++ b/usr/src/cmd/cmd-inet/sbin/dhcpagent/interface.c	Mon Feb 12 10:07:54 2007 -0800
@@ -117,7 +117,7 @@
 		 */
 
 		/* step 1 */
-		pif->pif_dlpi_fd = dlpi_open(pname, dlia, sizeof (buf),
+		pif->pif_dlpi_fd = dhcp_dlpi_open(pname, dlia, sizeof (buf),
 		    ETHERTYPE_IP);
 		if (pif->pif_dlpi_fd == -1) {
 			*error = DHCP_IPC_E_INVIF;
@@ -347,15 +347,15 @@
 		uint32_t		buf[DLPI_BUF_MAX / sizeof (uint32_t)];
 		dl_info_ack_t		*dlia = (dl_info_ack_t *)buf;
 
-		pif->pif_dlpi_fd = dlpi_open(pif->pif_name, dlia, sizeof (buf),
-		    ETHERTYPE_IP);
+		pif->pif_dlpi_fd = dhcp_dlpi_open(pif->pif_name, dlia,
+		    sizeof (buf), ETHERTYPE_IP);
 		if (pif->pif_dlpi_fd == -1)
 			return (B_FALSE);
 		set_packet_filter(pif->pif_dlpi_fd, dhcp_filter, NULL, "DHCP");
 		pif->pif_dlpi_id = iu_register_event(eh, pif->pif_dlpi_fd,
 		    POLLIN, dhcp_collect_dlpi, pif);
 		if (pif->pif_dlpi_id == -1) {
-			(void) dlpi_close(pif->pif_dlpi_fd);
+			(void) dhcp_dlpi_close(pif->pif_dlpi_fd);
 			pif->pif_dlpi_fd = -1;
 			return (B_FALSE);
 		}
@@ -385,7 +385,7 @@
 		pif->pif_dlpi_id = -1;
 	}
 	if (pif->pif_dlpi_fd != -1) {
-		(void) dlpi_close(pif->pif_dlpi_fd);
+		(void) dhcp_dlpi_close(pif->pif_dlpi_fd);
 		pif->pif_dlpi_fd = -1;
 	}
 }