[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [linux-2.6.18-xen] netfront: reduce gso_max_size to account for max TCP header
# HG changeset patch # User Wei Liu <wei.liu2@xxxxxxxxxx> # Date 1367332425 -7200 # Node ID 5e80033562fa444531ba87e51c7d8cc45c93715b # Parent 03152e80954136f7eb4ea37c7dc358024a45888f netfront: reduce gso_max_size to account for max TCP header The maximum packet including header that can be handled by netfront / netback wire format is 65535. Reduce gso_max_size accordingly. Drop skb and print warning when skb->len > 65535. This can 1) save the effort to send malformed packet to netback, 2) help spotting misconfiguration of netfront in the future. Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx> Committed-by: Jan Beulich <jbeulich@xxxxxxxx> --- diff -r 03152e809541 -r 5e80033562fa drivers/xen/netfront/netfront.c --- a/drivers/xen/netfront/netfront.c Tue Apr 30 16:30:31 2013 +0200 +++ b/drivers/xen/netfront/netfront.c Tue Apr 30 16:33:45 2013 +0200 @@ -52,6 +52,7 @@ #include <net/pkt_sched.h> #include <net/arp.h> #include <net/route.h> +#include <net/tcp.h> #include <asm/uaccess.h> #include <xen/evtchn.h> #include <xen/xenbus.h> @@ -960,6 +961,16 @@ static int network_start_xmit(struct sk_ return 0; } + /* + * If skb->len is too big for wire format, drop skb and alert + * user about misconfiguration. + */ + if (unlikely(skb->len > XEN_NETIF_MAX_TX_SIZE)) { + printk(KERN_ALERT "xennet: length %u too big for interface\n", + skb->len); + goto drop; + } + frags += (offset + len + PAGE_SIZE - 1) / PAGE_SIZE; if (unlikely(frags > MAX_SKB_FRAGS + 1)) { printk(KERN_ALERT "xennet: skb rides the rocket: %d frags\n", @@ -1709,7 +1720,8 @@ static int xennet_set_mac_address(struct static int xennet_change_mtu(struct net_device *dev, int mtu) { - int max = xennet_can_sg(dev) ? 65535 - ETH_HLEN : ETH_DATA_LEN; + int max = xennet_can_sg(dev) ? XEN_NETIF_MAX_TX_SIZE - MAX_TCP_HEADER + : ETH_DATA_LEN; if (mtu > max) return -EINVAL; @@ -2111,6 +2123,10 @@ static struct net_device * __devinit cre SET_MODULE_OWNER(netdev); SET_NETDEV_DEV(netdev, &dev->dev); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26) + netif_set_gso_max_size(netdev, XEN_NETIF_MAX_TX_SIZE - MAX_TCP_HEADER); +#endif + np->netdev = netdev; netfront_carrier_off(np); diff -r 03152e809541 -r 5e80033562fa include/xen/interface/io/netif.h --- a/include/xen/interface/io/netif.h Tue Apr 30 16:30:31 2013 +0200 +++ b/include/xen/interface/io/netif.h Tue Apr 30 16:33:45 2013 +0200 @@ -71,6 +71,7 @@ struct netif_tx_request { uint16_t flags; /* NETTXF_* */ uint16_t id; /* Echoed in response message. */ uint16_t size; /* Packet size in bytes. */ +#define XEN_NETIF_MAX_TX_SIZE 0xFFFF }; typedef struct netif_tx_request netif_tx_request_t; _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |