PERFORCE change 167442 for review

Ana Kukec anchie at FreeBSD.org
Mon Aug 17 12:22:01 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=167442

Change 167442 by anchie at anchie_malimis on 2009/08/17 12:21:47

	Set socket options for the packets that are going back to kernel.	

Affected files ...

.. //depot/projects/soc2009/anchie_send/send_0.2/sendd/net.c#25 edit

Differences ...

==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/net.c#25 (text+ko) ====

@@ -176,6 +176,8 @@
 	if (rtm->rtm_flags & M_MCAST)
 		DBG(&dbg_snd, "M_MCAST!");
 
+	DBG_HEXDUMP(&dbg_snd, "Sending back to kernel: ", rtm, rtm->rtm_msglen);
+
 	if (send(sndsock, rtm, b->len, 0) < 0) {
 		DBG(&dbg_snd, "Failed to send routing message back to kernel.");
 		perror("Failed");
@@ -274,7 +276,7 @@
 		applog(LOG_ERR, "%s: read: %s", __FUNCTION__, strerror(errno));
 		goto done;
 	} else
-		DBG(&dbg_snd, "%d bytes received on routing socket.", n);
+		DBG(&dbg_snd, "%d bytes received on routing socket. (%d)", n, b->rem);
 
 	b->len = n;
 
@@ -396,7 +398,7 @@
 int
 snd_net_init(int *icmp6socket, int *sndsocket)
 {
-	int v;
+	int v, off;
 	struct icmp6_filter filter;
 #ifdef	DEBUG
 	struct dlog_desc *dbgs[] = {
@@ -440,7 +442,15 @@
 		       __FUNCTION__, strerror(errno));
 		return (-1);
 	}
-	
+
+	/* Tell the kernel to not send us back our own rt messages. */
+	off = 0;
+	if (setsockopt(sndsock, SOL_SOCKET, SO_USELOOPBACK, &off, sizeof(off)) < 0) {
+		applog(LOG_ERR, "%s: setsock(sndsock, SO_USELOOPBACK, off) "
+			"failed: %s.", __func__, strerror(errno));
+		return(-1);
+	}
+
 	ICMP6_FILTER_SETBLOCKALL(&filter);
 	ICMP6_FILTER_SETPASS(ICMP6_SND_CPS, &filter);
 	ICMP6_FILTER_SETPASS(ICMP6_SND_CPA, &filter);


More information about the p4-projects mailing list