Skip to content

Commit 42db672

Browse files
David L Stevensdavem330
David L Stevens
authored andcommitted
sunvnet: allow admin to set sunvnet MTU
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8e845f4 commit 42db672

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

arch/sparc/kernel/ldc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2159,7 +2159,7 @@ int ldc_map_single(struct ldc_channel *lp,
21592159
state.pte_idx = (base - iommu->page_table);
21602160
state.nc = 0;
21612161
fill_cookies(&state, (pa & PAGE_MASK), (pa & ~PAGE_MASK), len);
2162-
BUG_ON(state.nc != 1);
2162+
BUG_ON(state.nc > ncookies);
21632163

21642164
return state.nc;
21652165
}

drivers/net/ethernet/sun/sunvnet.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,9 @@ static int vnet_start_xmit(struct sk_buff *skb, struct net_device *dev)
913913
if (unlikely(!skb))
914914
goto out_dropped;
915915

916+
if (skb->len > port->rmtu)
917+
goto out_dropped;
918+
916919
spin_lock_irqsave(&port->vio.lock, flags);
917920

918921
dr = &port->vio.drings[VIO_DRIVER_TX_RING];
@@ -944,7 +947,7 @@ static int vnet_start_xmit(struct sk_buff *skb, struct net_device *dev)
944947
skb = NULL;
945948

946949
err = ldc_map_single(port->vio.lp, start, nlen,
947-
port->tx_bufs[txi].cookies, 2,
950+
port->tx_bufs[txi].cookies, VNET_MAXCOOKIES,
948951
(LDC_MAP_SHADOW | LDC_MAP_DIRECT | LDC_MAP_RW));
949952
if (err < 0) {
950953
netdev_info(dev, "tx buffer map error %d\n", err);
@@ -1182,7 +1185,7 @@ static void vnet_set_rx_mode(struct net_device *dev)
11821185

11831186
static int vnet_change_mtu(struct net_device *dev, int new_mtu)
11841187
{
1185-
if (new_mtu != ETH_DATA_LEN)
1188+
if (new_mtu < 68 || new_mtu > 65535)
11861189
return -EINVAL;
11871190

11881191
dev->mtu = new_mtu;

drivers/net/ethernet/sun/sunvnet.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
#define VNET_CLEAN_TIMEOUT ((HZ/100)+1)
1818

19-
#define VNET_MAXPACKET 1518ULL /* ETH_FRAMELEN + VLAN_HDR */
19+
#define VNET_MAXPACKET (65535ULL + ETH_HLEN + VLAN_HLEN)
2020
#define VNET_TX_RING_SIZE 512
2121
#define VNET_TX_WAKEUP_THRESH(dr) ((dr)->pending / 4)
2222

@@ -26,10 +26,12 @@
2626
*/
2727
#define VNET_PACKET_SKIP 6
2828

29+
#define VNET_MAXCOOKIES (VNET_MAXPACKET/PAGE_SIZE + 1)
30+
2931
struct vnet_tx_entry {
3032
struct sk_buff *skb;
3133
unsigned int ncookies;
32-
struct ldc_trans_cookie cookies[2];
34+
struct ldc_trans_cookie cookies[VNET_MAXCOOKIES];
3335
};
3436

3537
struct vnet;

0 commit comments

Comments
 (0)