From d9e4afe64c0cf5b573094d3f7d0e13673aaa59e6 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Tue, 28 Feb 2012 12:09:05 -0800 Subject: [PATCH] Fixed internal loopback packet processing. We should only respond to loopback packets addressed to the physical MAC address OR the Broadcast address OR a Multicast address we're listening to (we may receive other loopback packets if we're in promiscuous mode but we should not respond to them). --- PDP11/pdp11_xq.c | 10 ++++++++++ PDP11/pdp11_xu.c | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/PDP11/pdp11_xq.c b/PDP11/pdp11_xq.c index c4eb46e7..f3b3ce1f 100644 --- a/PDP11/pdp11_xq.c +++ b/PDP11/pdp11_xq.c @@ -1689,6 +1689,16 @@ t_stat xq_process_loopback(CTLR* xq, ETH_PACK* pack) physical_address = &xq->var->setup.macs[0]; else physical_address = &xq->var->mac; + + /* The only packets we should be responding to are ones which + we received due to them being directed to our physical MAC address, + OR the Broadcast address OR to a Multicast address we're listening to + (we may receive others if we're in promiscuous mode, but shouldn't + respond to them) */ + if ((0 == (pack->msg[0]&1)) && /* Multicast or Broadcast */ + (0 != memcmp(physical_address, pack->msg, sizeof(ETH_MAC)))) + return SCPE_NOFNC; + memcpy (&response.msg[0], &response.msg[offset+2], sizeof(ETH_MAC)); memcpy (&response.msg[6], physical_address, sizeof(ETH_MAC)); offset += 8 - 16; /* Account for the Ethernet Header and Offset value in this number */ diff --git a/PDP11/pdp11_xu.c b/PDP11/pdp11_xu.c index 36e97ca0..05bccaed 100644 --- a/PDP11/pdp11_xu.c +++ b/PDP11/pdp11_xu.c @@ -416,6 +416,17 @@ t_stat xu_process_loopback(CTLR* xu, ETH_PACK* pack) /* create forward response packet */ memcpy (&response, pack, sizeof(ETH_PACK)); memcpy (physical_address, xu->var->setup.macs[0], sizeof(ETH_MAC)); + + /* The only packets we should be responding to are ones which + we received due to them being directed to our physical MAC address, + OR the Broadcast address OR to a Multicast address we're listening to + (we may receive others if we're in promiscuous mode, but shouldn't + respond to them) */ + if ((0 == (pack->msg[0]&1)) && /* Multicast or Broadcast */ + (0 != memcmp(physical_address, pack->msg, sizeof(ETH_MAC)))) + return SCPE_NOFNC; + + memcpy (&response.msg[0], &response.msg[offset+2], sizeof(ETH_MAC)); memcpy (&response.msg[6], physical_address, sizeof(ETH_MAC)); offset += 8;