Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/xen/xen Enable the VLAN mtu capability and check fo...
details: https://anonhg.NetBSD.org/src/rev/86f9a7ec3be6
branches: trunk
changeset: 341713:86f9a7ec3be6
user: christos <christos%NetBSD.org@localhost>
date: Thu Nov 19 17:01:40 2015 +0000
description:
Enable the VLAN mtu capability and check for the adjusted packet size
(Jean-Jacques.Puig at espci.fr).
Factor out the packet-size checking function for clarity.
diffstat:
sys/arch/xen/xen/if_xennet_xenbus.c | 5 ++-
sys/arch/xen/xen/xennetback_xenbus.c | 43 ++++++++++++++++++++++-------------
2 files changed, 30 insertions(+), 18 deletions(-)
diffs (112 lines):
diff -r 4594d346884f -r 86f9a7ec3be6 sys/arch/xen/xen/if_xennet_xenbus.c
--- a/sys/arch/xen/xen/if_xennet_xenbus.c Thu Nov 19 16:23:54 2015 +0000
+++ b/sys/arch/xen/xen/if_xennet_xenbus.c Thu Nov 19 17:01:40 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_xennet_xenbus.c,v 1.64 2015/04/13 21:18:40 riastradh Exp $ */
+/* $NetBSD: if_xennet_xenbus.c,v 1.65 2015/11/19 17:01:40 christos Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -85,7 +85,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.64 2015/04/13 21:18:40 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.65 2015/11/19 17:01:40 christos Exp $");
#include "opt_xen.h"
#include "opt_nfs_boot.h"
@@ -362,6 +362,7 @@
ether_sprintf(sc->sc_enaddr));
/* Initialize ifnet structure and attach interface */
strlcpy(ifp->if_xname, device_xname(self), IFNAMSIZ);
+ sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU;
ifp->if_softc = sc;
ifp->if_start = xennet_start;
ifp->if_ioctl = xennet_ioctl;
diff -r 4594d346884f -r 86f9a7ec3be6 sys/arch/xen/xen/xennetback_xenbus.c
--- a/sys/arch/xen/xen/xennetback_xenbus.c Thu Nov 19 16:23:54 2015 +0000
+++ b/sys/arch/xen/xen/xennetback_xenbus.c Thu Nov 19 17:01:40 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xennetback_xenbus.c,v 1.52 2013/10/20 11:37:53 bouyer Exp $ */
+/* $NetBSD: xennetback_xenbus.c,v 1.53 2015/11/19 17:01:40 christos Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.52 2013/10/20 11:37:53 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.53 2015/11/19 17:01:40 christos Exp $");
#include "opt_xen.h"
@@ -301,6 +301,7 @@
/* create pseudo-interface */
aprint_verbose_ifnet(ifp, "Ethernet address %s\n",
ether_sprintf(xneti->xni_enaddr));
+ xneti->xni_ec.ec_capabilities |= ETHERCAP_VLAN_MTU;
ifp->if_flags =
IFF_BROADCAST|IFF_SIMPLEX|IFF_NOTRAILERS|IFF_MULTICAST;
ifp->if_snd.ifq_maxlen =
@@ -710,6 +711,23 @@
}
}
+static inline const char *
+xennetback_tx_check_packet(const netif_tx_request_t *txreq, int vlan)
+{
+ if (__predict_false(txreq->size < ETHER_HDR_LEN))
+ return "too small";
+
+ if (__predict_false(txreq->offset + txreq->size > PAGE_SIZE))
+ return "crossing a page boundary";
+
+ const int maxlen =
+ vlan ? (ETHER_VLAN_ENCAP_LEN + ETHER_MAX_LEN) : ETHER_MAX_LEN;
+ if (__predict_false(txreq->size > maxlen))
+ return "too big";
+
+ return NULL;
+}
+
static int
xennetback_evthandler(void *arg)
{
@@ -745,28 +763,21 @@
NETIF_RSP_DROPPED);
continue;
}
+
/*
* Do some sanity checks, and map the packet's page.
*/
- if (__predict_false(txreq->size < ETHER_HDR_LEN ||
- txreq->size > (ETHER_MAX_LEN - ETHER_CRC_LEN))) {
- printf("%s: packet size %d too big\n",
- ifp->if_xname, txreq->size);
+ const char *msg = xennetback_tx_check_packet(txreq,
+ xneti->xni_ec.ec_capenable & ETHERCAP_VLAN_MTU);
+ if (msg) {
+ printf("%s: packet with size %d is %s\n",
+ ifp->if_xname, txreq->size, msg);
xennetback_tx_response(xneti, txreq->id,
NETIF_RSP_ERROR);
ifp->if_ierrors++;
continue;
}
- /* don't cross page boundaries */
- if (__predict_false(
- txreq->offset + txreq->size > PAGE_SIZE)) {
- printf("%s: packet cross page boundary\n",
- ifp->if_xname);
- xennetback_tx_response(xneti, txreq->id,
- NETIF_RSP_ERROR);
- ifp->if_ierrors++;
- continue;
- }
+
/* get a mbuf for this packet */
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (__predict_false(m == NULL)) {
Home |
Main Index |
Thread Index |
Old Index