Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/rump/net/lib/libshmif Make shmif SIMPLEX
details: https://anonhg.NetBSD.org/src/rev/4534ec866cb4
branches: trunk
changeset: 331593:4534ec866cb4
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Fri Aug 15 15:03:03 2014 +0000
description:
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@
diffstat:
sys/rump/net/lib/libshmif/if_shmem.c | 14 ++++++++++----
sys/rump/net/lib/libshmif/shmifvar.h | 4 +++-
2 files changed, 13 insertions(+), 5 deletions(-)
diffs (79 lines):
diff -r 8534508b38fe -r 4534ec866cb4 sys/rump/net/lib/libshmif/if_shmem.c
--- a/sys/rump/net/lib/libshmif/if_shmem.c Fri Aug 15 13:40:39 2014 +0000
+++ b/sys/rump/net/lib/libshmif/if_shmem.c Fri Aug 15 15:03:03 2014 +0000
@@ -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.63 2014/08/15 15:03:03 ozaki-r 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.63 2014/08/15 15:03:03 ozaki-r Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -97,6 +97,8 @@
struct lwp *sc_rcvl;
bool sc_dying;
+
+ uint64_t sc_uuid;
};
static void shmif_rcv(void *);
@@ -167,12 +169,13 @@
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 @@
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 @@
* 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)) {
diff -r 8534508b38fe -r 4534ec866cb4 sys/rump/net/lib/libshmif/shmifvar.h
--- a/sys/rump/net/lib/libshmif/shmifvar.h Fri Aug 15 13:40:39 2014 +0000
+++ b/sys/rump/net/lib/libshmif/shmifvar.h Fri Aug 15 15:03:03 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: shmifvar.h,v 1.7 2013/12/20 09:06:35 pooka Exp $ */
+/* $NetBSD: shmifvar.h,v 1.8 2014/08/15 15:03:03 ozaki-r Exp $ */
/*-
* Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved.
@@ -56,6 +56,8 @@
uint32_t sp_sec;
uint32_t sp_usec;
+
+ uint64_t sp_sender;
};
#define BUSMEM_SIZE (1024*1024)
Home |
Main Index |
Thread Index |
Old Index