All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 3/4] sunvnet: allow admin to set sunvnet MTU
@ 2014-09-29 17:17 David L Stevens
  2014-09-29 18:58 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: David L Stevens @ 2014-09-29 17:17 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Sowmini Varadhan, Raghuram Kothakota

This patch allows an admin to set the MTU on a sunvnet device to arbitrary
values between the minimum (68) and maximum (65535) IPv4 packet sizes.

Signed-off-by: David L Stevens <david.stevens@oracle.com>
---
 arch/sparc/kernel/ldc.c            |    2 +-
 drivers/net/ethernet/sun/sunvnet.c |    7 +++++--
 drivers/net/ethernet/sun/sunvnet.h |    6 ++++--
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/arch/sparc/kernel/ldc.c b/arch/sparc/kernel/ldc.c
index 66dacd5..0af28b9 100644
--- a/arch/sparc/kernel/ldc.c
+++ b/arch/sparc/kernel/ldc.c
@@ -2159,7 +2159,7 @@ int ldc_map_single(struct ldc_channel *lp,
 	state.pte_idx = (base - iommu->page_table);
 	state.nc = 0;
 	fill_cookies(&state, (pa & PAGE_MASK), (pa & ~PAGE_MASK), len);
-	BUG_ON(state.nc != 1);
+	BUG_ON(state.nc > ncookies);
  	return state.nc;
 }
diff --git a/drivers/net/ethernet/sun/sunvnet.c b/drivers/net/ethernet/sun/sunvnet.c
index f3a3fc1..1a7dce0 100644
--- a/drivers/net/ethernet/sun/sunvnet.c
+++ b/drivers/net/ethernet/sun/sunvnet.c
@@ -884,6 +884,9 @@ static int vnet_start_xmit(struct sk_buff *skb, struct net_device *dev)
  	skb = vnet_skb_shape(skb, &start, &nlen);
 +	if (skb->len > port->rmtu)
+		goto out_dropped;
+
 	spin_lock_irqsave(&port->vio.lock, flags);
  	dr = &port->vio.drings[VIO_DRIVER_TX_RING];
@@ -914,7 +917,7 @@ static int vnet_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	port->tx_bufs[txi].skb = skb;
  	err = ldc_map_single(port->vio.lp, start, nlen,
-			     port->tx_bufs[txi].cookies, 2,
+			     port->tx_bufs[txi].cookies, VNET_MAXCOOKIES,
 			     (LDC_MAP_SHADOW | LDC_MAP_DIRECT | LDC_MAP_RW));
 	if (err < 0) {
 		netdev_info(dev, "tx buffer map error %d\n", err);
@@ -1143,7 +1146,7 @@ static void vnet_set_rx_mode(struct net_device *dev)
  static int vnet_change_mtu(struct net_device *dev, int new_mtu)
 {
-	if (new_mtu != ETH_DATA_LEN)
+	if (new_mtu < 68 || new_mtu > 65535)
 		return -EINVAL;
  	dev->mtu = new_mtu;
diff --git a/drivers/net/ethernet/sun/sunvnet.h b/drivers/net/ethernet/sun/sunvnet.h
index f18409b..ead9001 100644
--- a/drivers/net/ethernet/sun/sunvnet.h
+++ b/drivers/net/ethernet/sun/sunvnet.h
@@ -11,7 +11,7 @@
  */
 #define VNET_TX_TIMEOUT			(5 * HZ)
 -#define VNET_MAXPACKET			1518ULL /* ETH_FRAMELEN + VLAN_HDR */
+#define VNET_MAXPACKET			(65535ULL + ETH_HLEN + VLAN_HLEN)
 #define VNET_TX_RING_SIZE		512
 #define VNET_TX_WAKEUP_THRESH(dr)	((dr)->pending / 4)
 @@ -21,10 +21,12 @@
  */
 #define VNET_PACKET_SKIP		6
 +#define VNET_MAXCOOKIES			(VNET_MAXPACKET/PAGE_SIZE + 1)
+
 struct vnet_tx_entry {
 	struct sk_buff		*skb;
 	unsigned int		ncookies;
-	struct ldc_trans_cookie	cookies[2];
+	struct ldc_trans_cookie	cookies[VNET_MAXCOOKIES];
 };
  struct vnet;
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next 3/4] sunvnet: allow admin to set sunvnet MTU
  2014-09-29 17:17 [PATCH net-next 3/4] sunvnet: allow admin to set sunvnet MTU David L Stevens
@ 2014-09-29 18:58 ` David Miller
  2014-09-29 19:13   ` David L Stevens
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2014-09-29 18:58 UTC (permalink / raw)
  To: david.stevens; +Cc: netdev, sowmini.varadhan, Raghuram.Kothakota

From: David L Stevens <david.stevens@oracle.com>
Date: Mon, 29 Sep 2014 13:17:01 -0400

> @@ -884,6 +884,9 @@ static int vnet_start_xmit(struct sk_buff *skb, struct net_device *dev)
>   	skb = vnet_skb_shape(skb, &start, &nlen);
>  +	if (skb->len > port->rmtu)
> +		goto out_dropped;
> +
>  	spin_lock_irqsave(&port->vio.lock, flags);

More patch corruption.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next 3/4] sunvnet: allow admin to set sunvnet MTU
  2014-09-29 18:58 ` David Miller
@ 2014-09-29 19:13   ` David L Stevens
  0 siblings, 0 replies; 3+ messages in thread
From: David L Stevens @ 2014-09-29 19:13 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, sowmini.varadhan, Raghuram.Kothakota



On 09/29/2014 02:58 PM, David Miller wrote:

> 
> More patch corruption.
> 

Yes, sorry about that. I lost my .gitconfig in a crash and the backup
wasn't quite right; fixed, and the ones with subject "PATCHv7" I believe
are correct.

						+-DLS

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-09-29 19:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-29 17:17 [PATCH net-next 3/4] sunvnet: allow admin to set sunvnet MTU David L Stevens
2014-09-29 18:58 ` David Miller
2014-09-29 19:13   ` David L Stevens

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.