Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Sep 2010 16:37:31 +0000 (UTC)
From:      Attilio Rao <attilio@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r212673 - in projects/sv/sys: conf net netinet
Message-ID:  <201009151637.o8FGbVY1043004@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: attilio
Date: Wed Sep 15 16:37:31 2010
New Revision: 212673
URL: http://svn.freebsd.org/changeset/base/212673

Log:
  - Adds missing headers and renames wrong ones
  - Implements a local version of ether_set_broadcast() rather than
  relying on SV-crafted ETHER_SET_BROADCAST() (and dirtier in the
  implementation IMHO)
  - Fix another htonll() occurrence
  - Uses correct logic for VLANTAG detection in -CURRENT
  - Makes netdump nomore dependent by DEVICE_POLLING option. In order to
  do that I had to specify the enum poll_cmd and poll callbacks typedef
  also in !DEVICE_POLLING case, but I don't think this should be a
  problem
  - General compilation fix-ups

Modified:
  projects/sv/sys/conf/files
  projects/sv/sys/net/if_var.h
  projects/sv/sys/netinet/netdump.h
  projects/sv/sys/netinet/netdump_client.c

Modified: projects/sv/sys/conf/files
==============================================================================
--- projects/sv/sys/conf/files	Wed Sep 15 16:20:24 2010	(r212672)
+++ projects/sv/sys/conf/files	Wed Sep 15 16:37:31 2010	(r212673)
@@ -2577,6 +2577,7 @@ netinet/ip_ipsec.c		optional inet ipsec
 netinet/ip_mroute.c		optional mrouting inet | mrouting inet6
 netinet/ip_options.c		optional inet
 netinet/ip_output.c		optional inet
+netinet/netdump_client.c	optional inet
 netinet/raw_ip.c		optional inet
 netinet/sctp_asconf.c		optional inet sctp
 netinet/sctp_auth.c		optional inet sctp

Modified: projects/sv/sys/net/if_var.h
==============================================================================
--- projects/sv/sys/net/if_var.h	Wed Sep 15 16:20:24 2010	(r212672)
+++ projects/sv/sys/net/if_var.h	Wed Sep 15 16:37:31 2010	(r212673)
@@ -891,10 +891,11 @@ void	if_deregister_com_alloc(u_char type
 #define IF_LLADDR(ifp)							\
     LLADDR((struct sockaddr_dl *)((ifp)->if_addr->ifa_addr))
 
-#ifdef DEVICE_POLLING
 enum poll_cmd {	POLL_ONLY, POLL_AND_CHECK_STATUS };
 
 typedef	int poll_handler_t(struct ifnet *ifp, enum poll_cmd cmd, int count);
+
+#ifdef DEVICE_POLLING
 int    ether_poll_register(poll_handler_t *h, struct ifnet *ifp);
 int    ether_poll_deregister(struct ifnet *ifp);
 #endif /* DEVICE_POLLING */

Modified: projects/sv/sys/netinet/netdump.h
==============================================================================
--- projects/sv/sys/netinet/netdump.h	Wed Sep 15 16:20:24 2010	(r212672)
+++ projects/sv/sys/netinet/netdump.h	Wed Sep 15 16:37:31 2010	(r212673)
@@ -61,11 +61,13 @@ struct netdump_msg {
 
 #ifdef _KERNEL
 
+typedef void ndumplock_handler_t(struct ifnet *);
+
 struct netdump_methods {
-	void	(*test_get_lock)(struct ifnet *);
-	void	(*acquire_lock)(struct ifnet *);
-	void	(*release_lock)(struct ifnet *);
-	int	(*poll_locked)(struct ifnet *, enum poll_cmd, int);
+	ndumplock_handler_t	*test_get_lock;
+	ndumplock_handler_t	*acquire_lock;
+	ndumplock_handler_t	*release_lock;
+	poll_handler_t		*poll_locked;
 };
 
 #endif

Modified: projects/sv/sys/netinet/netdump_client.c
==============================================================================
--- projects/sv/sys/netinet/netdump_client.c	Wed Sep 15 16:20:24 2010	(r212672)
+++ projects/sv/sys/netinet/netdump_client.c	Wed Sep 15 16:37:31 2010	(r212673)
@@ -34,10 +34,13 @@
 
 #include "opt_ddb.h"
 #include "opt_device_polling.h"
+#if 0
 #include "opt_netdump.h"
+#endif
 
 #include <sys/types.h>
 #include <sys/param.h>
+#include <sys/endian.h>
 #include <sys/mbuf.h>
 #include <sys/systm.h>
 #include <sys/proc.h>
@@ -63,7 +66,9 @@
 #include <netinet/in_systm.h>
 #include <netinet/ip.h>
 #include <netinet/ip_var.h>
+#include <netinet/ip_options.h>
 #include <netinet/in_var.h>
+#include <netinet/netdump.h>
 #include <netinet/udp.h>
 #include <netinet/udp_var.h>
 #include <machine/md_var.h>
@@ -75,7 +80,6 @@
 #include <machine/_inttypes.h>
 #include <net/if_media.h>
 #include <net/if_mib.h>
-#include <net/netdump.h>
 #include <machine/clock.h>
 
 #ifdef DDB
@@ -149,6 +153,24 @@ static int nd_polls=10000; /* Times to p
 static int nd_retries=10; /* Times to retransmit lost packets */
 
 /*
+ * [ether_set_broadcast]
+ *
+ * Fills up an ethernet address as broadcast
+ *
+ * Parameters:
+ *	addr	The ethernet address to be filled up
+ *
+ * Returns:
+ *	void
+ */
+static __inline void
+ether_set_broadcast(struct ether_addr *addr)
+{
+
+	memset(addr, 0xFF, ETHER_ADDR_LEN);
+}
+
+/*
  * [netdump_supported_nic]
  *
  * Checks for netdump support on a network interface
@@ -493,7 +515,7 @@ netdump_send_arp()
 	struct arphdr *ah;
 	struct ether_addr bcast;
 
-	ETHER_SET_BROADCAST(&bcast);
+	ether_set_broadcast(&bcast);
 
 	MGETHDR(m, M_DONTWAIT, MT_DATA);
 	if (m == NULL) {
@@ -618,7 +640,7 @@ retransmit:
 		nd_msg_hdr = mtod(m, struct netdump_msg_hdr *);
 		nd_msg_hdr->seqno = htonl(nd_seqno+i);
 		nd_msg_hdr->type = htonl(type);
-		nd_msg_hdr->offset = htonll(offset+sent_so_far);
+		nd_msg_hdr->offset = htobe64(offset + sent_so_far);
 		nd_msg_hdr->len = htonl(pktlen);
 		nd_msg_hdr->_pad = 0;
 
@@ -629,7 +651,7 @@ retransmit:
 				return ENOBUFS;
 			}
 			MEXTADD(m2, data+sent_so_far, pktlen, netdump_mbuf_nop,
-				NULL, M_RDONLY, EXT_MOD_TYPE);
+				NULL, NULL, M_RDONLY, EXT_MOD_TYPE);
 			m2->m_len = pktlen;
 			m->m_next = m2;
 			m->m_pkthdr.len += m2->m_len;
@@ -783,7 +805,7 @@ nd_handle_ip(struct mbuf **mb)
 	/* We would process IP options here, but we'll ignore them instead. */
 	/* Strip IP options */
 	if (hlen > sizeof(struct ip)) {
-		ip_stripoptions(m, (struct mbuf *)0);
+		ip_stripoptions(m, NULL);
 		hlen = sizeof(struct ip);
 	}
 
@@ -900,9 +922,9 @@ nd_handle_arp(struct mbuf **mb)
 	ah = mtod(m, struct arphdr *);
 
 	if (ntohs(ah->ar_hrd) != ARPHRD_ETHER &&
-	    ntohs(ar->ar_hrd) != ARPHRD_IEEE802 &&
-	    ntohs(ar->ar_hrd) != ARPHRD_ARCNET &&
-	    ntohs(ar->ar_hrd) != ARPHRD_IEEE1394) {
+	    ntohs(ah->ar_hrd) != ARPHRD_IEEE802 &&
+	    ntohs(ah->ar_hrd) != ARPHRD_ARCNET &&
+	    ntohs(ah->ar_hrd) != ARPHRD_IEEE1394) {
 		NETDDEBUG("nd_handle_arp: unknown hardware address fmt "
 		    "0x%2D)\n", (unsigned char *)&ah->ar_hrd, "");
 		return;
@@ -1038,8 +1060,7 @@ netdump_pkt_in(struct ifnet *ifp, struct
 	eh = mtod(m, struct ether_header *);
 	m->m_pkthdr.header = eh;
 	etype = ntohs(eh->ether_type);
-	if ((ifp->if_nvlans && m_tag_locate(m, MTAG_VLAN, MTAG_VLAN_TAG, NULL))
-	    || etype == ETHERTYPE_VLAN) {
+	if ((m->m_flags & M_VLANTAG) != 0 || etype == ETHERTYPE_VLAN) {
 		NETDDEBUG_IF(ifp, "ignoring vlan packets\n");
 		goto done;
 	}
@@ -1156,7 +1177,6 @@ netdump_trigger(void *arg, int howto)
 {
 	struct dumperinfo dumper;
 	void (*old_if_input)(struct ifnet *, struct mbuf *)=NULL;
-	int error;
 
 	if ((howto&(RB_HALT|RB_DUMP))!=RB_DUMP || !nd_enable || cold ||
 	    dumping)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201009151637.o8FGbVY1043004>