Module Name:    src
Committed By:   riz
Date:           Sun Aug 17 03:26:51 UTC 2014

Modified Files:
        src/sys/rump/net/lib/libshmif [netbsd-7]: if_shmem.c shmifvar.h

Log Message:
Pull up following revision(s) (requested by ozaki-r in ticket #28):
        sys/rump/net/lib/libshmif/shmifvar.h: revision 1.8
        sys/rump/net/lib/libshmif/if_shmem.c: revision 1.63
        sys/rump/net/lib/libshmif/shmifvar.h: revision 1.9
Make shmif SIMPLEX
Add a sender field to a packet header on a shmif bus to identify
and ignore packets sent by itself.
This makes shmif work with bridges.
ok pooka@
Bump SHMIF_VERSION


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.62.2.1 src/sys/rump/net/lib/libshmif/if_shmem.c
cvs rdiff -u -r1.7 -r1.7.4.1 src/sys/rump/net/lib/libshmif/shmifvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/rump/net/lib/libshmif/if_shmem.c
diff -u src/sys/rump/net/lib/libshmif/if_shmem.c:1.62 src/sys/rump/net/lib/libshmif/if_shmem.c:1.62.2.1
--- src/sys/rump/net/lib/libshmif/if_shmem.c:1.62	Sat Aug  9 09:43:49 2014
+++ src/sys/rump/net/lib/libshmif/if_shmem.c	Sun Aug 17 03:26:51 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_shmem.c,v 1.62 2014/08/09 09:43:49 ozaki-r Exp $	*/
+/*	$NetBSD: if_shmem.c,v 1.62.2.1 2014/08/17 03:26:51 riz Exp $	*/
 
 /*
  * Copyright (c) 2009, 2010 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.62 2014/08/09 09:43:49 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.62.2.1 2014/08/17 03:26:51 riz Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -97,6 +97,8 @@ struct shmif_sc {
 
 	struct lwp *sc_rcvl;
 	bool sc_dying;
+
+	uint64_t sc_uuid;
 };
 
 static void shmif_rcv(void *);
@@ -167,12 +169,13 @@ allocif(int unit, struct shmif_sc **scp)
 	sc = kmem_zalloc(sizeof(*sc), KM_SLEEP);
 	sc->sc_memfd = -1;
 	sc->sc_unit = unit;
+	sc->sc_uuid = cprng_fast64();
 
 	ifp = &sc->sc_ec.ec_if;
 
 	snprintf(ifp->if_xname, sizeof(ifp->if_xname), "shmif%d", unit);
 	ifp->if_softc = sc;
-	ifp->if_flags = IFF_BROADCAST | IFF_MULTICAST;
+	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 	ifp->if_init = shmif_init;
 	ifp->if_ioctl = shmif_ioctl;
 	ifp->if_start = shmif_start;
@@ -540,6 +543,7 @@ shmif_start(struct ifnet *ifp)
 		sp.sp_len = pktsize;
 		sp.sp_sec = tv.tv_sec;
 		sp.sp_usec = tv.tv_usec;
+		sp.sp_sender = sc->sc_uuid;
 
 		bpf_mtap(ifp, m0);
 
@@ -743,7 +747,9 @@ shmif_rcv(void *arg)
 		 * Test if we want to pass the packet upwards
 		 */
 		eth = mtod(m, struct ether_header *);
-		if (memcmp(eth->ether_dhost, CLLADDR(ifp->if_sadl),
+		if (sp.sp_sender == sc->sc_uuid) {
+			passup = false;
+		} else if (memcmp(eth->ether_dhost, CLLADDR(ifp->if_sadl),
 		    ETHER_ADDR_LEN) == 0) {
 			passup = true;
 		} else if (ETHER_IS_MULTICAST(eth->ether_dhost)) {

Index: src/sys/rump/net/lib/libshmif/shmifvar.h
diff -u src/sys/rump/net/lib/libshmif/shmifvar.h:1.7 src/sys/rump/net/lib/libshmif/shmifvar.h:1.7.4.1
--- src/sys/rump/net/lib/libshmif/shmifvar.h:1.7	Fri Dec 20 09:06:35 2013
+++ src/sys/rump/net/lib/libshmif/shmifvar.h	Sun Aug 17 03:26:51 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: shmifvar.h,v 1.7 2013/12/20 09:06:35 pooka Exp $	*/
+/*	$NetBSD: shmifvar.h,v 1.7.4.1 2014/08/17 03:26:51 riz Exp $	*/
 
 /*-
  * Copyright (c) 2009, 2010 Antti Kantee.  All Rights Reserved.
@@ -31,7 +31,7 @@
 #define _RUMP_NET_SHMIFVAR_H_
 
 #define SHMIF_MAGIC 0xca11d054
-#define SHMIF_VERSION 2
+#define SHMIF_VERSION 3
 
 struct shmif_mem {
 	uint32_t shm_magic;
@@ -56,6 +56,8 @@ struct shmif_pkthdr {
 
 	uint32_t sp_sec;
 	uint32_t sp_usec;
+
+	uint64_t sp_sender;
 };
 
 #define BUSMEM_SIZE (1024*1024)

Reply via email to